|
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [PATCH v7 2/3] xen/domain: adjust domain ID allocation for Arm
From: Denis Mukhin <dmukhin@xxxxxxxx>
Remove the hardcoded domain ID 0 allocation for hardware domain and replace it
with a call to get_initial_domain_id() (returns the value of hardware_domid on
Arm).
Update domid_alloc(DOMID_INVALID) case to ensure that get_initial_domain_id()
ID is skipped during domain ID allocation to cover domU case in dom0less
configuration. That also fixes a potential issue with re-using ID#0 for domUs
when get_initial_domain_id() returns non-zero.
Signed-off-by: Denis Mukhin <dmukhin@xxxxxxxx>
---
Changes since v6:
- reworked to use bitmap
---
xen/arch/arm/domain_build.c | 4 ++--
xen/common/device-tree/dom0less-build.c | 9 +++------
xen/common/domain.c | 6 ++++++
3 files changed, 11 insertions(+), 8 deletions(-)
diff --git a/xen/arch/arm/domain_build.c b/xen/arch/arm/domain_build.c
index e9d563c269..0ad80b020a 100644
--- a/xen/arch/arm/domain_build.c
+++ b/xen/arch/arm/domain_build.c
@@ -2035,9 +2035,9 @@ void __init create_dom0(void)
if ( !llc_coloring_enabled )
flags |= CDF_directmap;
- domid = domid_alloc(0);
+ domid = domid_alloc(get_initial_domain_id());
if ( domid == DOMID_INVALID )
- panic("Error allocating domain ID 0\n");
+ panic("Error allocating domain ID %d\n", get_initial_domain_id());
dom0 = domain_create(domid, &dom0_cfg, flags);
if ( IS_ERR(dom0) )
diff --git a/xen/common/device-tree/dom0less-build.c
b/xen/common/device-tree/dom0less-build.c
index 9236dbae11..8e38affd0c 100644
--- a/xen/common/device-tree/dom0less-build.c
+++ b/xen/common/device-tree/dom0less-build.c
@@ -974,14 +974,11 @@ void __init create_domUs(void)
arch_create_domUs(node, &d_cfg, flags);
- /*
- * The variable max_init_domid is initialized with zero, so here it's
- * very important to use the pre-increment operator to call
- * domain_create() with a domid > 0. (domid == 0 is reserved for Dom0)
- */
- domid = domid_alloc(++max_init_domid);
+ domid = domid_alloc(DOMID_INVALID);
if ( domid == DOMID_INVALID )
panic("Error allocating ID for domain %s\n", dt_node_name(node));
+ if ( max_init_domid < domid )
+ max_init_domid = domid;
d = domain_create(domid, &d_cfg, flags);
if ( IS_ERR(d) )
diff --git a/xen/common/domain.c b/xen/common/domain.c
index 37fe811f3f..0145870a7d 100644
--- a/xen/common/domain.c
+++ b/xen/common/domain.c
@@ -2424,6 +2424,9 @@ domid_t domid_alloc(domid_t domid)
}
else
{
+ domid_t reserved;
+
+ reserved = __test_and_set_bit(get_initial_domain_id(), domid_bitmap);
domid = find_next_zero_bit(domid_bitmap, CONFIG_MAX_DOMID,
domid_last);
@@ -2439,6 +2442,9 @@ domid_t domid_alloc(domid_t domid)
__set_bit(domid, domid_bitmap);
domid_last = domid;
}
+
+ if ( !reserved )
+ __clear_bit(reserved, domid_bitmap);
}
spin_unlock(&domid_lock);
--
2.34.1
|
![]() |
Lists.xenproject.org is hosted with RackSpace, monitoring our |