From nobody Thu Apr 25 07:04:55 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass(p=quarantine dis=none) header.from=suse.com ARC-Seal: i=1; a=rsa-sha256; t=1631106303; cv=none; d=zohomail.com; s=zohoarc; b=FTaX3EfrTUBJC1qji/42ZDE50WUcmyA4Sl0UYy5AEkJOTBRUZIaCUP8NxaIHqjc0531efh6BVv5DP9CqtOIVEdgCZuzUZkM1SZbm26g98DJ/snQS2uQ3Ux9uP/dRZFHicFGi2bSJK7hK9zn9eYRrbYOzyCw8KLWi9FKkhWY/u3o= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1631106303; h=Content-Transfer-Encoding:Cc:Date:From:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:To; bh=fASvCnULJeUIRs9+t4Wk0OtjCFkWaouH82TpoiiwbKE=; b=Ygk/16yV16FRNSctZ2RB/kkmiRnxq9WMH9nuBtO2x5o8pdK5KxWPstKdqqvbBDkGzQYW7Q/2DjWEZCuheXmqTz2Tb4D0nnVGgBPF5hHXlUqoxpNugJur5F6DtoP890gYQPylH/CEB/fLVnGWThH3WuWQov6vkvTJ6DwlimOVS/s= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1631106303240744.7942231258114; Wed, 8 Sep 2021 06:05:03 -0700 (PDT) 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 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-Outflank-Mailman: Message body and most headers restored to incoming version 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: quoted-printable X-ZohoMail-DKIM: pass (identity @suse.com) X-ZM-MESSAGEID: 1631106306532100001 Content-Type: text/plain; charset="utf-8" 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 cpupool= s with different granularity") Reported-by: Bertrand Marquis Signed-off-by: Juergen Gross Reviewed-by: Dario Faggioli Reviewed-by: Luca Fancellu --- 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 =3D dom_scheduler(d); void *old_domdata; unsigned int gran =3D cpupool_get_granularity(c); - unsigned int n_units =3D DIV_ROUND_UP(d->max_vcpus, gran); + unsigned int n_units =3D d->vcpu[0] ? DIV_ROUND_UP(d->max_vcpus, gran)= : 0; int ret =3D 0; =20 for_each_vcpu ( d, v ) --=20 2.26.2