From nobody Sun May 3 15:41:11 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=1777037845; cv=none; d=zohomail.com; s=zohoarc; b=FYYe2ohkH9v/LnVEPsbFyJ4omN3dj7KB2YI7DEgIFU/JsiHvDrHe3114wwZorQ9xhjls436u2TEvxRjLyrS6vevjjAukT08R/XTMWUYYdAcgWz/HgHjRznKQpq16LY1Hr5NL29ijC585jSUmVj0uKHcF+6G3/kBUOxTPD1Tujw4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1777037845; 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=YeUlz7Qpf2B9MkICZ3XhoDDRV4QPAj1kbAZBfKIlP24=; b=NYLIyU+ym3EQfkMRXTN+q1ZsDfS5B/Nck8HhAwWGJcI3dYUswnlxwE+zT39VcdbG9lK2VqAknoLocSMj9TyeX8w2KqbDzOVX5MtYZcnWIZupJOIvQYa5VCxS2+Gp67EDvKE7nheRd2nTiSoFr6jblZKGzSv9dWtCu5lVdnG3a5E= 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 1777037845613458.60284522849724; Fri, 24 Apr 2026 06:37:25 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.1293570.1571202 (Exim 4.92) (envelope-from ) id 1wGGiO-0002fX-2E; Fri, 24 Apr 2026 13:37:04 +0000 Received: by outflank-mailman (output) from mailman id 1293570.1571202; Fri, 24 Apr 2026 13:37:04 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1wGGiN-0002fM-Uk; Fri, 24 Apr 2026 13:37:03 +0000 Received: by outflank-mailman (input) for mailman id 1293570; Fri, 24 Apr 2026 13:37:02 +0000 Received: from mx.expurgate.net ([195.190.135.10]) by lists.xenproject.org with esmtp (Exim 4.92) id 1wGGiM-0002Rg-6C for xen-devel@lists.xenproject.org; Fri, 24 Apr 2026 13:37:02 +0000 Received: from mx.expurgate.net (helo=localhost) by mx.expurgate.net with esmtp id 1wGGiL-000jjh-JA for xen-devel@lists.xenproject.org; Fri, 24 Apr 2026 15:37:01 +0200 Received: from [10.42.69.9] (helo=localhost) by localhost with ESMTP (eXpurgate MTA 0.9.1) (envelope-from ) id 69eb71fa-5cb7-0a2a0a5109dd-0a2a4509da28-20 for ; Fri, 24 Apr 2026 15:37:01 +0200 Received: from [209.85.167.46] (helo=mail-lf1-f46.google.com) by tlsNG-bad1c0.mxtls.expurgate.net with ESMTPS (eXpurgate 4.56.1) (envelope-from ) id 69eb71fd-2497-0a2a45090019-d155a72eac6f-3 for ; Fri, 24 Apr 2026 15:37:01 +0200 Received: by mail-lf1-f46.google.com with SMTP id 2adb3069b0e04-5a0faa0d15cso7756722e87.0 for ; Fri, 24 Apr 2026 06:37:01 -0700 (PDT) Received: from fedora (user-109-243-69-121.play-internet.pl. [109.243.69.121]) by smtp.gmail.com with ESMTPSA id 2adb3069b0e04-5a5241f6583sm3649078e87.39.2026.04.24.06.36.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 24 Apr 2026 06:36:59 -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=1777037820; x=1777642620; 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=YeUlz7Qpf2B9MkICZ3XhoDDRV4QPAj1kbAZBfKIlP24=; b=AYM3+x8i1CyqgPAV+spfNGgmteZh8NLrT9c2BjeeihffZ9QTlsoLIgD/jm1G2RZjSp 8dW3nUGFGmz8bpFRF7GPNXoJvS1aSZgeYx/8cxilkHsDZp8vPEskvmpWNhyCWEUfT3kf scMnDXECjyj7uDUeD2Yxyzz5dUDSMfLBI7w5UISBUeXvZqYTGHOA7OZMs31Ux/Smv6Qa y9ddyFuhHEZW6H2NP+UnGQfCPQTWom4d9hd9YK68qLRL/UVXE9JHd6RqMsVRJBS5Bdg7 42+/VQQ6up5FMHQ0b7O4mpmO8NMOlXeOa7XYY3qJkZc9GVWQ0ff7A8iHN5S3LLodMfbb qHzA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1777037820; x=1777642620; 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=YeUlz7Qpf2B9MkICZ3XhoDDRV4QPAj1kbAZBfKIlP24=; b=oyNe639n0aOTOeoVrmtbHDHoAWR+1ylrLIMzFrtv0zexG9o52rizYs2raQpgEoE/hG OxI//jpc2qvrk06oPw7ls4hzvDC/+/cvWIonEkK1RW4Ypkp62aH67XEIQByDxcdEhpiT KS/7Pj6sslUzxoXoUVnpGjT7gYL80LbE7uoW/QPxXJI3qqhh4HCUVvEAAEJsk2NGNeCJ Oqa6YEHcQFWbYlWNU1DK2bUEylD+3vCzYDXlXoPvI85TxTBMhmne6I4Pkdfw8cup1kCe TombQfs9fgXnjU/lW//AxV8MylZYi19VUlL/H8xPLGa5tVyK/mrqzIgiCSPt52Kp7xJJ e/Uw== X-Gm-Message-State: AOJu0Yw8MiTY5pSozOQgwefTNr7lXN2RApB3jF1qqJulxKG7SzWf+RWX gn8BdeZK3jXEYM1e0C08QN7YntxZIuzvU7oKiTIrBa4HtwSe/emYfl/Au41ZkA== X-Gm-Gg: AeBDievO15GWn7UwZ5s8C9HgaTJtvtVBgPX3/6Yf+l4pi74SqD8XSi+59AWsBoc6FmW HH/2JB/eIjpQUuZAeAwKSu9oxi5yYjD+Wub6viUutzw33sG5oET9qiRGWQQ8GmIMSYLn+EAXyt1 UIkPQiYHZHqrs03xrGThv6epNF93Wi5+Ui0qX0P8QhUBaeIpzqGYcMwFzpqFXNFY+2/XohYJMbX +tncqWnXZ4xxz3ghrW/K7ueuOUymn1tdlMlzIL8wSzZv/XMA+Ce2/effljEIjJeJLLlrtRxhmuK pWhQRx5ORtyeDd0F+zq0drY7Jfr6TAPzA5WatnN7XKFTeGF3ki3AgvaiV3ys+Dv/xw0DTjjDEqd 2rE8Ifj1JMeW4dEw63G8d71N4yy2VQIiJ8HAyYzyIr10RvPG0CaPEDJ5pbwH5NVM7CWpEbeQTBu tEUsLSdW2P0g08KTFLFlXGAw3fSudIBD0/MeJMCLusrMvqWClvl+tJJNEJgx3D5FwZT1j9lByN/ g8S X-Received: by 2002:a05:6512:1302:b0:5a3:fe60:471c with SMTP id 2adb3069b0e04-5a4172cb33amr11125558e87.16.1777037820163; Fri, 24 Apr 2026 06:37:00 -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 v3 1/3] xen/dom0less: introduce next_phandle in struct kernel_info Date: Fri, 24 Apr 2026 15:36:49 +0200 Message-ID: <5e3ffb41fab84b5f1b59ea81e6d267def89e2d65.1776957840.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-bad1c0/1777037821-92971A53-E7173810/10/73395122804 X-purgate-type: spam X-purgate-size: 6206 X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1777037847964154100 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 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 Sun May 3 15:41:11 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=1777037840; cv=none; d=zohomail.com; s=zohoarc; b=Mr7kWVihjHa7mrCAdEoKrGN9YX3MtfXOCI7dsHLxo8GcL1jLfuvNEVyYb2hce4FYPTVPyeK6DZbN/bQqAn982ffBG/Th+RQxKDYLXc3V0ydc5O0E8NziqwVT06+10QevelSg2aYk2jzGBXSUUKA1IqM8q5SbOW0FDjCMCuP5cPM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1777037840; 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=0/RZ80b7VFUK2z86zIRDb2DVaNRf6KFOtP42XANEu1E=; b=SQtR+J9rF8Y7Z+ARoUf+37E+d2qtkMjVB3Sj7P7rJjEWWmD/aYNXbVwql83BkdRuZgMX46qklhBYQPFSumyZKe6Zqr7R/IeAm6vAkKE1079qxLZFkOot2QajGgWwXaU0g3A0qG2Ch1oAq2K3zgrS0EP1S000o/u3hoFxF7VUFCE= 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 1777037840768866.7054900034384; Fri, 24 Apr 2026 06:37:20 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.1293571.1571211 (Exim 4.92) (envelope-from ) id 1wGGiP-0002tQ-7q; Fri, 24 Apr 2026 13:37:05 +0000 Received: by outflank-mailman (output) from mailman id 1293571.1571211; Fri, 24 Apr 2026 13:37:05 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1wGGiP-0002tG-4i; Fri, 24 Apr 2026 13:37:05 +0000 Received: by outflank-mailman (input) for mailman id 1293571; Fri, 24 Apr 2026 13:37:04 +0000 Received: from mx.expurgate.net ([195.190.135.10]) by lists.xenproject.org with esmtp (Exim 4.92) id 1wGGiN-0002dY-RT for xen-devel@lists.xenproject.org; Fri, 24 Apr 2026 13:37:03 +0000 Received: from mx.expurgate.net (helo=localhost) by mx.expurgate.net with esmtp id 1wGGiN-00EP0d-88 for xen-devel@lists.xenproject.org; Fri, 24 Apr 2026 15:37:03 +0200 Received: from [10.42.69.11] (helo=localhost) by localhost with ESMTP (eXpurgate MTA 0.9.1) (envelope-from ) id 69eb71e7-2eae-0a2a0a5409dd-0a2a450bc858-42 for ; Fri, 24 Apr 2026 15:37:03 +0200 Received: from [209.85.167.47] (helo=mail-lf1-f47.google.com) by tlsNG-42698a.mxtls.expurgate.net with ESMTPS (eXpurgate 4.56.1) (envelope-from ) id 69eb71fe-212f-0a2a450b0019-d155a72fa495-3 for ; Fri, 24 Apr 2026 15:37:03 +0200 Received: by mail-lf1-f47.google.com with SMTP id 2adb3069b0e04-5a10d130b37so7847646e87.0 for ; Fri, 24 Apr 2026 06:37:03 -0700 (PDT) Received: from fedora (user-109-243-69-121.play-internet.pl. [109.243.69.121]) by smtp.gmail.com with ESMTPSA id 2adb3069b0e04-5a5241f6583sm3649078e87.39.2026.04.24.06.37.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 24 Apr 2026 06:37:00 -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=1777037822; x=1777642622; 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=0/RZ80b7VFUK2z86zIRDb2DVaNRf6KFOtP42XANEu1E=; b=WWEcydPAnyslEO2fQ2ZRiw3DyvUaSPq/ygEQYBhKHLqOWKo4KV5t9T70OcamQlXLeu JZyFxsJqsO5+cmiuXiBNGcDb1URmINFTRLNj8Ido+n+oF9IuhyWuQeIJ7AEb2hai3LGO 6qZncYVTiuQhrH56SSnKw7yb9bt7MIMqFR+CdF0ri34nkO5F1ERduvKFQ5oYMbAytV/K Zpd2VDAqsb/XrHjriPqm0wQJ4aNObI1h3pjJ9MuG0W//d+5jgcZtPMTMt//vYMIp8S5I 5Fak5VLMvHYAR8BQ1p75PffFt0cwq4AwJGqsCYE3a+7zCi2ASmT6dvDZOlg0cADteXJo nClQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1777037822; x=1777642622; 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=0/RZ80b7VFUK2z86zIRDb2DVaNRf6KFOtP42XANEu1E=; b=Hfi2jPfdUGwlymR1yQL2R5hfy8+3wnSODZaPMLZe6Nje/cqDztZ0g52TIZxquruUVv S0JSN2/nMnSxNieBmfiohO23KwHtBRWJ9DaDBnW7jFdrHtO3hPbuDlwJPN6Q3YQ9rQUA ohf/jv+TaS4xUBeEo136pHTrMBfZBL3k25vIflpDObaTOP40rbLXbKJrI/gQLl1uneMV m3k4I4/0gPcpDCqCT+8RJC2LV89anLLoG4gszaty7FIgKCD0HKpcDsI204kv5q/AVVmG xKQxMn+8akFGsW2/1J/+fAbQ8u/2DdirTJkjXJMYtYJPYjgpcT4ZeTyElcn1nxI/La2c zDRQ== X-Gm-Message-State: AOJu0Yz1/1xqvLxk3R/+FQ9Y2BQLrs0Vuzi/CswDizpR3k5+DYveraRx kvvrHz4xsrv2Vn21kz3kTtHTxv62DAmYUqa4LNYWs09Iux9MXIK5EzBi/uowCQ== X-Gm-Gg: AeBDietbQsx3sDIG1qv1rVQB3bVHuWHg3TcuQ9xV90P5eQ6Ad8zSW608Tgc7SZduPEA KGv4fg6Qo4sOr8dGmd6hIFEqXZb8JmZXRWavpK8sl/boaG4ryB7pNP33z4UcK7LpcmIfrxkgXvN DctdPUsUhUjXXhLaNbKBuSAabZYysPgmQ4b3pcvRYBfoE0/C9FwdGzwc1R3YWk9yi3zj3XMpN20 Q9Uihl+lD6qBAabAjCHAcCL//g2tT+4S30eUSdLtZCx6w8C6p25joBadTAnl5VmaDOBg3mlO9bk AV/eOuoMn27U5eRhEfR7ve4KrqQUhFmEDTgtGd/YzfdsNB4Pplurt9nRc8uakc8dsXFvdiajqiX lIHpANhOiS3DgQOpr4xm62mnFxiOwmEMVnM3KTFihtqHKUlvBBevmxsoAWhF+LBYNMaEXLYlk1Y ZItt3dRKdmi0NqcmTkIwkIbX/vJCpjD3V8p08/DdJG1Kn5MA/RPS1BNJh0cVr+Z9QysxMoYUNXP ROM X-Received: by 2002:a05:6512:3094:b0:5a4:165:3ddb with SMTP id 2adb3069b0e04-5a417299a02mr10621418e87.12.1777037821762; Fri, 24 Apr 2026 06:37:01 -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 v3 2/3] xen/dom0less: pass kernel_info struct instead of fdt to make_cpus_node() Date: Fri, 24 Apr 2026 15:36:50 +0200 Message-ID: <23edbf2f4b102ff68aacdc744ac9968aedbc6854.1776957840.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-42698a/1777037823-244B4F3B-88265D88/10/73395122804 X-purgate-type: spam X-purgate-size: 3199 X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1777037843856154100 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 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 Sun May 3 15:41:11 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=1777037846; cv=none; d=zohomail.com; s=zohoarc; b=JdKoa7K6lbowIa5tncNUriiU31Fb0Fb77rnc4BoM9u+L5Qe1nCO/rBrDgfhEFhVrU1mQtHnVUk++BGgcbKPgq5iQ4UPhuIElRuBeBgh/LPAFZ1rNViTknxolaXB2eCEEzHUa/Prbz/qBxj9ih8JpopYjtUXGLQ2Mg94A1GSB1ls= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1777037846; 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=faxicMWV0pyOsr9LCBEsD50TaZnCHvDt9RPH9o+wZSY=; b=MLvP1a/xqxll5/pPKalpDQw0vWkHx2+RWijqFABZuBybGcyoAFXwBadPvEpPyxSEluk/Mq2H0zeG5zPX51b6r/syXWQeWeePwI1z8sJxmQT6G3xo5NzpuL1a981icpTFFoZ49npeAR2lr/T/wi+xOOxa0d9IJip1By+7GQuxajY= 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 1777037846475238.58657523265708; Fri, 24 Apr 2026 06:37:26 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.1293572.1571220 (Exim 4.92) (envelope-from ) id 1wGGiQ-00037w-HM; Fri, 24 Apr 2026 13:37:06 +0000 Received: by outflank-mailman (output) from mailman id 1293572.1571220; Fri, 24 Apr 2026 13:37:06 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1wGGiQ-00037m-Dh; Fri, 24 Apr 2026 13:37:06 +0000 Received: by outflank-mailman (input) for mailman id 1293572; Fri, 24 Apr 2026 13:37:05 +0000 Received: from mx.expurgate.net ([195.190.135.10]) by lists.xenproject.org with esmtp (Exim 4.92) id 1wGGiP-0002tN-BN for xen-devel@lists.xenproject.org; Fri, 24 Apr 2026 13:37:05 +0000 Received: from mx.expurgate.net (helo=localhost) by mx.expurgate.net with esmtp id 1wGGiO-00EP4D-OV for xen-devel@lists.xenproject.org; Fri, 24 Apr 2026 15:37:04 +0200 Received: from [10.42.69.4] (helo=localhost) by localhost with ESMTP (eXpurgate MTA 0.9.1) (envelope-from ) id 69eb71e8-e002-0a2a0a5209dd-0a2a4504ab34-34 for ; Fri, 24 Apr 2026 15:37:04 +0200 Received: from [209.85.167.42] (helo=mail-lf1-f42.google.com) by tlsNG-ebf023.mxtls.expurgate.net with ESMTPS (eXpurgate 4.56.1) (envelope-from ) id 69eb7200-1dec-0a2a45040019-d155a72ae9d4-3 for ; Fri, 24 Apr 2026 15:37:04 +0200 Received: by mail-lf1-f42.google.com with SMTP id 2adb3069b0e04-5a62f43b76aso2954889e87.3 for ; Fri, 24 Apr 2026 06:37:04 -0700 (PDT) Received: from fedora (user-109-243-69-121.play-internet.pl. [109.243.69.121]) by smtp.gmail.com with ESMTPSA id 2adb3069b0e04-5a5241f6583sm3649078e87.39.2026.04.24.06.37.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 24 Apr 2026 06:37:02 -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=1777037823; x=1777642623; 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=faxicMWV0pyOsr9LCBEsD50TaZnCHvDt9RPH9o+wZSY=; b=gnW5SaxfUqA5z44hed2+oJPnTyMvWxoKkVjd+k+QuKu/U4yrJ5TGLpI3hhWJRN+aJz z3aYmvu+0x/OrgCi4URxmkG07ASTsocHQeA97u1mXD2q+1YFyT4KR6cdtf8W1aG3xURT Se+nmov+EA881D92OxSgonXHcnlJirzFrYlxC696DMpCZdcH1F7a+f4h16RgdjrndTmx m7S2r+SzLvTt62Vx3NFwcjtMDPlD94Mry4QcT9/sPrZZkhgTYJtdA2VlC7lKsns4HB9/ Clcge+rmo5scP9//mMUCqgY4SX9le9jfsiqCb5kz0XoNLQyBRZBh3oQO6K9Ti7vHsyO+ 6daw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1777037823; x=1777642623; 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=faxicMWV0pyOsr9LCBEsD50TaZnCHvDt9RPH9o+wZSY=; b=le0oslk7A5EeUL/F3AG/kTyXhLjb8gqfprOQEk4ECvp17WRRuDVGiuii+dlBUWaPPU i8vArOQdde1GsyzNGHoDCIUiz4mWxArR3Oo0b2YoC23ZabMNsiaJVyBUrWj1IBFe8ujM DT9H7N5l4cFeMsng9PrFhE7gJerAkx/kk9aB3UyFPEyP8No9OQzLV3oQH+uAJEMgyMpH JJvVBTEQrF0ciZNthaLOuxII1CPfCXvZ7oRxqHRAvdSmnHjG3rcFhQhahECjG1oo3veP DvjTggf5EC2t+Xw0n+BP4vdYjXFhHMyoXIXTqsEA02J3XL5tRp9ZEohHkA/DqKhD7/bU +CNA== X-Gm-Message-State: AOJu0YyRL4muV+fHWqR9Y/8TPnjWcDKrR3gfiTEQZN9TwhGi62lj7g9M qmmTbFxiku754d4D0rbINGoRjBqaVYRY8JUqX81FnUqDJcLZ2X41tZo9aDh9hg== X-Gm-Gg: AeBDievMsd0u/0DypvFvUuW0uvNdL69z9+hGs2ZwWJ18/ZbrhjM0bXwssSkTK8JRE6q 0klCfMQTR/B9wGCp1GKuCJsfNHMru4dcDMXAQKqJgilN2L1NeeZtFOuP7J+8ESNqZfESvdUqdgt OGw7F+iAbgknWW0TmPGHC74p9gSgaGUzusEq1TUQS4Ce8+KTJENH7LY5HlWiG9JtsoePoNP46Mz jdUgGAv3iniJ2W93qhlge7QPIq1yU59y0pkfmOffddHlfelSx+KFbGrPZxtA8STwUkAwpoBSbt4 bI8CGu/7Lc9eWyanZaJlA9vJOPMW6QvfDZu3zXSyUh/SPaiWSDXpeT/SBjjQKj0w3JDDaja/tQ3 hzN5YRUEkBEYQPYK37cEajtAecAi4eTLpjeT8OZGHWWMKGPA1QreRQcbPQwjUahWblN91sbdmwG qWFId51wuS70F4QgLGXemk1qLy2vzT43PvKkd8auuwVwRRfluX+D1tJxHiJR1nHAElewWPvad1J T49 X-Received: by 2002:a05:6512:154b:20b0:5a3:ff44:f01b with SMTP id 2adb3069b0e04-5a4172e3131mr7107204e87.34.1777037823257; Fri, 24 Apr 2026 06:37:03 -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 v3 3/3] xen: introduce CONFIG_HAS_DOMAIN_TYPE Date: Fri, 24 Apr 2026 15:36:51 +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-ebf023/1777037824-2B5683FF-798A559E/10/73395122804 X-purgate-type: spam X-purgate-size: 11153 X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1777037847544158500 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 --- 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 | 12 ------------ 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(+), 49 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..e51baa0557bd 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? * 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