From nobody Mon Nov 23 22:45:29 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass(p=none dis=none) header.from=vates.tech ARC-Seal: i=1; a=rsa-sha256; t=1791886062; cv=none; d=zohomail.com; s=zohoarc; b=VVO/2iGZhkossCnvPW8kK8I0hwDkT3lSNMAmeH/npwJ6M/JavUTog6PdyN4tT6CpJZJSDN/o61OXeSH2IzhnIDrrIDv9ZaEfS8ljt0dLqSOoiCRrBEg0EYMlax3WvElBoz39kAj58bOjcnAK+dkLc8CDDN0W03sI9xQuxoAD9Mw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1791886062; h=Content-Type: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:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=8teWVWejhPLG6xNGLIN8xlYcoOyIlp83feFf6NZmWPw=; b=PBtC1fZt3VyVR/vOF9vYz/cXWutUG2Ngwu/rZuNpADe6JhKdIDra86Cyf6F/GgR+yZvZxf9khrADmhbgsnVW5KgBRoH4bBagObGBYh8vJiDqk1U41c15AOGJuQeHMRtk2OEsdhUIAfP/qsk1owwDx9fX5H2ij0KQHKGyU3alos4= 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 1791886062809223.1561114351324; Tue, 13 Oct 2026 03:07:42 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.1446886.1662999 (Exim 4.92) (envelope-from ) id 1xGZPq-0004CE-GJ; Tue, 13 Oct 2026 10:07:26 +0000 Received: by outflank-mailman (output) from mailman id 1446886.1662999; Tue, 13 Oct 2026 10:07:26 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1xGZPq-0004C7-DH; Tue, 13 Oct 2026 10:07:26 +0000 Received: by outflank-mailman (input) for mailman id 1446886; Tue, 13 Oct 2026 10:07:25 +0000 Received: from mx.expurgate.net ([195.190.135.10]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1xGZPp-0004By-2L for xen-devel@lists.xenproject.org; Tue, 13 Oct 2026 10:07:25 +0000 Received: from mx.expurgate.net (helo=localhost) by mx.expurgate.net with esmtp id 1xGZPo-00EvYK-6M for xen-devel@lists.xenproject.org; Tue, 13 Oct 2026 12:07:24 +0200 Received: from [10.42.69.9] (helo=localhost) by localhost with ESMTP (eXpurgate MTA 0.9.1) (envelope-from ) id 6ace02d0-e002-0a2a0a5209dd-0a2a4509b680-46 for ; Tue, 13 Oct 2026 12:07:24 +0200 Received: from [185.255.28.34] (helo=prod-mta-13-01.swg-srv.net) by tlsNG-bad1c0.mxtls.expurgate.net with ESMTPS (eXpurgate 4.57.1) (envelope-from ) id 6ace02db-be1a-0a2a45090019-b9ff1c229891-3 for ; Tue, 13 Oct 2026 12:07:24 +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 1a134bb169d0008425.007 for (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384); Tue, 13 Oct 2026 10:07:18 +0000 Received: from leducb.home (lfbn-gre-1-371-96.w90-112.abo.wanadoo.fr [90.112.87.96]) (Authenticated sender: baptiste.le-duc) by mail2.vates.fr (Postfix) with ESMTPSA id B4E2182990; Tue, 13 Oct 2026 12:07:17 +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:Content-Transfer-Encoding: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=8teWVWejhPLG6xNGLIN8xlYcoOyIlp83feFf6NZmWPw=; h=from:subject:date:message-id:to:cc:mime-version:content-type:content-transfer-encoding:in-reply-to:references:feedback-id; b=WBlOfhpQ+US+Yw2OYVZosa+rMrX0x4NaEbpAr5B+AkO/CtzZDP4bhbGiqjr+aNdW767+SqmrS /qVW8SAjAIKmGhbvMLQp5B0eunO62TL3gNY5CNaPhXVZQ+vOl76YMYWKD/LQjH+8M3aljQi/cu5 FgdaRRJhIX662qD0lg6YmVBhu1KGZGenyRrCr+1IqcfSo99RUrmo42fcGUhNyFDOYeP3Jm9gAGu T7XRhtMMhfMzJf5mSqYcC6rEwBJt2PCMd9fXRe80lInYvbHqIw/GrUOFn13sxPcMSy+/umrIX9Z RC/nkNrANpjwDmERm3qEbc/TheHVOhy3b7n18RpC8KSA== X-Zone-Loop: 711da3f44893e60fb7830ddb2da63de3298db7ec2e8f x-campaign-type: default x-transaction-id: 937a9762-1bc2-42aa-982b-644ce61b6688 x-swg-uid: 01-896914e9-55ab-4bc5-9b6c-be76e1224f87 X-Mailer: Sweego Message-ID: <1791886038.8631fc262581453bbf619ec5b2062170.1a134bb169d0008425@vates.tech> x-swg-bid: 1791886038.8631fc262581453bbf619ec5b2062170.1a134bb169d0008425 Feedback-ID: default:8631fc262581453bbf619ec5b2062170:Sweego x-campaign-id: default x-client-id: 8631fc262581453bbf619ec5b2062170 X-Originating-IP: [37.26.189.201] From: Baptiste Le Duc To: xen-devel@lists.xenproject.org Cc: Baptiste Le Duc , Andrew Cooper , Anthony PERARD , Michal Orzel , Jan Beulich , Julien Grall , =?utf-8?q?Roger_Pau_Monn=C3=A9?= , Stefano Stabellini , Alistair Francis , Connor Davis , Oleksii Kurochko , Zheng Zhang Subject: [PATCH v6 1/4] xen/riscv: probe the PTE A/D bits update scheme at boot Date: Tue, 13 Oct 2026 12:07:10 +0200 In-Reply-To: <1791885904.8631fc262581453bbf619ec5b2062170.1a134b909b40008425@vates.tech> References: <1791885904.8631fc262581453bbf619ec5b2062170.1a134b909b40008425@vates.tech> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" X-Developer-Signature: v=1; a=ed25519-sha256; t=1791885856; l=6663; i=baptiste.le-duc@vates.tech; s=20260810; h=from:subject:message-id; bh=OTMIVll/AQFPtyeJIuGVE8cRR2HbRSAUit0myRvwEDQ=; b=dqgWVqjSlntGy/q+e6qgOVUhs9UJGRQN3mt8zjil3THgpaFM0FusztA0PdX9zgSn3GOiC37Bo L1wkzmJcT/MCQWeat/GD4P199dIh6R/ekvD08hXi2dXCku1gA708Su0 X-Developer-Key: i=baptiste.le-duc@vates.tech; a=ed25519; pk=N+BbdvMXRzrCuX/ieh4RWodiAKcLNvI+KjflcZ0oXCo= Content-Transfer-Encoding: quoted-printable X-Bm-Milter-Handled: 4ffbd6c1-ee69-4e1b-aabd-f977039bd3e2 X-Bm-Transport-Timestamp: 1791886037948 X-purgate-ID: tlsNG-bad1c0/1791886044-BDAC0034-D2CB0D37/0/0 X-purgate-type: clean X-purgate-size: 6665 X-ZohoMail-DKIM: pass (identity @vates.tech) X-ZM-MESSAGEID: 1791886064525158500 p2m_set_pte_flags() presets the A/D bits of G-stage PTEs only when RISCV_ISA_EXT_svade is set, which today only reflects the device tree. Platforms that fault on clear A/D bits without advertising Svade, such as the HiFive Premier P550, then leave A/D clear and take guest-page faults that Xen does not handle. The device tree cannot be trusted alone to tell which scheme is in effect. Introduce probe_hw_ad_update(): map a scratch page through the FIX_MISC fixmap slot with a PTE whose A bit is clear, and read from it under an exception table fixup. The read succeeds if hardware updates A/D bits and faults otherwise. Introduce resolve_ad_scheme(), called from riscv_fill_hwcap(), to check the probe against what the device tree advertises, following the DT binding: - Svade and Svadu: if the probe faults, Svade applies. Warn that hardware updating can be used by dropping Svade from the device tree, or through SBI FWFT once Xen supports it. Otherwise hardware updating applies and nothing is needed. - Svadu only: firmware must have enabled hardware updating. Panic if the probe faults. - Svade only: the hart must not update A/D bits. Assert the probe faults. - Neither: record the probed scheme by setting RISCV_ISA_EXT_svadu or RISCV_ISA_EXT_svade. Add Svadu to the known ISA extensions so it can be told apart from Svade. Assisted-by: Claude:claude-opus-5-5 Signed-off-by: Baptiste Le Duc --- Changes since v5: - new patch, probe the A/D bits update scheme instead of trusting the device tree alone. --- xen/arch/riscv/cpufeature.c | 97 +++++++++++++++++++++++++++++= ++++ xen/arch/riscv/include/asm/cpufeature.h | 1 + 2 files changed, 98 insertions(+) diff --git a/xen/arch/riscv/cpufeature.c b/xen/arch/riscv/cpufeature.c index 3d5bbd2228..60e48652a6 100644 --- a/xen/arch/riscv/cpufeature.c +++ b/xen/arch/riscv/cpufeature.c @@ -20,6 +20,8 @@ =20 #include #include +#include +#include =20 #ifdef CONFIG_ACPI # error "cpufeature.c functions should be updated to support ACPI" @@ -200,6 +202,7 @@ static const struct riscv_isa_ext_entry __initconstrel = riscv_isa_ext[] =3D { RISCV_ISA_EXT_ENTRY(ssaia, ANY), RISCV_ISA_EXT_ENTRY(sstc, NONE), RISCV_ISA_EXT_ENTRY(svade, NONE), + RISCV_ISA_EXT_ENTRY(svadu, NONE), RISCV_ISA_EXT_ENTRY(svpbmt, NONE), }; =20 @@ -620,6 +623,98 @@ static void __init compute_guest_isa(void) panic("Failed to build guest \"riscv,isa\" string\n"); } =20 +static bool __init probe_hw_ad_update(void) +{ + bool updated =3D false; + unsigned int slot =3D FIX_MISC; + vaddr_t va =3D FIXMAP_ADDR(slot); + struct page_info *pg; + pte_t *entry, pte; + mfn_t mfn; + unsigned long tmp; + + pg =3D alloc_domheap_page(NULL, 0); + if ( !pg ) + return false; + + mfn =3D page_to_mfn(pg); + + arch_pmap_map(FIX_MISC, mfn); + entry =3D &xen_fixmap[slot]; + pte =3D pte_from_mfn(mfn, PTE_VALID | PTE_READABLE); + write_pte(entry, pte); + + flush_tlb_one_local(va); + + asm_inline volatile ( + "1: ld %[tmp], 0(%[va])\n" + " li %[updated], 1\n" + "2:\n" + ASM_EXTABLE(1b, 2b) + : [tmp] "=3D&r" (tmp), [updated] "+r" (updated) + : [va] "r" (va) + : "memory" ); + + arch_pmap_unmap(slot); + free_domheap_page(pg); + + return updated; +} + +/* + * The privileged spec allows exactly two schemes for the PTE A and D bits: + * 1) hardware sets them on access and on write. + * 2) accessing a page whose A and/or D bit is clear raises a page fault, + * so that software can set them (ratified as Svade). + * + * Hence an implementation without Svade uses the hardware scheme (1), and= one + * that faults on clear A/D bits implements Svade, whether or not it says = so. + * + * Svadu isn't itself a scheme: it adds menvcfg.ADUE, selecting between the + * two for S-mode and G-stage translation, and henvcfg.ADUE, doing the same + * for VS-stage translation (read-only zero when menvcfg.ADUE is zero). + * + * Rather than trusting the DTS alone, probe the scheme in effect with a r= ead + * through a PTE whose A bit is clear, and check it against what the DTS + * advertises, as described by the DT binding. Panic on a mismatch Xen can= not + * run with, and record the probed scheme when the DTS advertises neither. + */ +static void __init resolve_ad_scheme(void) +{ + bool svade =3D riscv_isa_extension_available(NULL, RISCV_ISA_EXT_svade= ); + bool svadu =3D riscv_isa_extension_available(NULL, RISCV_ISA_EXT_svadu= ); + bool has_hw_update =3D probe_hw_ad_update(); + + /* Both advertised: Svade applies until FWFT enables hardware updating= . */ + if ( svade && svadu ) + { + if ( !has_hw_update ) + printk(XENLOG_WARNING + "Svade and Svadu are both advertised, but software upda= tes A/D bits. " + "To use hardware updating, drop Svade from the DTS or u= se FWFT (not implemented yet)\n"); + return; + } + + /* Only Svadu advertised: firmware must have enabled hardware updating= . */ + if ( svadu ) + { + if ( !has_hw_update ) + panic("Svadu is advertised but A/D bits are not updated by har= dware\n"); + return; + } + + /* Only Svade advertised: the hart must not update A/D bits. */ + if ( svade ) + { + ASSERT(!has_hw_update); + return; + } + + /* Neither advertised: trust the probe. */ + __set_bit(has_hw_update ? RISCV_ISA_EXT_svadu : RISCV_ISA_EXT_svade, + riscv_isa); +} + void init_guest_isa(struct domain *d) { d->arch.isa =3D guest_isa; @@ -674,6 +769,8 @@ void __init riscv_fill_hwcap(void) "Zihintpause unavailable: cpu_relax() gives the CPU no hint= ; " "wire up this platform's pause equivalent in cpu_relax()\n"= ); =20 + resolve_ad_scheme(); + for ( i =3D 0; i < req_extns_amount; i++ ) { const struct riscv_isa_ext_data ext =3D required_extensions[i]; diff --git a/xen/arch/riscv/include/asm/cpufeature.h b/xen/arch/riscv/inclu= de/asm/cpufeature.h index 2973eb13a5..6fb8ad4b9c 100644 --- a/xen/arch/riscv/include/asm/cpufeature.h +++ b/xen/arch/riscv/include/asm/cpufeature.h @@ -42,6 +42,7 @@ enum riscv_isa_ext_id { RISCV_ISA_EXT_sstc, RISCV_ISA_EXT_svade, RISCV_ISA_EXT_svpbmt, + RISCV_ISA_EXT_svadu, RISCV_ISA_EXT_MAX }; =20 --=20 2.55.0 From nobody Mon Nov 23 22:45:29 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass(p=none dis=none) header.from=vates.tech ARC-Seal: i=1; a=rsa-sha256; t=1791886064; cv=none; d=zohomail.com; s=zohoarc; b=bhRO54RV53wChDwAo+dK0cjEDiVsZrc+Mveh1kCiNnObJ/kVLNTAE6T7Wxl5VeulYx3OiVkPx6IYYK0y2u3ZVabJTlHYzgwp+7RTkAEs6TI6MsHRinK/MCt2/iawn4rL5Pv5YA/gzzEfGITJgfkAabhn8npjBJir2Mjqy1qoC+U= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1791886064; h=Content-Type: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:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=pN68Pey1130RdZLakyTwj+bcfE8E3n1QCjuI9IdiXPs=; b=N59pFNfVPU9FtTvoMX8FdCdU7ZAPHfePwHdzW/UINjxJdNhxjETTesdxGIuk8fG3FC/JwU6xjUg/EBj3JDW82kprINR/jwWOhVee/xN7yBxxDxySgFYaXsl2kl9yQDhPSPGKIlM7/TwqsysYZ26XyR8uqoZ4263/GV0is+Qkuwo= 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 1791886064654984.4629187423169; Tue, 13 Oct 2026 03:07:44 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.1446887.1663008 (Exim 4.92) (envelope-from ) id 1xGZPt-0004PX-Nc; Tue, 13 Oct 2026 10:07:29 +0000 Received: by outflank-mailman (output) from mailman id 1446887.1663008; Tue, 13 Oct 2026 10:07:29 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1xGZPt-0004PO-Ko; Tue, 13 Oct 2026 10:07:29 +0000 Received: by outflank-mailman (input) for mailman id 1446887; Tue, 13 Oct 2026 10:07:29 +0000 Received: from mx.expurgate.net ([194.145.224.10]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1xGZPs-0004Os-Rs for xen-devel@lists.xenproject.org; Tue, 13 Oct 2026 10:07:28 +0000 Received: from mx.expurgate.net (helo=localhost) by mx.expurgate.net with esmtp id 1xGZPs-009Aaq-8H for xen-devel@lists.xenproject.org; Tue, 13 Oct 2026 12:07:28 +0200 Received: from [10.42.69.9] (helo=localhost) by localhost with ESMTP (eXpurgate MTA 0.9.1) (envelope-from ) id 6ace02e0-bab6-0a2a0a5309dd-0a2a4509b6f6-0 for ; Tue, 13 Oct 2026 12:07:28 +0200 Received: from [185.255.28.34] (helo=prod-mta-13-01.swg-srv.net) by tlsNG-bad1c0.mxtls.expurgate.net with ESMTPS (eXpurgate 4.57.1) (envelope-from ) id 6ace02db-be1a-0a2a45090019-b9ff1c229891-4 for ; Tue, 13 Oct 2026 12:07:28 +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 1a134bb17e50008425.007 for (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384); Tue, 13 Oct 2026 10:07:19 +0000 Received: from leducb.home (lfbn-gre-1-371-96.w90-112.abo.wanadoo.fr [90.112.87.96]) (Authenticated sender: baptiste.le-duc) by mail2.vates.fr (Postfix) with ESMTPSA id 5ADCD829EF; Tue, 13 Oct 2026 12:07:18 +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:Content-Transfer-Encoding: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=pN68Pey1130RdZLakyTwj+bcfE8E3n1QCjuI9IdiXPs=; h=from:subject:date:message-id:to:cc:mime-version:content-type:content-transfer-encoding:in-reply-to:references:feedback-id; b=j89Lo38WLQx9ytfDVqHF8grhDVyGtuDCDraKjZuFVJ6Fkk06tVuuMg1qT3VLTbdeKAFnxuQbZ 9geEom6ZWlZdyM7hPQ3EcC4pJYDWb6DplE6rHo9d9Yy8Jc8h0v0bwdrxqWTqv9D+QUmiqCQCvS5 3SFVqsYsb0DkPQM5rupylDAzQ2YmJN8x45l55KlaSSXR2NAkkJ0FEnCDbH5gduF5V3nLBfG5zgK qDBfrR0dbKDfRmF3KgQ8psOnM6a8xY7Emy507FlwWwtS3ISY3+uaemV1RMMIUaX5enAR9LFCmhY gwETG60tdJkgRBQld3NTJ0ruJrociMUejDD8YHYwBFkw== X-Zone-Loop: 171204e8908826c6893b23eb59e653f24e0edb637fd7 x-campaign-type: default x-transaction-id: b57b6a65-c326-4763-91bd-d423aaa69419 x-swg-uid: 01-5fd61160-5f77-427a-9f39-a4a559b14c97 X-Mailer: Sweego Message-ID: <1791886039.8631fc262581453bbf619ec5b2062170.1a134bb17e50008425@vates.tech> x-swg-bid: 1791886039.8631fc262581453bbf619ec5b2062170.1a134bb17e50008425 Feedback-ID: default:8631fc262581453bbf619ec5b2062170:Sweego x-campaign-id: default x-client-id: 8631fc262581453bbf619ec5b2062170 X-Originating-IP: [37.26.189.201] From: Baptiste Le Duc To: xen-devel@lists.xenproject.org Cc: Baptiste Le Duc , Andrew Cooper , Anthony PERARD , Michal Orzel , Jan Beulich , Julien Grall , =?utf-8?q?Roger_Pau_Monn=C3=A9?= , Stefano Stabellini , Alistair Francis , Connor Davis , Oleksii Kurochko , Zheng Zhang Subject: [PATCH v6 2/4] xen/riscv: rework the A/D bits comment in p2m_set_pte_flags() Date: Tue, 13 Oct 2026 12:07:11 +0200 In-Reply-To: <1791885904.8631fc262581453bbf619ec5b2062170.1a134b909b40008425@vates.tech> References: <1791885904.8631fc262581453bbf619ec5b2062170.1a134b909b40008425@vates.tech> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" X-Developer-Signature: v=1; a=ed25519-sha256; t=1791885856; l=4274; i=baptiste.le-duc@vates.tech; s=20260810; h=from:subject:message-id; bh=N7vS901esIjgCTP/Wrafpr20c991cunLT9Cp2otKlx0=; b=zCJI1wJWeLlTAGGTBKPedAwB/+h033hjox509aalCEBBYTx6rlkPBe3Mz18aWbfKLqBitw4Tf lHieXAyKsLPADaVa7ahkdL5OmGrSS00xK4LiGGndRpsSDgyPiyTAfRi X-Developer-Key: i=baptiste.le-duc@vates.tech; a=ed25519; pk=N+BbdvMXRzrCuX/ieh4RWodiAKcLNvI+KjflcZ0oXCo= Content-Transfer-Encoding: quoted-printable X-Bm-Milter-Handled: 4ffbd6c1-ee69-4e1b-aabd-f977039bd3e2 X-Bm-Transport-Timestamp: 1791886038569 X-purgate-ID: tlsNG-bad1c0/1791886048-FD86F034-8F5A8C6F/0/0 X-purgate-type: clean X-purgate-size: 4276 X-ZohoMail-DKIM: pass (identity @vates.tech) X-ZM-MESSAGEID: 1791886066609158500 The comment in p2m_set_pte_flags() quotes the spec at length to describe the two A/D bits schemes, and its TODO mixes two things: why A/D are preset today (OpenSBI delegates the resulting page faults to a lower privilege mode, so Xen would take them with no handler) and what remains to be done. Summarise the two schemes as a short list. The reason for presetting A/D is not future work, so move it out of the TODO, next to the schemes. The TODO now keeps only the later work, handling these page faults instead of presetting A/D, which only concerns Svade as A/D page faults cannot happen otherwise. No functional change. Assisted-by: Claude:claude-opus-5-5 Signed-off-by: Baptiste Le Duc --- Changes since v5: - new patch, split out of "xen/riscv: always preset A/D bits in G-stage PTEs". --- xen/arch/riscv/p2m.c | 42 ++++++++++++++++-------------------------- 1 file changed, 16 insertions(+), 26 deletions(-) diff --git a/xen/arch/riscv/p2m.c b/xen/arch/riscv/p2m.c index 3d195294d5..b32472538e 100644 --- a/xen/arch/riscv/p2m.c +++ b/xen/arch/riscv/p2m.c @@ -591,35 +591,25 @@ static void p2m_set_pte_flags(pte_t *e, p2m_type_t t) e->pte |=3D PTE_USER; =20 /* - * Two schemes to manage the A and D bits are defined: - * =E2=80=A2 The Svade extension: when a virtual page is accessed an= d the A bit - * is clear, or is written and the D bit is clear, a page-fault - * exception is raised. - * =E2=80=A2 When the Svade extension is not implemented, the follow= ing scheme - * applies. - * When a virtual page is accessed and the A bit is clear, the PTE= is - * updated to set the A bit. When the virtual page is written and = the - * D bit is clear, the PTE is updated to set the D bit. When G-sta= ge - * address translation is in use and is not Bare, the G-stage virt= ual - * pages may be accessed or written by implicit accesses to VS-lev= el - * memory management data structures, such as page tables. - * Thereby to avoid a page-fault in case of Svade is available, it is - * necessary to set A and D bits. + * A RISC-V implementation can either: + * 1) Update the 'A' and 'D' PTE bits in hardware. + * 2) Generate a page fault when 'A' and/or 'D' is clear, so that + * software can set them. * - * TODO: For now, it=E2=80=99s fine to simply set the A/D bits, since = OpenSBI - * delegates page faults to a lower privilege mode and so OpenSBI - * isn't expect to handle page-faults occured in lower modes. - * By setting the A/D bits here, page faults that would otherwise - * be generated due to unset A/D bits will not occur in Xen. + * (1) needs nothing more as it is handled by hardware. For (2), set '= A' + * and 'D' up front: OpenSBI delegates such page faults to a lower + * privilege mode, so they would be raised in Xen, which has no handler + * for them. * - * Currently, Xen on RISC-V does not make use of the information - * that could be obtained from handling such page faults, which - * could otherwise be useful for several use cases such as demand - * paging, cache-flushing optimizations, memory access tracking,= etc. + * TODO: Xen on RISC-V currently makes no use of the information that + * handling such page faults could provide, which would be useful + * for several use cases such as demand paging, cache-flushing + * optimizations, memory access tracking, etc. * - * To support the more general case and the optimizations mentio= ned - * above, it would be better to stop setting the A/D bits here a= nd - * instead handle page faults that occur due to unset A/D bits. + * To support the more general case and the optimizations + * mentioned above, it would be better to stop setting the A/D + * bits here and instead handle the page faults that occur due to + * unset A/D bits. */ if ( riscv_isa_extension_available(NULL, RISCV_ISA_EXT_svade) ) e->pte |=3D PTE_ACCESSED | PTE_DIRTY; --=20 2.55.0 From nobody Mon Nov 23 22:45:29 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass(p=none dis=none) header.from=vates.tech ARC-Seal: i=1; a=rsa-sha256; t=1791886075; cv=none; d=zohomail.com; s=zohoarc; b=BS/q3E8qciy3rwzFx+gBRwf/R1pt6LoEfc383khLkTnuFQN/CScyeGrdE2qI8DSFybcDwn1FsSNlEMAkI8NZ1S9cE5h75wiI3GWJm/4CPVqkj32PS2EKk4f84sQMabNCUcEH011Km4/F1Gigls2xuC7Sl7CUKrgqR+nX20NIp/M= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1791886075; h=Content-Type: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:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=TYcEAn0o+duldPjksK5lNbTyrPK4j1Hmo32hqY1SRSk=; b=SiST3iLGY+17LnR7mZsuccXBJPFPW3mhV9ZTQBab0lD3c3nc8+ozJbRCXprR8le1iKRhJ2YRDzSi+O7//5k6siK9f/EpgLiILtpo+jc0u/LFdv1L/HDfr5a0Hnh1RCM8P9ohndlCVm4A4/V1ySXiNXMopY63zF9k8zmN/nbcMDw= 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 17918860754951020.2405824353546; Tue, 13 Oct 2026 03:07:55 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.1446888.1663016 (Exim 4.92) (envelope-from ) id 1xGZPy-0004fN-2h; Tue, 13 Oct 2026 10:07:34 +0000 Received: by outflank-mailman (output) from mailman id 1446888.1663016; Tue, 13 Oct 2026 10:07:34 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1xGZPx-0004fG-WD; Tue, 13 Oct 2026 10:07:34 +0000 Received: by outflank-mailman (input) for mailman id 1446888; Tue, 13 Oct 2026 10:07:32 +0000 Received: from mx.expurgate.net ([194.145.224.10]) by lists.xenproject.org with esmtp (Exim 4.92) id 1xGZPw-0004e9-I3 for xen-devel@lists.xenproject.org; Tue, 13 Oct 2026 10:07:32 +0000 Received: from mx.expurgate.net (helo=localhost) by mx.expurgate.net with esmtp id 1xGZPv-009Aep-V8 for xen-devel@lists.xenproject.org; Tue, 13 Oct 2026 12:07:31 +0200 Received: from [10.42.69.2] (helo=localhost) by localhost with ESMTP (eXpurgate MTA 0.9.1) (envelope-from ) id 6ace02e2-bab6-0a2a0a5309dd-0a2a4502bb5e-10 for ; Tue, 13 Oct 2026 12:07:31 +0200 Received: from [185.255.28.35] (helo=prod-mta-13-02.swg-srv.net) by tlsNG-720697.mxtls.expurgate.net with ESMTPS (eXpurgate 4.57.1) (envelope-from ) id 6ace02e2-6ca4-0a2a45020019-b9ff1c238655-3 for ; Tue, 13 Oct 2026 12:07:31 +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 1a134bb191b0008425.007 for (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384); Tue, 13 Oct 2026 10:07:19 +0000 Received: from leducb.home (lfbn-gre-1-371-96.w90-112.abo.wanadoo.fr [90.112.87.96]) (Authenticated sender: baptiste.le-duc) by mail2.vates.fr (Postfix) with ESMTPSA id A8F6D82A32; Tue, 13 Oct 2026 12:07:18 +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:Content-Transfer-Encoding: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=TYcEAn0o+duldPjksK5lNbTyrPK4j1Hmo32hqY1SRSk=; h=from:subject:date:message-id:to:cc:mime-version:content-type:content-transfer-encoding:in-reply-to:references:feedback-id; b=VA2b1gtp2GAQWASewBEGbZPsfEe4ks3hN/NQXUHSzQup8lf4v0mhld7NlXG6U0QV+3C+SZr00 M10uizGSCR+zNlGj4NWlK63XsjiEozNhnGCkzr6btSijVirGLvSzelONLmDhirkf+3RXvPLM5cX g0ZT5VBDrpc5qfA7TDRZOTQtwfoufhdpKhBqBHsEz/QbHfpnNWyaJXkgMboanS/fgTbxlqiqQWV pZocUzWBP2z4KCfvzT7plZnR5PL1TXduc4MBZBaHGMufXaDFy/j0aTPVPVlUpXuvK2yvDP4NtZC UwsAjUsrlfD4jRI/QQlLBN/gdlu+j/dtFIQNRF15WwqQ== X-Zone-Loop: 722c9c76425bc8b00d376c4d17e734fb70d517433e60 x-campaign-type: default x-transaction-id: eee22e5f-b357-4705-83e2-143bf6c162aa x-swg-uid: 01-c900d9ae-357d-4f84-813f-5b00ff797ed5 X-Mailer: Sweego Message-ID: <1791886039.8631fc262581453bbf619ec5b2062170.1a134bb191b0008425@vates.tech> x-swg-bid: 1791886039.8631fc262581453bbf619ec5b2062170.1a134bb191b0008425 Feedback-ID: default:8631fc262581453bbf619ec5b2062170:Sweego x-campaign-id: default x-client-id: 8631fc262581453bbf619ec5b2062170 X-Originating-IP: [37.26.189.201] From: Baptiste Le Duc To: xen-devel@lists.xenproject.org Cc: Baptiste Le Duc , Andrew Cooper , Anthony PERARD , Michal Orzel , Jan Beulich , Julien Grall , =?utf-8?q?Roger_Pau_Monn=C3=A9?= , Stefano Stabellini , Alistair Francis , Connor Davis , Oleksii Kurochko , Zheng Zhang Subject: [PATCH v6 3/4] xen/riscv: fix A/D bits in Xen's page-table mappings Date: Tue, 13 Oct 2026 12:07:12 +0200 In-Reply-To: <1791885904.8631fc262581453bbf619ec5b2062170.1a134b909b40008425@vates.tech> References: <1791885904.8631fc262581453bbf619ec5b2062170.1a134b909b40008425@vates.tech> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" X-Developer-Signature: v=1; a=ed25519-sha256; t=1791885856; l=7701; i=baptiste.le-duc@vates.tech; s=20260810; h=from:subject:message-id; bh=Jrbvgl2ZleNh0b6oBc9NXBIKurYx2aHFGmESflVTzm4=; b=K2KCJ8ZvBka/XXVcZwJ6WwUlg89W8hgF1rfaKnGarh5pDSN7zxMGHxAzI6Taor5+19jHoob+p 4x5ienbd/1BBjA7l46J7Hp9hrOOI8hDZ+Wzn4fWI5WQe0blc/kbx/cx X-Developer-Key: i=baptiste.le-duc@vates.tech; a=ed25519; pk=N+BbdvMXRzrCuX/ieh4RWodiAKcLNvI+KjflcZ0oXCo= Content-Transfer-Encoding: quoted-printable X-Bm-Milter-Handled: 4ffbd6c1-ee69-4e1b-aabd-f977039bd3e2 X-Bm-Transport-Timestamp: 1791886038889 X-purgate-ID: tlsNG-720697/1791886051-31BC82AC-E4839CFC/10/73395122804 X-purgate-type: spam X-purgate-size: 7703 X-ZohoMail-DKIM: pass (identity @vates.tech) X-ZM-MESSAGEID: 1791886078871158500 Xen does not handle page faults caused by clear A/D bits, so it presets them when creating PTEs. pt_update_entry() does so, but three places build leaf PTEs directly without going through it: setup_initial_mapping() (the boot page tables), check_pgtbl_mode_support() (the temporary root entry used to probe SATP mode support) and arch_pmap_map() (the fixmap). Without Svadu, all three fault on first access. For check_pgtbl_mode_support(), the fault is raised by the instruction fetch right after the SATP write, before any trap handler is set. Add PTE_ACCESSED and PTE_DIRTY to PAGE_HYPERVISOR_RO, and build PAGE_HYPERVISOR_RW and PAGE_HYPERVISOR_RX on top of it. PTE_DIRTY is set in all cases for consistency with pt_update_entry() which sets it at runtime. This fixes arch_pmap_map() for free, since it already builds its PTE from PAGE_HYPERVISOR_RW. Switch setup_initial_mapping() to use these macros for its default, text and rodata permissions, and check_pgtbl_mode_support() to use PAGE_HYPERVISOR_RX for its temporary root entry. The latter drops PTE_WRITABLE, going from RWX to RX, but this is harmless, as that entry only has to make the current instruction stream fetchable between the two CSR_SATP writes, and nothing writes through it. Drop the now-redundant PTE_LEAF_DEFAULT, since converting the last open-coded site above leaves it with no user outside page.h itself. pte_is_table() and pte_is_mapping() both assert that a PTE doesn't use one of the two reserved encodings, (V=3D1, W=3D1, R=3D0) and (V=3D1, X=3D1, W= =3D1, R=3D0), by masking it with PAGE_HYPERVISOR_RW. Now that PAGE_HYPERVISOR_RW also carries A and D, a reserved PTE with A or D set would no longer be caught. Mask with the V, R and W bits explicitly instead, and factor the check out into pte_has_reserved_rwx(). Fixes: e66003e7be19 ("xen/riscv: introduce setup_initial_pages") Assisted-by: Claude:claude-opus-5 Signed-off-by: Baptiste Le Duc Reviewed-by: Oleksii Kurochko --- Changes since v5: - no changes, already reviewed and waiting to be merged. --- Changes since v4: - rebase on top of staging. - add a missing changes line in "Changes since v3". --- Changes since v3: - rebase patch 2/6 which modified wrong indentation. - change commit message to address review comments. - rename pte_is_reserved() to pte_has_reserved_rwx() --- Changes since v2: - add fixes commit ref. - add A/D bits to PAGE_HYPERVISOR_RO and derive PAGE_HYPERVISOR_RW/RX from it for consistency with runtime. - introduce pte_is_reserved() to factor out the reserved-encoding assert shared by pte_is_table() and pte_is_mapping(). - reword commit title --- Changes since v1: - change commit title - mention in patch message that arch_pmap_map() is fixed too, via the PAGE_HYPERVISOR_RW change, not just setup_initial_mapping(). - convert check_pgtbl_mode_support()'s temporary root entry to PAGE_HYPERVISOR_RX, as it's harmless. - drop PTE_LEAF_DEFAULT entirely instead of keeping it, now that no site open-codes it anymore. - drop the pte_is_table() comment line that referenced PAGE_HYPERVISOR_RW, now stale. --- xen/arch/riscv/include/asm/page.h | 33 +++++++++++++++++---------------- xen/arch/riscv/mm.c | 11 +++++------ 2 files changed, 22 insertions(+), 22 deletions(-) diff --git a/xen/arch/riscv/include/asm/page.h b/xen/arch/riscv/include/asm= /page.h index b465a90325..8a3e3e1e66 100644 --- a/xen/arch/riscv/include/asm/page.h +++ b/xen/arch/riscv/include/asm/page.h @@ -46,12 +46,12 @@ #define PTE_PBMT_NOCACHE BIT(61, UL) #define PTE_PBMT_IO BIT(62, UL) =20 -#define PTE_LEAF_DEFAULT (PTE_VALID | PTE_READABLE | PTE_WRITAB= LE) #define PTE_TABLE (PTE_VALID) =20 -#define PAGE_HYPERVISOR_RO (PTE_VALID | PTE_READABLE) -#define PAGE_HYPERVISOR_RW (PTE_VALID | PTE_READABLE | PTE_WRITAB= LE) -#define PAGE_HYPERVISOR_RX (PTE_VALID | PTE_READABLE | PTE_EXECUT= ABLE) +#define PAGE_HYPERVISOR_RO (PTE_VALID | PTE_READABLE | \ + PTE_ACCESSED | PTE_DIRTY) +#define PAGE_HYPERVISOR_RW (PAGE_HYPERVISOR_RO | PTE_WRITABLE) +#define PAGE_HYPERVISOR_RX (PAGE_HYPERVISOR_RO | PTE_EXECUTABLE) =20 #define PAGE_HYPERVISOR PAGE_HYPERVISOR_RW /* @@ -161,31 +161,32 @@ static inline bool pte_is_valid(pte_t p) * X W R Meaning * 0 0 0 Pointer to next level of page table. * 0 0 1 Read-only page. - * 0 1 0 Reserved for future use. + * 0 1 0 Reserved for future use. [1] * 0 1 1 Read-write page. * 1 0 0 Execute-only page. * 1 0 1 Read-execute page. - * 1 1 0 Reserved for future use. + * 1 1 0 Reserved for future use. [2] * 1 1 1 Read-write-execute page. + * + * So if V=3D1 and W=3D1 then R also needs to be 1 as R =3D 0 is reserve= d for + * future use ([1], [2]). */ +static inline bool pte_has_reserved_rwx(pte_t p) +{ + return (p.pte & (PTE_VALID | PTE_READABLE | PTE_WRITABLE)) =3D=3D + (PTE_VALID | PTE_WRITABLE); +} + static inline bool pte_is_table(pte_t p) { - /* - * According to the spec if V=3D1 and W=3D1 then R also needs to be 1 = as - * R =3D 0 is reserved for future use ( look at the Table 4.5 ) so che= ck - * in ASSERT that if (V=3D=3D1 && W=3D=3D1) then R isn't 0. - * - * PAGE_HYPERVISOR_RW contains PTE_VALID too. - */ - ASSERT(((p.pte & PAGE_HYPERVISOR_RW) !=3D (PTE_VALID | PTE_WRITABLE))); + ASSERT(!pte_has_reserved_rwx(p)); =20 return ((p.pte & (PTE_VALID | PTE_ACCESS_MASK)) =3D=3D PTE_VALID); } =20 static inline bool pte_is_mapping(pte_t p) { - /* See pte_is_table() */ - ASSERT(((p.pte & PAGE_HYPERVISOR_RW) !=3D (PTE_VALID | PTE_WRITABLE))); + ASSERT(!pte_has_reserved_rwx(p)); =20 return (p.pte & PTE_VALID) && (p.pte & PTE_ACCESS_MASK); } diff --git a/xen/arch/riscv/mm.c b/xen/arch/riscv/mm.c index 06f0406781..6f7dcd10b2 100644 --- a/xen/arch/riscv/mm.c +++ b/xen/arch/riscv/mm.c @@ -140,19 +140,18 @@ static void __init setup_initial_mapping(struct mmu_d= esc *mmu_desc, case 1: /* Level 0 */ { unsigned long paddr =3D (page_addr - map_start) + pa_start; - unsigned int pte_flags =3D PTE_LEAF_DEFAULT; + unsigned int pte_flags =3D PAGE_HYPERVISOR_RW; unsigned long addr =3D is_identity_mapping ? page_addr : virt_to_maddr(page_addr= ); pte_t pte_to_be_written; =20 index =3D pt_index(0, page_addr); =20 - if ( is_kernel_text(addr) || - is_kernel_inittext(addr) ) - pte_flags =3D PTE_EXECUTABLE | PTE_READABLE | PTE_VALI= D; + if ( is_kernel_text(addr) || is_kernel_inittext(addr) ) + pte_flags =3D PAGE_HYPERVISOR_RX; =20 if ( is_kernel_rodata(addr) ) - pte_flags =3D PTE_READABLE | PTE_VALID; + pte_flags =3D PAGE_HYPERVISOR_RO; =20 pte_to_be_written =3D paddr_to_pte(paddr, pte_flags); =20 @@ -197,7 +196,7 @@ static bool __init check_pgtbl_mode_support(struct mmu_= desc *mmu_desc, =20 index =3D pt_index(page_table_level, aligned_load_start); stage1_pgtbl_root[index] =3D paddr_to_pte(aligned_load_start, - PTE_LEAF_DEFAULT | PTE_EXECUTA= BLE); + PAGE_HYPERVISOR_RX); =20 sfence_vma(); csr_write(CSR_SATP, --=20 2.55.0 From nobody Mon Nov 23 22:45:29 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass(p=none dis=none) header.from=vates.tech ARC-Seal: i=1; a=rsa-sha256; t=1791886071; cv=none; d=zohomail.com; s=zohoarc; b=KkyMkiwfVkh75tmaqCenpZevFyUrnCAzczvsuWBteFaxO5XCMB7VGeZ5+rlZfYGuC8rAS8NdXyXRLcpv6Ah7tqt2oHedZYilg1AiuhLSe/oW81ODnHA89vsccl/ZCKk+8r1bBmEFH2scrLTe+n3amL07AyxRfQdB3rLP8QRCtzo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1791886071; h=Content-Type: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:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=5k7rt7koC4EV6CBmJQy3vnSMBgJHJLR/LUoGlfSBZyY=; b=GxuCy7hJL2+8BmvMpjPPEBU1JIWFnKMt+D27FumU2l7/RjG/xO6ixgsBc5fru/P0Dv1o9AYFhcGe7TBKftzQklhlAVZW1inkkeajT2L72aTK+SOBXj+/oT5Abgj3KPQecdemuTKdY3Fxjl/CtOaYeq3Kh2bw9m5jrE98HfD5rxg= 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 17918860710381023.7876707936215; Tue, 13 Oct 2026 03:07:51 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.1446889.1663026 (Exim 4.92) (envelope-from ) id 1xGZQ0-0004up-BH; Tue, 13 Oct 2026 10:07:36 +0000 Received: by outflank-mailman (output) from mailman id 1446889.1663026; Tue, 13 Oct 2026 10:07: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 1xGZQ0-0004uZ-73; Tue, 13 Oct 2026 10:07:36 +0000 Received: by outflank-mailman (input) for mailman id 1446889; Tue, 13 Oct 2026 10:07:35 +0000 Received: from mx.expurgate.net ([194.145.224.10]) by lists.xenproject.org with esmtp (Exim 4.92) id 1xGZPz-0004pp-08 for xen-devel@lists.xenproject.org; Tue, 13 Oct 2026 10:07:35 +0000 Received: from mx.expurgate.net (helo=localhost) by mx.expurgate.net with esmtp id 1xGZPy-009Aep-DA for xen-devel@lists.xenproject.org; Tue, 13 Oct 2026 12:07:34 +0200 Received: from [10.42.69.2] (helo=localhost) by localhost with ESMTP (eXpurgate MTA 0.9.1) (envelope-from ) id 6ace02e2-bab6-0a2a0a5309dd-0a2a4502bb5e-28 for ; Tue, 13 Oct 2026 12:07:34 +0200 Received: from [185.255.28.35] (helo=prod-mta-13-02.swg-srv.net) by tlsNG-720697.mxtls.expurgate.net with ESMTPS (eXpurgate 4.57.1) (envelope-from ) id 6ace02e2-6ca4-0a2a45020019-b9ff1c238655-4 for ; Tue, 13 Oct 2026 12:07:34 +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 1a134bb1a5b0008425.007 for (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384); Tue, 13 Oct 2026 10:07:19 +0000 Received: from leducb.home (lfbn-gre-1-371-96.w90-112.abo.wanadoo.fr [90.112.87.96]) (Authenticated sender: baptiste.le-duc) by mail2.vates.fr (Postfix) with ESMTPSA id 0341382990; Tue, 13 Oct 2026 12:07:19 +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:Content-Transfer-Encoding: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=5k7rt7koC4EV6CBmJQy3vnSMBgJHJLR/LUoGlfSBZyY=; h=from:subject:date:message-id:to:cc:mime-version:content-type:content-transfer-encoding:in-reply-to:references:feedback-id; b=jejmvJUPEDXqSCqrXPnlrfk9mPJk3KkOu4EGLjC5R8B077du9l3eKCsBS544a2sZBCUd7RH5e +cmfV8Xivut5t4NixJEziBOcATPnG+WRu+JV7DewkXE50WVrK+/94R5Wv8H7fxAgJQEk3DYk8I0 /X5fx29zqwSDRtEieWprB+sgaX/+QLzYaEJXxRxDneqrrFBOQM2I9AD48kW6AIVObzOLMw+WKSU 1CApmkupUfyKLE1mqmQZpY5FquwWlgXdrNqPpdlFYseuTKOH3z7Zi8uI+x7Dad50MWhRXmzUSKp 8MwCF12eZAhVyYdB+Y/ksCgj0+55eER5efMiR9EbUhbg== X-Zone-Loop: 1454c97216d3762ddaf79e6c6f693902a6d250f273eb x-campaign-type: default x-transaction-id: c70b2fee-9137-4e96-82b4-6ef1353cdc59 x-swg-uid: 01-65d51739-90a1-48ed-b085-48277a2b67d7 X-Mailer: Sweego Message-ID: <1791886039.8631fc262581453bbf619ec5b2062170.1a134bb1a5b0008425@vates.tech> x-swg-bid: 1791886039.8631fc262581453bbf619ec5b2062170.1a134bb1a5b0008425 Feedback-ID: default:8631fc262581453bbf619ec5b2062170:Sweego x-campaign-id: default x-client-id: 8631fc262581453bbf619ec5b2062170 X-Originating-IP: [37.26.189.201] From: Baptiste Le Duc To: xen-devel@lists.xenproject.org Cc: Baptiste Le Duc , Andrew Cooper , Anthony PERARD , Michal Orzel , Jan Beulich , Julien Grall , =?utf-8?q?Roger_Pau_Monn=C3=A9?= , Stefano Stabellini , Alistair Francis , Connor Davis , Oleksii Kurochko , Zheng Zhang Subject: [PATCH v6 4/4] xen/riscv: use pte_is_valid() in pte_is_mapping() Date: Tue, 13 Oct 2026 12:07:13 +0200 In-Reply-To: <1791885904.8631fc262581453bbf619ec5b2062170.1a134b909b40008425@vates.tech> References: <1791885904.8631fc262581453bbf619ec5b2062170.1a134b909b40008425@vates.tech> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" X-Developer-Signature: v=1; a=ed25519-sha256; t=1791885856; l=1099; i=baptiste.le-duc@vates.tech; s=20260810; h=from:subject:message-id; bh=Af/b9/pAf+eE4YvnmAH7fU3eq2R32LznKCQUe6Hiujw=; b=/uJEAa5iz79LK6RIBI68GDyEmvaDK7mfdn4I6/G2NbPF/FIZY426IdCG8Ks3wDghrVOL4Tfka VDXe0AUaihOCcirYp0uYgPX0CLzXOSG2SxCvyrQO72GaZGWwaWQBEfN X-Developer-Key: i=baptiste.le-duc@vates.tech; a=ed25519; pk=N+BbdvMXRzrCuX/ieh4RWodiAKcLNvI+KjflcZ0oXCo= Content-Transfer-Encoding: quoted-printable X-Bm-Milter-Handled: 4ffbd6c1-ee69-4e1b-aabd-f977039bd3e2 X-Bm-Transport-Timestamp: 1791886039210 X-purgate-ID: tlsNG-720697/1791886054-303C42AC-1C26280A/10/73395122804 X-purgate-type: spam X-purgate-size: 1101 X-ZohoMail-DKIM: pass (identity @vates.tech) X-ZM-MESSAGEID: 1791886072664158500 Use pte_is_valid() instead of open-coding the PTE_VALID check. No functional change. Assisted-by: Claude:claude-opus-5 Signed-off-by: Baptiste Le Duc Reviewed-by: Oleksii Kurochko --- Changes since v5: - no changes, already reviewed and waiting to be merged. --- Changes since v4: - rebase on top of staging. --- Changes since v3: - no changes. - add trailers. --- Changes since v2: - new patch. --- xen/arch/riscv/include/asm/page.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/xen/arch/riscv/include/asm/page.h b/xen/arch/riscv/include/asm= /page.h index 8a3e3e1e66..f9e59e61de 100644 --- a/xen/arch/riscv/include/asm/page.h +++ b/xen/arch/riscv/include/asm/page.h @@ -188,7 +188,7 @@ static inline bool pte_is_mapping(pte_t p) { ASSERT(!pte_has_reserved_rwx(p)); =20 - return (p.pte & PTE_VALID) && (p.pte & PTE_ACCESS_MASK); + return pte_is_valid(p) && (p.pte & PTE_ACCESS_MASK); } =20 static inline bool pte_is_superpage(pte_t p, unsigned int level) --=20 2.55.0