[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH v6 1/4] xen/riscv: probe the PTE A/D bits update scheme at boot


  • To: xen-devel@xxxxxxxxxxxxxxxxxxxx
  • From: Baptiste Le Duc <baptiste.le-duc@xxxxxxxxxx>
  • Date: Fri, 16 Oct 2026 14:54:43 +0200
  • 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:MIME-Version:Content-Type:Content-Transfer-Encoding:In-Reply-To:References:Feedback-ID"
  • Autocrypt: addr=baptiste.le-duc@xxxxxxxxxx; keydata= xsBNBGoPSX8BCADSuTikqW3FD4mscQugY1thRaKlIhcJ2G9YCWYXAlp+xosvTlzfIftOZZim 750MLvyKtLPkQzB6TZtFZBiexSraaF/MdDKRTT5DcVa3r7ZnHgqMclWlPa4ioysS4yFcJanL cyNOT7HUFvIdirMMqiViedfYtS0GORPBBPVISD6ClMz3ecHIxqllfq9CHYQn4amKEfHmh6tm Rufo4Gjl6x8cUFZZlRQf+aCmUzdSPA0P5u3sueYH1uEz4w/jbD53MlKqzCvxUeOsfS2swTQA 6mS9jIgOjNadpUTOzKfDHMgFirtG+HFpm45Nwp6KQizxgDVOfTnOfVHm5Gwqm3ETl9y5ABEB AAHNPEJhcHRpc3RlIExlIER1YyAoVmF0ZXMgWXViaWtleSkgPGJhcHRpc3RlLmxlLWR1Y0B2 YXRlcy50ZWNoPsLAjgQTAQoAOBYhBGiSJ6HgW88MgT/gfu2Cu2XL9M6QBQJqD0l/AhsDBQsJ CAcCBhUKCQgLAgQWAgMBAh4BAheAAAoJEO2Cu2XL9M6QuMcH/ihiy/Nrxp919AmY0ENnc0NK r/2LDvW/hrX4FfbpxAmrGmQ7MU1aQTk0JDbfcsG8OYH6wO5sqnXb1gz50YrEdpfVSbHz5YTZ EhDIxE4g7NrvJZh3Qc0m0CAyjYTNHen7J6olVaCMjrOH7uRHUYZ7Pl3am9mZosfLmez/aWJO a6ihQxBXHI75brlk1teIURkep2kP7P0Flmfl4cA//saREoTF7GXCtjOSQk/xg8PP0Sswqp5G TdJptn3FQn6lAzfz0eFSYqkaoX2c2k1MDa7o+UX9cfGPL8ybMKnYkasLxck6eOWGJWf+YTrm ga/r0kBaftmqNDgt5nI2jNTDwZcT9g3OwE0Eag9JfwEIAM6IWbuBSvz+erv27oGDDpo8M6Fp dGUvft7v+WceHUfxiXpYFx9qgIU6XGy6y+3lJMAvNcltS8DuhioqMlfKRSYGKZlpliY65dNP 557IuM4ctVJ+I9CVclvv9eahARQKgF5auLJAAlvGSmU+ufNvlwTUmLIRcrPviTmB6X5jJYc+ fiNeyI0HcsgcN21C0r62tUCypuZ+vgEJXw2bx1V8mVGZKxdGJPh58QF6kRK+xmd4kEComLGV BeM6BcVOtEjDcGNC0tLhXb0p9g1Ys55iA8sd6s4WacyolW2J6rwmcOkjiWexWw1caYgIWAV1 004M3gwUaOz0dGq2i7HQ0AiVfVkAEQEAAcLAdgQYAQoAIBYhBGiSJ6HgW88MgT/gfu2Cu2XL 9M6QBQJqD0l/AhsMAAoJEO2Cu2XL9M6QovYH/RjstyL5o/V5K74ylBtz0j5t3pLX5JKbwApi 656rGgDdqElImyvvZppNMl/mgHNzvxmfFAhJXnSX9f1fqVEQKOGEhLUastnl/ssBiE5x7btM V0GAffxXbXJZbVv4b/DI+gVrOPc2YXlVwruapvTZNtD3hqPrkjrmq5WTtGR2loIVSe62hmh0 BGD2Fy79b/hYWyBqhayPBEjwGW75u4/yn+Yqy1PgG3hIcvg7GSuT3akhHZSB2Mbguzcoyf9Q DJl6t33JxPRkkNrEdkPPmRlQCTSiUkVjKqMDF3jlINWsJ5t4jKFsNF91ksdw7aQgiX+tQIpE ugMC1NuNi5dDGip66bw=
  • Delivery-date: Fri, 16 Oct 2026 12:54:53 +0000
  • Feedback-id: default:8631fc262581453bbf619ec5b2062170:Sweego
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>



On 10/16/26 2:51 PM, Jan Beulich wrote:
On 16.10.2026 13:35, Baptiste Le Duc wrote:
On 2026-10-15 18:04 +0200, Jan Beulich wrote:
Based on Andrew's answer to your question on GitHub [1], I see two options
for handling a DT that doesn't advertise the scheme in effect. Please
feel free to choose one.

1) Trust the probe and fix up riscv_isa on a mismatch. This avoids having
people edit their DTs, and is safe as, per Andrew, the spec has only ever
allowed these two schemes:

/*
  * 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.
  *
  * Rather than trusting the DTS alone, probe the scheme in effect with a write
  * through a PTE whose A and D bits are clear. If the DTS does not advertise
  * it, replace it by the probed scheme. As the spec has only ever allowed
  * these two schemes, this is safe even on implementations that predate Svade
  * and Svadu.
  */
static void __init check_ad_scheme(void)
{
     bool has_hw_scheme = probe_hw_ad_update();
     const char *scheme_name = has_hw_scheme ? "Svadu" : "Svade";
     enum riscv_isa_ext_id ext = has_hw_scheme ? RISCV_ISA_EXT_svadu
                                               : RISCV_ISA_EXT_svade;

     /* Fix DTS in case of mismatch */
     if ( !riscv_isa_extension_available(NULL, ext) )
     {
         printk(XENLOG_WARNING
                "CPU implements %s but the DTS does not advertise it\n",
                scheme_name);
         __clear_bit(RISCV_ISA_EXT_svade, riscv_isa);
         __clear_bit(RISCV_ISA_EXT_svadu, riscv_isa);
         __set_bit(ext, riscv_isa);
     }

     printk(XENLOG_DEBUG "CPU is using %s A/D bits scheme\n", scheme_name);
}

Yes, if the assumption is that this would be used only when neither extension
is advertised, then I agree (taking Andrew's response into account). I'm sorry,
this has been quite a bit of back and forth, but hopefully we're now all on the
same page.
Ok thanks, great to hear. Just to not mistaken, when you said "would be used only when neither extension is advertised" it would means that in other cases where there would be a mismatch between what the DTS advertised and what the CPU actually support we should panic?


Jan




 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.