Message ID | 20250318233617.849903-4-dmukhin@ford.com (mailing list archive) |
---|---|
State | Superseded |
Headers | show |
Series | xen/console: cleanup console input switch logic | expand |
On 19.03.2025 00:36, dmkhn@proton.me wrote: > Rename max_init_domid to domid_top to align with its usage in the code > (Arm), where it represents the upper boundary of the non-system domain > ID range. I think I said before that I don't share this view of yours. The variable is quite appropriately named; it's the further use you made of it in earlier versions of work of yours in this area where the name ended up no longer reflecting the purpose. Yet that's not a reason to change the name. I'm unconvinced we actually need a variable tracking the largest known non-system domain ID. The domain list is sorted, so obtaining that ID should be reasonably easy and cheap without such a variable. Furthermore such a variable would likely also need reducing when the domain with the highest ID dies. > --- a/xen/drivers/char/console.c > +++ b/xen/drivers/char/console.c > @@ -472,7 +472,7 @@ static void cf_check dump_console_ring_key(unsigned char key) > */ > static unsigned int __read_mostly console_rx = 0; > > -#define max_console_rx (max_init_domid + 1) > +#define max_console_rx (domid_top + 1) This use in particular is bogus. The intention here is to permit console access only to (some?) domains created during boot. Making a (conceptual) change here would require separate justification. Jan
diff --git a/xen/arch/arm/dom0less-build.c b/xen/arch/arm/dom0less-build.c index 573b0d25ae..d7d7665c0a 100644 --- a/xen/arch/arm/dom0less-build.c +++ b/xen/arch/arm/dom0less-build.c @@ -981,7 +981,7 @@ void __init create_domUs(void) if ( !dt_device_is_compatible(node, "xen,domain") ) continue; - if ( (max_init_domid + 1) >= DOMID_FIRST_RESERVED ) + if ( (domid_top + 1) >= DOMID_FIRST_RESERVED ) panic("No more domain IDs available\n"); if ( dt_find_property(node, "xen,static-mem", NULL) ) @@ -1112,7 +1112,7 @@ void __init create_domUs(void) * very important to use the pre-increment operator to call * domain_create() with a domid > 0. (domid == 0 is reserved for Dom0) */ - d = domain_create(++max_init_domid, &d_cfg, flags); + d = domain_create(++domid_top, &d_cfg, flags); if ( IS_ERR(d) ) panic("Error creating domain %s (rc = %ld)\n", dt_node_name(node), PTR_ERR(d)); diff --git a/xen/arch/arm/include/asm/setup.h b/xen/arch/arm/include/asm/setup.h index 6cf272c160..f107e8eebb 100644 --- a/xen/arch/arm/include/asm/setup.h +++ b/xen/arch/arm/include/asm/setup.h @@ -25,8 +25,6 @@ struct map_range_data struct rangeset *irq_ranges; }; -extern domid_t max_init_domid; - void copy_from_paddr(void *dst, paddr_t paddr, unsigned long len); size_t estimate_efi_size(unsigned int mem_nr_banks); diff --git a/xen/arch/arm/setup.c b/xen/arch/arm/setup.c index ffcae900d7..ab60f0d189 100644 --- a/xen/arch/arm/setup.c +++ b/xen/arch/arm/setup.c @@ -60,8 +60,6 @@ struct cpuinfo_arm __read_mostly system_cpuinfo; bool __read_mostly acpi_disabled; #endif -domid_t __read_mostly max_init_domid; - static __used void init_done(void) { int rc; diff --git a/xen/arch/ppc/include/asm/setup.h b/xen/arch/ppc/include/asm/setup.h index e4f64879b6..956fa6985a 100644 --- a/xen/arch/ppc/include/asm/setup.h +++ b/xen/arch/ppc/include/asm/setup.h @@ -1,6 +1,4 @@ #ifndef __ASM_PPC_SETUP_H__ #define __ASM_PPC_SETUP_H__ -#define max_init_domid (0) - #endif /* __ASM_PPC_SETUP_H__ */ diff --git a/xen/arch/riscv/include/asm/setup.h b/xen/arch/riscv/include/asm/setup.h index c9d69cdf51..d1fc64b673 100644 --- a/xen/arch/riscv/include/asm/setup.h +++ b/xen/arch/riscv/include/asm/setup.h @@ -5,8 +5,6 @@ #include <xen/types.h> -#define max_init_domid (0) - void setup_mm(void); void copy_from_paddr(void *dst, paddr_t paddr, unsigned long len); diff --git a/xen/arch/x86/include/asm/setup.h b/xen/arch/x86/include/asm/setup.h index 5c2391a868..296348655b 100644 --- a/xen/arch/x86/include/asm/setup.h +++ b/xen/arch/x86/include/asm/setup.h @@ -69,6 +69,4 @@ extern bool opt_dom0_verbose; extern bool opt_dom0_cpuid_faulting; extern bool opt_dom0_msr_relaxed; -#define max_init_domid (0) - #endif diff --git a/xen/common/domain.c b/xen/common/domain.c index b9f549c617..dac910d454 100644 --- a/xen/common/domain.c +++ b/xen/common/domain.c @@ -66,6 +66,9 @@ DEFINE_RCU_READ_LOCK(domlist_read_lock); static struct domain *domain_hash[DOMAIN_HASH_SIZE]; struct domain *domain_list; +/* Highest known non-system domain ID. */ +domid_t domid_top; + /* * Insert a domain into the domlist/hash. This allows the domain to be looked * up by domid, and therefore to be the subject of hypercalls/etc. diff --git a/xen/drivers/char/console.c b/xen/drivers/char/console.c index d7d9800095..d04a5335ce 100644 --- a/xen/drivers/char/console.c +++ b/xen/drivers/char/console.c @@ -472,7 +472,7 @@ static void cf_check dump_console_ring_key(unsigned char key) */ static unsigned int __read_mostly console_rx = 0; -#define max_console_rx (max_init_domid + 1) +#define max_console_rx (domid_top + 1) static struct domain *console_get_domain_by_id(domid_t domid) { diff --git a/xen/include/xen/domain.h b/xen/include/xen/domain.h index 83069de501..b7425827b8 100644 --- a/xen/include/xen/domain.h +++ b/xen/include/xen/domain.h @@ -35,6 +35,8 @@ void getdomaininfo(struct domain *d, struct xen_domctl_getdomaininfo *info); void arch_get_domain_info(const struct domain *d, struct xen_domctl_getdomaininfo *info); +extern domid_t domid_top; + domid_t get_initial_domain_id(void); /* CDF_* constant. Internal flags for domain creation. */
Rename max_init_domid to domid_top to align with its usage in the code (Arm), where it represents the upper boundary of the non-system domain ID range. Relocate the domid_top declaration to an architecture-independent location. Signed-off-by: Denis Mukhin <dmukhin@ford.com> --- xen/arch/arm/dom0less-build.c | 4 ++-- xen/arch/arm/include/asm/setup.h | 2 -- xen/arch/arm/setup.c | 2 -- xen/arch/ppc/include/asm/setup.h | 2 -- xen/arch/riscv/include/asm/setup.h | 2 -- xen/arch/x86/include/asm/setup.h | 2 -- xen/common/domain.c | 3 +++ xen/drivers/char/console.c | 2 +- xen/include/xen/domain.h | 2 ++ 9 files changed, 8 insertions(+), 13 deletions(-)