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

[RFCv2 37/38] x86/hyperlaunch: generalize domid assignment


  • To: xen-devel@xxxxxxxxxxxxxxxxxxxx
  • From: "Daniel P. Smith" <dpsmith@xxxxxxxxxxxxxxxxxxxx>
  • Date: Thu, 15 May 2025 09:19:49 -0400
  • Arc-authentication-results: i=1; mx.zohomail.com; dkim=pass header.i=apertussolutions.com; spf=pass smtp.mailfrom=dpsmith@xxxxxxxxxxxxxxxxxxxx; dmarc=pass header.from=<dpsmith@xxxxxxxxxxxxxxxxxxxx>
  • Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1747315212; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:MIME-Version:Message-ID:References:Subject:Subject:To:To:Message-Id:Reply-To; bh=TCd5wTbVXQm1/qDiCEzXOZKvySaWqAmfH5oNFsGkQLM=; b=DceaBjWZoB04mP2wLMWNXvihLUqJew91/CMRqGrqhEMnJl5aKE/IJczStqtGlUiStGfiWzkSl4jHxrz93F1Gkf4QHSe1jzQ9dLyyeGBfO/OL5T4RXneytU9fTQXf3Urc+f50Nb8tFlTJ+mR3oo/gsYaWpxsL4d9CywbKKiOEj4M=
  • Arc-seal: i=1; a=rsa-sha256; t=1747315212; cv=none; d=zohomail.com; s=zohoarc; b=MaZQZVgSGmBm0AONeCXNoLnW18Jojn047+kvWN/Bmf/4I570pEckVQEUY3y8oIZOfUtmpRl4CjG1nb9UDXNmus+P1M+zBfqdtlzOBxSohRT0kodbGZpzh4aZoMu/VNb76Lg66c9ZQXohI1/m9k0DsncXu/QEGw8CFxOOEm8+sbc=
  • Cc: "Daniel P. Smith" <dpsmith@xxxxxxxxxxxxxxxxxxxx>, jason.andryuk@xxxxxxx, stefano.stabellini@xxxxxxx, agarciav@xxxxxxx, Christopher Clark <christopher.w.clark@xxxxxxxxx>
  • Delivery-date: Thu, 15 May 2025 13:35:43 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

Signed-off-by: Daniel P. Smith <dpsmith@xxxxxxxxxxxxxxxxxxxx>
---
 xen/common/domain-builder/fdt.c | 32 +++++++++++++++++++++++---------
 1 file changed, 23 insertions(+), 9 deletions(-)

diff --git a/xen/common/domain-builder/fdt.c b/xen/common/domain-builder/fdt.c
index 1b3492571b15..414bbf5d9fb1 100644
--- a/xen/common/domain-builder/fdt.c
+++ b/xen/common/domain-builder/fdt.c
@@ -16,6 +16,21 @@
 
 #include "fdt.h"
 
+#define MAX_DOMID  DOMID_FIRST_RESERVED
+static __initdata DECLARE_BITMAP(domid_alloc, MAX_DOMID);
+
+static domid_t __init find_next_domid(void)
+{
+    unsigned long n = find_next_zero_bit(domid_alloc, MAX_DOMID, 1);
+
+    if ( n == MAX_DOMID )
+        return DOMID_INVALID;
+
+    set_bit(n, domid_alloc);
+
+    return (domid_t) n;
+}
+
 static int __init fdt_prop_as_u32(const struct fdt_property *prop,
                                   uint32_t *val)
 {
@@ -231,18 +246,17 @@ static int __init fdt_process_domain_node(
 
             if ( val >= DOMID_FIRST_RESERVED )
             {
-                printk(XENLOG_ERR "  invalid domain id for domain %s\n", name);
-                return -EINVAL;
-            }
-
-            for ( unsigned int i = 0; i < bi->nr_domains; i++ )
-            {
-                if ( bi->domains[i].domid == val )
+                if ( (val = find_next_domid()) == DOMID_INVALID )
                 {
-                    printk(XENLOG_ERR "  duplicate id for domain %s\n", name);
-                    return -EINVAL;
+                    printk("  unable to allocate domid for domain %s\n", name);
+                    return -EFAULT;
                 }
             }
+            else if ( test_and_set_bit(val, domid_alloc) )
+            {
+                printk(XENLOG_ERR "  duplicate id for domain %s\n", name);
+                return -EINVAL;
+            }
 
             bd->domid = val;
             printk(XENLOG_INFO "  domid: %d\n", bd->domid);
-- 
2.30.2




 


Rackspace

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