]> xenbits.xensource.com Git - xen.git/commitdiff
xen/arm: Introduce frame_table and virt_to_page
authorLuca Fancellu <luca.fancellu@arm.com>
Tue, 1 Apr 2025 08:58:54 +0000 (09:58 +0100)
committerMichal Orzel <michal.orzel@amd.com>
Wed, 2 Apr 2025 09:15:10 +0000 (11:15 +0200)
Introduce frame_table in order to provide the implementation of
virt_to_page for MPU system, move the MMU variant in mmu/mm.h.

Introduce FRAMETABLE_NR that is required for 'pdx_group_valid' in
pdx.c, but leave the initialisation of the frame table to a later
stage.
Define FRAMETABLE_SIZE for MPU to support up to 1TB of ram at this
stage, as the only current implementation of armv8-r aarch64, which
is cortex R82, can support 1TB or 256TB (r82 TRM r3p1
ID_AA64MMFR0_EL1.PARange).

Take the occasion to sort alphabetically the headers following
the Xen code style and add the emacs footer in mpu/mm.c.

Signed-off-by: Luca Fancellu <luca.fancellu@arm.com>
Reviewed-by: Michal Orzel <michal.orzel@amd.com>
xen/arch/arm/include/asm/mm.h
xen/arch/arm/include/asm/mmu/mm.h
xen/arch/arm/include/asm/mpu/layout.h
xen/arch/arm/include/asm/mpu/mm.h
xen/arch/arm/mpu/mm.c

index 444fd03823ec985ab80e47646692439c41bc4c27..fbffaccef49b11f62f5b1d147ccd253b31a61914 100644 (file)
@@ -294,20 +294,6 @@ static inline uint64_t gvirt_to_maddr(vaddr_t va, paddr_t *pa,
 #error "Unknown memory management layout"
 #endif
 
-/* Convert between Xen-heap virtual addresses and page-info structures. */
-static inline struct page_info *virt_to_page(const void *v)
-{
-    unsigned long va = (unsigned long)v;
-    unsigned long pdx;
-
-    ASSERT(va >= XENHEAP_VIRT_START);
-    ASSERT(va < directmap_virt_end);
-
-    pdx = (va - XENHEAP_VIRT_START) >> PAGE_SHIFT;
-    pdx += mfn_to_pdx(directmap_mfn_start);
-    return frame_table + pdx - frametable_base_pdx;
-}
-
 static inline void *page_to_virt(const struct page_info *pg)
 {
     return mfn_to_virt(mfn_x(page_to_mfn(pg)));
index 6737c3ede783d3bbaa91a3da86f9a61235aee478..caba987edc855dd0e2e9311891923f47d87df158 100644 (file)
@@ -70,6 +70,20 @@ static inline void *maddr_to_virt(paddr_t ma)
 }
 #endif
 
+/* Convert between Xen-heap virtual addresses and page-info structures. */
+static inline struct page_info *virt_to_page(const void *v)
+{
+    unsigned long va = (unsigned long)v;
+    unsigned long pdx;
+
+    ASSERT(va >= XENHEAP_VIRT_START);
+    ASSERT(va < directmap_virt_end);
+
+    pdx = (va - XENHEAP_VIRT_START) >> PAGE_SHIFT;
+    pdx += mfn_to_pdx(directmap_mfn_start);
+    return frame_table + pdx - frametable_base_pdx;
+}
+
 /*
  * Print a walk of a page table or p2m
  *
index 248e55f8882d20a84128f615876c545eedbcc354..c331d1feaa84743583ad374b373853e038c4bfef 100644 (file)
@@ -3,6 +3,9 @@
 #ifndef __ARM_MPU_LAYOUT_H__
 #define __ARM_MPU_LAYOUT_H__
 
+#define FRAMETABLE_SIZE   GB(16)
+#define FRAMETABLE_NR     (FRAMETABLE_SIZE / sizeof(*frame_table))
+
 #define XEN_START_ADDRESS CONFIG_XEN_START_ADDRESS
 
 /*
index 6cfd0f5cd2c20dd1e6893a43826522c0238195d2..86f33d9836b7b35422da9678c3c975c11757c47c 100644 (file)
@@ -3,9 +3,13 @@
 #ifndef __ARM_MPU_MM_H__
 #define __ARM_MPU_MM_H__
 
+#include <xen/bug.h>
 #include <xen/macros.h>
 #include <xen/page-size.h>
 #include <xen/types.h>
+#include <asm/mm.h>
+
+extern struct page_info *frame_table;
 
 #define virt_to_maddr(va) ((paddr_t)((vaddr_t)(va) & PADDR_MASK))
 
@@ -15,6 +19,16 @@ static inline void *maddr_to_virt(paddr_t ma)
     return _p(ma);
 }
 
+/* Convert between virtual address to page-info structure. */
+static inline struct page_info *virt_to_page(const void *v)
+{
+    mfn_t mfn = _mfn(virt_to_mfn(v));
+
+    ASSERT(mfn_valid(mfn));
+
+    return mfn_to_page(mfn);
+}
+
 #endif /* __ARM_MPU_MM_H__ */
 
 /*
index 0b8748e575988d4c38269a6d07f1f69bdb2f6859..3632011c1013b14c23bb379c9f85cf65a49646e6 100644 (file)
@@ -1,9 +1,12 @@
 /* SPDX-License-Identifier: GPL-2.0-only */
 
-#include <xen/lib.h>
 #include <xen/init.h>
+#include <xen/lib.h>
+#include <xen/mm.h>
 #include <xen/sizes.h>
 
+struct page_info *frame_table;
+
 static void __init __maybe_unused build_assertions(void)
 {
     /*
@@ -13,3 +16,12 @@ static void __init __maybe_unused build_assertions(void)
      */
     BUILD_BUG_ON(PAGE_SIZE != SZ_4K);
 }
+
+/*
+ * Local variables:
+ * mode: C
+ * c-file-style: "BSD"
+ * c-basic-offset: 4
+ * indent-tabs-mode: nil
+ * End:
+ */