From patchwork Tue Mar 18 23:36:40 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Denis Mukhin X-Patchwork-Id: 14021744 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id B6997C35FFC for ; Tue, 18 Mar 2025 23:37:00 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.919888.1324246 (Exim 4.92) (envelope-from ) id 1tugUJ-0004iY-MQ; Tue, 18 Mar 2025 23:36:47 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 919888.1324246; Tue, 18 Mar 2025 23:36:47 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1tugUJ-0004iR-Ik; Tue, 18 Mar 2025 23:36:47 +0000 Received: by outflank-mailman (input) for mailman id 919888; Tue, 18 Mar 2025 23:36:46 +0000 Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50] helo=se1-gles-flk1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1tugUI-0004Rg-7r for xen-devel@lists.xenproject.org; Tue, 18 Mar 2025 23:36:46 +0000 Received: from mail-10631.protonmail.ch (mail-10631.protonmail.ch [79.135.106.31]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id da0c246c-0451-11f0-9899-31a8f345e629; Wed, 19 Mar 2025 00:36:44 +0100 (CET) X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: da0c246c-0451-11f0-9899-31a8f345e629 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=proton.me; s=protonmail; t=1742341003; x=1742600203; bh=an7oco9t2MW1aPCyVdsDXyaEu4dmL76TiBG8/A0s7xA=; h=Date:To:From:Cc:Subject:Message-ID:In-Reply-To:References: Feedback-ID:From:To:Cc:Date:Subject:Reply-To:Feedback-ID: Message-ID:BIMI-Selector:List-Unsubscribe:List-Unsubscribe-Post; b=PhDhJTdJEEerElqeuorniNkGGyf08ZNC7jbDQr8SnfQcjhNH9lpaqpmFsXJDsbtag dXj6hrtrbd2FcsGYGGv744CLVokUdWf+PnZ/nkFX/8+TOi7RY2woQxm9wuFehHl2F7 gGZiDR9yOPGoNH60k4ciy48CYZ45Vp9NOcZfup/cddMy10v7Ky1wiG0wOoMDbqMrte 1YN+KRYA0rWcj/oOUWF6nxInBCw29jeIhQeNyB5lD3149eN5SCO0jV0wkY8muHkz/k xeow6G6x6MKoGCu0xKj+X7xcjPDybcBMYIYosFGnYviRi/wppWOTk06CAd7Fm1e7Vg LPdpu4JyNtceQ== Date: Tue, 18 Mar 2025 23:36:40 +0000 To: xen-devel@lists.xenproject.org From: dmkhn@proton.me Cc: andrew.cooper3@citrix.com, anthony.perard@vates.tech, jbeulich@suse.com, julien@xen.org, michal.orzel@amd.com, roger.pau@citrix.com, sstabellini@kernel.org, dmukhin@ford.com Subject: [PATCH v1 3/8] xen/domain: introduce domid_top Message-ID: <20250318233617.849903-4-dmukhin@ford.com> In-Reply-To: <20250318233617.849903-1-dmukhin@ford.com> References: <20250318233617.849903-1-dmukhin@ford.com> Feedback-ID: 123220910:user:proton X-Pm-Message-ID: 68345f0592094b4e9be75b2581fdeb838d44de27 MIME-Version: 1.0 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 --- 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(-) 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 -#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. */