[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH 2/2] x86: generalise vcpu0 creation for a domain


  • To: <xen-devel@xxxxxxxxxxxxxxxxxxxx>
  • From: Alejandro Vallejo <alejandro.garciavallejo@xxxxxxx>
  • Date: Thu, 17 Jul 2025 19:51:27 +0200
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=lists.xenproject.org smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none (0)
  • Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=K39k6RuvWWJkMEIkdG6HzIGtOxXf/lCeRD5qU5gOaxk=; b=R+B2DnLNxtsgu5iBrssf178neKdcRmKyHixpARkA07UvAcRkQA4ftMk5ljvWBRdgDQk2HvVze02BNeu416zs8jr2E5O5QzuFwyfV41uWXjxEbZiB0Yh6saX5KC2PMnHWJ4I4A5SU8DY8hej05hGrwLUlmjH4K92hmtxnszrwMbrK98mYVpaagA6Xyw0Dylc3VvQpDegHJDBAH51Rvsa02RpYVfMouYLbu+x2/HIFk3EpVGisFaJKGV6m8JuZ61ocnTmxLVOyLnxr4gEM+swkvODSg4jnra5HZXZ79romGeW4S1I3D1YRBl78YkZcF9SvB4LXUtRDbafcYlMzWzjj7Q==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=KNmUGjYNmsGqNjA9pSbzQPRpBywEQBjr0ZbGy0fftkuJ6c3T5Eg/1TQyK+dhO1L/MAbAoOHKi9W80/gjHBxQzcHD31P8lSVC9Da9LqmpDHyeSyLRBwKvfAXZzTl7xHL6KPs6HYJ4y9SuYockhmBEfy6nFyhnGLdu1oCZgDkU58uM7f2QgokYaivPVQfKqVkrLJNtEY2c+dnr0/LNBhiD8DV+obzijNoNVsaCKq/h6g1bTQFC+Fq252sIod8HCuxaj3k6DcgTExDGLjGZkBxDDOwPNZX6Axx3xwIxfsBNKRaB4f+gqFZTS84fOYuiUuL+zgQnpk4yQTDdPgjCW5CETg==
  • Cc: Alejandro Vallejo <alejandro.garciavallejo@xxxxxxx>, Jan Beulich <jbeulich@xxxxxxxx>, Andrew Cooper <andrew.cooper3@xxxxxxxxxx>, Roger Pau Monné <roger.pau@xxxxxxxxxx>, Anthony PERARD <anthony.perard@xxxxxxxxxx>, Michal Orzel <michal.orzel@xxxxxxx>, "Julien Grall" <julien@xxxxxxx>, Stefano Stabellini <sstabellini@xxxxxxxxxx>, "Daniel P . Smith" <dpsmith@xxxxxxxxxxxxxxxxxxxx>
  • Delivery-date: Thu, 17 Jul 2025 17:52:28 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

Make alloc_dom0_vcpu0() viable as a general vcpu0 allocator. Keep
behaviour on any hwdom/ctldom identical to that dom0 used to have, and
make non-dom0 have auto node affinity.

Rename the function to alloc_dom_vcpu0() to reflect this change in
scope, and move the prototype to asm/domain.h from xen/domain.h as it's
only used in x86.

Signed-off-by: Daniel P. Smith <dpsmith@xxxxxxxxxxxxxxxxxxxx>
Signed-off-by: Alejandro Vallejo <alejandro.garciavallejo@xxxxxxx>
---
 xen/arch/x86/dom0_build.c             | 12 ++++++++----
 xen/arch/x86/include/asm/dom0_build.h |  5 +++++
 xen/arch/x86/setup.c                  |  6 ++++--
 xen/include/xen/domain.h              |  1 -
 4 files changed, 17 insertions(+), 7 deletions(-)

