|
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [RFC 37/38] x86/hyperlaunch: generalize domid assignment
Signed-off-by: Daniel P. Smith <dpsmith@xxxxxxxxxxxxxxxxxxxx>
---
xen/arch/x86/domain-builder/fdt.c | 29 +++++++++++++++++++++++++++--
1 file changed, 27 insertions(+), 2 deletions(-)
diff --git a/xen/arch/x86/domain-builder/fdt.c
b/xen/arch/x86/domain-builder/fdt.c
index 9c6c0ae09a24..543a0c92adb4 100644
--- a/xen/arch/x86/domain-builder/fdt.c
+++ b/xen/arch/x86/domain-builder/fdt.c
@@ -15,6 +15,21 @@
#include "fdt.h"
+#define MAX_DOMID DOMID_FIRST_RESERVED
+static __initdata DECLARE_BITMAP(domid_alloc, MAX_DOMID);
+
+static domid_t 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;
+}
+
/*
* Unpacks a "reg" property into its address and size constituents.
*
@@ -186,11 +201,21 @@ static int __init process_domain_node(
printk(" failed processing domain id for domain %s\n", name);
return -EINVAL;
}
+
if ( val >= DOMID_FIRST_RESERVED )
{
- printk(" invalid domain id for domain %s\n", name);
- return -EINVAL;
+ if ( (val = find_next_domid()) == DOMID_INVALID )
+ {
+ printk(" unable to allocate domid for domain %s\n", name);
+ return -EFAULT;
+ }
}
+ else if ( test_and_set_bit(val, domid_alloc) )
+ {
+ printk(XENLOG_ERR "ERR: domid (%d) already assigned\n", val);
+ return -EFAULT;
+ }
+
bd->domid = (domid_t)val;
printk(" domid: %d\n", bd->domid);
}
--
2.30.2
|
![]() |
Lists.xenproject.org is hosted with RackSpace, monitoring our |