From: Jan Beulich <jbeulich@suse.com>
To: Baptiste Le Duc <baptiste.le-duc@vates.tech>
Cc: "Andrew Cooper" <andrew.cooper3@citrix.com>,
"Anthony PERARD" <anthony.perard@vates.tech>,
"Michal Orzel" <michal.orzel@amd.com>,
"Julien Grall" <julien@xen.org>,
"Roger Pau Monné" <roger@xenproject.org>,
"Stefano Stabellini" <sstabellini@kernel.org>,
"Alistair Francis" <alistair.francis@wdc.com>,
"Connor Davis" <connojdavis@gmail.com>,
"Oleksii Kurochko" <oleksii.kurochko@gmail.com>,
"Zheng Zhang" <zhangzheng@iscas.ac.cn>,
xen-devel@lists.xenproject.org
Subject: Re: [PATCH v7 3/4] xen/riscv: panic if the device tree advertises neither Svade nor Svadu
Date: Mon, 26 Oct 2026 10:32:15 +0100 [thread overview]
Message-ID: <4526ac23-ca7c-40e2-a9d6-9d366369d3bb@suse.com> (raw)
In-Reply-To: <1792164867.8631fc262581453bbf619ec5b2062170.1a14559ab900008425@vates.tech>
On 16.10.2026 17:34, Baptiste Le Duc wrote:
> p2m_set_pte_flags() presets the A/D bits of G-stage PTEs only when
> RISCV_ISA_EXT_svade is set, which is correct only if the device tree is.
>
> The privileged spec allows exactly two schemes for updating the PTE A and D
> bits: hardware sets them on access and on write, or accessing a page whose
> A and/or D bit is clear raises a page fault so that software can set them
> (ratified as Svade). Every implementation uses one of them, but platforms
> designed before Svade and Svadu were ratified, such as the HiFive Premier
> P550, may advertise neither. Xen then cannot tell which scheme is in
> effect, so rather than guess, panic in riscv_fill_hwcap() when the device
> tree advertises neither Svade nor Svadu, so that the device tree gets
> fixed.
>
> Add Svadu to the known ISA extensions so it can be told apart from Svade.
> The comment above the enum asks for new extensions to go at the bottom to
> avoid shuffling, a leftover from Linux where the IDs were macros with
> explicit values. Nothing depends on the enum values, so have the comment
> say that multi-letter extensions follow the order of riscv_isa_ext[].
>
> Suggested-by: Jan Beulich <jbeulich@suse.com>
Did I, really? Iirc I left open whether to go the panic() route or the
alternative one. Based on Andrew's clarification as to pre-Svad{e,u}
behavior, I think I further tried to indicate that synthesizing the
correct extension may be preferable, to allow older systems' DTs to be
used as-is. In any event ...
> @@ -674,6 +675,22 @@ 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");
>
> + /*
> + * The privileged spec allows exactly two schemes for updating 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).
> + *
> + * Every implementation uses one of them, but may predate the extensions
> + * and advertise neither. The device tree is then ambiguous: Xen cannot
> + * tell which scheme is in effect, so panic and have the device tree
> + * fixed.
> + */
> + if ( !riscv_isa_extension_available(NULL, RISCV_ISA_EXT_svade) &&
> + !riscv_isa_extension_available(NULL, RISCV_ISA_EXT_svadu) )
> + panic("Device tree advertises neither Svade nor Svadu, A/D bits update scheme unknown\n");
... this message leaves the observer to figure out what to do about the
situation.
Jan
next prev parent reply other threads:[~2026-10-26 9:32 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-16 15:31 [PATCH v7 0/4] xen/riscv: fix boot on missing extensions and MMU setup bugs Baptiste Le Duc
2026-10-16 15:34 ` [PATCH v7 1/4] xen/riscv: use pte_is_valid() in pte_is_mapping() Baptiste Le Duc
2026-10-16 15:49 ` Oleksii Kurochko
2026-10-26 9:26 ` Jan Beulich
2026-10-16 15:34 ` [PATCH v7 2/4] xen/riscv: fix A/D bits in Xen's page-table mappings Baptiste Le Duc
2026-10-23 2:37 ` Zhang Zheng
2026-10-26 9:27 ` Jan Beulich
2026-10-16 15:34 ` [PATCH v7 3/4] xen/riscv: panic if the device tree advertises neither Svade nor Svadu Baptiste Le Duc
2026-10-16 15:45 ` Oleksii Kurochko
2026-10-23 2:37 ` Zhang Zheng
2026-10-26 9:32 ` Jan Beulich [this message]
2026-10-26 9:44 ` Baptiste Le Duc
2026-10-26 9:52 ` Jan Beulich
2026-10-16 15:34 ` [PATCH v7 4/4] xen/riscv: rework the A/D bits comment in p2m_set_pte_flags() Baptiste Le Duc
2026-10-16 15:47 ` Oleksii Kurochko
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=4526ac23-ca7c-40e2-a9d6-9d366369d3bb@suse.com \
--to=jbeulich@suse.com \
--cc=alistair.francis@wdc.com \
--cc=andrew.cooper3@citrix.com \
--cc=anthony.perard@vates.tech \
--cc=baptiste.le-duc@vates.tech \
--cc=connojdavis@gmail.com \
--cc=julien@xen.org \
--cc=michal.orzel@amd.com \
--cc=oleksii.kurochko@gmail.com \
--cc=roger@xenproject.org \
--cc=sstabellini@kernel.org \
--cc=xen-devel@lists.xenproject.org \
--cc=zhangzheng@iscas.ac.cn \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.