diff --git a/xen/arch/x86/dom0_build.c b/xen/arch/x86/dom0_build.c
index 0b467fd4a4..dfae7f888f 100644
--- a/xen/arch/x86/dom0_build.c
+++ b/xen/arch/x86/dom0_build.c
@@ -254,12 +254,16 @@ unsigned int __init dom0_max_vcpus(void)
     return max_vcpus;
 }
 
-struct vcpu *__init alloc_dom0_vcpu0(struct domain *dom0)
+struct vcpu *__init alloc_dom_vcpu0(struct domain *d)
 {
-    dom0->node_affinity = dom0_nodes;
-    dom0->auto_node_affinity = !dom0_nr_pxms;
+    d->auto_node_affinity = true;
+    if ( is_hardware_domain(d) || is_control_domain(d) )
+    {
+        d->node_affinity = dom0_nodes;
+        d->auto_node_affinity = !dom0_nr_pxms;
+    }
 
-    return vcpu_create(dom0, 0);
+    return vcpu_create(d, 0);
 }
 
 #ifdef CONFIG_SHADOW_PAGING
diff --git a/xen/arch/x86/include/asm/dom0_build.h 
b/xen/arch/x86/include/asm/dom0_build.h
index ff021c24af..46bfd111f2 100644
--- a/xen/arch/x86/include/asm/dom0_build.h
+++ b/xen/arch/x86/include/asm/dom0_build.h
@@ -23,6 +23,11 @@ unsigned long dom0_paging_pages(const struct domain *d,
 void dom0_update_physmap(bool compat, unsigned long pfn,
                          unsigned long mfn, unsigned long vphysmap_s);
 
+/* general domain construction */
+
+/* Create the first vCPU of a domain. Sets up node affinity as a side effect */
+struct vcpu *alloc_dom_vcpu0(struct domain *d);
+
 #endif /* _DOM0_BUILD_H_ */
 
 /*
diff --git a/xen/arch/x86/setup.c b/xen/arch/x86/setup.c
index c6890669b9..77a8ca60c3 100644
--- a/xen/arch/x86/setup.c
+++ b/xen/arch/x86/setup.c
@@ -37,6 +37,7 @@
 #include <asm/bzimage.h>
 #include <asm/cpu-policy.h>
 #include <asm/desc.h>
+#include <asm/dom0_build.h>
 #include <asm/e820.h>
 #include <asm/edd.h>
 #include <asm/genapic.h>
@@ -1054,9 +1055,11 @@ static struct domain *__init create_dom0(struct 
boot_info *bi)
     if ( IS_ERR(d) )
         panic("Error creating d%u: %ld\n", bd->domid, PTR_ERR(d));
 
+    bd->d = d;
+
     init_dom0_cpuid_policy(d);
 
-    if ( alloc_dom0_vcpu0(d) == NULL )
+    if ( alloc_dom_vcpu0(d) == NULL )
         panic("Error creating %pdv0\n", d);
 
     cmdline_size = domain_cmdline_size(bi, bd);
@@ -1093,7 +1096,6 @@ static struct domain *__init create_dom0(struct boot_info 
*bi)
         bd->cmdline = cmdline;
     }
 
-    bd->d = d;
     if ( construct_dom0(bd) != 0 )
         panic("Could not construct domain 0\n");
 
diff --git a/xen/include/xen/domain.h b/xen/include/xen/domain.h
index e10baf2615..bf1fc6227f 100644
--- a/xen/include/xen/domain.h
+++ b/xen/include/xen/domain.h
@@ -24,7 +24,6 @@ struct vcpu *vcpu_create(struct domain *d, unsigned int 
vcpu_id);
 
 unsigned int dom0_max_vcpus(void);
 int parse_arch_dom0_param(const char *s, const char *e);
-struct vcpu *alloc_dom0_vcpu0(struct domain *dom0);
 
 int vcpu_reset(struct vcpu *v);
 int vcpu_up(struct vcpu *v);
-- 
2.43.0




 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.