|
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] Re: [PATCH v2 23/40] xen/mpu: initialize frametable in MPU system
Hi, On 13/01/2023 05:28, Penny Zheng wrote: Xen is using page as the smallest granularity for memory managment. And we want to follow the same concept in MPU system. That is, structure page_info and the frametable which is used for storing and managing page_info is also required in MPU system. In MPU system, since there is no virtual address translation (VA == PA), we can not use a fixed VA address(FRAMETABLE_VIRT_START) to map frametable like MMU system does. Instead, we define a variable "struct page_info *frame_table" as frametable pointer, and ask boot allocator to allocate memory for frametable. As frametable is successfully initialized, the convertion between machine frame number/machine address/"virtual address" and page-info structure is ready too, like mfn_to_page/maddr_to_page/virt_to_page, etc Signed-off-by: Penny Zheng <penny.zheng@xxxxxxx> Signed-off-by: Wei Chen <wei.chen@xxxxxxx> --- xen/arch/arm/include/asm/mm.h | 15 --------------- xen/arch/arm/include/asm/mm_mmu.h | 16 ++++++++++++++++ You are already moving some bits related to the frametable in an earlier patch. So I am a bit surprised to see some changes in mm_mmu.h here. I would also rather prefer if the code changes are separated from the addition of the MPU code. They could them be moved at the beginning of the series and hopefully be merged before the rest (reducing the size this series). You are describing an implementation details of virt_to_maddr() which doesn't matter here.xen/arch/arm/include/asm/mm_mpu.h | 17 +++++++++++++++++ xen/arch/arm/mm_mpu.c | 25 +++++++++++++++++++++++++ 4 files changed, 58 insertions(+), 15 deletions(-) diff --git a/xen/arch/arm/include/asm/mm.h b/xen/arch/arm/include/asm/mm.h index e29158028a..7969ec9f98 100644 --- a/xen/arch/arm/include/asm/mm.h +++ b/xen/arch/arm/include/asm/mm.h @@ -176,7 +176,6 @@ struct page_info#define maddr_get_owner(ma) (page_get_owner(maddr_to_page((ma)))) -#define frame_table ((struct page_info *)FRAMETABLE_VIRT_START)/* PDX of the first page in the frame table. */ extern unsigned long frametable_base_pdx;@@ -280,20 +279,6 @@ static inline uint64_t gvirt_to_maddr(vaddr_t va, paddr_t *pa,#define virt_to_mfn(va) __virt_to_mfn(va) #define mfn_to_virt(mfn) __mfn_to_virt(mfn)-/* Convert between Xen-heap virtual addresses and page-info structures. */ + pdx = mfn_to_pdx(maddr_to_mfn(virt_to_maddr(va))); Why not using virt_to_mfn()?Also, I would consider to add ASSERT(mfn_is_valid(...)) to confirm the MFN you pass is covered by the frametable. (This would be a sort of equalivent check to the MMU one). + + return frame_table + pdx - frametable_base_pdx; +} + #endif /* __ARCH_ARM_MM_MPU__ *//*diff --git a/xen/arch/arm/mm_mpu.c b/xen/arch/arm/mm_mpu.c index f057ee26df..7b282be4fb 100644 --- a/xen/arch/arm/mm_mpu.c +++ b/xen/arch/arm/mm_mpu.c @@ -69,6 +69,8 @@ static DEFINE_SPINLOCK(xen_mpumap_lock);static paddr_t dtb_paddr; +struct page_info *frame_table; I have to admit, I am a bit puzzled why you added some stub in earlier patches for some functions but not for others. How did you make the decision on which one to stub? Maybe assert()/panic() the function is not called twice? + /* + * Since VA == PA in MPU and we've already setup Xenheap mapping + * in setup_staticheap_mappings(), we could easily deduce the + * "virtual address" of frame table. + */ + base_mfn = alloc_boot_pages(frametable_size >> PAGE_SHIFT, 1); + frame_table = (struct page_info*)mfn_to_virt(base_mfn); Coding style: "struct page_info *". Cheers, -- Julien Grall
|
![]() |
Lists.xenproject.org is hosted with RackSpace, monitoring our |