The top 10 bits of a pte are reserved by specification and are not part of the PPN
For those playing along at home, from 'Volume II: RISC-V Privileged Architectures V20190608-Priv-MSU-Ratified', '4.4.1 Addressing and Memory Protection', page 72: "The PTE format for Sv39 is shown in Figure 4.18. Bits 9–0 have the same meaning as for Sv32. Bits 63–54 are reserved for future use and must be zeroed by software for forward compatibility.".
|362 ↗||(On Diff #73923)|
I'd prefer to see a definition for the constant placed in pte.h, something like PTE_MASK.
#define PTE_TO_PHYS(pte) \ ((((pte) & PTE_MASK) >> PTE_PPN0_S) * PAGE_SIZE)
(The second line has a 4-space indent)