Re: [PATCH v9 09/12] riscv: add RISC-V Svpbmt extension support

From: Philipp Tomsich
Date: Wed Apr 13 2022 - 05:11:51 EST


On Wed, 13 Apr 2022 at 05:03, Heiko Stuebner <heiko@xxxxxxxxx> wrote:
>
> Svpbmt (the S should be capitalized) is the
> "Supervisor-mode: page-based memory types" extension
> that specifies attributes for cacheability, idempotency
> and ordering.
>
> The relevant settings are done in special bits in PTEs:
>
> Here is the svpbmt PTE format:
> | 63 | 62-61 | 60-8 | 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0
> N MT RSW D A G U X W R V
> ^
>
> Of the Reserved bits [63:54] in a leaf PTE, the high bit is already
> allocated (as the N bit), so bits [62:61] are used as the MT (aka
> MemType) field. This field specifies one of three memory types that
> are close equivalents (or equivalent in effect) to the three main x86
> and ARMv8 memory types - as shown in the following table.
>
> RISC-V
> Encoding &
> MemType RISC-V Description
> ---------- ------------------------------------------------
> 00 - PMA Normal Cacheable, No change to implied PMA memory type
> 01 - NC Non-cacheable, idempotent, weakly-ordered Main Memory
> 10 - IO Non-cacheable, non-idempotent, strongly-ordered I/O memory
> 11 - Rsvd Reserved for future standard use
>
> As the extension will not be present on all implementations,
> implement a method to handle cpufeatures via alternatives
> to not incur runtime penalties on cpu variants not supporting
> specific extensions and patch relevant code parts at runtime.
>
> Co-developed-by: Wei Fu <wefu@xxxxxxxxxx>
> Signed-off-by: Wei Fu <wefu@xxxxxxxxxx>
> Co-developed-by: Liu Shaohua <liush@xxxxxxxxxxxxxxxxx>
> Signed-off-by: Liu Shaohua <liush@xxxxxxxxxxxxxxxxx>
> Co-developed-by: Guo Ren <guoren@xxxxxxxxxx>
> Signed-off-by: Guo Ren <guoren@xxxxxxxxxx>
> [moved to use the alternatives mechanism]
> Signed-off-by: Heiko Stuebner <heiko@xxxxxxxxx>
> Cc: Christoph Hellwig <hch@xxxxxx>
> Cc: Arnd Bergmann <arnd@xxxxxxxx>
> Cc: Drew Fustini <drew@xxxxxxxxxxxxxxx>
> Cc: Wei Fu <wefu@xxxxxxxxxx>
> Cc: Wei Wu <lazyparser@xxxxxxxxx>
> Cc: Chen-Yu Tsai <wens@xxxxxxxx>
> Cc: Maxime Ripard <maxime@xxxxxxxxxx>
> Cc: Daniel Lustig <dlustig@xxxxxxxxxx>
> Cc: Greg Favor <gfavor@xxxxxxxxxxxxxxxx>
> Cc: Andrea Mondelli <andrea.mondelli@xxxxxxxxxx>
> Cc: Jonathan Behrens <behrensj@xxxxxxx>
> Cc: Xinhaoqu (Freddie) <xinhaoqu@xxxxxxxxxx>
> Cc: Bill Huffman <huffman@xxxxxxxxxxx>
> Cc: Nick Kossifidis <mick@xxxxxxxxxxxx>
> Cc: Allen Baum <allen.baum@xxxxxxxxxxxxxxxxx>
> Cc: Josh Scheid <jscheid@xxxxxxxxxxxxxxxx>
> Cc: Richard Trauben <rtrauben@xxxxxxxxx>

Reviewed-by: Philipp Tomsich <philipp.tomsich@xxxxxxxx>