From nobody Mon Nov 23 22:35:37 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=vates.tech ARC-Seal: i=1; a=rsa-sha256; t=1790598037; cv=none; d=zohomail.com; s=zohoarc; b=GvDCWiR/h0f/0E1QqSTvI2BA0KZ9YftTjF+bo2V6wGvD1FEZVynWbmowfUH/njm6YfJoUZX2tZHCSsk47Q5fFCuxvE18ow0eka0L/JO0flaNIHr3p1dJPdNxc1kdIj07mIQ1nX1ZOlC3LmTrTyyJlo6RynE/ICNJ8ub2JqI74Lo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1790598037; h=Content-Type:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=iocBX3cltKfTaESL4JWdF/xt400c4Ukdk4SJ5T0Ttqs=; b=OtLYf5xMNor4DbdtVOapKIr/YwezeghfBGVDJQOOVz3a6spRbooJ5dV9O9i6ybcRpqnj/5kDHqCoIwhI++af0J4ccnkZWTReu24snd53aUsqr/Rht7M0fG2sczA3kLgWLwE1VsKoZUbDMNpfGc+7fLqAkmUlPFKLcgPOA1TPszc= 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 1790598037850838.4815493318955; Mon, 28 Sep 2026 05:20:37 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.1435959.1654712 (Exim 4.92) (envelope-from ) id 1xBAL9-0002H4-O2; Mon, 28 Sep 2026 12:20:15 +0000 Received: by outflank-mailman (output) from mailman id 1435959.1654712; Mon, 28 Sep 2026 12:20:15 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1xBAL9-0002Gx-LH; Mon, 28 Sep 2026 12:20:15 +0000 Received: by outflank-mailman (input) for mailman id 1435959; Mon, 28 Sep 2026 12:20:13 +0000 Received: from mx.expurgate.net ([194.145.224.20]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1xBAL7-0002Gr-NU for xen-devel@lists.xenproject.org; Mon, 28 Sep 2026 12:20:13 +0000 Received: from mx.expurgate.net (helo=localhost) by mx.expurgate.net with esmtp id 1xBAL7-009KUh-40 for xen-devel@lists.xenproject.org; Mon, 28 Sep 2026 14:20:13 +0200 Received: from [10.42.69.5] (helo=localhost) by localhost with ESMTP (eXpurgate MTA 0.9.1) (envelope-from ) id 6aba5b71-8faa-0a2a0a5109dd-0a2a4505d61c-48 for ; Mon, 28 Sep 2026 14:20:13 +0200 Received: from [185.255.28.34] (helo=prod-mta-13-01.swg-srv.net) by tlsNG-c201ff.mxtls.expurgate.net with ESMTPS (eXpurgate 4.57.1) (envelope-from ) id 6aba5b7c-4cb1-0a2a45050019-b9ff1c228d05-3 for ; Mon, 28 Sep 2026 14:20:12 +0200 Received: from mail2.vates.fr ([37.26.189.201] mail2.vates.fr) (Authenticated sender: 8631fc262581453bbf619ec5b2062170/smtp/7773de5a-2839-4720-82ee-e06722ae1d3e) by prod-mta-13-01.swg-srv.net (ZoneMTA - prod-mta-13) with ESMTPSA id 1a0e7f55246000b504.00a for (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384); Mon, 28 Sep 2026 12:20:09 +0000 Received: from julian.home (areims-651-1-80-194.w90-18.abo.wanadoo.fr [90.18.187.194]) (Authenticated sender: julian.vetter@vates.tech) by mail2.vates.fr (Postfix) with ESMTPSA id 5C6E982326; Mon, 28 Sep 2026 14:20:08 +0200 (CEST) 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=selector1 header.d=vates.tech header.i="@vates.tech" header.h="From:Subject:Date:Message-ID:To:Cc:MIME-Version:Content-Type:In-Reply-To:References:Feedback-ID" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=vates.tech; q=dns/txt; s=selector1; bh=iocBX3cltKfTaESL4JWdF/xt400c4Ukdk4SJ5T0Ttqs=; h=from:subject:date:message-id:to:cc:mime-version:content-type:in-reply-to:references:feedback-id; b=B0T0DgdcwkADiy/rtqwmnfZoB7+QXQsU8ZuPPLSh4SlLYlYZpu6jxC3wGLXTzaUfNwqzUCOVl eiUchAHeM/hWANlMrkSvdlikUapcek2SbWMd3ZQvlOvipRiLIcSMyKPaXK1y1nf2C3X94XlmXtC kJPH5Oczo4POS3ikmogVuse60C+qjRcuxlXCQDe8V2yFa+WV9H4aIMTWRmYhJjRx+jC/edLQGE4 kMYVK4+tTVDJKRszLF4FbRyx8suoy7PipGSD6/3Ic33pVG31uqjnLUH1EqIa6Py+JaVBpt+jrl4 fEe+XC0e75n6TLFhAEfxZ4UUnFVPzDSjbFIk5Dcqjgkg== X-Zone-Loop: 7f047ca3871b4a595658ec116b9944e68b0dea3e1c0f x-campaign-type: default x-transaction-id: e2556a15-e081-49bd-a13a-e986583bdd21 x-swg-uid: 01-37a9d32a-4c4d-4999-a2b2-a32ca40ec2ea X-Mailer: Sweego Message-ID: <1790598009.8631fc262581453bbf619ec5b2062170.1a0e7f55246000b504@vates.tech> x-swg-bid: 1790598009.8631fc262581453bbf619ec5b2062170.1a0e7f55246000b504 Feedback-ID: default:8631fc262581453bbf619ec5b2062170:Sweego x-campaign-id: default x-client-id: 8631fc262581453bbf619ec5b2062170 X-Originating-IP: [37.26.189.201] From: Julian Vetter To: xen-devel@lists.xenproject.org Cc: Oleksii Kurochko , Community Manager , Andrew Cooper , Anthony PERARD , Michal Orzel , Jan Beulich , Julien Grall , =?UTF-8?q?Roger=20Pau=20Monn=C3=A9?= , Stefano Stabellini , Juergen Gross , Andrii Sultanov , Guillaume Thouvenin , =?UTF-8?q?Marek=20Marczykowski-G=C3=B3recki?= , Bertrand Marquis , Volodymyr Babchuk , Oleksii Moisieiev , Timothy Pearson , Alistair Francis , Connor Davis , Teddy Astie , Julian Vetter Subject: [PATCH v6 1/5] ARM/sysctl: Expose the supported guest GIC modes in physinfo Date: Mon, 28 Sep 2026 14:19:57 +0200 In-Reply-To: <1790597845.8631fc262581453bbf619ec5b2062170.1a0e7f2cff3000b504@vates.tech> References: <1790597845.8631fc262581453bbf619ec5b2062170.1a0e7f2cff3000b504@vates.tech> MIME-Version: 1.0 X-BM-Disclaimer: Yes Content-Type: multipart/alternative; boundary="-=Part.487.c3390be706352a8d.1a0e7f54f8a.3b4b18f457f6e29b=-" X-Bm-Milter-Handled: 4ffbd6c1-ee69-4e1b-aabd-f977039bd3e2 X-Bm-Transport-Timestamp: 1790598008714 X-purgate-ID: tlsNG-c201ff/1790598012-F7ABF2A1-2E769EA8/0/0 X-purgate-type: clean X-purgate-size: 5104 X-ZohoMail-DKIM: pass (identity @vates.tech) X-ZM-MESSAGEID: 1790598040487158500 ---=Part.487.c3390be706352a8d.1a0e7f54f8a.3b4b18f457f6e29b=- Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Andrew Cooper In preparation to simplify the domain creation logic surrounding GIC version. On a GICv3 host, also report support for GICv2-compatible guests when the hardware's vGICv2 compatibility mode is enabled, rather than just the native GIC version. Signed-off-by: Andrew Cooper Signed-off-by: Julian Vetter Reviewed-by: Michal Orzel --- Changes in v6: - Drop now stale comment - default: instead of case GIC_INVALID: - Print message before ASSERT_UNREACHABLE(), not after - Added Reviewed-by --- xen/arch/arm/include/asm/vgic.h | 6 ++++++ xen/arch/arm/sysctl.c | 29 +++++++++++++++++++++++++++++ xen/arch/arm/vgic-v2.c | 5 +++++ xen/arch/arm/vgic/vgic-v2.c | 5 +++++ xen/include/public/sysctl.h | 2 ++ 5 files changed, 47 insertions(+) diff --git a/xen/arch/arm/include/asm/vgic.h b/xen/arch/arm/include/asm/vgi= c.h index 6f9ab1c98c..26c53aaf3c 100644 --- a/xen/arch/arm/include/asm/vgic.h +++ b/xen/arch/arm/include/asm/vgic.h @@ -433,6 +433,12 @@ unsigned int vgic_max_vcpus(unsigned int domctl_vgic_v= ersion); void vgic_v2_setup_hw(paddr_t dbase, paddr_t cbase, paddr_t csize, paddr_t vbase, uint32_t aliased_offset); =20 +#ifdef CONFIG_VGICV2 +bool vgic_v2_hw_enabled(void); +#else +static inline bool vgic_v2_hw_enabled(void) { return false; } +#endif + #ifdef CONFIG_GICV3 struct rdist_region; void vgic_v3_setup_hw(paddr_t dbase, diff --git a/xen/arch/arm/sysctl.c b/xen/arch/arm/sysctl.c index 32cab4feff..8de4027b9c 100644 --- a/xen/arch/arm/sysctl.c +++ b/xen/arch/arm/sysctl.c @@ -12,7 +12,11 @@ #include #include #include + #include +#include +#include + #include =20 void arch_do_physinfo(struct xen_sysctl_physinfo *pi) @@ -21,6 +25,31 @@ void arch_do_physinfo(struct xen_sysctl_physinfo *pi) =20 pi->arch_capabilities |=3D MASK_INSR(sve_encode_vl(get_sys_vl_len()), XEN_SYSCTL_PHYSCAP_ARM_SVE_MASK); + + switch ( gic_hw_version() ) + { + case GIC_V2: + pi->arch_capabilities |=3D XEN_SYSCTL_PHYSCAP_ARM_GIC_V2; + break; + + case GIC_V3: + pi->arch_capabilities |=3D XEN_SYSCTL_PHYSCAP_ARM_GIC_V3; + + /* GICv3 may additionally support GICv2-compatible guests. */ + if ( vgic_v2_hw_enabled() ) + pi->arch_capabilities |=3D XEN_SYSCTL_PHYSCAP_ARM_GIC_V2; + break; + + default: + /* + * Running a control domain without having the GIC sorted yet? + * Something's broken, but there's nothing we can do about it here. + */ + printk_once(XENLOG_ERR "Unrecognised GIC version %d\n", + gic_hw_version()); + ASSERT_UNREACHABLE(); + break; + } } =20 long arch_do_sysctl(struct xen_sysctl *sysctl, diff --git a/xen/arch/arm/vgic-v2.c b/xen/arch/arm/vgic-v2.c index 6328ce6f7e..62666a84db 100644 --- a/xen/arch/arm/vgic-v2.c +++ b/xen/arch/arm/vgic-v2.c @@ -49,6 +49,11 @@ void __init vgic_v2_setup_hw(paddr_t dbase, paddr_t cbas= e, paddr_t csize, vgic_v2_hw.aliased_offset =3D aliased_offset; } =20 +bool vgic_v2_hw_enabled(void) +{ + return vgic_v2_hw.enabled; +} + #define NR_TARGETS_PER_ITARGETSR 4U #define NR_BITS_PER_TARGET (32U / NR_TARGETS_PER_ITARGETSR) =20 diff --git a/xen/arch/arm/vgic/vgic-v2.c b/xen/arch/arm/vgic/vgic-v2.c index 06fa365453..f6a58ed89e 100644 --- a/xen/arch/arm/vgic/vgic-v2.c +++ b/xen/arch/arm/vgic/vgic-v2.c @@ -47,6 +47,11 @@ void __init vgic_v2_setup_hw(paddr_t dbase, paddr_t cbas= e, paddr_t csize, printk("Using the new VGIC implementation.\n"); } =20 +bool vgic_v2_hw_enabled(void) +{ + return gic_v2_hw_data.enabled; +} + /* * transfer the content of the LRs back into the corresponding ap_list: * - active bit is transferred as is diff --git a/xen/include/public/sysctl.h b/xen/include/public/sysctl.h index 63d0ee062b..a1216d7287 100644 --- a/xen/include/public/sysctl.h +++ b/xen/include/public/sysctl.h @@ -106,6 +106,8 @@ struct xen_sysctl_tbuf_op { =20 #if defined(__arm__) || defined(__aarch64__) #define XEN_SYSCTL_PHYSCAP_ARM_SVE_MASK (0x1FU) +#define XEN_SYSCTL_PHYSCAP_ARM_GIC_V2 (1U << 5) +#define XEN_SYSCTL_PHYSCAP_ARM_GIC_V3 (1U << 6) #endif =20 struct xen_sysctl_physinfo { --=20 2.53.0 --=20 Julian Vetter | Vates Hypervisor & Kernel Developer XCP-ng & Xen Orchestra - Vates solutions web: https://vates.tech ---=Part.487.c3390be706352a8d.1a0e7f54f8a.3b4b18f457f6e29b=--- From nobody Mon Nov 23 22:35:37 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=vates.tech ARC-Seal: i=1; a=rsa-sha256; t=1790598034; cv=none; d=zohomail.com; s=zohoarc; b=J3bNVamr5ydlpM/K3XCNu4/Cf0Y2xfzfVWfGb2FXfCI9TZvUThaEARZoUB7ddgGtj1DW1lLxrUq+oCXUmtT846Nxi8QJJoFJ8jaeyANcRNWgNqH4J6Hk55YcDrfykYyPkMI//76O3J+YhZgQ3AT3qvPm9hzF7OWdHLGf49KKZoo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1790598034; h=Content-Type:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=5rmjn5fAk9KBpQVB6tsbk4f1wy8pxqKqN5YuMXCfnPQ=; b=lA6+0++KizPob3HfnXqfpsZe+J28l2zDiHcCj9EuT7DK5F67SYNo4LlZl5GAjhUMRVS4+91c5jDKUoZGd0jLh9IG9pp/Pd722/lvgePdfdgFQLu6EBN+K8PnINh8t5LfZBJ48gG9ZORoWjtf8I7twiL4UtKdLF1E8svou9LgkkY= 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 179059803412728.129232959548176; Mon, 28 Sep 2026 05:20:34 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.1435960.1654720 (Exim 4.92) (envelope-from ) id 1xBALE-0002VB-Uq; Mon, 28 Sep 2026 12:20:20 +0000 Received: by outflank-mailman (output) from mailman id 1435960.1654720; Mon, 28 Sep 2026 12:20:20 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1xBALE-0002V4-Rv; Mon, 28 Sep 2026 12:20:20 +0000 Received: by outflank-mailman (input) for mailman id 1435960; Mon, 28 Sep 2026 12:20:20 +0000 Received: from mx.expurgate.net ([195.190.135.10]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1xBALE-0002Ug-50 for xen-devel@lists.xenproject.org; Mon, 28 Sep 2026 12:20:20 +0000 Received: from mx.expurgate.net (helo=localhost) by mx.expurgate.net with esmtp id 1xBALD-00HKwy-IB for xen-devel@lists.xenproject.org; Mon, 28 Sep 2026 14:20:19 +0200 Received: from [10.42.69.11] (helo=localhost) by localhost with ESMTP (eXpurgate MTA 0.9.1) (envelope-from ) id 6aba5b82-bab6-0a2a0a5309dd-0a2a450b8416-6 for ; Mon, 28 Sep 2026 14:20:19 +0200 Received: from [185.255.28.35] (helo=prod-mta-13-02.swg-srv.net) by tlsNG-42698a.mxtls.expurgate.net with ESMTPS (eXpurgate 4.57.1) (envelope-from ) id 6aba5b83-b7e8-0a2a450b0019-b9ff1c2386a9-3 for ; Mon, 28 Sep 2026 14:20:19 +0200 Received: from mail2.vates.fr ([37.26.189.201] mail2.vates.fr) (Authenticated sender: 8631fc262581453bbf619ec5b2062170/smtp/7773de5a-2839-4720-82ee-e06722ae1d3e) by prod-mta-13-02.swg-srv.net (ZoneMTA - prod-mta-13) with ESMTPSA id 1a0e7f553fe000b504.00a for (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384); Mon, 28 Sep 2026 12:20:09 +0000 Received: from julian.home (areims-651-1-80-194.w90-18.abo.wanadoo.fr [90.18.187.194]) (Authenticated sender: julian.vetter@vates.tech) by mail2.vates.fr (Postfix) with ESMTPSA id 1F5CA8299A; Mon, 28 Sep 2026 14:20:09 +0200 (CEST) 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=selector1 header.d=vates.tech header.i="@vates.tech" header.h="From:Subject:Date:Message-ID:To:Cc:MIME-Version:Content-Type:In-Reply-To:References:Feedback-ID" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=vates.tech; q=dns/txt; s=selector1; bh=5rmjn5fAk9KBpQVB6tsbk4f1wy8pxqKqN5YuMXCfnPQ=; h=from:subject:date:message-id:to:cc:mime-version:content-type:in-reply-to:references:feedback-id; b=lT2kg+1sA1ak1clf10JAfpcgVxKBYJto+llvLUfm1NzkN324j7Of7EiKRYIwYgLfZBT6ghYwL 38g2Yg2qbTxZgMkdKBhcFk1MKooB0Ll/WGTZelyv9vUItMejGKF3HKn/OhaLUEt0uE8UL+BNqnr xqifVkpAdrhdxmf6JiP324qiNmtZHq4EL0CBOezsu396FFPBsOSvCGwFT3zIirillbl5IIeU5TP YWm/0gjWmCdza5VI2WdsMnMO6u2Vw7bp44Tr8jUH+tcrho/lwtNHN/6jldpDNy5pkTgmQC9vbXI D5ql/Z0XnaweR8K6PXe1/6hhhv8f3SR726Esoa9qpDQA== X-Zone-Loop: 422306ef4d33905e08e7088168e9fc3e059754464545 x-campaign-type: default x-transaction-id: c5123e33-0e04-4ba8-85bf-cbc030d8b895 x-swg-uid: 01-d096b643-abb8-402b-81f7-e565d2fb009a X-Mailer: Sweego Message-ID: <1790598009.8631fc262581453bbf619ec5b2062170.1a0e7f553fe000b504@vates.tech> x-swg-bid: 1790598009.8631fc262581453bbf619ec5b2062170.1a0e7f553fe000b504 Feedback-ID: default:8631fc262581453bbf619ec5b2062170:Sweego x-campaign-id: default x-client-id: 8631fc262581453bbf619ec5b2062170 X-Originating-IP: [37.26.189.201] From: Julian Vetter To: xen-devel@lists.xenproject.org Cc: Oleksii Kurochko , Community Manager , Andrew Cooper , Anthony PERARD , Michal Orzel , Jan Beulich , Julien Grall , =?UTF-8?q?Roger=20Pau=20Monn=C3=A9?= , Stefano Stabellini , Juergen Gross , Andrii Sultanov , Guillaume Thouvenin , =?UTF-8?q?Marek=20Marczykowski-G=C3=B3recki?= , Bertrand Marquis , Volodymyr Babchuk , Oleksii Moisieiev , Timothy Pearson , Alistair Francis , Connor Davis , Teddy Astie , Julian Vetter Subject: [PATCH v6 2/5] tools/arm: choose GIC version explicitly instead of relying on GIC_NATIVE Date: Mon, 28 Sep 2026 14:19:58 +0200 In-Reply-To: <1790597845.8631fc262581453bbf619ec5b2062170.1a0e7f2cff3000b504@vates.tech> References: <1790597845.8631fc262581453bbf619ec5b2062170.1a0e7f2cff3000b504@vates.tech> MIME-Version: 1.0 X-BM-Disclaimer: Yes Content-Type: multipart/alternative; boundary="-=Part.488.c27758c69efec212.1a0e7f55265.74081c0671ec0fb6=-" X-Bm-Milter-Handled: 4ffbd6c1-ee69-4e1b-aabd-f977039bd3e2 X-Bm-Transport-Timestamp: 1790598009445 X-purgate-ID: tlsNG-42698a/1790598019-A86CA9EA-EA485DA6/0/0 X-purgate-type: clean X-purgate-size: 8315 X-ZohoMail-DKIM: pass (identity @vates.tech) X-ZM-MESSAGEID: 1790598036342158500 ---=Part.488.c27758c69efec212.1a0e7f55265.74081c0671ec0fb6=- Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" XEN_DOMCTL_CONFIG_GIC_NATIVE lets the toolstack ask Xen to silently resolve the domain's GIC version to whatever the host hardware has. Xen then writes the resolved value back into the same in/out xen_arch_domainconfig the toolstack used as input, which is the kind of API abuse we're trying to get rid of. The struct passed to createdomain should only be an input parameter. Move the "pick the best available GIC version" decision to the toolstack, using the XEN_SYSCTL_PHYSCAP_ARM_GIC_V2/V3 capability bits already exposed via XEN_SYSCTL_physinfo: * libxl__arch_domain_build_info_setdefault() resolves the GIC version against those bits before the config is built. An unspecified version becomes v3 if available, else v2, else fails. An explicitly requested v2/v3 is validated against the same bits, so a version the host cannot provide is directly rejected in the toolstack. * The Python xc.domain_create() binding does the same via a call to xc_physinfo(). * libxl__arch_domain_prepare_config() therefore only ever sees a concrete v2/v3 request and just validates it. The GIC_NATIVE case is dropped since setdefault() always resolves it first. LIBXL_GIC_VERSION_DEFAULT keeps its name and value: xl.cfg still accepts "default" as the C keyword, and setdefault() resolves it to a concrete v2/v3 before anything else can observe it. This guarantees no toolstack path can still produce XEN_DOMCTL_CONFIG_GIC_NATIVE, in preparation for removing it from the Xen side and from the ABI entirely. Signed-off-by: Julian Vetter Acked-by: Michal Orzel Acked-by: Anthony PERARD --- Changes in v6: - Drop the xl.cfg(5) mention of XEN_SYSCTL_physinfo - Brace every branch of the has_v3/has_v2 if/else, not just the else - Keep LIBXL_GIC_VERSION_DEFAULT, to not break gic_version=3D"default" - Move has_v3/has_v2 declarations to the top - Added Acked-by --- docs/man/xl.cfg.5.pod.in | 4 +- .../include/xen-tools/arm-arch-capabilities.h | 21 +++++++++ tools/libs/light/libxl_arm.c | 43 +++++++++++++++++-- tools/python/xen/lowlevel/xc/xc.c | 18 +++++++- 4 files changed, 80 insertions(+), 6 deletions(-) diff --git a/docs/man/xl.cfg.5.pod.in b/docs/man/xl.cfg.5.pod.in index d34951edb9..8daa9be123 100644 --- a/docs/man/xl.cfg.5.pod.in +++ b/docs/man/xl.cfg.5.pod.in @@ -3083,8 +3083,8 @@ GICv2 compatibility mode. =20 =3Ditem B =20 -Emulate the same version as the native GIC hardware used by the host where -the domain was created. +Let the toolstack choose the GIC version: GICv3 if the host supports it, +otherwise GICv2. This is the default when C is not specified. =20 =3Dback =20 diff --git a/tools/include/xen-tools/arm-arch-capabilities.h b/tools/includ= e/xen-tools/arm-arch-capabilities.h index 4aa4c6c34a..21e3c73bd1 100644 --- a/tools/include/xen-tools/arm-arch-capabilities.h +++ b/tools/include/xen-tools/arm-arch-capabilities.h @@ -6,6 +6,7 @@ #ifndef ARM_ARCH_CAPABILITIES_H #define ARM_ARCH_CAPABILITIES_H =20 +#include #include #include =20 @@ -25,4 +26,24 @@ unsigned int arch_capabilities_arm_sve(unsigned int arch= _capabilities) #endif } =20 +static inline +bool arch_capabilities_arm_gic_v2(unsigned int arch_capabilities) +{ +#if defined(__arm__) || defined(__aarch64__) + return MASK_EXTR(arch_capabilities, XEN_SYSCTL_PHYSCAP_ARM_GIC_V2); +#else + return false; +#endif +} + +static inline +bool arch_capabilities_arm_gic_v3(unsigned int arch_capabilities) +{ +#if defined(__arm__) || defined(__aarch64__) + return MASK_EXTR(arch_capabilities, XEN_SYSCTL_PHYSCAP_ARM_GIC_V3); +#else + return false; +#endif +} + #endif /* ARM_ARCH_CAPABILITIES_H */ diff --git a/tools/libs/light/libxl_arm.c b/tools/libs/light/libxl_arm.c index 7e9f8a1bc3..b9c0c820d6 100644 --- a/tools/libs/light/libxl_arm.c +++ b/tools/libs/light/libxl_arm.c @@ -196,9 +196,6 @@ int libxl__arch_domain_prepare_config(libxl__gc *gc, LOG(DEBUG, " - Allocate %u SPIs", config->arch.nr_spis); =20 switch (d_config->b_info.arch_arm.gic_version) { - case LIBXL_GIC_VERSION_DEFAULT: - config->arch.gic_version =3D XEN_DOMCTL_CONFIG_GIC_NATIVE; - break; case LIBXL_GIC_VERSION_V2: config->arch.gic_version =3D XEN_DOMCTL_CONFIG_GIC_V2; break; @@ -1794,12 +1791,52 @@ int libxl__arch_domain_build_info_setdefault(libxl_= _gc *gc, libxl_domain_build_info *b_in= fo, const libxl_physinfo *physinf= o) { + bool has_v3 =3D arch_capabilities_arm_gic_v3(physinfo->arch_capabiliti= es); + bool has_v2 =3D arch_capabilities_arm_gic_v2(physinfo->arch_capabiliti= es); + /* ACPI is disabled by default */ libxl_defbool_setdefault(&b_info->acpi, false); =20 /* Trapping of unmapped accesses enabled by default. */ libxl_defbool_setdefault(&b_info->trap_unmapped_accesses, true); =20 + /* + * Resolve the GIC version against the host capabilities reported by + * XEN_SYSCTL_physinfo. If the user didn't request a specific version,= pick + * the best one available. Otherwise validate the requested version he= re, + * so a bad request fails early instead of in the hypervisor. + */ + switch (b_info->arch_arm.gic_version) { + case LIBXL_GIC_VERSION_DEFAULT: + if (has_v3) { + b_info->arch_arm.gic_version =3D LIBXL_GIC_VERSION_V3; + } else if (has_v2) { + b_info->arch_arm.gic_version =3D LIBXL_GIC_VERSION_V2; + } else { + LOG(ERROR, "No supported GIC version found on this host"); + return ERROR_FAIL; + } + break; + + case LIBXL_GIC_VERSION_V3: + if (!has_v3) { + LOG(ERROR, "GICv3 requested but not supported on this host"); + return ERROR_FAIL; + } + break; + + case LIBXL_GIC_VERSION_V2: + if (!has_v2) { + LOG(ERROR, "GICv2 requested but not supported on this host"); + return ERROR_FAIL; + } + break; + + default: + LOG(ERROR, "Unknown GIC version %d", b_info->arch_arm.gic_version); + return ERROR_FAIL; + } + /* Sanitise SVE parameter */ if (b_info->arch_arm.sve_vl) { unsigned int max_sve_vl =3D diff --git a/tools/python/xen/lowlevel/xc/xc.c b/tools/python/xen/lowlevel/= xc/xc.c index 7a4bf54597..0127b4b1b7 100644 --- a/tools/python/xen/lowlevel/xc/xc.c +++ b/tools/python/xen/lowlevel/xc/xc.c @@ -163,7 +163,23 @@ static PyObject *pyxc_domain_create(XcObject *self, ~(XEN_X86_EMU_VPCI | XEN_X86_EMU_USE_PIRQ); #elif defined (__arm__) || defined(__aarch64__) - config.arch.gic_version =3D XEN_DOMCTL_CONFIG_GIC_NATIVE; + { + xc_physinfo_t pinfo; + + if ( xc_physinfo(self->xc_handle, &pinfo) !=3D 0 ) + return pyxc_error_to_exception(self->xc_handle); + + if ( arch_capabilities_arm_gic_v3(pinfo.arch_capabilities) ) + config.arch.gic_version =3D XEN_DOMCTL_CONFIG_GIC_V3; + else if ( arch_capabilities_arm_gic_v2(pinfo.arch_capabilities) ) + config.arch.gic_version =3D XEN_DOMCTL_CONFIG_GIC_V2; + else + { + errno =3D EINVAL; + PyErr_SetFromErrno(xc_error_obj); + return NULL; + } + } #else #error Architecture not supported #endif --=20 2.53.0 --=20 Julian Vetter | Vates Hypervisor & Kernel Developer XCP-ng & Xen Orchestra - Vates solutions web: https://vates.tech ---=Part.488.c27758c69efec212.1a0e7f55265.74081c0671ec0fb6=--- From nobody Mon Nov 23 22:35:37 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=vates.tech ARC-Seal: i=1; a=rsa-sha256; t=1790598044; cv=none; d=zohomail.com; s=zohoarc; b=jwWie9jdHjiCUXwEckW+h0/iG1H6iTrDHEaHBaVBOD6kPuUvG7GOSAqtQ8LriX9ZOu1mvS/gaQXk3p1FDBFKo5yXKrT0qUANzeMCTkYJGsB8uhc5sClVTC5iAEv5w0bE5+QgyG42g4VLDLkUX+yTgC3jnPellR+DpwEAh+avS18= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1790598044; h=Content-Type:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=PBE437VdKD3Vgvc0Eaa3tnPX0Gx632/HUWGHPgvQ5IA=; b=JLz9AmMLFRjdBGxTCC0L4A3Q8GVeYNwQRbnRQXE7Hxr+yPXGTOmEop6UJ4GKpgZ2HEFcuYqgeGuHWIA5iMtAgkz8eNTuJz1La52jjNz70+Jsk1EEdNmviQ2sscSapihjB5K+Eu3eYjQScHcii9BB8AHhw/B5ZQ9DFy57P4CMDKc= 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 1790598044073992.0255383573059; Mon, 28 Sep 2026 05:20:44 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.1435962.1654731 (Exim 4.92) (envelope-from ) id 1xBALI-0002kE-9R; Mon, 28 Sep 2026 12:20:24 +0000 Received: by outflank-mailman (output) from mailman id 1435962.1654731; Mon, 28 Sep 2026 12:20:24 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1xBALI-0002k4-5W; Mon, 28 Sep 2026 12:20:24 +0000 Received: by outflank-mailman (input) for mailman id 1435962; Mon, 28 Sep 2026 12:20:23 +0000 Received: from mx.expurgate.net ([195.190.135.10]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1xBALH-0002jF-1k for xen-devel@lists.xenproject.org; Mon, 28 Sep 2026 12:20:23 +0000 Received: from mx.expurgate.net (helo=localhost) by mx.expurgate.net with esmtp id 1xBALG-00HKwy-Ev for xen-devel@lists.xenproject.org; Mon, 28 Sep 2026 14:20:22 +0200 Received: from [10.42.69.11] (helo=localhost) by localhost with ESMTP (eXpurgate MTA 0.9.1) (envelope-from ) id 6aba5b82-bab6-0a2a0a5309dd-0a2a450b8416-12 for ; Mon, 28 Sep 2026 14:20:21 +0200 Received: from [185.255.28.35] (helo=prod-mta-13-02.swg-srv.net) by tlsNG-42698a.mxtls.expurgate.net with ESMTPS (eXpurgate 4.57.1) (envelope-from ) id 6aba5b83-b7e8-0a2a450b0019-b9ff1c2386a9-4 for ; Mon, 28 Sep 2026 14:20:21 +0200 Received: from mail2.vates.fr ([37.26.189.201] mail2.vates.fr) (Authenticated sender: 8631fc262581453bbf619ec5b2062170/smtp/7773de5a-2839-4720-82ee-e06722ae1d3e) by prod-mta-13-02.swg-srv.net (ZoneMTA - prod-mta-13) with ESMTPSA id 1a0e7f5564e000b504.00a for (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384); Mon, 28 Sep 2026 12:20:10 +0000 Received: from julian.home (areims-651-1-80-194.w90-18.abo.wanadoo.fr [90.18.187.194]) (Authenticated sender: julian.vetter@vates.tech) by mail2.vates.fr (Postfix) with ESMTPSA id 8934282326; Mon, 28 Sep 2026 14:20:09 +0200 (CEST) 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=selector1 header.d=vates.tech header.i="@vates.tech" header.h="From:Subject:Date:Message-ID:To:Cc:MIME-Version:Content-Type:In-Reply-To:References:Feedback-ID" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=vates.tech; q=dns/txt; s=selector1; bh=PBE437VdKD3Vgvc0Eaa3tnPX0Gx632/HUWGHPgvQ5IA=; h=from:subject:date:message-id:to:cc:mime-version:content-type:in-reply-to:references:feedback-id; b=Fsf0VJzOz7J5dsXbHjngK5+fDJmMCK+iDeEqQRdCNuIDBOJoCJ9pnffdVRGSAMqtlnvCM5cPm MViVnsrM+pBNKXdQ5vSToo9NHmdxhk2488d/Xp0NjzPwHSe7loRHdejuVG3cl58fPkARPC46gUP jKzpkRAjpeEaIUYzx1q063enZyezC7loTvUhEUJK0rSVmLjSZV/7HcIvS88U/2QvKyVJ1CcFD5i 3m6Ymg1jXeQt/0A3MfxPZ9lj8zRUpthd2S1p4ctyksZNqS5W71IjnqwJTdcJDH3fhVNasKJJI62 1OevIrcD4qDMXH/Ox/VTJDYxbbO4VihdOds1KgOMEPGA== X-Zone-Loop: 0e64225d0a313687dfda0cda1d9e0efe0641a6525d4c x-campaign-type: default x-transaction-id: c536ace2-b5cd-4d00-952b-33188a78fa62 x-swg-uid: 01-f95ce4f2-2088-4093-9096-f63bb7fa34ac X-Mailer: Sweego Message-ID: <1790598010.8631fc262581453bbf619ec5b2062170.1a0e7f5564e000b504@vates.tech> x-swg-bid: 1790598010.8631fc262581453bbf619ec5b2062170.1a0e7f5564e000b504 Feedback-ID: default:8631fc262581453bbf619ec5b2062170:Sweego x-campaign-id: default x-client-id: 8631fc262581453bbf619ec5b2062170 X-Originating-IP: [37.26.189.201] From: Julian Vetter To: xen-devel@lists.xenproject.org Cc: Oleksii Kurochko , Community Manager , Andrew Cooper , Anthony PERARD , Michal Orzel , Jan Beulich , Julien Grall , =?UTF-8?q?Roger=20Pau=20Monn=C3=A9?= , Stefano Stabellini , Juergen Gross , Andrii Sultanov , Guillaume Thouvenin , =?UTF-8?q?Marek=20Marczykowski-G=C3=B3recki?= , Bertrand Marquis , Volodymyr Babchuk , Oleksii Moisieiev , Timothy Pearson , Alistair Francis , Connor Davis , Teddy Astie , Julian Vetter Subject: [PATCH v6 3/5] xen/arm: remove XEN_DOMCTL_CONFIG_GIC_NATIVE from the ABI Date: Mon, 28 Sep 2026 14:19:59 +0200 In-Reply-To: <1790597845.8631fc262581453bbf619ec5b2062170.1a0e7f2cff3000b504@vates.tech> References: <1790597845.8631fc262581453bbf619ec5b2062170.1a0e7f2cff3000b504@vates.tech> MIME-Version: 1.0 X-BM-Disclaimer: Yes Content-Type: multipart/alternative; boundary="-=Part.489.e19a30c940e9e69b.1a0e7f5540d.5371c206770e1581=-" X-Bm-Milter-Handled: 4ffbd6c1-ee69-4e1b-aabd-f977039bd3e2 X-Bm-Transport-Timestamp: 1790598009870 X-purgate-ID: tlsNG-42698a/1790598021-18ECE9EA-827477DA/0/0 X-purgate-type: clean X-purgate-size: 8662 X-ZohoMail-DKIM: pass (identity @vates.tech) X-ZM-MESSAGEID: 1790598046531158500 ---=Part.489.e19a30c940e9e69b.1a0e7f5540d.5371c206770e1581=- Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Now that the toolstack always resolves a concrete GIC_V2 or GIC_V3 before calling createdomain, nothing on the Xen side needs to resolve GIC_NATIVE either: * A new gic_domctl_hw_version() helper returns the XEN_DOMCTL_CONFIG_GIC_* value matching the host's gic_hw_version(). * arch_sanitise_domain_config() uses it to validate the requested version against the hardware, rather than resolving GIC_NATIVE and writing the result back into config->arch.gic_version. A guest must use the host's GIC version, except that a GICv3 host with the GICv2 compatibility mode enabled may also run GICv2 guests. This is the same information that XEN_SYSCTL_physinfo reports to the toolstack. * create_dom0() and arch_parse_dom0less_node(), which both always want a vGIC that exactly matches the hardware, use the same helper instead of GIC_NATIVE. With nothing left resolving or relying on it, drop XEN_DOMCTL_CONFIG_GIC_NATIVE from the public ABI. Every caller must now request a concrete GIC_V2 or GIC_V3. This is an incompatible change for any toolstack still passing 0 (formerly GIC_NATIVE) expecting Xen to auto-select a version. Add a CHANGELOG.md entry, noting that available GIC versions can be queried via XEN_SYSCTL_physinfo. Signed-off-by: Julian Vetter Reviewed-by: Michal Orzel --- Changes in v6: - Mark the now-dead max_vcpus =3D=3D 0 check with ASSERT_UNREACHABLE() - Use BUG() instead of ASSERT_UNREACHABLE()+return 0 in gic_domctl_hw_version()'s default case - Drop extern on the gic_domctl_hw_version() prototype - Move the gic_version IN/OUT -> IN comment fix here from a later patch --- CHANGELOG.md | 4 ++++ xen/arch/arm/dom0less-build.c | 3 ++- xen/arch/arm/domain.c | 28 ++++++++++++---------------- xen/arch/arm/domain_build.c | 3 ++- xen/arch/arm/gic.c | 15 +++++++++++++++ xen/arch/arm/include/asm/gic.h | 6 ++++++ xen/include/public/arch-arm.h | 4 ++-- 7 files changed, 43 insertions(+), 20 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index aa1a777dd4..78d1b13f3f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -18,6 +18,10 @@ The format is based on [Keep a Changelog](https://keepac= hangelog.com/en/1.0.0/) ### Added =20 ### Removed + - On Arm: + - XEN_DOMCTL_CONFIG_GIC_NATIVE has been removed. Toolstacks must now + explicitly request GIC_V2 or GIC_V3 when creating a domain. + Available GIC versions can be queried via XEN_SYSCTL_physinfo. - On x86: - The kexec "v1" interface, which was declared obsolete in Xen 4.4 (201= 3). The only known user was the classic-xen fork of Linux. This does not diff --git a/xen/arch/arm/dom0less-build.c b/xen/arch/arm/dom0less-build.c index 3f48f74226..7bbb2eafb6 100644 --- a/xen/arch/arm/dom0less-build.c +++ b/xen/arch/arm/dom0less-build.c @@ -23,6 +23,7 @@ #include #include #include +#include #include #include =20 @@ -368,7 +369,7 @@ int __init arch_parse_dom0less_node(struct dt_device_no= de *node, unsigned int flags =3D bd->create_flags; uint32_t val; =20 - d_cfg->arch.gic_version =3D XEN_DOMCTL_CONFIG_GIC_NATIVE; + d_cfg->arch.gic_version =3D gic_domctl_hw_version(); d_cfg->flags |=3D XEN_DOMCTL_CDF_hvm | XEN_DOMCTL_CDF_hap; =20 if ( domu_dt_sci_parse(node, d_cfg) ) diff --git a/xen/arch/arm/domain.c b/xen/arch/arm/domain.c index a739dd157e..5678ee3fe0 100644 --- a/xen/arch/arm/domain.c +++ b/xen/arch/arm/domain.c @@ -609,23 +609,18 @@ int arch_sanitise_domain_config(struct xen_domctl_cre= atedomain *config) return -EINVAL; } =20 - /* Fill in the native GIC version, passed back to the toolstack. */ - if ( config->arch.gic_version =3D=3D XEN_DOMCTL_CONFIG_GIC_NATIVE ) + /* + * A guest can only use the host's GIC version, except that a GICv3 ho= st + * with the GICv2 compatibility mode enabled can also run GICv2 guests. + * This mirrors what XEN_SYSCTL_physinfo reports to the toolstack. + */ + if ( config->arch.gic_version !=3D gic_domctl_hw_version() && + !(config->arch.gic_version =3D=3D XEN_DOMCTL_CONFIG_GIC_V2 && + vgic_v2_hw_enabled()) ) { - switch ( gic_hw_version() ) - { - case GIC_V2: - config->arch.gic_version =3D XEN_DOMCTL_CONFIG_GIC_V2; - break; - - case GIC_V3: - config->arch.gic_version =3D XEN_DOMCTL_CONFIG_GIC_V3; - break; - - default: - ASSERT_UNREACHABLE(); - return -EINVAL; - } + dprintk(XENLOG_INFO, "Unsupported GIC version %u\n", + config->arch.gic_version); + return -EINVAL; } =20 /* max_vcpus depends on the GIC version, and Xen's compiled limit. */ @@ -634,6 +629,7 @@ int arch_sanitise_domain_config(struct xen_domctl_creat= edomain *config) if ( max_vcpus =3D=3D 0 ) { dprintk(XENLOG_INFO, "Unsupported GIC version\n"); + ASSERT_UNREACHABLE(); return -EINVAL; } =20 diff --git a/xen/arch/arm/domain_build.c b/xen/arch/arm/domain_build.c index 72d5316180..cf7e1100bd 100644 --- a/xen/arch/arm/domain_build.c +++ b/xen/arch/arm/domain_build.c @@ -26,6 +26,7 @@ #include #include #include +#include #include #include #include @@ -1960,7 +1961,7 @@ void __init create_dom0(void) int rc; =20 /* The vGIC for DOM0 is exactly emulating the hardware GIC */ - dom0_cfg.arch.gic_version =3D XEN_DOMCTL_CONFIG_GIC_NATIVE; + dom0_cfg.arch.gic_version =3D gic_domctl_hw_version(); dom0_cfg.arch.nr_spis =3D vgic_def_nr_spis(); dom0_cfg.arch.tee_type =3D tee_get_type(); dom0_cfg.max_vcpus =3D dom0_max_vcpus(); diff --git a/xen/arch/arm/gic.c b/xen/arch/arm/gic.c index 078049e741..0b89515b9d 100644 --- a/xen/arch/arm/gic.c +++ b/xen/arch/arm/gic.c @@ -56,6 +56,21 @@ enum gic_version gic_hw_version(void) return gic_hw_ops->info->hw_version; } =20 +uint8_t gic_domctl_hw_version(void) +{ + switch ( gic_hw_version() ) + { + case GIC_V2: + return XEN_DOMCTL_CONFIG_GIC_V2; + + case GIC_V3: + return XEN_DOMCTL_CONFIG_GIC_V3; + + default: + BUG(); + } +} + unsigned int gic_number_lines(void) { return gic_hw_ops->info->nr_lines; diff --git a/xen/arch/arm/include/asm/gic.h b/xen/arch/arm/include/asm/gic.h index ee2c26adb4..bf874eab9a 100644 --- a/xen/arch/arm/include/asm/gic.h +++ b/xen/arch/arm/include/asm/gic.h @@ -262,6 +262,12 @@ DECLARE_PER_CPU(uint64_t, lr_mask); =20 extern enum gic_version gic_hw_version(void); =20 +/* + * The XEN_DOMCTL_CONFIG_GIC_* value matching the GIC version actually + * present on this host. + */ +uint8_t gic_domctl_hw_version(void); + /* Program the IRQ type into the GIC */ void gic_set_irq_type(struct irq_desc *desc, unsigned int type); =20 diff --git a/xen/include/public/arch-arm.h b/xen/include/public/arch-arm.h index 00de30b896..44c26fdc38 100644 --- a/xen/include/public/arch-arm.h +++ b/xen/include/public/arch-arm.h @@ -319,7 +319,7 @@ DEFINE_XEN_GUEST_HANDLE(vcpu_guest_context_t); * struct xen_arch_domainconfig's ABI is covered by * XEN_DOMCTL_INTERFACE_VERSION. */ -#define XEN_DOMCTL_CONFIG_GIC_NATIVE 0 +/* XEN_DOMCTL_CONFIG_GIC_NATIVE 0 - removed in Xen 4.23 */ #define XEN_DOMCTL_CONFIG_GIC_V2 1 #define XEN_DOMCTL_CONFIG_GIC_V3 2 =20 @@ -335,7 +335,7 @@ DEFINE_XEN_GUEST_HANDLE(vcpu_guest_context_t); #define XEN_DOMCTL_CONFIG_ARM_V8R_EL1_MSA_VMSA 2 =20 struct xen_arch_domainconfig { - /* IN/OUT */ + /* IN */ uint8_t gic_version; /* IN - Contains SVE vector length divided by 128 */ uint8_t sve_vl; --=20 2.53.0 --=20 Julian Vetter | Vates Hypervisor & Kernel Developer XCP-ng & Xen Orchestra - Vates solutions web: https://vates.tech ---=Part.489.e19a30c940e9e69b.1a0e7f5540d.5371c206770e1581=--- From nobody Mon Nov 23 22:35:37 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=vates.tech ARC-Seal: i=1; a=rsa-sha256; t=1790598045; cv=none; d=zohomail.com; s=zohoarc; b=jCaFlG3CpOElrS76n7WYZp99SXjMybU20MgAa0gH9DOeW6ywckDKs/Mw8JB8W6NMWT5fab1Nk2TnJjQtQT+jm5FPKuzDez/L6nR/EVwvdY9GsqPmxQjN85+RtArrxeRWCAOPzu3doG5ALfPFEXkCRZl6ycGVyAacj8RF2BY6PZA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1790598045; h=Content-Type:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=ia6U5wmKWwkBKUuqdeNdKMoE+waIUVqp6v2FBgSNEdM=; b=ZNmpTj1z9566jRNC8kjirKCjzWUNK3QaFoWb+hF+6yzChT8fddth99hZRvLqvZ89F8AfUCeh60WdmmjQbv3DIXU1VKvPNZU3XpNFXD5sZPj7SgDQDr9GmStqqzTias97VHfUa2675pLyHzEAS5I4uzl+jTmnPNmniTCREY7QmkU= 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 1790598045141849.1891235797373; Mon, 28 Sep 2026 05:20:45 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.1435963.1654740 (Exim 4.92) (envelope-from ) id 1xBALM-00030v-H3; Mon, 28 Sep 2026 12:20:28 +0000 Received: by outflank-mailman (output) from mailman id 1435963.1654740; Mon, 28 Sep 2026 12:20:28 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1xBALM-00030o-Bu; Mon, 28 Sep 2026 12:20:28 +0000 Received: by outflank-mailman (input) for mailman id 1435963; Mon, 28 Sep 2026 12:20:27 +0000 Received: from mx.expurgate.net ([194.145.224.20]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1xBALL-0002z4-6N for xen-devel@lists.xenproject.org; Mon, 28 Sep 2026 12:20:27 +0000 Received: from mx.expurgate.net (helo=localhost) by mx.expurgate.net with esmtp id 1xBALK-009KbS-FV for xen-devel@lists.xenproject.org; Mon, 28 Sep 2026 14:20:26 +0200 Received: from [10.42.69.10] (helo=localhost) by localhost with ESMTP (eXpurgate MTA 0.9.1) (envelope-from ) id 6aba5b87-8faa-0a2a0a5109dd-0a2a450ac6bc-14 for ; Mon, 28 Sep 2026 14:20:26 +0200 Received: from [185.255.28.34] (helo=prod-mta-13-01.swg-srv.net) by tlsNG-4011c0.mxtls.expurgate.net with ESMTPS (eXpurgate 4.57.1) (envelope-from ) id 6aba5b8a-f2d2-0a2a450a0019-b9ff1c22aa6b-3 for ; Mon, 28 Sep 2026 14:20:26 +0200 Received: from mail2.vates.fr ([37.26.189.201] mail2.vates.fr) (Authenticated sender: 8631fc262581453bbf619ec5b2062170/smtp/7773de5a-2839-4720-82ee-e06722ae1d3e) by prod-mta-13-01.swg-srv.net (ZoneMTA - prod-mta-13) with ESMTPSA id 1a0e7f55818000b504.00a for (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384); Mon, 28 Sep 2026 12:20:10 +0000 Received: from julian.home (areims-651-1-80-194.w90-18.abo.wanadoo.fr [90.18.187.194]) (Authenticated sender: julian.vetter@vates.tech) by mail2.vates.fr (Postfix) with ESMTPSA id 268C98299A; Mon, 28 Sep 2026 14:20:10 +0200 (CEST) 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=selector1 header.d=vates.tech header.i="@vates.tech" header.h="From:Subject:Date:Message-ID:To:Cc:MIME-Version:Content-Type:In-Reply-To:References:Feedback-ID" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=vates.tech; q=dns/txt; s=selector1; bh=ia6U5wmKWwkBKUuqdeNdKMoE+waIUVqp6v2FBgSNEdM=; h=from:subject:date:message-id:to:cc:mime-version:content-type:in-reply-to:references:feedback-id; b=fuzNftPjeMMx8hYQfoEkbqx7uMfMenBsM/5LNBswpDsvGZmuNs3J1J5HUdrzQkP6/CyrvVQbr m7A4ZHoIcYHhzd2qz3u9WAygasq6U9s1ayly/UthGjmOZju7MMFu/jxgep+wowspuZaRXGBAWUK ga5axUqY+NZQOUlIZwCfpEGMwUlBwER7dDrcqPzjATKzgaKzB8PVtP3xMkzxi1Vpcp7NQd+aLj/ WVqd2qxlIdPLaEMcISkI8XBWRYIRsOyHQKlLKhXQEm12gBiwkeTJR09YRt1Z4x+66TXbI48lQS0 hsq8ysrL1lVNmFHH+mfPIY7QWho37XotFNlgbCEa4qaA== X-Zone-Loop: 17bc66fa19710bc3c69fe2d69d4c57c7b42a74f97adf x-campaign-type: default x-transaction-id: 5fd6a8f4-8318-43bd-9a9d-0da35ffed4fc x-swg-uid: 01-f34aeccc-4405-4591-a17d-40945fe37337 X-Mailer: Sweego Message-ID: <1790598010.8631fc262581453bbf619ec5b2062170.1a0e7f55818000b504@vates.tech> x-swg-bid: 1790598010.8631fc262581453bbf619ec5b2062170.1a0e7f55818000b504 Feedback-ID: default:8631fc262581453bbf619ec5b2062170:Sweego x-campaign-id: default x-client-id: 8631fc262581453bbf619ec5b2062170 X-Originating-IP: [37.26.189.201] From: Julian Vetter To: xen-devel@lists.xenproject.org Cc: Oleksii Kurochko , Community Manager , Andrew Cooper , Anthony PERARD , Michal Orzel , Jan Beulich , Julien Grall , =?UTF-8?q?Roger=20Pau=20Monn=C3=A9?= , Stefano Stabellini , Juergen Gross , Andrii Sultanov , Guillaume Thouvenin , =?UTF-8?q?Marek=20Marczykowski-G=C3=B3recki?= , Bertrand Marquis , Volodymyr Babchuk , Oleksii Moisieiev , Timothy Pearson , Alistair Francis , Connor Davis , Teddy Astie , Julian Vetter Subject: [PATCH v6 4/5] xen/arm: report clock_frequency via sysctl physinfo, not createdomain Date: Mon, 28 Sep 2026 14:20:00 +0200 In-Reply-To: <1790597845.8631fc262581453bbf619ec5b2062170.1a0e7f2cff3000b504@vates.tech> References: <1790597845.8631fc262581453bbf619ec5b2062170.1a0e7f2cff3000b504@vates.tech> MIME-Version: 1.0 X-BM-Disclaimer: Yes Content-Type: multipart/alternative; boundary="-=Part.48a.96b029bbc2385a11.1a0e7f55676.542907f5d18e1568=-" X-Bm-Milter-Handled: 4ffbd6c1-ee69-4e1b-aabd-f977039bd3e2 X-Bm-Transport-Timestamp: 1790598010486 X-purgate-ID: tlsNG-4011c0/1790598026-597C2CFC-907F541B/0/0 X-purgate-type: clean X-purgate-size: 16785 X-ZohoMail-DKIM: pass (identity @vates.tech) X-ZM-MESSAGEID: 1790598046551158501 ---=Part.48a.96b029bbc2385a11.1a0e7f55676.542907f5d18e1568=- Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" The xen_arch_domainconfig.clock_frequency value is populated in domain_vtimer_init() during XEN_DOMCTL_createdomain from the global timer_dt_clock_frequency, which comes from the host's DT timer node and has nothing to do with the domain being created. Like now removed GIC_NATIVE resolution, this is a host-wide system property being smuggled out through a domain-creation IN struct. Expose it instead as a new arm_clock_frequency_hz field in XEN_SYSCTL_physinfo, populated via arch_do_physinfo(), and mirroring how the GIC capability bits were already moved there. Rather than making the field dependant on DT boot, make Xen always report the timer frequency, either via the DT "clock-frequency" node, or directly via CNTFRQ_EL0. preinit_xen_time() already computes cpu_khz for every boot path. The renamed timer_clock_frequency_hz now captures whichever of the two produced that value, in full Hz precision, instead of only recording the DT case. So, ACPI guests get a real value too, allowing to drop the special case. The DT "clock-frequency" property exists because firmware might leave CNTFRQ_EL0 wrong, and since CNTFRQ_EL0 cannot be trapped the only fix is to replicate the correct value into the guest DT. To keep that signal, a new XEN_SYSCTL_PHYSCAP_ARM_TIMER_DT_FREQ capability bit records whether arm_clock_frequency_hz came from the DT property. Then libxl only emits a "clock-frequency" property into the guest timer node when that bit is set. A guest whose CNTFRQ_EL0 is already correct keeps an unmodified timer node, exactly as before. Although the CNTFRQ_EL0 register is 64 bits wide, and some current timer implementations run at 1GHz, a 32bit value is sufficient to store the timer value, because it only mirrors the DT 'clock-frequency' property, which the bindings define as a single 32-bit cell. In struct xen_sysctl_physinfo the new field just reuses the former pad word, so sysctl consumers are unaffected. struct xen_arch_domainconfig however loses clock_frequency from its middle, which shrinks the struct and shifts every field after it, so bump XEN_DOMCTL_INTERFACE_VERSION. The xen_arch_domainconfig parameter passed to domain_vtimer_init() is no longer needed, so drop that parameter entirely. libxl now fetches the frequency via libxl_get_physinfo() in libxl__arch_domain_save_config() instead of reading it back out of the createdomain reply. The OCaml xen_arch_domainconfig mirror drops the field too. Signed-off-by: Julian Vetter Reviewed-by: Michal Orzel Reviewed-by: Anthony PERARD --- Changes in v6: - Rename arch_clock_frequency_hz to arm_clock_frequency_hz - Drop now-redundant "# ARM only" comment on the libxl IDL entry - Rework libxl__arch_domain_save_config() to a single exit point: fetch physinfo up front and use "goto out" on every error path - Move the gic_version IN/OUT -> IN comment update to the GIC_NATIVE removal patch - Added Reviewed-by --- .../include/xen-tools/arm-arch-capabilities.h | 10 +++++++ tools/libs/light/libxl.c | 1 + tools/libs/light/libxl_arm.c | 29 +++++++++++++++++-- tools/libs/light/libxl_types.idl | 1 + tools/ocaml/libs/xc/xenctrl.ml | 1 - tools/ocaml/libs/xc/xenctrl.mli | 1 - xen/arch/arm/domain.c | 2 +- xen/arch/arm/include/asm/time.h | 7 +++-- xen/arch/arm/include/asm/vtimer.h | 3 +- xen/arch/arm/sysctl.c | 5 ++++ xen/arch/arm/time.c | 9 ++++-- xen/arch/arm/vtimer.c | 4 +-- xen/include/public/arch-arm.h | 14 --------- xen/include/public/domctl.h | 4 +-- xen/include/public/sysctl.h | 20 ++++++++++++- 15 files changed, 77 insertions(+), 34 deletions(-) diff --git a/tools/include/xen-tools/arm-arch-capabilities.h b/tools/includ= e/xen-tools/arm-arch-capabilities.h index 21e3c73bd1..a927bc4703 100644 --- a/tools/include/xen-tools/arm-arch-capabilities.h +++ b/tools/include/xen-tools/arm-arch-capabilities.h @@ -46,4 +46,14 @@ bool arch_capabilities_arm_gic_v3(unsigned int arch_capa= bilities) #endif } =20 +static inline +bool arch_capabilities_arm_timer_dt_freq(unsigned int arch_capabilities) +{ +#if defined(__arm__) || defined(__aarch64__) + return MASK_EXTR(arch_capabilities, XEN_SYSCTL_PHYSCAP_ARM_TIMER_DT_FR= EQ); +#else + return false; +#endif +} + #endif /* ARM_ARCH_CAPABILITIES_H */ diff --git a/tools/libs/light/libxl.c b/tools/libs/light/libxl.c index a1fe16274d..98c7f0fdb3 100644 --- a/tools/libs/light/libxl.c +++ b/tools/libs/light/libxl.c @@ -410,6 +410,7 @@ int libxl_get_physinfo(libxl_ctx *ctx, libxl_physinfo *= physinfo) physinfo->cap_gnttab_v2 =3D !!(xcphysinfo.capabilities & XEN_SYSCTL_PHYSCAP_gnttab_v2); physinfo->arch_capabilities =3D xcphysinfo.arch_capabilities; + physinfo->arm_clock_frequency_hz =3D xcphysinfo.arm_clock_frequency_hz; =20 GC_FREE; return 0; diff --git a/tools/libs/light/libxl_arm.c b/tools/libs/light/libxl_arm.c index b9c0c820d6..47b662ea5c 100644 --- a/tools/libs/light/libxl_arm.c +++ b/tools/libs/light/libxl_arm.c @@ -252,6 +252,16 @@ int libxl__arch_domain_save_config(libxl__gc *gc, libxl__domain_build_state *state, const struct xen_domctl_createdomain *c= onfig) { + libxl_physinfo info; + int rc; + + libxl_physinfo_init(&info); + rc =3D libxl_get_physinfo(CTX, &info); + if (rc) { + LOG(ERROR, "failed to get physinfo"); + goto out; + } + switch (config->arch.gic_version) { case XEN_DOMCTL_CONFIG_GIC_V2: d_config->b_info.arch_arm.gic_version =3D LIBXL_GIC_VERSION_V2; @@ -261,12 +271,25 @@ int libxl__arch_domain_save_config(libxl__gc *gc, break; default: LOG(ERROR, "Unexpected gic version %u", config->arch.gic_version); - return ERROR_FAIL; + rc =3D ERROR_FAIL; + goto out; } =20 - state->clock_frequency =3D config->arch.clock_frequency; + /* + * Pass the timer frequency on to the guest DT only when Xen took it f= rom + * the host DT (XEN_SYSCTL_PHYSCAP_ARM_TIMER_DT_FREQ). Otherwise the g= uest + * gets the right value from CNTFRQ_EL0. + */ + if (arch_capabilities_arm_timer_dt_freq(info.arch_capabilities)) + state->clock_frequency =3D info.arm_clock_frequency_hz; + else + state->clock_frequency =3D 0; =20 - return 0; + rc =3D 0; +out: + libxl_physinfo_dispose(&info); + + return rc; } =20 int libxl__arch_domain_create(libxl__gc *gc, diff --git a/tools/libs/light/libxl_types.idl b/tools/libs/light/libxl_type= s.idl index a7893460f0..4284a4f577 100644 --- a/tools/libs/light/libxl_types.idl +++ b/tools/libs/light/libxl_types.idl @@ -1201,6 +1201,7 @@ libxl_physinfo =3D Struct("physinfo", [ ("cap_gnttab_v1", bool), ("cap_gnttab_v2", bool), ("arch_capabilities", uint32), + ("arm_clock_frequency_hz", uint32), ], dir=3DDIR_OUT) =20 libxl_connectorinfo =3D Struct("connectorinfo", [ diff --git a/tools/ocaml/libs/xc/xenctrl.ml b/tools/ocaml/libs/xc/xenctrl.ml index 147afa62c2..582897af6d 100644 --- a/tools/ocaml/libs/xc/xenctrl.ml +++ b/tools/ocaml/libs/xc/xenctrl.ml @@ -32,7 +32,6 @@ type xen_arm_arch_domainconfig =3D { gic_version: int; nr_spis: int; - clock_frequency: int32; } =20 type x86_arch_emulation_flags =3D diff --git a/tools/ocaml/libs/xc/xenctrl.mli b/tools/ocaml/libs/xc/xenctrl.= mli index 9fccb2c2c2..9414b87164 100644 --- a/tools/ocaml/libs/xc/xenctrl.mli +++ b/tools/ocaml/libs/xc/xenctrl.mli @@ -26,7 +26,6 @@ type vcpuinfo =3D { type xen_arm_arch_domainconfig =3D { gic_version: int; nr_spis: int; - clock_frequency: int32; } =20 type x86_arch_emulation_flags =3D diff --git a/xen/arch/arm/domain.c b/xen/arch/arm/domain.c index 5678ee3fe0..4ca3a3749f 100644 --- a/xen/arch/arm/domain.c +++ b/xen/arch/arm/domain.c @@ -714,7 +714,7 @@ int arch_domain_create(struct domain *d, if ( (rc =3D domain_vgic_init(d, config->arch.nr_spis)) !=3D 0 ) goto fail; =20 - if ( (rc =3D domain_vtimer_init(d, &config->arch)) !=3D 0 ) + if ( (rc =3D domain_vtimer_init(d)) !=3D 0 ) goto fail; =20 if ( (rc =3D tee_domain_init(d, config->arch.tee_type)) !=3D 0 ) diff --git a/xen/arch/arm/include/asm/time.h b/xen/arch/arm/include/asm/tim= e.h index c194dbb9f5..fd79dd31eb 100644 --- a/xen/arch/arm/include/asm/time.h +++ b/xen/arch/arm/include/asm/time.h @@ -87,10 +87,11 @@ enum timer_ppi }; =20 /* - * Value of "clock-frequency" in the DT timer node if present. - * 0 means the property doesn't exist. + * The timer frequency, in Hz, that Xen ended up using, and whether it came + * from the DT "clock-frequency" property rather than CNTFRQ_EL0. */ -extern uint32_t timer_dt_clock_frequency; +extern uint32_t timer_clock_frequency_hz; +extern bool timer_clock_frequency_from_dt; =20 /* Get one of the timer IRQ number */ unsigned int timer_get_irq(enum timer_ppi ppi); diff --git a/xen/arch/arm/include/asm/vtimer.h b/xen/arch/arm/include/asm/v= timer.h index 9d4fb4c6e8..6bbfcf4e69 100644 --- a/xen/arch/arm/include/asm/vtimer.h +++ b/xen/arch/arm/include/asm/vtimer.h @@ -20,8 +20,7 @@ #ifndef __ARCH_ARM_VTIMER_H__ #define __ARCH_ARM_VTIMER_H__ =20 -extern int domain_vtimer_init(struct domain *d, - struct xen_arch_domainconfig *config); +extern int domain_vtimer_init(struct domain *d); extern int vcpu_vtimer_init(struct vcpu *v); extern bool vtimer_emulate(struct cpu_user_regs *regs, union hsr hsr); extern void virt_timer_save(struct vcpu *v); diff --git a/xen/arch/arm/sysctl.c b/xen/arch/arm/sysctl.c index 8de4027b9c..cc42d1b532 100644 --- a/xen/arch/arm/sysctl.c +++ b/xen/arch/arm/sysctl.c @@ -15,6 +15,7 @@ =20 #include #include +#include #include =20 #include @@ -26,6 +27,10 @@ void arch_do_physinfo(struct xen_sysctl_physinfo *pi) pi->arch_capabilities |=3D MASK_INSR(sve_encode_vl(get_sys_vl_len()), XEN_SYSCTL_PHYSCAP_ARM_SVE_MASK); =20 + pi->arm_clock_frequency_hz =3D timer_clock_frequency_hz; + if ( timer_clock_frequency_from_dt ) + pi->arch_capabilities |=3D XEN_SYSCTL_PHYSCAP_ARM_TIMER_DT_FREQ; + switch ( gic_hw_version() ) { case GIC_V2: diff --git a/xen/arch/arm/time.c b/xen/arch/arm/time.c index be54b87438..438a27825d 100644 --- a/xen/arch/arm/time.c +++ b/xen/arch/arm/time.c @@ -35,7 +35,8 @@ uint64_t __read_mostly boot_count; * register-mapped time source in the SoC. */ unsigned long __read_mostly cpu_khz; /* CPU clock frequency in kHz. */ =20 -uint32_t __read_mostly timer_dt_clock_frequency; +uint32_t __read_mostly timer_clock_frequency_hz; +bool __read_mostly timer_clock_frequency_from_dt; =20 static unsigned int timer_irq[MAX_TIMER_PPI]; =20 @@ -120,7 +121,8 @@ static void __init preinit_dt_xen_time(void) { cpu_khz =3D DIV_ROUND(rate, 1000); validate_timer_frequency(); - timer_dt_clock_frequency =3D rate; + timer_clock_frequency_hz =3D rate; + timer_clock_frequency_from_dt =3D true; } } =20 @@ -136,7 +138,8 @@ void __init preinit_xen_time(void) =20 if ( !cpu_khz ) { - cpu_khz =3D DIV_ROUND(READ_SYSREG(CNTFRQ_EL0) & CNTFRQ_MASK, 1000); + timer_clock_frequency_hz =3D READ_SYSREG(CNTFRQ_EL0) & CNTFRQ_MASK; + cpu_khz =3D DIV_ROUND(timer_clock_frequency_hz, 1000); validate_timer_frequency(); } =20 diff --git a/xen/arch/arm/vtimer.c b/xen/arch/arm/vtimer.c index 2e85ff2b6e..18f5676158 100644 --- a/xen/arch/arm/vtimer.c +++ b/xen/arch/arm/vtimer.c @@ -52,7 +52,7 @@ static void virt_timer_expired(void *data) perfc_incr(vtimer_virt_inject); } =20 -int domain_vtimer_init(struct domain *d, struct xen_arch_domainconfig *con= fig) +int domain_vtimer_init(struct domain *d) { d->arch.virt_timer_base.offset =3D get_cycles(); d->arch.virt_timer_base.nanoseconds =3D @@ -60,8 +60,6 @@ int domain_vtimer_init(struct domain *d, struct xen_arch_= domainconfig *config) d->time_offset.seconds =3D d->arch.virt_timer_base.nanoseconds; do_div(d->time_offset.seconds, 1000000000); =20 - config->clock_frequency =3D timer_dt_clock_frequency; - /* * Per the ACPI specification, providing a secure EL1 timer * interrupt is optional and will be ignored by non-secure OS. diff --git a/xen/include/public/arch-arm.h b/xen/include/public/arch-arm.h index 44c26fdc38..5d15f572c7 100644 --- a/xen/include/public/arch-arm.h +++ b/xen/include/public/arch-arm.h @@ -343,20 +343,6 @@ struct xen_arch_domainconfig { uint16_t tee_type; /* IN */ uint32_t nr_spis; - /* - * OUT - * Based on the property clock-frequency in the DT timer node. - * The property may be present when the bootloader/firmware doesn't - * set correctly CNTFRQ which hold the timer frequency. - * - * As it's not possible to trap this register, we have to replicate - * the value in the guest DT. - * - * =3D 0 =3D> property not present - * > 0 =3D> Value of the property - * - */ - uint32_t clock_frequency; /* IN */ uint8_t arm_sci_type; /* IN */ diff --git a/xen/include/public/domctl.h b/xen/include/public/domctl.h index 510300bb67..4ca8a2d7ca 100644 --- a/xen/include/public/domctl.h +++ b/xen/include/public/domctl.h @@ -30,9 +30,9 @@ * fields) don't require a change of the version. * Stable ops are NOT covered by XEN_DOMCTL_INTERFACE_VERSION! * - * Last version bump: Xen 4.22 + * Last version bump: Xen 4.23 */ -#define XEN_DOMCTL_INTERFACE_VERSION 0x00000018 +#define XEN_DOMCTL_INTERFACE_VERSION 0x00000019 =20 /* * NB. xen_domctl.domain is an IN/OUT parameter for this operation. diff --git a/xen/include/public/sysctl.h b/xen/include/public/sysctl.h index a1216d7287..6f9b1624ad 100644 --- a/xen/include/public/sysctl.h +++ b/xen/include/public/sysctl.h @@ -108,6 +108,8 @@ struct xen_sysctl_tbuf_op { #define XEN_SYSCTL_PHYSCAP_ARM_SVE_MASK (0x1FU) #define XEN_SYSCTL_PHYSCAP_ARM_GIC_V2 (1U << 5) #define XEN_SYSCTL_PHYSCAP_ARM_GIC_V3 (1U << 6) +/* See arm_clock_frequency_hz in struct xen_sysctl_physinfo. */ +#define XEN_SYSCTL_PHYSCAP_ARM_TIMER_DT_FREQ (1U << 7) #endif =20 struct xen_sysctl_physinfo { @@ -120,7 +122,23 @@ struct xen_sysctl_physinfo { uint32_t cpu_khz; uint32_t capabilities;/* XEN_SYSCTL_PHYSCAP_??? */ uint32_t arch_capabilities;/* XEN_SYSCTL_PHYSCAP_{X86,ARM,...}_??? */ - uint32_t pad; + + /* + * ARM only. The timer frequency, in Hz, that Xen is using, taken eith= er + * from the host DT timer node's "clock-frequency" property or from a + * direct CNTFRQ_EL0 read. + * + * XEN_SYSCTL_PHYSCAP_ARM_TIMER_DT_FREQ is set in the former case. The= host + * DT overrides CNTFRQ_EL0 (the usual way a wrong bootloader/firmware = value + * is corrected), so the toolstack must carry the same override into t= he + * guest's timer node, since CNTFRQ_EL0 cannot be trapped and fixed up= per + * guest. + * + * =3D 0 =3D> Non-ARM. On ARM the frequency is validated at boot and is + * always non-zero. + * > 0 =3D> The frequency, in Hz. + */ + uint32_t arm_clock_frequency_hz; uint64_aligned_t total_pages; uint64_aligned_t free_pages; uint64_aligned_t scrub_pages; --=20 2.53.0 --=20 Julian Vetter | Vates Hypervisor & Kernel Developer XCP-ng & Xen Orchestra - Vates solutions web: https://vates.tech ---=Part.48a.96b029bbc2385a11.1a0e7f55676.542907f5d18e1568=--- From nobody Mon Nov 23 22:35:37 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=vates.tech ARC-Seal: i=1; a=rsa-sha256; t=1790598054; cv=none; d=zohomail.com; s=zohoarc; b=jzBw2TYWGrPuxOFcx2LGE3CaF3i46WbRzf1/8K4Vsiqe+Wxzb12qTNftvjMlLUpBBOFWAwW4iIi1Q4+OuTVfRcZtcoricnu8QXhOoPPapy6AIUJc3/+IdvcxVF3nKpYWeky0JkTrGffBMQn5mKB/U5o/zM6R5WETdN9NDG0EbLk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1790598054; h=Content-Type:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=1a+uPUAHcNZZmfky+bDS4ycNHBXD1SRW+s2bHfQv5wM=; b=HK34ZfUtNh7OnVjnU7fgxuk2NwtxW6XHOTKD+vDIXurKNGyktd1sgr2VgwNpUCofC6qwW/YMGLLetTPoSuwFbXIK4MqYTCkyexVhz+RlG83plDPtg22PBOXf+ztJGX4RujzPzWNSuPi9qFJ9Y2cRYlOj019NcCZlDT3bj7+Maew= 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 1790598054033695.3541361124229; Mon, 28 Sep 2026 05:20:54 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.1435964.1654748 (Exim 4.92) (envelope-from ) id 1xBALQ-0003Ko-Ru; Mon, 28 Sep 2026 12:20:32 +0000 Received: by outflank-mailman (output) from mailman id 1435964.1654748; Mon, 28 Sep 2026 12:20:32 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1xBALQ-0003Kf-Og; Mon, 28 Sep 2026 12:20:32 +0000 Received: by outflank-mailman (input) for mailman id 1435964; Mon, 28 Sep 2026 12:20:30 +0000 Received: from mx.expurgate.net ([194.145.224.20]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1xBALO-0003H0-NK for xen-devel@lists.xenproject.org; Mon, 28 Sep 2026 12:20:30 +0000 Received: from mx.expurgate.net (helo=localhost) by mx.expurgate.net with esmtp id 1xBALO-009KbS-3y for xen-devel@lists.xenproject.org; Mon, 28 Sep 2026 14:20:30 +0200 Received: from [10.42.69.10] (helo=localhost) by localhost with ESMTP (eXpurgate MTA 0.9.1) (envelope-from ) id 6aba5b87-8faa-0a2a0a5109dd-0a2a450ac6bc-38 for ; Mon, 28 Sep 2026 14:20:30 +0200 Received: from [185.255.28.34] (helo=prod-mta-13-01.swg-srv.net) by tlsNG-4011c0.mxtls.expurgate.net with ESMTPS (eXpurgate 4.57.1) (envelope-from ) id 6aba5b8a-f2d2-0a2a450a0019-b9ff1c22aa6b-4 for ; Mon, 28 Sep 2026 14:20:30 +0200 Received: from mail2.vates.fr ([37.26.189.201] mail2.vates.fr) (Authenticated sender: 8631fc262581453bbf619ec5b2062170/smtp/7773de5a-2839-4720-82ee-e06722ae1d3e) by prod-mta-13-01.swg-srv.net (ZoneMTA - prod-mta-13) with ESMTPSA id 1a0e7f55a6e000b504.00a for (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384); Mon, 28 Sep 2026 12:20:11 +0000 Received: from julian.home (areims-651-1-80-194.w90-18.abo.wanadoo.fr [90.18.187.194]) (Authenticated sender: julian.vetter@vates.tech) by mail2.vates.fr (Postfix) with ESMTPSA id 9515782326; Mon, 28 Sep 2026 14:20:10 +0200 (CEST) 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=selector1 header.d=vates.tech header.i="@vates.tech" header.h="From:Subject:Date:Message-ID:To:Cc:MIME-Version:Content-Type:In-Reply-To:References:Feedback-ID" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=vates.tech; q=dns/txt; s=selector1; bh=1a+uPUAHcNZZmfky+bDS4ycNHBXD1SRW+s2bHfQv5wM=; h=from:subject:date:message-id:to:cc:mime-version:content-type:in-reply-to:references:feedback-id; b=dKvP9ED5E1JrusY6rvkB03cWEK+ULtwg3qDJwmkH05ygPsu1+ABaOqnj/6hLkAkvLt4eOTWsg thvACWZyp+pi780D2XbzfbjdF4ypJ0grkkQsOEOUlbIv0Pojm0DkQJLaueZsaqVfZa6Y0IC3ZLv WZwAEnRJFqhw9CHBk7GmCRklN+VUeLrqvGddVfUT6BdmuxGs6PMHDZCzX0svBDjWzjYXBy2Uhx/ tQJ+IegSYfgDHcoiszI06tDeUunBj4NV65/pU/CLEXq7huKPaiCvkSCgbyrU1tqDT7Bf4EtvkAi rKHvU0s0kmwVTHtvKNvzVTS7JNAJzco5/URA+LvCZFsQ== X-Zone-Loop: 30051cfd7c70b028c76330d70068bd57d3e1c1680279 x-campaign-type: default x-transaction-id: 588a73cc-8273-427f-bb4b-4c3508fdabbb x-swg-uid: 01-362fd03c-1b37-41d3-b295-8200c0e582a7 X-Mailer: Sweego Message-ID: <1790598011.8631fc262581453bbf619ec5b2062170.1a0e7f55a6e000b504@vates.tech> x-swg-bid: 1790598011.8631fc262581453bbf619ec5b2062170.1a0e7f55a6e000b504 Feedback-ID: default:8631fc262581453bbf619ec5b2062170:Sweego x-campaign-id: default x-client-id: 8631fc262581453bbf619ec5b2062170 X-Originating-IP: [37.26.189.201] From: Julian Vetter To: xen-devel@lists.xenproject.org Cc: Oleksii Kurochko , Community Manager , Andrew Cooper , Anthony PERARD , Michal Orzel , Jan Beulich , Julien Grall , =?UTF-8?q?Roger=20Pau=20Monn=C3=A9?= , Stefano Stabellini , Juergen Gross , Andrii Sultanov , Guillaume Thouvenin , =?UTF-8?q?Marek=20Marczykowski-G=C3=B3recki?= , Bertrand Marquis , Volodymyr Babchuk , Oleksii Moisieiev , Timothy Pearson , Alistair Francis , Connor Davis , Teddy Astie , Julian Vetter Subject: [PATCH v6 5/5] xen: make config argument const Date: Mon, 28 Sep 2026 14:20:01 +0200 In-Reply-To: <1790597845.8631fc262581453bbf619ec5b2062170.1a0e7f2cff3000b504@vates.tech> References: <1790597845.8631fc262581453bbf619ec5b2062170.1a0e7f2cff3000b504@vates.tech> MIME-Version: 1.0 X-BM-Disclaimer: Yes Content-Type: multipart/alternative; boundary="-=Part.48b.9a1a93d8a6409988.1a0e7f5583b.b13d91549d459bad=-" X-Bm-Milter-Handled: 4ffbd6c1-ee69-4e1b-aabd-f977039bd3e2 X-Bm-Transport-Timestamp: 1790598010939 X-purgate-ID: tlsNG-4011c0/1790598030-510C9CFC-980318A6/0/0 X-purgate-type: clean X-purgate-size: 8371 X-ZohoMail-DKIM: pass (identity @vates.tech) X-ZM-MESSAGEID: 1790598054404158500 ---=Part.48b.9a1a93d8a6409988.1a0e7f5583b.b13d91549d459bad=- Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" arch_sanitise_domain_config() validates the configuration requested by the toolstack, and should not fill anything in. The config struct passed to createdomain is supposed to be pure input. ARM used to abuse this (GIC_NATIVE resolution, now removed) to smuggle output back to the toolstack. Making the parameter const stops that type of abuse from happening on any architecture. The x86 implementation turned out to have its own instance of the same issue. It set XEN_DOMCTL_CDF_oos_off into config->flags for non-HVM guests. Since The sanitisation runs before the function domain_create() copies config->flags into d->options, this relied on mutating the toolstack's config to take effect. Move the default onto d->options directly in arch_domain_create() (which runs after d->options is populated), where all the remaining domain options are resolved. This has the same effect and no mutation of the input config is required. ARM, PPC and RISC-V need no equivalent change, Their implementations were already read-only. Signed-off-by: Julian Vetter Reviewed-by: Jan Beulich # x86 Reviewed-by: Michal Orzel --- Changes in v6: - Added Reviewed-by --- xen/arch/arm/domain.c | 2 +- xen/arch/arm/firmware/sci.c | 2 +- xen/arch/arm/firmware/scmi-smc.c | 2 +- xen/arch/arm/include/asm/firmware/sci.h | 6 +++--- xen/arch/ppc/stubs.c | 2 +- xen/arch/riscv/domain.c | 2 +- xen/arch/x86/domain.c | 16 ++++++++-------- xen/include/xen/sched.h | 5 ++--- 8 files changed, 18 insertions(+), 19 deletions(-) diff --git a/xen/arch/arm/domain.c b/xen/arch/arm/domain.c index 4ca3a3749f..34b5a85f9f 100644 --- a/xen/arch/arm/domain.c +++ b/xen/arch/arm/domain.c @@ -557,7 +557,7 @@ static bool v8r_el1_msa_domain_sanitise_config( } } =20 -int arch_sanitise_domain_config(struct xen_domctl_createdomain *config) +int arch_sanitise_domain_config(const struct xen_domctl_createdomain *conf= ig) { unsigned int max_vcpus; unsigned int flags_required =3D (XEN_DOMCTL_CDF_hvm | XEN_DOMCTL_CDF_h= ap); diff --git a/xen/arch/arm/firmware/sci.c b/xen/arch/arm/firmware/sci.c index aa93cda7f0..f73ed06092 100644 --- a/xen/arch/arm/firmware/sci.c +++ b/xen/arch/arm/firmware/sci.c @@ -45,7 +45,7 @@ int sci_domain_init(struct domain *d, struct xen_domctl_c= reatedomain *config) return cur_mediator->domain_init(d, config); } =20 -int sci_domain_sanitise_config(struct xen_domctl_createdomain *config) +int sci_domain_sanitise_config(const struct xen_domctl_createdomain *confi= g) { if ( !cur_mediator ) return 0; diff --git a/xen/arch/arm/firmware/scmi-smc.c b/xen/arch/arm/firmware/scmi-= smc.c index a0cc6c6192..391df8b945 100644 --- a/xen/arch/arm/firmware/scmi-smc.c +++ b/xen/arch/arm/firmware/scmi-smc.c @@ -68,7 +68,7 @@ static bool scmi_handle_smc(struct cpu_user_regs *regs) } =20 static int -scmi_smc_domain_sanitise_config(struct xen_domctl_createdomain *config) +scmi_smc_domain_sanitise_config(const struct xen_domctl_createdomain *conf= ig) { if ( config->arch.arm_sci_type !=3D XEN_DOMCTL_CONFIG_ARM_SCI_NONE && config->arch.arm_sci_type !=3D XEN_DOMCTL_CONFIG_ARM_SCI_SCMI_SMC= ) diff --git a/xen/arch/arm/include/asm/firmware/sci.h b/xen/arch/arm/include= /asm/firmware/sci.h index 485ce211c9..1d566be8e2 100644 --- a/xen/arch/arm/include/asm/firmware/sci.h +++ b/xen/arch/arm/include/asm/firmware/sci.h @@ -32,7 +32,7 @@ struct sci_mediator_ops { * it to sanitize domain SCI configuration parameters. * Optional. */ - int (*domain_sanitise_config)(struct xen_domctl_createdomain *config); + int (*domain_sanitise_config)(const struct xen_domctl_createdomain *co= nfig); =20 /* * Called during domain destruction, releases all resources, that @@ -101,7 +101,7 @@ int sci_domain_init(struct domain *d, struct xen_domctl= _createdomain *config); * Sanitise domain configuration parameters. * */ -int sci_domain_sanitise_config(struct xen_domctl_createdomain *config); +int sci_domain_sanitise_config(const struct xen_domctl_createdomain *confi= g); =20 /* * Destroy SCI domain instance. @@ -162,7 +162,7 @@ static inline int sci_domain_init(struct domain *d, } =20 static inline int -sci_domain_sanitise_config(struct xen_domctl_createdomain *config) +sci_domain_sanitise_config(const struct xen_domctl_createdomain *config) { if ( config->arch.arm_sci_type !=3D XEN_DOMCTL_CONFIG_ARM_SCI_NONE ) return -EINVAL; diff --git a/xen/arch/ppc/stubs.c b/xen/arch/ppc/stubs.c index a333f06119..82a289af85 100644 --- a/xen/arch/ppc/stubs.c +++ b/xen/arch/ppc/stubs.c @@ -162,7 +162,7 @@ void arch_vcpu_destroy(struct vcpu *v) BUG_ON("unimplemented"); } =20 -int arch_sanitise_domain_config(struct xen_domctl_createdomain *config) +int arch_sanitise_domain_config(const struct xen_domctl_createdomain *conf= ig) { BUG_ON("unimplemented"); } diff --git a/xen/arch/riscv/domain.c b/xen/arch/riscv/domain.c index d94652809e..cfce8e91fa 100644 --- a/xen/arch/riscv/domain.c +++ b/xen/arch/riscv/domain.c @@ -284,7 +284,7 @@ void sync_vcpu_execstate(struct vcpu *v) /* Nothing to do -- no lazy switching */ } =20 -int arch_sanitise_domain_config(struct xen_domctl_createdomain *config) +int arch_sanitise_domain_config(const struct xen_domctl_createdomain *conf= ig) { return 0; } diff --git a/xen/arch/x86/domain.c b/xen/arch/x86/domain.c index 996b50af7a..0ddddb1024 100644 --- a/xen/arch/x86/domain.c +++ b/xen/arch/x86/domain.c @@ -590,7 +590,7 @@ void arch_vcpu_destroy(struct vcpu *v) ASSERT_UNREACHABLE(); } =20 -int arch_sanitise_domain_config(struct xen_domctl_createdomain *config) +int arch_sanitise_domain_config(const struct xen_domctl_createdomain *conf= ig) { bool hvm =3D config->flags & XEN_DOMCTL_CDF_hvm; bool hap =3D config->flags & XEN_DOMCTL_CDF_hap; @@ -633,13 +633,6 @@ int arch_sanitise_domain_config(struct xen_domctl_crea= tedomain *config) return -EINVAL; } =20 - if ( !hvm ) - /* - * It is only meaningful for XEN_DOMCTL_CDF_oos_off to be clear - * for HVM guests. - */ - config->flags |=3D XEN_DOMCTL_CDF_oos_off; - if ( nested_virt && !hvm_nested_virt_supported() ) { dprintk(XENLOG_INFO, "Nested virt requested but not available\n"); @@ -833,6 +826,13 @@ int arch_domain_create(struct domain *d, =20 spin_lock_init(&d->arch.e820_lock); =20 + /* + * It is only meaningful for XEN_DOMCTL_CDF_oos_off to be clear for HVM + * guests. + */ + if ( !is_hvm_domain(d) ) + d->options |=3D XEN_DOMCTL_CDF_oos_off; + if ( d->domain_id && cpu_has_amd_erratum(&boot_cpu_data, AMD_ERRATUM_1= 21) ) { if ( !opt_allow_unsafe ) diff --git a/xen/include/xen/sched.h b/xen/include/xen/sched.h index 73c54794ac..ce1fa636db 100644 --- a/xen/include/xen/sched.h +++ b/xen/include/xen/sched.h @@ -772,10 +772,9 @@ static inline void domain_update_node_affinity(struct = domain *d) } =20 /* - * To be implemented by each architecture, sanity checking the configurati= on - * and filling in any appropriate defaults. + * To be implemented by each architecture, sanity checking the configurati= on. */ -int arch_sanitise_domain_config(struct xen_domctl_createdomain *config); +int arch_sanitise_domain_config(const struct xen_domctl_createdomain *conf= ig); =20 /* * Create a domain: the configuration is only necessary for real domain --=20 2.53.0 --=20 Julian Vetter | Vates Hypervisor & Kernel Developer XCP-ng & Xen Orchestra - Vates solutions web: https://vates.tech ---=Part.48b.9a1a93d8a6409988.1a0e7f5583b.b13d91549d459bad=---