From nobody Tue May 5 10:13:29 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; 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; dmarc=pass(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1777304111; cv=none; d=zohomail.com; s=zohoarc; b=gGa6DdXPXfwhCK/qodkRtLzDdy5j9oJ3YH0FFf+yJO+0xuop5763qSOKg/dVruChRawbAn1L5i/xUH5M1zQhnh1gP30e6p6wfI3SYV+ZTeZmlQLH0S3jjKhxmzh/srIMsKnJ7TkxYtgQr9zm8Ic1vNPvRudPAJmHepTGwHm5oEE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1777304111; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=M/P5e4xXherIeaejZwj9DdoItZcrKaqfgLMdEPxMeGI=; b=WhJj4SeYv8nW5WuPapBmdUkg5YwUFDG76k+e1s2BSiUHdUTsN5vqRx3PXwnNThZPz4CiHCzH4fd9nij12yI52i/YozhhlG0CH/oHBGJo5OOzDnZava/wDfzkze5NbDwCHqHx2u6BgyWWkyLhRnx2jTeAe0k2iAKdcCKT0lXsS3A= 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; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1777304111973755.3260029892323; Mon, 27 Apr 2026 08:35:11 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.1295026.1571724 (Exim 4.92) (envelope-from ) id 1wHNyp-0004ky-41; Mon, 27 Apr 2026 15:34:39 +0000 Received: by outflank-mailman (output) from mailman id 1295026.1571724; Mon, 27 Apr 2026 15:34:39 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1wHNyo-0004km-VU; Mon, 27 Apr 2026 15:34:38 +0000 Received: by outflank-mailman (input) for mailman id 1295026; Mon, 27 Apr 2026 15:34:37 +0000 Received: from mx.expurgate.net ([195.190.135.10]) by lists.xenproject.org with esmtp (Exim 4.92) id 1wHNyn-0004h0-Dx for xen-devel@lists.xenproject.org; Mon, 27 Apr 2026 15:34:37 +0000 Received: from mx.expurgate.net (helo=localhost) by mx.expurgate.net with esmtp id 1wHNym-005DEt-NA for xen-devel@lists.xenproject.org; Mon, 27 Apr 2026 17:34:36 +0200 Received: from [10.42.69.8] (helo=localhost) by localhost with ESMTP (eXpurgate MTA 0.9.1) (envelope-from ) id 69ef81f4-e002-0a2a0a5209dd-0a2a4508ec26-16 for ; Mon, 27 Apr 2026 17:34:36 +0200 Received: from [209.85.128.54] (helo=mail-wm1-f54.google.com) by tlsNG-c1860d.mxtls.expurgate.net with ESMTPS (eXpurgate 4.56.1) (envelope-from ) id 69ef820c-63b5-0a2a45080019-d1558036d83d-3 for ; Mon, 27 Apr 2026 17:34:36 +0200 Received: by mail-wm1-f54.google.com with SMTP id 5b1f17b1804b1-4891c00e7aeso78057725e9.2 for ; Mon, 27 Apr 2026 08:34:36 -0700 (PDT) Received: from fedora (user-109-243-69-121.play-internet.pl. [109.243.69.121]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-488fc1c0354sm737076355e9.11.2026.04.27.08.34.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 27 Apr 2026 08:34:34 -0700 (PDT) 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" Authentication-Results: eu.smtp.expurgate.cloud; dkim=pass header.s=20251104 header.d=gmail.com header.i="@gmail.com" header.h="Content-Transfer-Encoding:MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:Cc:To:From" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1777304076; x=1777908876; darn=lists.xenproject.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=M/P5e4xXherIeaejZwj9DdoItZcrKaqfgLMdEPxMeGI=; b=IXF9hNbYg0XEuMVt+TzOvTbAdjKfju9/Ln05E2+qXMeMdkJk8D8yY27AwOGAPcuhs0 a/KDq6MGQlzDAATD9UI5tofMJIcFos8duZNHsorcuGNIG9PCsMGP0H2we3EKYPP4aJ45 tLo4YwVnU1tBoVj+64kdc+2/4OtubFTPXt4ifpmlX0FXbwJ1bcNSPc9m1uahnoRjsxV7 17WZI1n0k7XEm0DnOU3S9b8PzGsyWjdVLQjQULO4PdKDiMMfwBtTMk3YmrgsF8zKPB4h hbDQkeBK/80NEGKeX53EIkloa9ryCw+7ckQm+TZilXmEQmOoAfXwfLFhcDA7fI9dMeLR Mpeg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1777304076; x=1777908876; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=M/P5e4xXherIeaejZwj9DdoItZcrKaqfgLMdEPxMeGI=; b=HjMac7tvkvIOJqSdDjJ7ps9h4AFrnutszJJyF2MnewelpjlUxbvYeVzhXe4EghUBF7 gSBYvdiZ0diOybkNKIJlsWlvLnxqg5nUGv4IHkjeNP/BqynmwjGaPUAYXM/rGqSSEv+/ 0d8mDD6oiQCas1lrYEO8u/GVhsnRQSiqDyOEGIylwSIIHMUzLghqqhZVYbZ8l1FllgEp uWA6Uzc02FViO7RCDACbNT1CTr/SHFyzSsSd/fr51VMdlUinx6iU1/Upou9kY+iI2iHW ID9+9HKciuL2WV3pGCQ5KgAeecZ2i2PGa3vk3BU193abaC1OwqJzxMumzYFtLxEQ2V6B ASlg== X-Gm-Message-State: AOJu0YxC8Q0elGcXhWt1zlbjDrXeJ5pAFuNetBuu0groeCSC52sEmXFg PQVvaZcQrkH3vQ0UcO0TWKcwS3zK6dEJZnAaXXMBQur1HYsVooNszIWSa8AImQ== X-Gm-Gg: AeBDievG+1aGB9yHMD6jtazcl1oG7lyoHXr/0PI2JJRmTfDnVcSnGDCYgf0GuuWHVUa dFW98KQw4OL3hb0qvdRlr0mlYAhFs0MzDw5qGHiMS3eTPxeVzQfBDXWKzRt4HxL2aXOJoWbMjyY lrzj1OdaJWo1fb/wiDBNJTZcTBIR7U5ua5yB4vtdbAQv1bvLQbLc9KxV2cPTgZjqfgq8zkDDHl3 YX9xCYPc3p16yHn941Tv9smJ5/7GDlgyoDj0hhDrGe9qHkkeT8E6ubgxkp96lOevQ4gE57Qqzww sbcoaMlHTVL3OvmC9uzT+yZ7rk12zZNOu1jnLyafLFX7rqUR6Yoy24gGyiVMhKDMw6ryBtvPABB TuOhirNrjQKQrLLQtcdmtvwZNSWGvJqclnhNs0QNaUZ4StMv/r0rNv2ne9THA1VQAqNbpZImk3E rMroa/QWzbxFUuuhRBqzGar8pQ47ef7QdjBPn+Zp9KmSFwyOLhBNWxN5ey6ucQCp0mPhKQu0fCl lIq X-Received: by 2002:a05:600c:1907:b0:489:201c:dc46 with SMTP id 5b1f17b1804b1-489201cdf13mr426972005e9.12.1777304075162; Mon, 27 Apr 2026 08:34:35 -0700 (PDT) From: Oleksii Kurochko To: xen-devel@lists.xenproject.org Cc: Romain Caritey , Oleksii Kurochko , Stefano Stabellini , Julien Grall , Bertrand Marquis , Michal Orzel , Andrew Cooper , Anthony PERARD , Jan Beulich , =?UTF-8?q?Roger=20Pau=20Monn=C3=A9?= Subject: [PATCH v4 1/3] xen/dom0less: introduce next_phandle in struct kernel_info Date: Mon, 27 Apr 2026 17:34:23 +0200 Message-ID: <3822f12057ecc9d51b314308b0e32a85e83a7558.1777296786.git.oleksii.kurochko@gmail.com> X-Mailer: git-send-email 2.53.0 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-purgate-ID: tlsNG-c1860d/1777304076-3A776DB1-10E9FD48/10/73395122804 X-purgate-type: spam X-purgate-size: 6329 X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1777304113227154100 Content-Type: text/plain; charset="utf-8" There are cases where it is necessary to know the next available phandle number in order to generate phandles for guest device nodes. When a partial FDT (pfdt) is provided, special care is needed during initialization of next_phandle, as the pfdt may already contain a dummy interrupt controller node with a phandle assigned to it. next_phandle must therefore be initialized to one past the highest phandle already present in the pfdt, to avoid collisions. Since next_phandle may be needed for the very first guest node generated, domain_handle_dtb_boot_module() is moved earlier in prepare_dtb_domU(). The new call site also aligns better with the existing comment stating that domain_handle_dtb_boot_module() must be called before the rest of the device tree is generated. Introduce alloc_phandle() to ensure that phandles allocated for guest nodes do not overlap the Xen-reserved phandle range. This helper will be used by subsequent patches (by RISC-V at the moment). Signed-off-by: Oleksii Kurochko Reviewed-by: Michal Orzel --- Here is an example of generated guest DTB: cpus { ... cpu@0 { ... interrupt-controller { compatible =3D "riscv,cpu-intc"; #interrupt-cells =3D <0x1>; interrupt-controller; phandle =3D <0xfdea>; }; }; }; /soc/imsics@28000000 { interrupts-extended =3D <0xfdea 0x9 >; phandle =3D <0xfdeb>; }; /soc/aplic@d000000 { ... msi-parent =3D <0xfdeb>; phandle =3D <0x1>; }; Note that phandle is generated in this example not by get_next_free_phandle= (). For non RISC-V people, APLIC is an interrupt controller (something like GIC= in Arm), IMSIC it is interrupt controller which provides MSI and connects to each CPU. [1] https://www.kernel.org/doc/Documentation/devicetree/bindings/interrupt-= controller/riscv%2Ccpu-intc.txt --- Changes in v4: - Add Reviewed-by: Michal Orzel --- Changes in v3: - Drop BUG_ON(GUEST_PHANDLE_GIC =3D=3D 1). - Update the comment above declaration of next_phandle field of srtuct kernel_info. --- Changes in v2: - s/free_phandle/next_phandle. - s/get_next_free_phandle/alloc_phandle. --- xen/common/device-tree/dom0less-build.c | 43 ++++++++++++++++++------- xen/include/xen/fdt-domain-build.h | 6 ++++ xen/include/xen/fdt-kernel.h | 6 ++++ 3 files changed, 43 insertions(+), 12 deletions(-) diff --git a/xen/common/device-tree/dom0less-build.c b/xen/common/device-tr= ee/dom0less-build.c index 840d14419da2..9787ee264975 100644 --- a/xen/common/device-tree/dom0less-build.c +++ b/xen/common/device-tree/dom0less-build.c @@ -389,6 +389,24 @@ static int __init domain_handle_dtb_boot_module(struct= domain *d, if ( res < 0 ) goto out; =20 + /* + * Find the highest phandle in the partial FDT so next_phandle starts + * above it, avoiding collisions with pfdt's own phandle assignments. + */ + res =3D fdt_generate_phandle(pfdt, &kinfo->next_phandle); + if ( res ) + { + res =3D (res =3D=3D -FDT_ERR_NOPHANDLES) ? -EOVERFLOW : -EINVAL; + goto out; + } + + if ( kinfo->next_phandle >=3D GUEST_PHANDLE_GIC ) + { + dprintk(XENLOG_ERR, "Phandle allocation overlaps Xen reserved rang= e\n"); + res =3D -EOVERFLOW; + goto out; + } + for ( node_next =3D fdt_first_subnode(pfdt, 0); node_next > 0; node_next =3D fdt_next_subnode(pfdt, node_next) ) @@ -459,6 +477,7 @@ static int __init prepare_dtb_domU(struct domain *d, st= ruct kernel_info *kinfo) BUILD_BUG_ON(DOMU_DTB_SIZE > SZ_2M); =20 kinfo->phandle_intc =3D GUEST_PHANDLE_GIC; + kinfo->next_phandle =3D 1; =20 #ifdef CONFIG_GRANT_TABLE kinfo->gnttab_start =3D GUEST_GNTTAB_BASE; @@ -499,6 +518,18 @@ static int __init prepare_dtb_domU(struct domain *d, s= truct kernel_info *kinfo) if ( ret ) goto err; =20 + /* + * domain_handle_dtb_boot_module() must be called before the rest of t= he + * device tree is generated because it sets phandle_intc and next_phan= dle, + * which subsequent node generation depends on. + */ + if ( kinfo->dtb ) + { + ret =3D domain_handle_dtb_boot_module(d, kinfo); + if ( ret ) + goto err; + } + ret =3D make_chosen_node(kinfo); if ( ret ) goto err; @@ -516,18 +547,6 @@ static int __init prepare_dtb_domU(struct domain *d, s= truct kernel_info *kinfo) if ( ret ) goto err; =20 - /* - * domain_handle_dtb_boot_module has to be called before the rest of - * the device tree is generated because it depends on the value of - * the field phandle_intc. - */ - if ( kinfo->dtb ) - { - ret =3D domain_handle_dtb_boot_module(d, kinfo); - if ( ret ) - goto err; - } - ret =3D make_intc_domU_node(kinfo); if ( ret ) goto err; diff --git a/xen/include/xen/fdt-domain-build.h b/xen/include/xen/fdt-domai= n-build.h index 886a85381651..fd2ba01ff0f4 100644 --- a/xen/include/xen/fdt-domain-build.h +++ b/xen/include/xen/fdt-domain-build.h @@ -63,6 +63,12 @@ int find_unallocated_memory(const struct kernel_info *ki= nfo, unsigned long e_gfn, void *data)); =20 +/* Return 0 (invalid phandle) if the Xen-reserved range has been reached */ +static inline uint32_t alloc_phandle(struct kernel_info *kinfo) +{ + return kinfo->next_phandle >=3D GUEST_PHANDLE_GIC ? 0 : kinfo->next_ph= andle++; +} + #endif /* __XEN_FDT_DOMAIN_BUILD_H__ */ =20 /* diff --git a/xen/include/xen/fdt-kernel.h b/xen/include/xen/fdt-kernel.h index 33a60597bb4d..4d0467bb396a 100644 --- a/xen/include/xen/fdt-kernel.h +++ b/xen/include/xen/fdt-kernel.h @@ -44,6 +44,12 @@ struct kernel_info { /* Interrupt controller phandle */ uint32_t phandle_intc; =20 + /* + * Next free phandle for guest device nodes; do not access directly, u= se + * alloc_phandle(). + */ + uint32_t next_phandle; + /* loader to use for this kernel */ void (*load)(struct kernel_info *info); =20 --=20 2.53.0 From nobody Tue May 5 10:13:29 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; 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; dmarc=pass(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1777304115; cv=none; d=zohomail.com; s=zohoarc; b=l2bz7g9+BROPmlDPWacRJAtALxDGh1DICEIF3wRpgJdXStKojxirg+UN1IyEqO2VDn4EC6arkqFf7wmyoG9Q7ND4JGWRP4ZCb+9KWw3RuYiiP6q8HUH5jmenr+Ns4lvV2VUYv1vTCjYS3yBZnx8+cjHHWsE4JLKx5i2c/02nzL4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1777304115; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=ZFryJZfQNF3su1ZPDgCjTPUOxEuDSdOZ8gDsjNuEUkM=; b=aC2icOXjaErI0YoRMZ39UmX0XT/9JxZzzEN/wtIOjmxeaWrW0eq7IuNRxw+VP3dIkiwtClZf+pcVqlcNJ8f2nSiXDDuDlOEdC0Q0MqQl4Vgx/LDkCpTOWIXofODOkiejDQBs7AY8gMPY1BvszSogEtdVII+6Vtv7Ce5hmTXLKP4= 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; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1777304115262464.47538623834816; Mon, 27 Apr 2026 08:35:15 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.1295027.1571734 (Exim 4.92) (envelope-from ) id 1wHNyp-0004wP-LA; Mon, 27 Apr 2026 15:34:39 +0000 Received: by outflank-mailman (output) from mailman id 1295027.1571734; Mon, 27 Apr 2026 15:34:39 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1wHNyp-0004w1-Ew; Mon, 27 Apr 2026 15:34:39 +0000 Received: by outflank-mailman (input) for mailman id 1295027; Mon, 27 Apr 2026 15:34:37 +0000 Received: from mx.expurgate.net ([195.190.135.10]) by lists.xenproject.org with esmtp (Exim 4.92) id 1wHNyn-0004hb-Ql for xen-devel@lists.xenproject.org; Mon, 27 Apr 2026 15:34:37 +0000 Received: from mx.expurgate.net (helo=localhost) by mx.expurgate.net with esmtp id 1wHNyn-00GEYf-7e for xen-devel@lists.xenproject.org; Mon, 27 Apr 2026 17:34:37 +0200 Received: from [10.42.69.3] (helo=localhost) by localhost with ESMTP (eXpurgate MTA 0.9.1) (envelope-from ) id 69ef8208-bab6-0a2a0a5309dd-0a2a4503b6ae-12 for ; Mon, 27 Apr 2026 17:34:37 +0200 Received: from [209.85.128.41] (helo=mail-wm1-f41.google.com) by tlsNG-33051d.mxtls.expurgate.net with ESMTPS (eXpurgate 4.56.1) (envelope-from ) id 69ef820d-672d-0a2a45030019-d1558029e86d-3 for ; Mon, 27 Apr 2026 17:34:37 +0200 Received: by mail-wm1-f41.google.com with SMTP id 5b1f17b1804b1-488ff90d6c7so89008875e9.2 for ; Mon, 27 Apr 2026 08:34:37 -0700 (PDT) Received: from fedora (user-109-243-69-121.play-internet.pl. [109.243.69.121]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-488fc1c0354sm737076355e9.11.2026.04.27.08.34.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 27 Apr 2026 08:34:36 -0700 (PDT) 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" Authentication-Results: eu.smtp.expurgate.cloud; dkim=pass header.s=20251104 header.d=gmail.com header.i="@gmail.com" header.h="Content-Transfer-Encoding:MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:Cc:To:From" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1777304076; x=1777908876; darn=lists.xenproject.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=ZFryJZfQNF3su1ZPDgCjTPUOxEuDSdOZ8gDsjNuEUkM=; b=LmtuCGoXSm1qEW1SBQgogExYSB5mFiBiHFP3OfLC0zRKZQagY+BDLenOqSH0HsbmhX L9pc3bkg/cTGDaA7TwDZWXAsxsuVXqGuldexOStgAhOcbsWckMV3hxr7YUzaRUJAQ0ov BKU38ixfNuxAXG3DLf9pIlVCmPhX4JV2zxAnitoZ/o5hff4Kq1D4SFa7OpPFr6GfyVHj Nn9asE+xDgwYvKtGR7hD4umjvOYPEDaz15pgdZG7Ys1VwaVCj3ElNBC3t1lluwQ0LO5B naG2S2KH3OxtKvopmwkyA10Rm82jMVk05XWmRZK2S1lYc6onR1q3+iQEBO5uwnbUf82B Ah4A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1777304076; x=1777908876; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=ZFryJZfQNF3su1ZPDgCjTPUOxEuDSdOZ8gDsjNuEUkM=; b=D4lLqkbUCS/0XNxP0ITQ/9BtBGspvCSkN9cIwT4sHf7zepIj8EqGvOaNLDGbuO587O c8iRP7dl64wZKGOxPnLmKXC9Y8NGrd6EbzhqKvV3Qhno+osRWWFn415iAw0GVFnhO7tw EEJqQ39qruFfe9k9OLDpLSTxPhwTaMve+p+PSmJ1GHotpfMwJPADUbj44/ffI4geox0V MbJQgGptGi0E9yMXjTZSVXq6XBhlWZI13LCx1OWnXjHHenukpMcIDpcvd0dZKq3r0eai /qXjd6pZgGZNe+3JPtfMRM7pp5pXCntd5CSnrwUIVu/BVajDB+BIpBI0E8Z2SjJ2oxp1 TpaQ== X-Gm-Message-State: AOJu0YxUaJaEfmI0rx3m/9XM8g2peEKqPwVAeHaRw84nuCS5H3Fmcgse kVIusI2SLUo5vC2kpbIS1rBelk/0JvTEhT+fvc1pp9jwAJWO9JqUzV+1g44Hdw== X-Gm-Gg: AeBDietTAZTK34HpMxDzhmtt+FhEGdBbyejTKlYxh36GQxF6eBypy2H9w38Ija7bHGa CpSv2q8938xHSgQyYMJiy2ehOZpWJMWG18Qtbnm6v6vm8OnH3OWrMx++F8j41lHLVs6281stj7D 3hOTHTHFXMwj4mMqqm/g7kVq7/SRNqdBk952EbWodIqghMrtXFFKSW/V5TLJ/3e0tF5G0cCxfLJ +MKSzD/8NeZj8YK93vzPH55ravR/LC1B+GzKLI9UQ0fWRz4uN2MVdaQyVbUuO/S167nK2foNZqi fi3wSMvFQX4y2LE3uzH9Np+w+tk/bERvMKS1Z3uRwUmrvtQSEZZh4QImq3A7oIC49U4g+jr6KQJ wJ5IAbVNO9RzJTjx0Iqhudf7DeMy3+mT5RmHv62feR5ENHxREVA7ozA6pNFZMy120HDe8Ufc5wE tK1uCTialvxjm2pYrzP3CJrbIyfEfcUTWXAcaexORrNVY+WAFwV6SmaP6db365ZtZInmBLG4jws qOO X-Received: by 2002:a05:600c:8b55:b0:48a:57e1:d8cc with SMTP id 5b1f17b1804b1-48a57e1d8d4mr407546505e9.9.1777304076329; Mon, 27 Apr 2026 08:34:36 -0700 (PDT) From: Oleksii Kurochko To: xen-devel@lists.xenproject.org Cc: Romain Caritey , Oleksii Kurochko , Stefano Stabellini , Julien Grall , Bertrand Marquis , Michal Orzel , Volodymyr Babchuk , Andrew Cooper , Anthony PERARD , Jan Beulich , =?UTF-8?q?Roger=20Pau=20Monn=C3=A9?= Subject: [PATCH v4 2/3] xen/dom0less: pass kernel_info struct instead of fdt to make_cpus_node() Date: Mon, 27 Apr 2026 17:34:24 +0200 Message-ID: X-Mailer: git-send-email 2.53.0 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-purgate-ID: tlsNG-33051d/1777304077-2B161938-1B3B62D1/10/73395122804 X-purgate-type: spam X-purgate-size: 3249 X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1777304117222154100 Content-Type: text/plain; charset="utf-8" There are two reasons of this change: 1. Align prototype with what other make_*_node() are passed. 2. A follow-up RISC-V patch will call get_next_free_phandle() inside make_cpus_node(), requiring mutable access to kinfo->free_phandle. Signed-off-by: Oleksii Kurochko Reviewed-by: Michal Orzel --- Look at the footer to the prev. patch to understand why phandle is needed inside cpu node. --- Changes in v4: - Nothing changed. Only rebase. --- Changes in v3: - Add Reviewed-by: Michal Orzel . --- Changes in v2: - Properly initialize local variable fdt in Arm's make_cpus_node(). --- xen/arch/arm/domain_build.c | 5 +++-- xen/common/device-tree/dom0less-build.c | 2 +- xen/include/xen/fdt-domain-build.h | 2 +- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/xen/arch/arm/domain_build.c b/xen/arch/arm/domain_build.c index 6c17a84b2633..a3ff70102376 100644 --- a/xen/arch/arm/domain_build.c +++ b/xen/arch/arm/domain_build.c @@ -1163,7 +1163,7 @@ int __init make_psci_node(void *fdt) return res; } =20 -int __init make_cpus_node(const struct domain *d, void *fdt) +int __init make_cpus_node(const struct domain *d, struct kernel_info *kinf= o) { int res; const struct dt_device_node *cpus =3D dt_find_node_by_path("/cpus"); @@ -1177,6 +1177,7 @@ int __init make_cpus_node(const struct domain *d, voi= d *fdt) /* Keep the compiler happy with -Og */ bool clock_valid =3D false; uint64_t mpidr_aff; + void *fdt =3D kinfo->fdt; =20 dt_dprintk("Create cpus node\n"); =20 @@ -1625,7 +1626,7 @@ static int __init handle_node(struct domain *d, struc= t kernel_info *kinfo, if ( res ) return res; =20 - res =3D make_cpus_node(d, kinfo->fdt); + res =3D make_cpus_node(d, kinfo); if ( res ) return res; =20 diff --git a/xen/common/device-tree/dom0less-build.c b/xen/common/device-tr= ee/dom0less-build.c index 9787ee264975..6d6882a34b5a 100644 --- a/xen/common/device-tree/dom0less-build.c +++ b/xen/common/device-tree/dom0less-build.c @@ -534,7 +534,7 @@ static int __init prepare_dtb_domU(struct domain *d, st= ruct kernel_info *kinfo) if ( ret ) goto err; =20 - ret =3D make_cpus_node(d, kinfo->fdt); + ret =3D make_cpus_node(d, kinfo); if ( ret ) goto err; =20 diff --git a/xen/include/xen/fdt-domain-build.h b/xen/include/xen/fdt-domai= n-build.h index fd2ba01ff0f4..0d40d8cfa105 100644 --- a/xen/include/xen/fdt-domain-build.h +++ b/xen/include/xen/fdt-domain-build.h @@ -25,7 +25,7 @@ int construct_domain(struct domain *d, struct kernel_info= *kinfo); int construct_hwdom(struct kernel_info *kinfo, const struct dt_device_node *node); int make_chosen_node(const struct kernel_info *kinfo); -int make_cpus_node(const struct domain *d, void *fdt); +int make_cpus_node(const struct domain *d, struct kernel_info *kinfo); int make_hypervisor_node(struct domain *d, const struct kernel_info *kinfo, int addrcells, int sizecells); int make_memory_node(const struct kernel_info *kinfo, int addrcells, --=20 2.53.0 From nobody Tue May 5 10:13:29 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; 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; dmarc=pass(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1777304108; cv=none; d=zohomail.com; s=zohoarc; b=maqONIbNRNT5wP80XynODkZN/3flK4aHz6Qc56ktwxMK+oaowZ/zNdciY+Xa0D2uI0Zn891sLP7qNFMp3eJCtFWg8U46dTCu2c0jfZPcOjCpuU6T71rIJ5CXV4XxA1BsYkSLQ/juUPpoN+FKiZ8rAEXIYXKu8vcYSCEvt58oOV4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1777304108; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=XqFH3ZM0YOXaw4rO6uZDoJyrUUgd988+AjZxylZcJqk=; b=h64SYIpsv/2GH91HC/aZpfr65p7FX768S8KDqB4ZS5Iz3pH6q2UYlJRTD2tEkUL8jtm3BwuJM5VRcbqeZZyjM3wZB4QF1ljjBflS8sJH7ADJHtxP7ggpJ20ZLoGOQB2e6v+8IebIIv6jLDNwWyNdRLF/fW9kuQVqyhKXxnBosOw= 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; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1777304108380189.05567490263536; Mon, 27 Apr 2026 08:35:08 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.1295028.1571746 (Exim 4.92) (envelope-from ) id 1wHNyq-0005LS-RF; Mon, 27 Apr 2026 15:34:40 +0000 Received: by outflank-mailman (output) from mailman id 1295028.1571746; Mon, 27 Apr 2026 15:34:40 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1wHNyq-0005LF-O7; Mon, 27 Apr 2026 15:34:40 +0000 Received: by outflank-mailman (input) for mailman id 1295028; Mon, 27 Apr 2026 15:34:39 +0000 Received: from mx.expurgate.net ([195.190.135.10]) by lists.xenproject.org with esmtp (Exim 4.92) id 1wHNyp-0004sz-IL for xen-devel@lists.xenproject.org; Mon, 27 Apr 2026 15:34:39 +0000 Received: from mx.expurgate.net (helo=localhost) by mx.expurgate.net with esmtp id 1wHNyo-00GEYf-V8 for xen-devel@lists.xenproject.org; Mon, 27 Apr 2026 17:34:38 +0200 Received: from [10.42.69.6] (helo=localhost) by localhost with ESMTP (eXpurgate MTA 0.9.1) (envelope-from ) id 69ef8201-bab6-0a2a0a5309dd-0a2a4506eb28-18 for ; Mon, 27 Apr 2026 17:34:38 +0200 Received: from [209.85.128.42] (helo=mail-wm1-f42.google.com) by tlsNG-16d1c6.mxtls.expurgate.net with ESMTPS (eXpurgate 4.56.1) (envelope-from ) id 69ef820e-7371-0a2a45060019-d155802ab08e-3 for ; Mon, 27 Apr 2026 17:34:38 +0200 Received: by mail-wm1-f42.google.com with SMTP id 5b1f17b1804b1-483487335c2so102261365e9.2 for ; Mon, 27 Apr 2026 08:34:38 -0700 (PDT) Received: from fedora (user-109-243-69-121.play-internet.pl. [109.243.69.121]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-488fc1c0354sm737076355e9.11.2026.04.27.08.34.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 27 Apr 2026 08:34:37 -0700 (PDT) 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" Authentication-Results: eu.smtp.expurgate.cloud; dkim=pass header.s=20251104 header.d=gmail.com header.i="@gmail.com" header.h="Content-Transfer-Encoding:MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:Cc:To:From" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1777304078; x=1777908878; darn=lists.xenproject.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=XqFH3ZM0YOXaw4rO6uZDoJyrUUgd988+AjZxylZcJqk=; b=hG4hcAXjKDtekz+7N3uQKjRhGgPIXx2Q048Huem2LkP5l0nKZmVCLQ/FIym7iOTqc1 wv1pnBrbikxQdhMTVKFi4wBB7vTvkXacDWiN9jYrFq6SxR4O9bq5Uopx0nR5QkjdPj6W 8+95iYBVyf1CTDN8qXhLNXgYVySLSCIBPPNTrSHw7WNYg/aCGVTW/faqAqqlB0gO7BSj KiIIzZphk5Ednm9IKUjLuInAPdzIf3rmbem8oZQOymWPayTdSsXZ+el6YpVzeC3o6J3M 4nEjbFuhaUxV8iXn7C4RF72EkPMMUuLszZAz26Ea5O1WKDGzQN/Qa5oGG1cR4uhHugx1 BUzg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1777304078; x=1777908878; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=XqFH3ZM0YOXaw4rO6uZDoJyrUUgd988+AjZxylZcJqk=; b=gLlywsGtMp6nyAh7B63xvCHgpvlmlA9sgfsuvreLQDz0fsn0MXCSy3eTsqgNNI09Ut /R23XCufL/3lEi8JvotJ0/ejRFZVPT9AA89ZekN2Q5wFnaQnZ6NPnOg7hELFjncpfHKT evFENNWIn4G89Ixa+9XVVtYspEfaopfyVNnHWRO53DCAkUvatrvgfmlbiYYFSme75N8n DeYLCoK6iH29ZLh6QSemvQLJrzdFEzYdcpKBPfkyWlekZ39Yz22LKwo0dTnNaDv/aNxk kWLiiT6ecBu0yji+RGNjMpGUs6C2o2cGomcWczhrqZ9bWjP4RJChl/GytSuak5bCs44m ByWQ== X-Gm-Message-State: AOJu0Yxw92QgSwDA45dnGzV3jLU25Ja084/XuwJnarGdYXC6TfESpV8s f2u3YFlQ0p0jAxRnY6bgAKruqL1hwI3fs2O0WkFSE9yJVesJGcnrEgfxlH8H6A== X-Gm-Gg: AeBDiet9CauMc8E6uxXj5IJlTr1j6Fv45PDDr4HX3XOJu6XkSj4msXjnHkMQLaools9 yyvUs3ouQlMbRLk/kgfj/wURoOJfrJVHke/IRs8fGXQj+WqECsI05qM6FP6HAD8FTKJOPbbfRr4 a5tkPWDaVfxZah/CZKhlvN+uUXJLZPB5xJ10htwKDGkgSPZWvw8en7gy60BfZnYStUAWd66MI2m 8tgzb/AZnuKPUC0AHCgIvBKa3ZrZJwnWBRimuRI8VxcDdu15d/WFPzDeWEuXyHgUSdEhN9J/H/h Chto9nAe1DeJ0ymfUVjhSvTvbY54VZ0KfID9PoddI8EO+4N0LMwRCZgavzv7xdqQUOPKefHmlaI SuWypz8tlazz+fwgauIOZbTZ9hVL4rAzhgHk9deBNKu6tZ2HYJwhZUPo0dWqT/PMVPOSU6yooom Fx32W4WcV3kzZTKcydVGSnTsz9mwabUwHbdtoAolSc5nfy3W6MFXSGpJJL+7d7ntzf3tBK5l5A7 mMx X-Received: by 2002:a05:600c:c177:b0:486:fb0b:ad79 with SMTP id 5b1f17b1804b1-488fb78129emr551476665e9.20.1777304077912; Mon, 27 Apr 2026 08:34:37 -0700 (PDT) From: Oleksii Kurochko To: xen-devel@lists.xenproject.org Cc: Romain Caritey , Oleksii Kurochko , Stefano Stabellini , Julien Grall , Bertrand Marquis , Michal Orzel , Volodymyr Babchuk , Andrew Cooper , Anthony PERARD , Jan Beulich , =?UTF-8?q?Roger=20Pau=20Monn=C3=A9?= Subject: [PATCH v4 3/3] xen: introduce CONFIG_HAS_DOMAIN_TYPE Date: Mon, 27 Apr 2026 17:34:25 +0200 Message-ID: <7c91e1a705e1046be4af1c5671a8d91cf3557013.1777296786.git.oleksii.kurochko@gmail.com> X-Mailer: git-send-email 2.53.0 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-purgate-ID: tlsNG-16d1c6/1777304078-5156ED75-0A6DE078/10/73395122804 X-purgate-type: spam X-purgate-size: 11569 X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1777304111579154100 Content-Type: text/plain; charset="utf-8" As domain type is part of common code now there is no any reason to have architecture-specific set_domain_type() functions so it is dropped. Change the guard around access of kinfo->type to CONFIG_HAS_DOMAIN_TYPE for consistency. Also, drop and add some parentheses to be aligned with the similar if() below. x86 with CONFIG_64BIT=3Dy shouldn't use is_{32,64}bit_domain() as x86 doesn't have support of CONFIG_HAS_DOMAIN_TYPE. Since x86_32 Xen no longer builds, the fallback is currently only relevant for arm32. Signed-off-by: Oleksii Kurochko Reviewed-by: Michal Orzel Acked-by: Jan Beulich --- Changes in v4: - Drop enum domain_type type; from Arm's struct arch_domain. - Add Reviewed-by: Michal Orzel . --- Changes in v3: - Sort properly HAS_DOMAIN_TYPE in xen/common/Kconfig. - Update the comment above is_*bit_domain() macros. --- Changes in v2: - Update the commit message. - Move HAS_DOMAIN_TYPE to xen/common/Kconfig. - Return set_domain_type(), move it to xen/fdt-domain-build.h and make it static inline. - s/CONFIG_ARM_64/CONFIG_HAS_DOMAIN for the places where kinfo->type is us= ed. - Drop parantethes around cpu_has_el1_32 in if() and add around (kinfo->type =3D=3D DOMAIN_32BIT) to be consistent with the similar chec= k below. - Fix comment code style. - Add __packed to definition of enum domain_type --- xen/arch/arm/Kconfig | 1 + xen/arch/arm/arm64/domctl.c | 4 ++-- xen/arch/arm/dom0less-build.c | 14 -------------- xen/arch/arm/domain_build.c | 12 +++++------- xen/arch/arm/include/asm/domain.h | 16 ---------------- xen/arch/arm/include/asm/kernel.h | 4 ---- xen/arch/arm/kernel.c | 16 ++++++++-------- xen/common/Kconfig | 3 +++ xen/include/xen/dom0less-build.h | 2 -- xen/include/xen/domain.h | 13 +++++++++++++ xen/include/xen/fdt-domain-build.h | 9 +++++++++ xen/include/xen/fdt-kernel.h | 5 +++++ xen/include/xen/sched.h | 4 ++++ 13 files changed, 50 insertions(+), 53 deletions(-) diff --git a/xen/arch/arm/Kconfig b/xen/arch/arm/Kconfig index 2f2b501fdac4..79622b46a10d 100644 --- a/xen/arch/arm/Kconfig +++ b/xen/arch/arm/Kconfig @@ -7,6 +7,7 @@ config ARM_64 def_bool y depends on !ARM_32 select 64BIT + select HAS_DOMAIN_TYPE select HAS_FAST_MULTIPLY select HAS_VPCI_GUEST_SUPPORT if PCI_PASSTHROUGH =20 diff --git a/xen/arch/arm/arm64/domctl.c b/xen/arch/arm/arm64/domctl.c index 8720d126c97d..9e9a29eb1e78 100644 --- a/xen/arch/arm/arm64/domctl.c +++ b/xen/arch/arm/arm64/domctl.c @@ -21,10 +21,10 @@ static long switch_mode(struct domain *d, enum domain_t= ype type) return -EINVAL; if ( domain_tot_pages(d) !=3D 0 ) return -EBUSY; - if ( d->arch.type =3D=3D type ) + if ( d->type =3D=3D type ) return 0; =20 - d->arch.type =3D type; + d->type =3D type; =20 if ( is_64bit_domain(d) ) for_each_vcpu(d, v) diff --git a/xen/arch/arm/dom0less-build.c b/xen/arch/arm/dom0less-build.c index 4181c105389a..6f73c65e5151 100644 --- a/xen/arch/arm/dom0less-build.c +++ b/xen/arch/arm/dom0less-build.c @@ -237,20 +237,6 @@ int __init make_arch_nodes(struct kernel_info *kinfo) return 0; } =20 -/* TODO: make arch.type generic ? */ -#ifdef CONFIG_ARM_64 -void __init set_domain_type(struct domain *d, struct kernel_info *kinfo) -{ - /* type must be set before allocate memory */ - d->arch.type =3D kinfo->arch.type; -} -#else -void __init set_domain_type(struct domain *d, struct kernel_info *kinfo) -{ - /* Nothing to do */ -} -#endif - int __init init_vuart(struct domain *d, struct kernel_info *kinfo, const struct dt_device_node *node) { diff --git a/xen/arch/arm/domain_build.c b/xen/arch/arm/domain_build.c index a3ff70102376..ad665cd3c045 100644 --- a/xen/arch/arm/domain_build.c +++ b/xen/arch/arm/domain_build.c @@ -1771,15 +1771,15 @@ int __init construct_domain(struct domain *d, struc= t kernel_info *kinfo) BUG_ON(d->vcpu[0] =3D=3D NULL); BUG_ON(v->is_initialised); =20 -#ifdef CONFIG_ARM_64 +#ifdef CONFIG_HAS_DOMAIN_TYPE /* if aarch32 mode is not supported at EL1 do not allow 32-bit domain = */ - if ( !(cpu_has_el1_32) && kinfo->arch.type =3D=3D DOMAIN_32BIT ) + if ( !cpu_has_el1_32 && (kinfo->type =3D=3D DOMAIN_32BIT) ) { printk("Platform does not support 32-bit domain\n"); return -EINVAL; } =20 - if ( is_sve_domain(d) && (kinfo->arch.type =3D=3D DOMAIN_32BIT) ) + if ( is_sve_domain(d) && (kinfo->type =3D=3D DOMAIN_32BIT) ) { printk("SVE is not available for 32-bit domain\n"); return -EINVAL; @@ -1893,10 +1893,8 @@ int __init construct_hwdom(struct kernel_info *kinfo, =20 iommu_hwdom_init(d); =20 -#ifdef CONFIG_ARM_64 - /* type must be set before allocate_memory */ - d->arch.type =3D kinfo->arch.type; -#endif + set_domain_type(d, kinfo); + find_gnttab_region(d, kinfo); if ( is_domain_direct_mapped(d) ) allocate_memory_11(d, kinfo); diff --git a/xen/arch/arm/include/asm/domain.h b/xen/arch/arm/include/asm/d= omain.h index ffe5d0d9f0a6..b24f02d269be 100644 --- a/xen/arch/arm/include/asm/domain.h +++ b/xen/arch/arm/include/asm/domain.h @@ -18,18 +18,6 @@ struct hvm_domain uint64_t params[HVM_NR_PARAMS]; }; =20 -#ifdef CONFIG_ARM_64 -enum domain_type { - DOMAIN_32BIT, - DOMAIN_64BIT, -}; -#define is_32bit_domain(d) ((d)->arch.type =3D=3D DOMAIN_32BIT) -#define is_64bit_domain(d) ((d)->arch.type =3D=3D DOMAIN_64BIT) -#else -#define is_32bit_domain(d) (1) -#define is_64bit_domain(d) (0) -#endif - /* * Is the domain using the host memory layout? * @@ -62,10 +50,6 @@ struct paging_domain { =20 struct arch_domain { -#ifdef CONFIG_ARM_64 - enum domain_type type; -#endif - #ifdef CONFIG_ARM64_SVE /* max SVE encoded vector length */ uint8_t sve_vl; diff --git a/xen/arch/arm/include/asm/kernel.h b/xen/arch/arm/include/asm/k= ernel.h index 7c3b7fde5b64..21f4273fa1b5 100644 --- a/xen/arch/arm/include/asm/kernel.h +++ b/xen/arch/arm/include/asm/kernel.h @@ -10,10 +10,6 @@ =20 struct arch_kernel_info { -#ifdef CONFIG_ARM_64 - enum domain_type type; -#endif - /* Enable pl011 emulation */ bool vpl011; }; diff --git a/xen/arch/arm/kernel.c b/xen/arch/arm/kernel.c index 7544fd50a20f..9395b5af8745 100644 --- a/xen/arch/arm/kernel.c +++ b/xen/arch/arm/kernel.c @@ -100,8 +100,8 @@ static paddr_t __init kernel_zimage_place(struct kernel= _info *info) const struct membanks *mem =3D kernel_info_get_mem(info); paddr_t load_addr; =20 -#ifdef CONFIG_ARM_64 - if ( (info->arch.type =3D=3D DOMAIN_64BIT) && (info->zimage.start =3D= =3D 0) ) +#ifdef CONFIG_HAS_DOMAIN_TYPE + if ( (info->type =3D=3D DOMAIN_64BIT) && (info->zimage.start =3D=3D 0)= ) return mem->bank[0].start + info->zimage.text_offset; #endif =20 @@ -268,14 +268,14 @@ int __init kernel_uimage_probe(struct kernel_info *in= fo, =20 info->load =3D kernel_zimage_load; =20 -#ifdef CONFIG_ARM_64 +#ifdef CONFIG_HAS_DOMAIN_TYPE switch ( uimage.arch ) { case IH_ARCH_ARM: - info->arch.type =3D DOMAIN_32BIT; + info->type =3D DOMAIN_32BIT; break; case IH_ARCH_ARM64: - info->arch.type =3D DOMAIN_64BIT; + info->type =3D DOMAIN_64BIT; break; default: printk(XENLOG_ERR "Unsupported uImage arch type %d\n", uimage.arch= ); @@ -345,7 +345,7 @@ static int __init kernel_zimage64_probe(struct kernel_i= nfo *info, =20 info->load =3D kernel_zimage_load; =20 - info->arch.type =3D DOMAIN_64BIT; + info->type =3D DOMAIN_64BIT; =20 return 0; } @@ -396,8 +396,8 @@ static int __init kernel_zimage32_probe(struct kernel_i= nfo *info, =20 info->load =3D kernel_zimage_load; =20 -#ifdef CONFIG_ARM_64 - info->arch.type =3D DOMAIN_32BIT; +#ifdef CONFIG_HAS_DOMAIN_TYPE + info->type =3D DOMAIN_32BIT; #endif =20 return 0; diff --git a/xen/common/Kconfig b/xen/common/Kconfig index 0a20aa0a1249..5ff71480eebe 100644 --- a/xen/common/Kconfig +++ b/xen/common/Kconfig @@ -128,6 +128,9 @@ config HAS_DEVICE_TREE_DISCOVERY config HAS_DOM0LESS bool =20 +config HAS_DOMAIN_TYPE + bool + config HAS_DIT # Data Independent Timing bool =20 diff --git a/xen/include/xen/dom0less-build.h b/xen/include/xen/dom0less-bu= ild.h index faaf660424b2..4118dec76c0a 100644 --- a/xen/include/xen/dom0less-build.h +++ b/xen/include/xen/dom0less-build.h @@ -57,8 +57,6 @@ int init_vuart(struct domain *d, struct kernel_info *kinf= o, int make_intc_domU_node(struct kernel_info *kinfo); int make_arch_nodes(struct kernel_info *kinfo); =20 -void set_domain_type(struct domain *d, struct kernel_info *kinfo); - int init_intc_phandle(struct kernel_info *kinfo, const char *name, const int node_next, const void *pfdt); =20 diff --git a/xen/include/xen/domain.h b/xen/include/xen/domain.h index 93c0fd00c1d7..8c898afe74fc 100644 --- a/xen/include/xen/domain.h +++ b/xen/include/xen/domain.h @@ -13,6 +13,19 @@ struct guest_area { void *map; }; =20 +#ifdef CONFIG_HAS_DOMAIN_TYPE +enum __packed domain_type { + DOMAIN_32BIT, + DOMAIN_64BIT, +}; +#define is_32bit_domain(d) ((d)->type =3D=3D DOMAIN_32BIT) +#define is_64bit_domain(d) ((d)->type =3D=3D DOMAIN_64BIT) +#elif !defined(CONFIG_64BIT) +/* At the moment on 32-bit-only platforms all domains are 32-bit. */ +#define is_32bit_domain(d) (true) +#define is_64bit_domain(d) (false) +#endif + #include =20 typedef union { diff --git a/xen/include/xen/fdt-domain-build.h b/xen/include/xen/fdt-domai= n-build.h index 0d40d8cfa105..bc7744270c8f 100644 --- a/xen/include/xen/fdt-domain-build.h +++ b/xen/include/xen/fdt-domain-build.h @@ -7,6 +7,7 @@ #include #include #include +#include #include =20 struct domain; @@ -69,6 +70,14 @@ static inline uint32_t alloc_phandle(struct kernel_info = *kinfo) return kinfo->next_phandle >=3D GUEST_PHANDLE_GIC ? 0 : kinfo->next_ph= andle++; } =20 +static inline void set_domain_type(struct domain *d, struct kernel_info *k= info) +{ +#ifdef CONFIG_HAS_DOMAIN_TYPE + /* Type must be set before allocate memory */ + d->type =3D kinfo->type; +#endif +} + #endif /* __XEN_FDT_DOMAIN_BUILD_H__ */ =20 /* diff --git a/xen/include/xen/fdt-kernel.h b/xen/include/xen/fdt-kernel.h index 4d0467bb396a..86a37a13048b 100644 --- a/xen/include/xen/fdt-kernel.h +++ b/xen/include/xen/fdt-kernel.h @@ -9,6 +9,7 @@ =20 #include #include +#include #include =20 #if __has_include() @@ -65,6 +66,10 @@ struct kernel_info { } zimage; }; =20 +#ifdef CONFIG_HAS_DOMAIN_TYPE + enum domain_type type; +#endif + #if __has_include() struct arch_kernel_info arch; #endif diff --git a/xen/include/xen/sched.h b/xen/include/xen/sched.h index 212c7d765c3e..00db1da12f21 100644 --- a/xen/include/xen/sched.h +++ b/xen/include/xen/sched.h @@ -386,6 +386,10 @@ struct domain { domid_t domain_id; =20 +#ifdef CONFIG_HAS_DOMAIN_TYPE + enum domain_type type; +#endif + unsigned int max_vcpus; =20 uint64_t unique_id; /* Unique domain identifier */ --=20 2.53.0