Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 16D63C433EF for ; Wed, 8 Sep 2021 13:04:54 +0000 (UTC) Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id D23856115B for ; Wed, 8 Sep 2021 13:04:53 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org D23856115B Authentication-Results: mail.kernel.org; dmarc=fail (p=quarantine dis=none) header.from=suse.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=lists.xenproject.org Received: from list by lists.xenproject.org with outflank-mailman.181983.329375 (Exim 4.92) (envelope-from ) id 1mNxFs-0004YC-T9; Wed, 08 Sep 2021 13:04:44 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 181983.329375; Wed, 08 Sep 2021 13:04:44 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1mNxFs-0004Y5-Pe; Wed, 08 Sep 2021 13:04:44 +0000 Received: by outflank-mailman (input) for mailman id 181983; Wed, 08 Sep 2021 13:04:43 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1mNxFr-0004Xt-Sv for xen-devel@lists.xenproject.org; Wed, 08 Sep 2021 13:04:43 +0000 Received: from smtp-out1.suse.de (unknown [195.135.220.28]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id 0c989046-50a8-4166-8785-446a842621e3; Wed, 08 Sep 2021 13:04:43 +0000 (UTC) Received: from imap1.suse-dmz.suse.de (imap1.suse-dmz.suse.de [192.168.254.73]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id 2982B2218A; Wed, 8 Sep 2021 13:04:42 +0000 (UTC) Received: from imap1.suse-dmz.suse.de (imap1.suse-dmz.suse.de [192.168.254.73]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap1.suse-dmz.suse.de (Postfix) with ESMTPS id EAF4E13A8B; Wed, 8 Sep 2021 13:04:41 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap1.suse-dmz.suse.de with ESMTPSA id NiHqN+m0OGG4HwAAGKfGzw (envelope-from ); Wed, 08 Sep 2021 13:04:41 +0000 X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: 0c989046-50a8-4166-8785-446a842621e3 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1631106282; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=fASvCnULJeUIRs9+t4Wk0OtjCFkWaouH82TpoiiwbKE=; b=I/u0pmQjYKnoOStNBLNJaroYMBAMzjdeULBS1z3Yzb+oU7l/hu30+gaGjCCizTj1wIjshq 6B7n7my7lDK1zSUXA6q4VqWE6579/zWMud9i3DTMcaFvFjx5s9rWTeij6U6FC3ghnByDGT TBaWSlb3DD9GoMCEyedi7x6tJZKELSA= From: Juergen Gross To: xen-devel@lists.xenproject.org Cc: Juergen Gross , George Dunlap , Dario Faggioli , Bertrand Marquis Subject: [PATCH v2] xen/sched: fix sched_move_domain() for domain without vcpus Date: Wed, 8 Sep 2021 15:04:40 +0200 Message-Id: <20210908130440.24605-1-jgross@suse.com> X-Mailer: git-send-email 2.26.2 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit In case a domain is created with a cpupool other than Pool-0 specified it will be moved to that cpupool before any vcpus are allocated. This will lead to a NULL pointer dereference in sched_move_domain(). Fix that by tolerating vcpus not being allocated yet. Fixes: 70fadc41635b9b6 ("xen/cpupool: support moving domain between cpupools with different granularity") Reported-by: Bertrand Marquis Signed-off-by: Juergen Gross --- V2: - Only test for vcpu[0] not being present (Jan Beulich) --- xen/common/sched/core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/xen/common/sched/core.c b/xen/common/sched/core.c index 8d178baf3d..8f4b1ca10d 100644 --- a/xen/common/sched/core.c +++ b/xen/common/sched/core.c @@ -651,7 +651,7 @@ int sched_move_domain(struct domain *d, struct cpupool *c) struct scheduler *old_ops = dom_scheduler(d); void *old_domdata; unsigned int gran = cpupool_get_granularity(c); - unsigned int n_units = DIV_ROUND_UP(d->max_vcpus, gran); + unsigned int n_units = d->vcpu[0] ? DIV_ROUND_UP(d->max_vcpus, gran) : 0; int ret = 0; for_each_vcpu ( d, v ) -- 2.26.2