On 07.01.2026 17:32, Oleksii Kurochko wrote:
> RISC-V's PTE has only two available bits that can be used to store the P2M
> type. This is insufficient to represent all the current RISC-V P2M types.
> Therefore, some P2M types must be stored outside the PTE bits.
>
> To address this, a metadata table is introduced to store P2M types that
> cannot fit in the PTE itself. Not all P2M types are stored in the
> metadata table—only those that require it.
>
> The metadata table is linked to the intermediate page table via the
> `struct page_info`'s v.md.metadata field of the corresponding intermediate
> page.
> Such pages are allocated with MEMF_no_owner, which allows us to use
> the v field for the purpose of storing the metadata table.
>
> To simplify the allocation and linking of intermediate and metadata page
> tables, `p2m_{alloc,free}_table()` functions are implemented.
>
> These changes impact `p2m_split_superpage()`, since when a superpage is
> split, it is necessary to update the metadata table of the new
> intermediate page table — if the entry being split has its P2M type set
> to `p2m_ext_storage` in its `P2M_TYPES` bits. In addition to updating
> the metadata of the new intermediate page table, the corresponding entry
> in the metadata for the original superpage is invalidated.
>
> Also, update p2m_{get,set}_type to work with P2M types which don't fit
> into PTE bits.
>
> Suggested-by: Jan Beulich <[email protected]>
> Signed-off-by: Oleksii Kurochko <[email protected]>
Acked-by: Jan Beulich <[email protected]>