|
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [xen staging] xen/riscv: introduce pte_{set,get}_mfn()
commit 3d197aad8aa98cbd22fca3054363aae7227f496d
Author: Oleksii Kurochko <oleksii.kurochko@xxxxxxxxx>
AuthorDate: Tue Dec 16 17:55:16 2025 +0100
Commit: Jan Beulich <jbeulich@xxxxxxxx>
CommitDate: Thu Dec 18 09:59:53 2025 +0100
xen/riscv: introduce pte_{set,get}_mfn()
Introduce helpers pte_{set,get}_mfn() to simplify setting and getting
of mfn.
Also, introduce PTE_PPN_MASK and add BUILD_BUG_ON() to be sure that
PTE_PPN_MASK remains the same for all MMU modes except Sv32.
Signed-off-by: Oleksii Kurochko <oleksii.kurochko@xxxxxxxxx>
Acked-by: Jan Beulich <jbeulich@xxxxxxxx>
---
xen/arch/riscv/include/asm/page.h | 24 ++++++++++++++++++++++++
1 file changed, 24 insertions(+)
diff --git a/xen/arch/riscv/include/asm/page.h
b/xen/arch/riscv/include/asm/page.h
index 7fde99f916..1fc5998a0b 100644
--- a/xen/arch/riscv/include/asm/page.h
+++ b/xen/arch/riscv/include/asm/page.h
@@ -112,6 +112,30 @@ typedef struct {
#endif
} pte_t;
+#if RV_STAGE1_MODE != SATP_MODE_SV32
+#define PTE_PPN_MASK _UL(0x3FFFFFFFFFFC00)
+#else
+#define PTE_PPN_MASK _U(0xFFFFFC00)
+#endif
+
+static inline void pte_set_mfn(pte_t *p, mfn_t mfn)
+{
+ /*
+ * At the moment spec provides Sv32 - Sv57.
+ * If one day new MMU mode will be added it will be needed
+ * to check that PPN mask still continue to cover bits 53:10.
+ */
+ BUILD_BUG_ON(RV_STAGE1_MODE > SATP_MODE_SV57);
+
+ p->pte &= ~PTE_PPN_MASK;
+ p->pte |= MASK_INSR(mfn_x(mfn), PTE_PPN_MASK);
+}
+
+static inline mfn_t pte_get_mfn(pte_t p)
+{
+ return _mfn(MASK_EXTR(p.pte, PTE_PPN_MASK));
+}
+
static inline bool pte_is_valid(pte_t p)
{
return p.pte & PTE_VALID;
--
generated by git-patchbot for /home/xen/git/xen.git#staging
|
![]() |
Lists.xenproject.org is hosted with RackSpace, monitoring our |