From nobody Mon Feb 9 02:23:45 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org ARC-Seal: i=1; a=rsa-sha256; t=1767967713; cv=none; d=zohomail.com; s=zohoarc; b=Ci5q2iGBbQzeyoWE0XoFEXv03WGXwFn3RB5uyQ33XMpy3Sb4YRemIvcsGtMQSmjaVvah+FVfyLqqe9pFC+3yWRF70sJqbOruI8kJazTqqSSpkEdOpwxbEcKbIK2c9RkEthwLEF+XL8dKZ8Dwd3bm3EAcIfOGXwpiei4L1udW+Cg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1767967713; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=qjgtr4bC7APkZhNKrkEmz/ndAIWVoimDzoPnpMO29/Y=; b=TcGd6aH2R2g1MUFqvVvH5n3MDuPMIr65sac2HqO77uJqRbpRDsRnJ/RkYLWmcpZORkrljQN69URehzxeLoTLMUX2Ds/oF8Xga/gy52rHvVA8iHIcHBYcE1VhS6hke4OUh3XFCEqRw1KuUaUOA03wgzTiU2KNQhc7jqo+SpL9FCI= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1767967713879188.9436179833781; Fri, 9 Jan 2026 06:08:33 -0800 (PST) Received: from list by lists.xenproject.org with outflank-mailman.1198883.1515684 (Exim 4.92) (envelope-from ) id 1veD9y-0001Uw-I3; Fri, 09 Jan 2026 14:08:14 +0000 Received: by outflank-mailman (output) from mailman id 1198883.1515684; Fri, 09 Jan 2026 14:08:14 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1veD9y-0001Up-Ep; Fri, 09 Jan 2026 14:08:14 +0000 Received: by outflank-mailman (input) for mailman id 1198883; Fri, 09 Jan 2026 14:08:12 +0000 Received: from mail.xenproject.org ([104.130.215.37]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1veD9w-0001Uh-MX for xen-devel@lists.xenproject.org; Fri, 09 Jan 2026 14:08:12 +0000 Received: from xenbits.xenproject.org ([104.239.192.120]) by mail.xenproject.org with esmtp (Exim 4.96) (envelope-from ) id 1veD9v-00GbCg-0C; Fri, 09 Jan 2026 14:08:11 +0000 Received: from [19.12.91.86] (helo=localhost) by xenbits.xenproject.org with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1veD9v-00FZLi-0H; Fri, 09 Jan 2026 14:08:11 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version 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" DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org; s=20200302mail; h=Content-Transfer-Encoding:MIME-Version:Message-ID:Date: Subject:Cc:To:From; bh=qjgtr4bC7APkZhNKrkEmz/ndAIWVoimDzoPnpMO29/Y=; b=wQnZC+ /xZQaAvCmgybtpUxVlYHS+2lWz77qObyvzA2lm5gM6i+Km/l136LnH1JZcHj+wCbNrP8W3DluvHMd 0TwJ3Z4UDl/fLxDHHVWERGrD3kEjEuvNoPjZVnq1VwoEJ9TRdb5QMVu7zX+u0RuBstFNh4D1Dm2NY SKsh+iS4B2I=; From: dmukhin@xen.org To: xen-devel@lists.xenproject.org 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 v4] xen/domain: introduce DOMID_ANY Date: Fri, 9 Jan 2026 06:07:48 -0800 Message-ID: <20260109140747.195460-2-dmukhin@ford.com> X-Mailer: git-send-email 2.52.0 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @xen.org) X-ZM-MESSAGEID: 1767967715058158500 Content-Type: text/plain; charset="utf-8" From: Denis Mukhin =20 Add a new symbol DOMID_ANY to improve the readability of the code. Update all relevant domid_alloc() call sites. Amends: 2d5065060710 ("xen/domain: unify domain ID allocation") Signed-off-by: Denis Mukhin Reviewed-by: Juergen Gross Reviewed-by: Stefano Stabellini --- Changes since v3: - new value for DOMID_ANY instead of aliasing DOMID_INVALID - Link to v3: https://lore.kernel.org/xen-devel/20250924030630.122229-2-dmu= khin@ford.com/ --- tools/tests/domid/harness.h | 1 + tools/tests/domid/test-domid.c | 12 ++++++------ xen/common/device-tree/dom0less-build.c | 2 +- xen/common/domctl.c | 2 +- xen/common/domid.c | 2 +- xen/include/public/xen.h | 5 +++++ 6 files changed, 15 insertions(+), 9 deletions(-) diff --git a/tools/tests/domid/harness.h b/tools/tests/domid/harness.h index 17eb22a9a854..65da0d075a2b 100644 --- a/tools/tests/domid/harness.h +++ b/tools/tests/domid/harness.h @@ -41,6 +41,7 @@ extern unsigned long find_next_zero_bit(const unsigned lo= ng *addr, =20 #define DOMID_FIRST_RESERVED (100) #define DOMID_INVALID (101) +#define DOMID_ANY (102) =20 #endif /* _TEST_HARNESS_ */ =20 diff --git a/tools/tests/domid/test-domid.c b/tools/tests/domid/test-domid.c index 5915c4699a5c..71cc4e7fd86d 100644 --- a/tools/tests/domid/test-domid.c +++ b/tools/tests/domid/test-domid.c @@ -41,20 +41,20 @@ int main(int argc, char **argv) domid_free(expected); =20 /* - * Test that that two consecutive calls of domid_alloc(DOMID_INVALID) + * Test that that two consecutive calls of domid_alloc(DOMID_ANY) * will never return the same ID. * NB: ID#0 is reserved and shall not be allocated by - * domid_alloc(DOMID_INVALID). + * domid_alloc(DOMID_ANY). */ for ( expected =3D 1; expected < DOMID_FIRST_RESERVED; expected++ ) { - allocated =3D domid_alloc(DOMID_INVALID); + allocated =3D domid_alloc(DOMID_ANY); verify(allocated =3D=3D expected, "TEST 3: expected %u allocated %u\n", expected, allocated); } for ( expected =3D 1; expected < DOMID_FIRST_RESERVED; expected++ ) { - allocated =3D domid_alloc(DOMID_INVALID); + allocated =3D domid_alloc(DOMID_ANY); verify(allocated =3D=3D DOMID_INVALID, "TEST 4: expected %u allocated %u\n", DOMID_INVALID, alloca= ted); } @@ -64,7 +64,7 @@ int main(int argc, char **argv) domid_free(expected); for ( expected =3D 1; expected < DOMID_FIRST_RESERVED / 2; expected++ ) { - allocated =3D domid_alloc(DOMID_INVALID); + allocated =3D domid_alloc(DOMID_ANY); verify(allocated =3D=3D expected, "TEST 5: expected %u allocated %u\n", expected, allocated); } @@ -72,7 +72,7 @@ int main(int argc, char **argv) /* Re-allocate last ID from [1..DOMID_FIRST_RESERVED - 1]. */ expected =3D DOMID_FIRST_RESERVED - 1; domid_free(DOMID_FIRST_RESERVED - 1); - allocated =3D domid_alloc(DOMID_INVALID); + allocated =3D domid_alloc(DOMID_ANY); verify(allocated =3D=3D expected, "TEST 6: expected %u allocated %u\n", expected, allocated); =20 diff --git a/xen/common/device-tree/dom0less-build.c b/xen/common/device-tr= ee/dom0less-build.c index 495ef7b16aa0..9130c38681df 100644 --- a/xen/common/device-tree/dom0less-build.c +++ b/xen/common/device-tree/dom0less-build.c @@ -842,7 +842,7 @@ void __init create_domUs(void) if ( (max_init_domid + 1) >=3D DOMID_FIRST_RESERVED ) panic("No more domain IDs available\n"); =20 - domid =3D domid_alloc(DOMID_INVALID); + domid =3D domid_alloc(DOMID_ANY); if ( domid =3D=3D DOMID_INVALID ) panic("Error allocating ID for domain %s\n", dt_node_name(node= )); =20 diff --git a/xen/common/domctl.c b/xen/common/domctl.c index 29a7726d32d0..e2c8990531ad 100644 --- a/xen/common/domctl.c +++ b/xen/common/domctl.c @@ -410,7 +410,7 @@ long do_domctl(XEN_GUEST_HANDLE_PARAM(xen_domctl_t) u_d= omctl) case XEN_DOMCTL_createdomain: { /* NB: ID#0 is reserved, find the first suitable ID instead. */ - domid_t domid =3D domid_alloc(op->domain ?: DOMID_INVALID); + domid_t domid =3D domid_alloc(op->domain ?: DOMID_ANY); =20 if ( domid =3D=3D DOMID_INVALID ) { diff --git a/xen/common/domid.c b/xen/common/domid.c index 2387ddb08300..76b7f3e7ae6e 100644 --- a/xen/common/domid.c +++ b/xen/common/domid.c @@ -19,7 +19,7 @@ static DECLARE_BITMAP(domid_bitmap, DOMID_FIRST_RESERVED); * @param domid Domain ID hint: * - If an explicit domain ID is provided, verify its availability and use= it * if ID is not used; - * - If DOMID_INVALID is provided, search [1..DOMID_FIRST_RESERVED-1] rang= e, + * - If DOMID_ANY is provided, search [1..DOMID_FIRST_RESERVED-1] range, * starting from the last used ID. Implementation guarantees that two * consecutive calls will never return the same ID. ID#0 is reserved for * the first boot domain (currently, dom0) and excluded from the allocat= ion diff --git a/xen/include/public/xen.h b/xen/include/public/xen.h index 7f15204c3885..b5789c32ae1f 100644 --- a/xen/include/public/xen.h +++ b/xen/include/public/xen.h @@ -608,6 +608,11 @@ DEFINE_XEN_GUEST_HANDLE(mmuext_op_t); /* DOMID_INVALID is used to identify pages with unknown owner. */ #define DOMID_INVALID xen_mk_uint(0x7FF4) =20 +#if defined(__XEN__) || defined(__XEN_TOOLS__) +/* Domain ID allocator: search [1..DOMID_FIRST_RESERVED-1] range. */ +#define DOMID_ANY xen_mk_uint(0x7FF5) +#endif + /* Idle domain. */ #define DOMID_IDLE xen_mk_uint(0x7FFF) =20 --=20 2.52.0