From nobody Sun May 3 14:24:07 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=1776851094; cv=none; d=zohomail.com; s=zohoarc; b=G1csC6yN7ot8FLs01xcEtDM2IIA/NB5wtsELFVu/dAWMk88vicBXc61Oxvb+JxZpG02ixjESM38+N/IC4mPgsea2O5KpKFusy1KeMwj2bjHbkX8fnWbVB8Unij1DGkiTO+xEr+2SjFADIPYu4HvBToAEbZWrfPxzY2HIfepSI5o= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1776851094; 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=ccoFJqXqscTgy/LGmtQbJuqk+NDolzkDBynx/48/gkQ=; b=gjky6ABw25Lf9OMGxXjgP3MUORNj5el5uupTm5h9oZieaRVBRznYkXI6b9JRqYtxCnYPqNB/3KpXhLNwK6hY3FoxYRf7l82dtvzNNK1Ps7d9dQ5maSyBdm7pZVRKkHctUSF8a/J++M8dFghQKbn/nJoYrwfYlkIGenwiJMbPhN0= 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 1776851094842777.2334205141963; Wed, 22 Apr 2026 02:44:54 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.1290140.1569832 (Exim 4.92) (envelope-from ) id 1wFU8J-0005tS-LE; Wed, 22 Apr 2026 09:44:35 +0000 Received: by outflank-mailman (output) from mailman id 1290140.1569832; Wed, 22 Apr 2026 09:44:35 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1wFU8J-0005st-FK; Wed, 22 Apr 2026 09:44:35 +0000 Received: by outflank-mailman (input) for mailman id 1290140; Wed, 22 Apr 2026 09:44:34 +0000 Received: from mx.expurgate.net ([195.190.135.10]) by lists.xenproject.org with esmtp (Exim 4.92) id 1wFU8H-0005eC-VF for xen-devel@lists.xenproject.org; Wed, 22 Apr 2026 09:44:34 +0000 Received: from mx.expurgate.net (helo=localhost) by mx.expurgate.net with esmtp id 1wFU8H-00E82D-By for xen-devel@lists.xenproject.org; Wed, 22 Apr 2026 11:44:33 +0200 Received: from [10.42.69.3] (helo=localhost) by localhost with ESMTP (eXpurgate MTA 0.9.1) (envelope-from ) id 69e89879-5cb7-0a2a0a5109dd-0a2a4503bf1a-48 for ; Wed, 22 Apr 2026 11:44:33 +0200 Received: from [209.85.167.46] (helo=mail-lf1-f46.google.com) by tlsNG-33051d.mxtls.expurgate.net with ESMTPS (eXpurgate 4.56.1) (envelope-from ) id 69e89880-672d-0a2a45030019-d155a72ed0f4-3 for ; Wed, 22 Apr 2026 11:44:32 +0200 Received: by mail-lf1-f46.google.com with SMTP id 2adb3069b0e04-5a41099fa86so4655054e87.2 for ; Wed, 22 Apr 2026 02:44:32 -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-5a41cc7f832sm3494193e87.28.2026.04.22.02.44.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 22 Apr 2026 02:44:30 -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=1776851071; x=1777455871; 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=ccoFJqXqscTgy/LGmtQbJuqk+NDolzkDBynx/48/gkQ=; b=BRTsnYl6l1eIx8r4worWJuyYK81brhYITiHMRnc8oxiNCQNSkbxUduOo8TYoLDGACi drO9JHSl+Qk7M60+uWkLPl1u5eaO3jGHVWyAUCN9SVg3LE9M0LzVYcXpoiTAfTQuJPRp 5ss5ClrD4qTU69I8bttnMT5GDGe0Ra0fVg+JS9G5DRz9r19yNvFT1vcYTLK8yiOx0YHN HEe7xHrNedis7OJQH1/SdWHjzDRqz3aC9d8BAM1RaGB7mo1LwmAsjYrNdwyKlW2Q+p+t nJOvp0E+hdy4IXZppQoIEdhELrbR7k2vUhn7IpfX7sdpyBUMybVksoESXB15Yklnd7Rj bA+A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1776851071; x=1777455871; 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=ccoFJqXqscTgy/LGmtQbJuqk+NDolzkDBynx/48/gkQ=; b=p43sB5Ovwl7oW3EyyY4nk9IEEZo45fjWudEoAtq1y3VrHpkGNOi6sMLF/SfL9f5I/K i5cUWaeR/w6B4EM8l7AQazf9rDVo69vhiKEGs1rCS3txTF1bYvL95l9BOiRtbbC2SeKD umkVDnxD8YuXNOcS6NcgnLHuMVhYZvzpz0MHU5DNmg12qEQ0zoIld/zBw4seKasaS+B4 nJlrwQp3t/3/a/XP7TrQXBIlkdIBp/AIXUYZ4xbOqHQ0zvV5lck14hhADyEMKszljU/t 2GCovbA9Xvs5Aq96u0g0bUsDvwWuEjYsJipu44P7eaNSr2hcPQyYQ2GAbS+A2qCGZ450 rdZw== X-Gm-Message-State: AOJu0YxONHfeNrH3ddNtgtTQVPr1l5xvvEhGMEknPs+Ep0rhDtr39uCE 0Xz5gFg5zW566TJgowjkj201JexbHMfqbx5+4wIV1Zc6AJkhfS6f49CPy3wtsw== X-Gm-Gg: AeBDievB0AQzvaSZ8lwVCsIJBR622peiKDRoUiHYjTtrdocc3MmO0PeBFMy/OBl6pkr 8NIWePQ998DUyp3C7RR0YcP5s4GNxJ0865LqBZYg6zz63KP05wAiyoLU48axeDyP6PydL5nJH4s DfZRKiOrnsUBfYbN3IAx6aHt4T8yYUp+CYsA/94umuJQr+yol6QmvGSJQVU4+viW0gaots58K4t GO4xymu41oY8XmLqDVExOJGXp/pr7C9j2yL9XV/hmqakrFFCzpTAx8p+Pcwom2sZ0cqTMhVDeef qiujaLjC8K6GT57nzY7/2nowyoXkt8Q77SEwUAS+APgJTJnhyD/86rz1KgXARX4dRavWzX5pz0y hao6PRq7E13olkto75TdwPR98+qtnoMg0sDwL+8h4uxyS8e1u0Wib0TV5h6iHbwrtyIWwTdUarJ YJ8kvummHs/UYBtDEj2mqb+Xxlq0GyCICNONXYu7VLyFm56f4ClVAkLbulNwHvc2hsC/n4d4JG2 H9B X-Received: by 2002:a05:6512:308f:b0:5a2:8495:965f with SMTP id 2adb3069b0e04-5a4172bfedcmr8378917e87.15.1776851071013; Wed, 22 Apr 2026 02:44:31 -0700 (PDT) From: Oleksii Kurochko To: xen-devel@lists.xenproject.org Cc: 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 v2 1/3] xen/dom0less: introduce next_phandle in struct kernel_info Date: Wed, 22 Apr 2026 11:44:17 +0200 Message-ID: <4a9d79a9ef2bf25e904c9f49ddef7d5a3f3a4ac2.1776780944.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-33051d/1776851072-2A567938-522BEE5E/10/73395122804 X-purgate-type: spam X-purgate-size: 6042 X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1776851095881154100 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 --- 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 v2: - s/free_phandle/next_phandle. - s/get_next_free_phandle/alloc_phandle. --- xen/common/device-tree/dom0less-build.c | 44 ++++++++++++++++++------- xen/include/xen/fdt-domain-build.h | 6 ++++ xen/include/xen/fdt-kernel.h | 3 ++ 3 files changed, 41 insertions(+), 12 deletions(-) diff --git a/xen/common/device-tree/dom0less-build.c b/xen/common/device-tr= ee/dom0less-build.c index 840d14419da2..ca3ac84a3ef3 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,8 @@ 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; + BUILD_BUG_ON(GUEST_PHANDLE_GIC =3D=3D 1); =20 #ifdef CONFIG_GRANT_TABLE kinfo->gnttab_start =3D GUEST_GNTTAB_BASE; @@ -499,6 +519,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 +548,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 1d9e77df0eb3..a604f3983fe6 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 aa977a50f4fc..438adfe3855b 100644 --- a/xen/include/xen/fdt-kernel.h +++ b/xen/include/xen/fdt-kernel.h @@ -44,6 +44,9 @@ struct kernel_info { /* Interrupt controller phandle */ uint32_t phandle_intc; =20 + /* Next free phandle available for assigning to guest device nodes */ + 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 14:24:07 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=1776851099; cv=none; d=zohomail.com; s=zohoarc; b=jJ60C0yVvvN3hWsXuUwXC+ZDUjJ15JalvJ6NFNloDfLYB+Amj60l0l/lInIEFnF5GDukgnDNb+BZ3dbSxy0jNy0H1PQl9TEMLk/6Ise4lvj+vTtU28orlY/jhwNl3CJsgevI4PsfX1pOVqNrh133r9DDVP9tU9QYu5KZ+4+RHN0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1776851099; 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=nGnMzW9+BkykHD5n+WLa+P6dRUGCjGxLUe0gqWqrB9w=; b=R08smdKPepRkPjIFcbHzOhmejXP+wpcficY1plPvElvKa3Pj9NgFT5SfFxjzaYdLNCCNdCd7gzTvOmh6O91JP0mj5p5tahkupl1MWu+ILbpngQnWox90S0VhTpfmD7dWa9BYHDREhS4CM+7HQnSxbyKvIWBqqPmOkoYe+831NZI= 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 1776851099402927.8261451095846; Wed, 22 Apr 2026 02:44:59 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.1290139.1569826 (Exim 4.92) (envelope-from ) id 1wFU8J-0005rT-Cv; Wed, 22 Apr 2026 09:44:35 +0000 Received: by outflank-mailman (output) from mailman id 1290139.1569826; Wed, 22 Apr 2026 09:44:35 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1wFU8J-0005rM-8q; Wed, 22 Apr 2026 09:44:35 +0000 Received: by outflank-mailman (input) for mailman id 1290139; Wed, 22 Apr 2026 09:44:34 +0000 Received: from mx.expurgate.net ([195.190.135.10]) by lists.xenproject.org with esmtp (Exim 4.92) id 1wFU8H-0005eD-VS for xen-devel@lists.xenproject.org; Wed, 22 Apr 2026 09:44:33 +0000 Received: from mx.expurgate.net (helo=localhost) by mx.expurgate.net with esmtp id 1wFU8H-006sRK-CS for xen-devel@lists.xenproject.org; Wed, 22 Apr 2026 11:44:33 +0200 Received: from [10.42.69.6] (helo=localhost) by localhost with ESMTP (eXpurgate MTA 0.9.1) (envelope-from ) id 69e89881-2eae-0a2a0a5409dd-0a2a4506d542-0 for ; Wed, 22 Apr 2026 11:44:33 +0200 Received: from [209.85.167.42] (helo=mail-lf1-f42.google.com) by tlsNG-16d1c6.mxtls.expurgate.net with ESMTPS (eXpurgate 4.56.1) (envelope-from ) id 69e89881-7371-0a2a45060019-d155a72ac892-3 for ; Wed, 22 Apr 2026 11:44:33 +0200 Received: by mail-lf1-f42.google.com with SMTP id 2adb3069b0e04-59e4a04f059so5864904e87.2 for ; Wed, 22 Apr 2026 02:44:33 -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-5a41cc7f832sm3494193e87.28.2026.04.22.02.44.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 22 Apr 2026 02:44:31 -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=1776851072; x=1777455872; 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=nGnMzW9+BkykHD5n+WLa+P6dRUGCjGxLUe0gqWqrB9w=; b=DTKI43cFmWzOX9EQhcs1yh7CGi1npJH5N0TAriT5SMgNEH5KRpnQ6hyE4UlK6yVwLD Vk6hnIEKzd3afNn/mKnR7qrv2YKtQKc5p/GuMYpE+MZWIpg0D87juJaO3/1jJW2V1iVS M3MDDhYn0UOKaFFzy9vsC3XSrdztuxq5805z+6lRo/ew53Z/Coxr1Tee/aiMD3Ux/W5H dLqKUS9oL10q3/49FIu2Z7QPCQgAVXS/g6q7ZcjDwipWSyx8W9UyvC4p+3kksd33Zhij 2+CnKQhaBICo3DWzHmLXCY1ojk6Yw3kDGGodY3wdqWdbPyHAEx2Gif2tHbFWZajnwiUJ 4GYg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1776851072; x=1777455872; 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=nGnMzW9+BkykHD5n+WLa+P6dRUGCjGxLUe0gqWqrB9w=; b=HOXcXH7n8zzo/wFYQlNBa2/iaBUHflNYM8PI1jggHGLvAgvnIDRbIJqBNb2ySgwKfo LHprTNn66sNNZHNaoNETJkWYWyIh9NcSkoj+m98e5vDpoNaFa1gtUNx75Q8yKy7WzAzT y9aGm7piT/ge15XvW4XC/seZysuNxAcsJRFJsMj0sr9c3Fj8LfyOPhOE2fEOk562CRuH cPI3Q9CIHzmOWdAQexJPeaynxfD5QbbggOKM6OjoGChykgcXsA64ZqyQKd/53zM5hiTW AVWirYa9dZU1s+TK2y9D9GNZjsOb7YFGc1S0UJjTHN4hJ8EfLSo40RzW9ETFUkUY8+GM +bGA== X-Gm-Message-State: AOJu0YwxC17unZY7RsO4ZM8ol/Qr+1NyoGHERl/DOj39pDrdUvFG65yu Eg5tz0uklSff9qpanazBSjZzMmf1quFRS1W4tWjp4sp01BwD1pH0ebn0wHFwtw== X-Gm-Gg: AeBDietfLp7S3UIZhBSHUUshZshDOzrxW9C1LDGI7q/5ZW7ATPUVhf1CL+ExI5S1ZHa rDkeuU62NCiuxE7RWoQrypi7Hq7h/UODduxV9oZNs6V+FWHEyhVlcoWfxT0nYjDU42pGTA6S30y qdY9leLQGx0QcNqdICzUOngUdJ1liTtQ5qIX49G8hfPrqbsR/RSX1DOyQ2/GDXA6F8nwjie6XMw PaUXWB7RvwgXrgcEK83NExTbLlPdklnPSQJ/glqB69dMQgYBeFEg2aRsHTW19dXJJWWxh6IyXEU GSsWNESfYvo/jeyBopK7DycLLWd7TPJwYZTZ8LiCcaARv2no7MtEFZVwzgR5q1dAiWr2VzmrGwm 9JD8z+dYlMdnvJquRBrew6lQueeSghBCnACUNYj5X5BYT9AInMRE7MPutxB4RCIkH9/q/T2+Ac8 o+g3Ca98K/GPlQRKMJ+1BnUh9j78dGIKQhR9zAnLJXh1cFmPytW068sYd0K5x1Od6vEH4//c/7x a6B X-Received: by 2002:a05:6512:398c:b0:5a4:7ed:3e4d with SMTP id 2adb3069b0e04-5a4172de851mr8467999e87.27.1776851071830; Wed, 22 Apr 2026 02:44:31 -0700 (PDT) From: Oleksii Kurochko To: xen-devel@lists.xenproject.org Cc: 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 v2 2/3] xen/dom0less: pass kernel_info struct instead of fdt to make_cpus_node() Date: Wed, 22 Apr 2026 11:44:18 +0200 Message-ID: <2617586205ec7b07a302fcb8dd9dd39f3eb2c5ed.1776780944.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/1776851073-91587D75-018CB061/10/73395122804 X-purgate-type: spam X-purgate-size: 3065 X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1776851100175158500 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 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 60a7cbf915a5..98f5dab35e83 100644 --- a/xen/arch/arm/domain_build.c +++ b/xen/arch/arm/domain_build.c @@ -1164,7 +1164,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"); @@ -1178,6 +1178,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 @@ -1626,7 +1627,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 ca3ac84a3ef3..f8b1166e4169 100644 --- a/xen/common/device-tree/dom0less-build.c +++ b/xen/common/device-tree/dom0less-build.c @@ -535,7 +535,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 a604f3983fe6..b7f6b1fc36a9 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 14:24:07 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=1776851098; cv=none; d=zohomail.com; s=zohoarc; b=ZA68180CotAytLntX2klZ+ZguSUk1ftTMtK43VePTMV7/Mdn2NZK/DaVgi4iZqD1KToBlN9zb1ze/dDpSEmdjLGqfNg2WCaelxf7RNQj9A7kwDZwlZUwL0gj0Lc9RHvVKle+600fEcJLOp2DQZUPJxPdDjr40nHrPxd+gV0ialY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1776851098; 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=QdrnKw1Nlrntb+VNA/letozKDP4oOCl6jEuvPSlVYk8=; b=mvGM7dWODfVFJz2p50YHHDBaQVhxJPQWmvXsfZ5o6EyBansk5FjpGipIZ/cR3L+TnQLEnLGGFpdJk7hxCgqrM/hTeDXv4ed3qEMWD6XjMDDGXvIWX41RSHVjlLUttKLCZdxujjUpd/OehEPbf//aH1blToF27NCi7znzEEWdCFU= 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 1776851098724706.7768573252589; Wed, 22 Apr 2026 02:44:58 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.1290141.1569837 (Exim 4.92) (envelope-from ) id 1wFU8K-00063P-3x; Wed, 22 Apr 2026 09:44:36 +0000 Received: by outflank-mailman (output) from mailman id 1290141.1569837; Wed, 22 Apr 2026 09:44:36 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1wFU8J-00062U-Tx; Wed, 22 Apr 2026 09:44:35 +0000 Received: by outflank-mailman (input) for mailman id 1290141; Wed, 22 Apr 2026 09:44:35 +0000 Received: from mx.expurgate.net ([195.190.135.10]) by lists.xenproject.org with esmtp (Exim 4.92) id 1wFU8J-0005rJ-86 for xen-devel@lists.xenproject.org; Wed, 22 Apr 2026 09:44:35 +0000 Received: from mx.expurgate.net (helo=localhost) by mx.expurgate.net with esmtp id 1wFU8I-00E82D-LI for xen-devel@lists.xenproject.org; Wed, 22 Apr 2026 11:44:34 +0200 Received: from [10.42.69.2] (helo=localhost) by localhost with ESMTP (eXpurgate MTA 0.9.1) (envelope-from ) id 69e89880-5cb7-0a2a0a5109dd-0a2a4502b5ae-12 for ; Wed, 22 Apr 2026 11:44:34 +0200 Received: from [209.85.208.178] (helo=mail-lj1-f178.google.com) by tlsNG-720697.mxtls.expurgate.net with ESMTPS (eXpurgate 4.56.1) (envelope-from ) id 69e89882-af86-0a2a45020019-d155d0b2a8a6-3 for ; Wed, 22 Apr 2026 11:44:34 +0200 Received: by mail-lj1-f178.google.com with SMTP id 38308e7fff4ca-38dd9f0fdc6so65609271fa.0 for ; Wed, 22 Apr 2026 02:44:34 -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-5a41cc7f832sm3494193e87.28.2026.04.22.02.44.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 22 Apr 2026 02:44:32 -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=1776851073; x=1777455873; 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=QdrnKw1Nlrntb+VNA/letozKDP4oOCl6jEuvPSlVYk8=; b=Y3sMvdCND6IDq5Mj7XAiwD5w7VzHeVcDKyVMsNbALvrTbAi8o+cb3EI18sCodetykM LLSplgYQD8pnnFmsC75sSbBo2L2oeAYoI7DHSg1rPTt9U9GENoi4uPJacPwjTHZBpPrq r3hA1dz5/+w/SH28OpFSA31/Z17Chefbb801AFRLu5PiLpgrD+UUu8KxiHuEtoj+BW7f cfLsDdbCdIFr7avCRMHM5a+VjvQVkB+BlEpbNUw+pwdGyX8xpqhG2ZcPUU5iCU52lytm u30k8Iy8oamREKBgW+87EOynqLlHLdEFVMr42FkW0Z1iGANGJ8V3XoL4Zc2p5vmLMCPh n0RA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1776851073; x=1777455873; 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=QdrnKw1Nlrntb+VNA/letozKDP4oOCl6jEuvPSlVYk8=; b=TRlnUruI8NcAVLndQbR+r0BOHRI7TwmOqNOytqJIkh4PN7hlZsA6XxmQWKSCqWtci4 BxV+aHri6DTqy/Wk/UatlkODMl2ZUTu9iEAZT9EDisJGFIJg1NM9XnuqtSQpdugGouaT nkXnon8h7ZYt7iJcQX0ztFzWkRVXJmK/w4tk4WhFHRynZZDaU/wElaessicIDmT3vcy4 rNBHAnWFlxIgSyjhewy6D3pfZMJum2sKimnl2T3oSRK46EhBJ9QK7hz6Bt710EjKC0FP KEGf2NxI+a81ZIiwO0uzNvMpBiyFRa+CIUn5lNooa7vSCMe5eJsYxbIORA7IqK2SPZWQ 5ZoQ== X-Gm-Message-State: AOJu0Yzz9e2MxL1jJEPGeJEZ75VxHHZy+O5IRwUPOHZFq1GCTHBUyE24 uSSPUi+4NZSETkuCAiZYY6MgNljljkdSpvsdXFIjyC7V9lXw1ZXTY7CZ0pXRwQ== X-Gm-Gg: AeBDiesWLOaPsufrk5eoUM7QlgnDI6NtWI4AsX7WxtZE4SlHjwavGxhI5gr/+XGeuGB FNooakBYLJSW4FXGDtyfkJwEqQYJYMm5wvAMJXRtCBDZvYTU1TPtw0r6YK+kcVLrWPyGk9SRAJ1 aEncwBbXTOTvPUjD4/QLqxMSrQWgP2Z6S5DbnuRSXHFctCF4Pv0dQCQgH9HY7taSaK5hjWiqm6j V7zPaBJdMFcK8RcY0F21DjmE1EvcevPkcjwqiF/wztsayc9QwiEWcvMYRPqXCMnXVijWeVwMFzW 135bGOR/lqm+/RbXKp0i+d9xxpbUH085P2YQ4K7+VLIVsY7Y20ygvBSf6WTKJ2OY/JlDaTu8F8Z 2rFHU1x6BCc14JLwmGouCiRJ/enUjwf0DbOOhGFeMdmyAp+zWfYHzOvHXCgmNomv9Pc1D0v7mHL rf7oKPIEMvL9vH2d9P8uBevR1pd6EW4lClm8rFIuHv4dz8Ngm+cA8X2x7gEyntpT4odEYVM0qcE 6zY X-Received: by 2002:a05:6512:31d3:b0:5a4:156:aea3 with SMTP id 2adb3069b0e04-5a417174a77mr6977256e87.7.1776851073183; Wed, 22 Apr 2026 02:44:33 -0700 (PDT) From: Oleksii Kurochko To: xen-devel@lists.xenproject.org Cc: 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 v2 3/3] xen: introduce CONFIG_HAS_DOMAIN_TYPE Date: Wed, 22 Apr 2026 11:44:19 +0200 Message-ID: <61c33c15d046110b5c99490f54191facf18068e1.1776780944.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-720697/1776851074-898C3161-DB3835E2/10/73395122804 X-purgate-type: spam X-purgate-size: 11008 X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1776851100311158500 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 --- 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 98f5dab35e83..1efddc60ef0a 100644 --- a/xen/arch/arm/domain_build.c +++ b/xen/arch/arm/domain_build.c @@ -1772,15 +1772,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; @@ -1894,10 +1894,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 f95ad1285e6e..2d4c1bdecb66 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 - struct vtimer { struct vcpu *v; int irq; 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 3c613cdb233f..a5554714cd7b 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->image.start =3D= =3D 0) ) +#ifdef CONFIG_HAS_DOMAIN_TYPE + if ( (info->type =3D=3D DOMAIN_64BIT) && (info->image.start =3D=3D 0) ) return mem->bank[0].start + info->image.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..ab62e9b07546 100644 --- a/xen/common/Kconfig +++ b/xen/common/Kconfig @@ -29,6 +29,9 @@ config DOM0LESS_BOOT config DOMAIN_BUILD_HELPERS bool =20 +config HAS_DOMAIN_TYPE + bool + config GRANT_TABLE bool "Grant table support" if EXPERT default y 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..fcb6dc136517 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) +/* 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 b7f6b1fc36a9..6ad9e8fd1642 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 438adfe3855b..8bcc9471814b 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() @@ -69,6 +70,10 @@ struct kernel_info { } image; }; =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