MPU mm subsystem skeleton
v2 cover MPU mm subsystem skeleton
Hi all,
this serie implements the skeleton for the MPU memory management subsystem, at the end of the serie it will be possible to compile the Arm64 arch using MPU.
The minimum Arm Kconfig configuration is this one:
CONFIG_UNSUPPORTED=yCONFIG_MPU=yCONFIG_XEN_START_ADDRESS=0x0
Luca Fancellu (5):
arm/mpu: Add HYPERVISOR_VIRT_START and avoid a check in xen.lds.S xen/arm: Introduce frame_table and virt_to_page arm/mpu: Kconfig symbols for MPU build
arm/mpu: Implement stubs for ioremap_attr on MPU arm/mpu: Create the skeleton for MPU compilation
Penny Zheng (2):
xen/arm: Implement virt/maddr conversion in MPU system
xen: introduce Kconfig HAS_PAGING_MEMPOOL
xen/arch/arm/Kconfig | 4 +- xen/arch/arm/arm64/mpu/Makefile | 2 + xen/arch/arm/arm64/mpu/p2m.c | 19 ++++++ xen/arch/arm/arm64/mpu/smpboot.c | 26 ++++++++ xen/arch/arm/dom0less-build.c | 48 ++++++++++---- xen/arch/arm/include/asm/domain.h | 2 + xen/arch/arm/include/asm/mm.h | 76 +++------------------- xen/arch/arm/include/asm/mmu/mm.h | 70 ++++++++++++++++++++ xen/arch/arm/include/asm/mpu/layout.h | 5 ++ xen/arch/arm/include/asm/mpu/mm.h | 42 ++++++++++++ xen/arch/arm/include/asm/mpu/p2m.h | 21 ++++++ xen/arch/arm/include/asm/p2m.h | 2 +- xen/arch/arm/mm.c | 5 ++ xen/arch/arm/mmu/pt.c | 5 -- xen/arch/arm/mpu/Makefile | 3 + xen/arch/arm/mpu/mm.c | 45 ++++++++++++- xen/arch/arm/mpu/p2m.c | 94 +++++++++++++++++++++++++++ xen/arch/arm/mpu/setup.c | 40 ++++++++++++ xen/arch/arm/mpu/vmap.c | 26 ++++++++ xen/arch/arm/xen.lds.S | 2 + xen/common/Kconfig | 3 + 21 files changed, 453 insertions(+), 87 deletions(-) create mode 100644 xen/arch/arm/arm64/mpu/p2m.c create mode 100644 xen/arch/arm/arm64/mpu/smpboot.c create mode 100644 xen/arch/arm/include/asm/mpu/mm.h create mode 100644 xen/arch/arm/include/asm/mpu/p2m.h create mode 100644 xen/arch/arm/mpu/p2m.c create mode 100644 xen/arch/arm/mpu/setup.c create mode 100644 xen/arch/arm/mpu/vmap.c
Signature · 1 line
2.34.1
PATCH v2 1/7 arm/mpu: Add HYPERVISOR_VIRT_START and avoid a check in xen.lds.S
The define HYPERVISOR_VIRT_START is required by the common code, even if MPU system doesn't use virtual memory, define it in mpu/layout.h in order to reuse existing code.
Disable a check in the linker script for arm for !MMU systems.
---
v2 changes:
- Add Michal R-by
--- xen/arch/arm/include/asm/mpu/layout.h | 2 ++ xen/arch/arm/xen.lds.S | 2 ++ 2 files changed, 4 insertions(+)
xen/arch/arm/include/asm/mpu/layout.h +2 -0
@@ -22,6 +22,8 @@*/ #define XEN_VIRT_START _AT(paddr_t, XEN_START_ADDRESS) +#define HYPERVISOR_VIRT_START XEN_VIRT_START +#endif /* __ARM_MPU_LAYOUT_H__ */ /* * Local variables:
xen/arch/arm/xen.lds.S +2 -0
@@ -239,4 +239,6 @@ ASSERT(IS_ALIGNED(__bss_start, POINTER_ALIGN), "__bss_start is misaligned") ASSERT(IS_ALIGNED(__bss_end, POINTER_ALIGN), "__bss_end is misaligned") /* To simplify the logic in head.S, we want to _end to be page aligned */ ASSERT(IS_ALIGNED(_end, PAGE_SIZE), "_end is not page aligned") +#ifdef CONFIG_MMU ASSERT((_end - _start) <= XEN_VIRT_SIZE, "Xen is too big") +#endif
Signature · 1 line
2.34.1
PATCH v2 2/7 xen/arm: Implement virt/maddr conversion in MPU system
In reply to Luca FancelluFrom: Penny Zheng <[email protected]>
virt_to_maddr and maddr_to_virt are used widely in Xen code. So even there is no VMSA in MPU system, we keep the interface in MPU to to avoid changing the existing common code.
In order to do that, move the virt_to_maddr() and maddr_to_virt() definitions to mmu/mm.h, move the include of memory management subsystems (MMU/MPU) on a different place because the mentioned helpers needs visibility of some macro in asm/mm.h.
Finally implement virt_to_maddr() and maddr_to_virt() for MPU systems under mpu/mm.h, the MPU version of virt/maddr conversion is simple since VA==PA.
---
v2 changes:
- add missing headers, fix header protection macro name convention
- take into account PADDR_MASK in virt_to_maddr
- fixed typo in commit message
- moved also maddr_to_virt to mmu/mm.h and moved include of mmu/mpu.
- moved introduction of mm.c footer on commit that touches that file.
--- xen/arch/arm/include/asm/mm.h | 64 +++++-------------------------- xen/arch/arm/include/asm/mmu/mm.h | 56 +++++++++++++++++++++++++++ xen/arch/arm/include/asm/mpu/mm.h | 27 +++++++++++++ 3 files changed, 92 insertions(+), 55 deletions(-) create mode 100644 xen/arch/arm/include/asm/mpu/mm.h
xen/arch/arm/include/asm/mm.h +9 -55
@@ -14,12 +14,6 @@# error "unknown ARM variant"#endif -#if defined(CONFIG_MMU ) -# include <asm/mmu/mm.h> -#elif !defined(CONFIG_MPU ) -# error "Unknown memory management layout" -#endif -/* Align Xen to a 2 MiB boundary. */ #define XEN_PADDR_ALIGN (1 << 21)
@@ -261,55 +255,6 @@ static inline void __iomem *ioremap_wc(paddr_t start, size_t len)/* Page-align address and convert to frame number format */ #define paddr_to_pfn_aligned (paddr) paddr_to_pfn(PAGE_ALIGN(paddr)) -#define virt_to_maddr (va) ({ \ - vaddr_t va_ = (vaddr_t)(va); \ - (paddr_t)((va_to_par(va_) & PADDR_MASK & PAGE_MASK) | (va_ & ~PAGE_MASK)); \ -}) - -#ifdef CONFIG_ARM_32 -/** -* Find the virtual address corresponding to a machine address -* -* Only memory backing the XENHEAP has a corresponding virtual address to -* be found. This is so we can save precious virtual space, as it's in -* short supply on arm32. This mapping is not subject to PDX compression -* because XENHEAP is known to be physically contiguous and can't hence -* jump over the PDX hole. This means we can avoid the roundtrips -* converting to/from pdx. -* -* @param ma Machine address -* @return Virtual address mapped to `ma` -*/ -static inline void *maddr_to_virt (paddr_t ma) -{ -ASSERT (is_xen_heap_mfn (maddr_to_mfn (ma))); - ma -=mfn_to_maddr (directmap_mfn_start); -return (void *)(unsigned long ) ma +XENHEAP_VIRT_START ; -} -#else -/** -* Find the virtual address corresponding to a machine address -* -* The directmap covers all conventional memory accesible by the -* hypervisor. This means it's subject to PDX compression. -* -* Note there's an extra offset applied (directmap_base_pdx) on top of the -* regular PDX compression logic. Its purpose is to skip over the initial -* range of non-existing memory, should there be one. -* -* @param ma Machine address -* @return Virtual address mapped to `ma` -*/ -static inline void *maddr_to_virt (paddr_t ma) -{ -ASSERT ((mfn_to_pdx (maddr_to_mfn (ma)) - directmap_base_pdx) < - (DIRECTMAP_SIZE >>PAGE_SHIFT )); -return (void *)(XENHEAP_VIRT_START - - (directmap_base_pdx <<PAGE_SHIFT ) + -maddr_to_directmapoff (ma)); -} -#endif -/* * Translate a guest virtual address to a machine address. * Return the fault information if the translation has failed else 0.
@@ -340,6 +285,15 @@ 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) +/* Memory management subsystem header placed here to see the above macros */ +#if defined(CONFIG_MMU ) +# include <asm/mmu/mm.h> +#elif defined(CONFIG_MPU ) +# include <asm/mpu/mm.h> +#else +#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) {
xen/arch/arm/include/asm/mmu/mm.h +56 -0
68 lines not on this page · raw message
xen/arch/arm/include/asm/mpu/mm.h new file +27 -0
@@ -0,0 +1,27 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ + +#ifndef __ARM_MPU_MM_H__ +#define __ARM_MPU_MM_H__ + +#include <xen/macros.h> +#include <xen/page-size.h> +#include <xen/types.h> + +#define virt_to_maddr (va) ((paddr_t)((vaddr_t)(va) & PADDR_MASK)) + +/* On MPU systems there is no translation, ma == va. */ +static inline void *maddr_to_virt (paddr_t ma) +{ +return _p (ma); +} + +#endif /* __ARM_MPU_MM_H__ */ + +/* +* Local variables: +* mode: C +* c-file-style: "BSD" +* c-basic-offset: 4 +* indent-tabs-mode: nil +* End: +*/
Signature · 1 line
2.34.1
Re: [PATCH v2 2/7] xen/arm: Implement virt/maddr conversion in MPU system
Quoted 13 lines · Luca Fancellu
From: Penny Zheng <[email protected]>
virt_to_maddrandmaddr_to_virtare used widely in Xen code. So even there is no VMSA in MPU system, we keep the interface in MPU to to avoid changing the existing common code.In order to do that, move the
virt_to_maddr()andmaddr_to_virt()definitions tommu/mm.h, move the include of memory management subsystems (MMU/MPU) on a different place because the mentioned helpers needs visibility of some macro inasm/mm.h.
Quoted 7 lines
Finally implement
virt_to_maddr()andmaddr_to_virt()for MPU systems undermpu/mm.h, the MPU version ofvirt/maddrconversion is simple since VA==PA.Signed-off-by Penny Zheng <[email protected]>Signed-off-by Wei Chen <[email protected]>Signed-off-by Luca Fancellu <[email protected]>
~Michal
PATCH v2 3/7 xen/arm: Introduce frame_table and virt_to_page
In reply to Luca FancelluIntroduce 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, as the only current implementation of armv8-r aarch64, which is cortex R82, can address up to that memory.
Take the occasion to sort alphabetically the headers following the Xen code style and add the emacs footer in mpu/mm.c.
---
v2 changes:
- sorted headers in mm.c
- modified commit message
- moved virt_to_page to MMU and MPU
- removed frametable_pdx_end, used mfn_valid
--- xen/arch/arm/include/asm/mm.h | 14 -------------- xen/arch/arm/include/asm/mmu/mm.h | 14 ++++++++++++++ xen/arch/arm/include/asm/mpu/layout.h | 3 +++ xen/arch/arm/include/asm/mpu/mm.h | 15 +++++++++++++++ xen/arch/arm/mpu/mm.c | 14 +++++++++++++- 5 files changed, 45 insertions(+), 15 deletions(-)
xen/arch/arm/include/asm/mm.h +0 -14
@@ -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)));
xen/arch/arm/include/asm/mmu/mm.h +14 -0
@@ -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 *
xen/arch/arm/include/asm/mpu/layout.h +3 -0
@@ -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/*
xen/arch/arm/include/asm/mpu/mm.h +15 -0
@@ -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,17 @@ 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) +{ +paddr_t paddr =virt_to_maddr (v); +unsigned long pdx =paddr_to_pdx (paddr); + +ASSERT (mfn_valid (maddr_to_mfn (paddr))); + +return frame_table + pdx - frametable_base_pdx; +} +#endif /* __ARM_MPU_MM_H__ */ /*
xen/arch/arm/mpu/mm.c +13 -1
@@ -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: +*/
Signature · 1 line
2.34.1
Re: [PATCH v2 3/7] xen/arm: Introduce frame_table and virt_to_page
Quoted 11 lines · Luca Fancellu
Introduce
frame_tablein order to provide the implementation ofvirt_to_pagefor MPU system, move the MMU variant inmmu/mm.h.Introduce
FRAMETABLE_NRthat is required for 'pdx_group_valid' inpdx.c, but leave the initialisation of the frame table to a later stage.
DefineFRAMETABLE_SIZEfor MPU to support up to 1TB of ram, as the only current implementation of armv8-r aarch64, which is cortex R82, can address up to that memory.
When mentioning support statements like this one, it'd be beneficial to provide a reference to a doc of some sort.
Also, shouldn't this be occasion to clarify SUPPORT statement as for max RAM supported for ARMv8R-AArch64? ARMv8R support is experimental, so I'm not 100% sure if we need to provide support statement for it at this stage though. Better check with others.
Quoted 105 lines
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 <[email protected]>---
v2 changes:
- sorted headers inmm.c
- modified commit message
- movedvirt_to_pageto MMU and MPU
- removedframetable_pdx_end, usedmfn_valid--- xen/arch/arm/include/asm/mm.h | 14 -------------- xen/arch/arm/include/asm/mmu/mm.h | 14 ++++++++++++++ xen/arch/arm/include/asm/mpu/layout.h | 3 +++ xen/arch/arm/include/asm/mpu/mm.h | 15 +++++++++++++++ xen/arch/arm/mpu/mm.c | 14 +++++++++++++- 5 files changed, 45 insertions(+), 15 deletions(-)xen/arch/arm/include/asm/mm.h +0
-14@@ -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)));xen/arch/arm/include/asm/mmu/mm.h +14
-0@@ -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 * xen/arch/arm/include/asm/mpu/layout.h +3
-0@@ -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/* xen/arch/arm/include/asm/mpu/mm.h +4
-0@@ -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,17 @@ static inline void *maddr_to_virt(paddr_t ma)return _p (ma); }
xen/arch/arm/include/asm/mpu/mm.h static inline void *maddr_to_virt(paddr_t ma) · line 31
Quoted 10 lines
xen/arch/arm/include/asm/mpu/mm.h +10
-0+/* Convert between virtual address to page-info structure. */ +static inline struct page_info *virt_to_page (const void *v) +{ +paddr_t paddr =virt_to_maddr (v); +unsigned long pdx =paddr_to_pdx (paddr); + +ASSERT (mfn_valid (maddr_to_mfn (paddr))); + +return frame_table + pdx - frametable_base_pdx; +}
This could be simplified (and number of conversions reduced) by doing sth like:mfn_t mfn = virt_to_mfn(v);
ASSERT(mfn_valid(mfn));
return mfn_to_page(mfn);
Other than that:
~Michal
Re: [PATCH v2 3/7] xen/arm: Introduce frame_table and virt_to_page
Hi Michal,
Quoted 10 lines · Michal
Quoted 5 lines · Luca Fancellu
Introduce
frame_tablein order to provide the implementation ofvirt_to_pagefor MPU system, move the MMU variant inmmu/mm.h.
Quoted 8 lines
Quoted 6 lines
Introduce
FRAMETABLE_NRthat is required for 'pdx_group_valid' inpdx.c, but leave the initialisation of the frame table to a later stage.
DefineFRAMETABLE_SIZEfor MPU to support up to 1TB of ram, as the only current implementation of armv8-r aarch64, which is cortex R82, can address up to that memory.When mentioning support statements like this one, it'd be beneficial to provide a reference to a doc of some sort.
So the only reference I have is this: https://developer.arm.com/Processors/Cortex-R82
but I would not be confident to use the link in the commit message as it could go stale very quickly. So I’m not sure about what I can do more.
Quoted 6 lines
Also, shouldn't this be occasion to clarify SUPPORT statement as for max RAM supported for ARMv8R-AArch64? ARMv8R support is experimental, so I'm not 100% sure if we need to provide support statement for it at this stage though. Better check with others.
Ok, I’ll stay tuned for the opinion of the others
Quoted 36 lines
Quoted 23 lines
xen/arch/arm/include/asm/mpu/mm.h +4
-0@@ -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,17 @@ static inline void *maddr_to_virt(paddr_t ma)return _p (ma); }xen/arch/arm/include/asm/mpu/mm.h static inline void *maddr_to_virt(paddr_t ma) · line 31
Quoted 10 lines
xen/arch/arm/include/asm/mpu/mm.h +10
-0+/* Convert between virtual address to page-info structure. */ +static inline struct page_info *virt_to_page (const void *v) +{ +paddr_t paddr =virt_to_maddr (v); +unsigned long pdx =paddr_to_pdx (paddr); + +ASSERT (mfn_valid (maddr_to_mfn (paddr))); + +return frame_table + pdx - frametable_base_pdx; +}This could be simplified (and number of conversions reduced) by doing sth like:
mfn_tmfn =virt_to_mfn(v);
Quoted 3 lines
ASSERT(mfn_valid(mfn));
return
mfn_to_page(mfn);
Right, I’ll test these and I’ll use them.
Quoted 3 lines
Other than that:
Reviewed-by Michal Orzel <[email protected]>
Thanks!
Quoted 3 lines
~Michal
Re: [PATCH v2 3/7] xen/arm: Introduce frame_table and virt_to_page
Quoted 20 lines · Luca Fancellu
Hi Michal,
Quoted 16 lines · Michal
Quoted 11 lines · Luca Fancellu
Introduce
frame_tablein order to provide the implementation ofvirt_to_pagefor MPU system, move the MMU variant inmmu/mm.h.Introduce
FRAMETABLE_NRthat is required for 'pdx_group_valid' inpdx.c, but leave the initialisation of the frame table to a later stage.
DefineFRAMETABLE_SIZEfor MPU to support up to 1TB of ram, as the only current implementation of armv8-r aarch64, which is cortex R82, can address up to that memory.
Quoted 7 lines
Quoted 2 lines
When mentioning support statements like this one, it'd be beneficial to provide a reference to a doc of some sort.
So the only reference I have is this: https://developer.arm.com/Processors/Cortex-R82
but I would not be confident to use the link in the commit message as it could go stale very quickly. So I’m not sure about what I can do more.
Well, not really. Max physical memory is advertised via ID_AA64MMFR0_EL1. I found some old R82 technical manual (you can surely find the latest one and provide reference to it - not the web page) and indeed it mentions PARange as 0b0010 which is 40bit which is 1TB. With the R82 being the only CPU model implementing ARMv8R-AArch64, that's solid information.
~Michal
Re: [PATCH v2 3/7] xen/arm: Introduce frame_table and virt_to_page
Quoted 32 lines · Michal
Quoted 25 lines · Luca Fancellu
Hi Michal,
Quoted 10 lines · Michal
Quoted 5 lines · Luca Fancellu
Introduce
frame_tablein order to provide the implementation ofvirt_to_pagefor MPU system, move the MMU variant inmmu/mm.h.Quoted 8 lines
Quoted 6 lines
Introduce
FRAMETABLE_NRthat is required for 'pdx_group_valid' inpdx.c, but leave the initialisation of the frame table to a later stage.
DefineFRAMETABLE_SIZEfor MPU to support up to 1TB of ram, as the only current implementation of armv8-r aarch64, which is cortex R82, can address up to that memory.When mentioning support statements like this one, it'd be beneficial to provide a reference to a doc of some sort.
So the only reference I have is this: https://developer.arm.com/Processors/Cortex-R82
Quoted 7 lines
Quoted 2 lines
but I would not be confident to use the link in the commit message as it could go stale very quickly. So I’m not sure about what I can do more.
Well, not really. Max physical memory is advertised via
ID_AA64MMFR0_EL1. I found some old R82 technical manual (you can surely find the latest one and provide reference to it - not the web page) and indeed it mentions PARange as 0b0010 which is 40bit which is 1TB. With the R82 being the only CPU model implementing ARMv8R-AArch64, that's solid information.
Right, I forgot about it, thanks for pointing that out, I’ll add a reference about it
Cheers,
Luca
PATCH v2 4/7 arm/mpu: Kconfig symbols for MPU build
In reply to Luca FancelluThe MPU system requires static memory to work, select that when building this memory management subsystem.
While there, provide a restriction for the ARM_EFI Kconfig parameter to be built only when !MPU, the EFI stub is not used as there are no implementation of UEFI services for armv8-r.
---
v2 changes:
- clarified commit message about static memory
- Add R-by Michal
--- xen/arch/arm/Kconfig | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
xen/arch/arm/Kconfig +2 -1
@@ -85,6 +85,7 @@ config MMU config MPU bool "MPU" if UNSUPPORTED + select STATIC_MEMORY help Memory Protection Unit (MPU). Select if you plan to run Xen on ARMv8-R systems supporting EL2. (UNSUPPORTED)
@@ -102,7 +103,7 @@ config ACPI config ARM_EFI bool "UEFI boot service support" - depends on ARM_64 + depends on ARM_64 && !MPU default y help This option provides support for boot services through
Signature · 1 line
2.34.1
PATCH v2 5/7 arm/mpu: Implement stubs for ioremap_attr on MPU
In reply to Luca FancelluImplement ioremap_attr() stub for MPU system; the implementation of ioremap() is the same between MMU and MPU system, and it relies on ioremap_attr(), so move the definition from mmu/pt.c to arm/mm.c.
---
v2 changes:
- Add R-by Michal
--- xen/arch/arm/mm.c | 5 +++++ xen/arch/arm/mmu/pt.c | 5 ----- xen/arch/arm/mpu/mm.c | 6 ++++++ 3 files changed, 11 insertions(+), 5 deletions(-)
xen/arch/arm/mm.c +5 -0
@@ -395,6 +395,11 @@ unsigned long get_upper_mfn_bound(void)return max_page -1 ; } +void *ioremap (paddr_t pa,size_t len) +{ +return ioremap_attr (pa, len,PAGE_HYPERVISOR_NOCACHE ); +} +/* * Local variables: * mode: C
xen/arch/arm/mmu/pt.c +0 -5
@@ -223,11 +223,6 @@ void *ioremap_attr(paddr_t start, size_t len, unsigned int attributes)return ptr + offs; } -void *ioremap (paddr_t pa,size_t len) -{ -return ioremap_attr (pa, len,PAGE_HYPERVISOR_NOCACHE ); -} -static int create_xen_table (lpae_t *entry) {mfn_t mfn;
xen/arch/arm/mpu/mm.c +6 -0
@@ -17,6 +17,12 @@ static void __init __maybe_unused build_assertions(void)BUILD_BUG_ON (PAGE_SIZE !=SZ_4K ); } +void __iomem *ioremap_attr (paddr_t start,size_t len,unsigned int flags) +{ +BUG_ON ("unimplemented" ); +return NULL ; +} +/* * Local variables: * mode: C
Signature · 1 line
2.34.1
PATCH v2 6/7 xen: introduce Kconfig HAS_PAGING_MEMPOOL
In reply to Luca FancelluFrom: Penny Zheng <[email protected]>
ARM MPU system doesn't need to use paging memory pool, as MPU memory mapping table at most takes only one 4KB page, which is enough to manage the maximum 255 MPU memory regions, for all EL2 stage 1 translation and EL1 stage 2 translation.
Introduce HAS_PAGING_MEMPOOL Kconfig common symbol, selected for Arm MMU systems.
Wrap the code inside 'construct_domU' that deal with p2m paging allocation in a new function 'domu_p2m_set_allocation', protected by HAS_PAGING_MEMPOOL, this is done in this way to prevent polluting the former function with #ifdefs and improve readability
Introduce arch_{get,set}_paging_mempool_size implementation for MPU system.
Remove 'struct paging_domain' from Arm 'struct arch_domain' when the field is not required.
---
v2 changes:
- make Kconfig HAS_PAGING_MEMPOOL common
- protect also "xen,domain-p2m-mem-mb" reading with HAS_PAGING_MEMPOOL
- do not define p2m_teardown{_allocation} in this patch
- change commit message
--- xen/arch/arm/Kconfig | 1 + xen/arch/arm/dom0less-build.c | 48 ++++++++++++++++++++++++------- xen/arch/arm/include/asm/domain.h | 2 ++ xen/arch/arm/mpu/Makefile | 1 + xen/arch/arm/mpu/p2m.c | 25 ++++++++++++++++ xen/common/Kconfig | 3 ++ 6 files changed, 69 insertions(+), 11 deletions(-) create mode 100644 xen/arch/arm/mpu/p2m.c
xen/arch/arm/Kconfig +1 -0
@@ -76,6 +76,7 @@ choice config MMU bool "MMU" select HAS_LLC_COLORING if !NUMA && ARM_64 + select HAS_PAGING_MEMPOOL select HAS_PMAP select HAS_VMAP select HAS_PASSTHROUGH
xen/arch/arm/dom0less-build.c +37 -11
78 lines not on this page · raw message
xen/arch/arm/include/asm/domain.h +2 -0
@@ -75,7 +75,9 @@ struct arch_domainstruct hvm_domain hvm; +#ifdef CONFIG_HAS_PAGING_MEMPOOL struct paging_domain paging; +#endif struct vmmio vmmio;
xen/arch/arm/mpu/Makefile +1 -0
@@ -1 +1,2 @@ obj-y += mm.o +obj-y += p2m.o
xen/arch/arm/mpu/p2m.c new file +25 -0
@@ -0,0 +1,25 @@ + +/* SPDX-License-Identifier: GPL-2.0-only */ + +#include <xen/domain.h> +#include <xen/errno.h> +#include <xen/types.h> + +int arch_get_paging_mempool_size (struct domain *d,uint64_t *size) +{ +return -EOPNOTSUPP ; +} + +int arch_set_paging_mempool_size (struct domain *d,uint64_t size) +{ +return -EOPNOTSUPP ; +} + +/* +* Local variables: +* mode: C +* c-file-style: "BSD" +* c-basic-offset: 4 +* indent-tabs-mode: nil +* End: +*/
xen/common/Kconfig +3 -0
@@ -74,6 +74,9 @@ config HAS_KEXEC config HAS_LLC_COLORING bool +config HAS_PAGING_MEMPOOL + bool + config HAS_PIRQ bool
Signature · 1 line
2.34.1
Re: [PATCH v2 6/7] xen: introduce Kconfig HAS_PAGING_MEMPOOL
xen/common/Kconfig config HAS_KEXEC · line 78
Quoted 8 lines · Luca Fancellu
xen/common/Kconfig +2
-0@@ -74,6 +74,9 @@ config HAS_KEXEC config HAS_LLC_COLORING bool +config HAS_PAGING_MEMPOOL + bool
Imo this is too little of a change outside of Arm-specific code here. Just go grep for "paging_mempool" to see what pretty obviously wants to fall under that new control. There may be more stuff. The stubs for arch_{get,set}_paging_mempool_size() likely also want to live in a header, perhaps even one in asm-generic/.
Jan
Re: [PATCH v2 6/7] xen: introduce Kconfig HAS_PAGING_MEMPOOL
Hi Jan,
Quoted 9 lines · Jan Beulich
Quoted 6 lines · Luca Fancellu
xen/common/Kconfig +0
-0@@ -74,6 +74,9 @@ config HAS_KEXECconfig
HAS_LLC_COLORING
bool
Quoted 8 lines
Quoted 2 lines
+config
HAS_PAGING_MEMPOOL
+ boolImo this is too little of a change outside of Arm-specific code here. Just go grep for "
paging_mempool" to see what pretty obviously wants to fall under that new control. There may be more stuff. The stubs for arch_{get,set}_paging_mempool_size() likely also want to live in a header, perhaps even one in asm-generic/.
I’m wondering, since we already have arch_{get,set}_paging_mempool_size architecture specific, I believe this config needs to be ARCH_PAGING_MEMPOOL and needs to provide stubs inside include/xen/domain.h in a similar way of how ARCH_MAP_DOMAIN_PAGE is done.
What do you think?
Cheers,
Luca
Re: [PATCH v2 6/7] xen: introduce Kconfig HAS_PAGING_MEMPOOL
Quoted 17 lines · Luca Fancellu
Quoted 8 lines · Jan Beulich
Quoted 6 lines · Luca Fancellu
xen/common/Kconfig +0
-0@@ -74,6 +74,9 @@ config HAS_KEXECconfig
HAS_LLC_COLORING
boolQuoted 8 lines
Quoted 2 lines
+config
HAS_PAGING_MEMPOOL
+ boolImo this is too little of a change outside of Arm-specific code here. Just go grep for "
paging_mempool" to see what pretty obviously wants to fall under that new control. There may be more stuff. The stubs for arch_{get,set}_paging_mempool_size() likely also want to live in a header, perhaps even one in asm-generic/.
Quoted 6 lines
I’m wondering, since we already have arch_{get,set}_paging_mempool_size architecture specific, I believe this config needs to be
ARCH_PAGING_MEMPOOLand needs to provide stubs insideinclude/xen/domain.hin a similar way of howARCH_MAP_DOMAIN_PAGEis done.What do you think?
Imo both routes are possible. I'm not sure we have a clear preference when looking at the code base as a whole.
Jan
Re: [PATCH v2 6/7] xen: introduce Kconfig HAS_PAGING_MEMPOOL
In reply to Luca FancelluQuoted 11 lines · Luca Fancellu
From: Penny Zheng <[email protected]>
ARM MPU system doesn't need to use paging memory pool, as MPU memory mapping table at most takes only one 4KB page, which is enough to manage the maximum 255 MPU memory regions, for all EL2 stage 1 translation and EL1 stage 2 translation.
Introduce
HAS_PAGING_MEMPOOLKconfigcommon symbol, selected for Arm MMU systems.
I think it should be selected by other arches that implement the stubs. Anyway, Jan added a comment and I do agree with him.
Just a few remarks.
Quoted 66 lines
Wrap the code inside '
construct_domU' that deal with p2m paging allocation in a new function 'domu_p2m_set_allocation', protected byHAS_PAGING_MEMPOOL, this is done in this way to prevent polluting the former function with #ifdefs and improve readabilityIntroduce arch_{get,set}_paging_mempool_size implementation for MPU system.
Remove 'struct
paging_domain' from Arm 'structarch_domain' when the field is not required.Signed-off-by Penny Zheng <[email protected]>Signed-off-by Wei Chen <[email protected]>Signed-off-by Luca Fancellu <[email protected]>---
v2 changes:
- makeKconfigHAS_PAGING_MEMPOOLcommon
- protect also "xen,domain-p2m-mem-mb" reading withHAS_PAGING_MEMPOOL
- do not define p2m_teardown{_allocation} in this patch
- change commit message--- xen/arch/arm/Kconfig | 1 + xen/arch/arm/dom0less-build.c | 48 ++++++++++++++++++++++++------- xen/arch/arm/include/asm/domain.h | 2 ++ xen/arch/arm/mpu/Makefile | 1 + xen/arch/arm/mpu/p2m.c | 25 ++++++++++++++++ xen/common/Kconfig | 3 ++ 6 files changed, 69 insertions(+), 11 deletions(-) create mode 100644 xen/arch/arm/mpu/p2m.cxen/arch/arm/Kconfig +1
-0@@ -76,6 +76,7 @@ choice config MMU bool "MMU" select HAS_LLC_COLORING if !NUMA && ARM_64 + select HAS_PAGING_MEMPOOL select HAS_PMAP select HAS_VMAP select HAS_PASSTHROUGHxen/arch/arm/dom0less-build.c +4
-0@@ -673,6 +673,8 @@ static int __init prepare_dtb_domU(struct domain *d, struct kernel_info *kinfo)return -EINVAL ; } +#ifdef CONFIG_HAS_PAGING_MEMPOOL +static unsigned long __init domain_p2m_pages (unsigned long maxmem_kb,unsigned int smp_cpus) {@@ -688,6 +690,8 @@ static unsigned long __init domain_p2m_pages(unsigned long maxmem_kb, return DIV_ROUND_UP(memkb, 1024) << (20 - PAGE_SHIFT); } +#endif +static int __init alloc_xenstore_evtchn (struct domain *d) {evtchn_alloc_unbound_t alloc;
xen/arch/arm/dom0less-build.c static void __init domain_vcpu_affinity(struct domain *d, · line 848
Quoted 4 lines
xen/arch/arm/dom0less-build.c +1
-0@@ -841,6 +845,38 @@ static void __init domain_vcpu_affinity(struct domain *d, } } +#ifdef CONFIG_HAS_PAGING_MEMPOOL
Why can't this be moved to upper CONFIG_HAS_PAGING_MEMPOOL block to avoid excessive ifdefery?
xen/arch/arm/dom0less-build.c static void __init domain_vcpu_affinity(struct domain *d, · line 850
Quoted 2 lines
xen/arch/arm/dom0less-build.c +2
-0+ +static int __init domu_p2m_set_allocation(struct domain *d, u64 mem,
s/domu/domain/ to match naming of other functions. uint64_t. Linux types shall no longer be used.
xen/arch/arm/dom0less-build.c static void __init domain_vcpu_affinity(struct domain *d, · line 854
Quoted 4 lines
xen/arch/arm/dom0less-build.c +4
-0+ const struct dt_device_node *node) +{ +unsigned long p2m_pages; +u32 p2m_mem_mb;
uint32_t
~Michal
PATCH v2 7/7 arm/mpu: Create the skeleton for MPU compilation
In reply to Luca FancelluThis commit introduces the skeleton for the MPU memory management subsystem that allows the compilation on Arm64.
---
The implementation of setup_virt_paging() is under arm64/mpu because it will have a different implementation from arm32.
v2 changes:
- p2m_teardown{_allocation} stubs are now part of this patch
- included missing headers
- rename vmap-mpu.c to vmap.c
- remove comment "Not used on MPU system" on implemented stubs
---
--- xen/arch/arm/arm64/mpu/Makefile | 2 + xen/arch/arm/arm64/mpu/p2m.c | 19 ++++++++ xen/arch/arm/arm64/mpu/smpboot.c | 26 +++++++++++ xen/arch/arm/include/asm/mpu/p2m.h | 21 +++++++++ xen/arch/arm/include/asm/p2m.h | 2 +- xen/arch/arm/mpu/Makefile | 2 + xen/arch/arm/mpu/mm.c | 25 +++++++++++ xen/arch/arm/mpu/p2m.c | 69 ++++++++++++++++++++++++++++++ xen/arch/arm/mpu/setup.c | 40 +++++++++++++++++ xen/arch/arm/mpu/vmap.c | 26 +++++++++++ 10 files changed, 231 insertions(+), 1 deletion(-) create mode 100644 xen/arch/arm/arm64/mpu/p2m.c create mode 100644 xen/arch/arm/arm64/mpu/smpboot.c create mode 100644 xen/arch/arm/include/asm/mpu/p2m.h create mode 100644 xen/arch/arm/mpu/setup.c create mode 100644 xen/arch/arm/mpu/vmap.c
xen/arch/arm/arm64/mpu/Makefile +2 -0
@@ -1 +1,3 @@ obj-y += head.o +obj-y += p2m.o +obj-y += smpboot.o
xen/arch/arm/arm64/mpu/p2m.c new file +19 -0
@@ -0,0 +1,19 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ + +#include <xen/bug.h> +#include <xen/init.h> +#include <asm/p2m.h> + +void __init setup_virt_paging (void ) +{ +BUG_ON ("unimplemented" ); +} + +/* +* Local variables: +* mode: C +* c-file-style: "BSD" +* c-basic-offset: 4 +* indent-tabs-mode: nil +* End: +*/
xen/arch/arm/arm64/mpu/smpboot.c new file +26 -0
@@ -0,0 +1,26 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ + +#include <xen/bug.h> +#include <xen/errno.h> +#include <xen/mm.h> +#include <xen/stdbool.h> + +int prepare_secondary_mm (int cpu) +{ +BUG_ON ("unimplemented" ); +return -EINVAL ; +} + +void update_boot_mapping (bool enable) +{ +BUG_ON ("unimplemented" ); +} + +/* +* Local variables: +* mode: C +* c-file-style: "BSD" +* c-basic-offset: 4 +* indent-tabs-mode: nil +* End: +*/
xen/arch/arm/include/asm/mpu/p2m.h new file +21 -0
@@ -0,0 +1,21 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ + +#ifndef __ARM_MPU_P2M_H__ +#define __ARM_MPU_P2M_H__ + +struct p2m_domain ; + +static inline void p2m_clear_root_pages (struct p2m_domain *p2m) {} + +static inline void p2m_tlb_flush_sync (struct p2m_domain *p2m) {} + +#endif /* __ARM_MPU_P2M_H__ */ + +/* +* Local variables: +* mode: C +* c-file-style: "BSD" +* c-basic-offset: 4 +* indent-tabs-mode: nil +* End: +*/
xen/arch/arm/include/asm/p2m.h +1 -1
@@ -168,7 +168,7 @@ typedef enum {#if defined(CONFIG_MMU )# include <asm/mmu/p2m.h> #else -# error "Unknown memory management layout" +# include <asm/mpu/p2m.h> #endif static inline bool arch_acquire_resource_check (struct domain *d)
xen/arch/arm/mpu/Makefile +2 -0
@@ -1,2 +1,4 @@ obj-y += mm.o obj-y += p2m.o +obj-y += setup.init.o +obj-y += vmap.o
xen/arch/arm/mpu/mm.c +25 -0
@@ -1,9 +1,12 @@/* SPDX-License-Identifier: GPL-2.0-only */ +#include <xen/bug.h> +#include <xen/errno.h> #include <xen/init.h> #include <xen/lib.h> #include <xen/mm.h> #include <xen/sizes.h> +#include <xen/types.h> struct page_info *frame_table;
@@ -17,6 +20,28 @@ static void __init __maybe_unused build_assertions(void)BUILD_BUG_ON (PAGE_SIZE !=SZ_4K ); } +void __init setup_mm (void ) +{ +BUG_ON ("unimplemented" ); +} + +int modify_xen_mappings (unsigned long s,unsigned long e,unsigned int nf) +{ +BUG_ON ("unimplemented" ); +return -EINVAL ; +} + +void dump_hyp_walk (vaddr_t addr) +{ +BUG_ON ("unimplemented" ); +} + +/* Release all __init and __initdata ranges to be reused */ +void free_init_memory (void ) +{ +BUG_ON ("unimplemented" ); +} +void __iomem *ioremap_attr (paddr_t start,size_t len,unsigned int flags) {BUG_ON ("unimplemented" );
xen/arch/arm/mpu/p2m.c +69 -0
78 lines not on this page · raw message
xen/arch/arm/mpu/setup.c new file +40 -0
@@ -0,0 +1,40 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ + +#include <xen/bug.h> +#include <xen/init.h> +#include <xen/mm.h> +#include <xen/types.h> +#include <asm/setup.h> + +void __init setup_pagetables (void ) {} + +void *__init early_fdt_map (paddr_t fdt_paddr) +{ +BUG_ON ("unimplemented" ); +return NULL ; +} + +/* +* copy_from_paddr - copy data from a physical address +* @dst: destination virtual address +* @paddr: source physical address +* @len: length to copy +*/ +void __init copy_from_paddr (void *dst,paddr_t paddr,unsigned long len) +{ +BUG_ON ("unimplemented" ); +} + +void __init remove_early_mappings (void ) +{ +BUG_ON ("unimplemented" ); +} + +/* +* Local variables: +* mode: C +* c-file-style: "BSD" +* c-basic-offset: 4 +* indent-tabs-mode: nil +* End: +*/
xen/arch/arm/mpu/vmap.c new file +26 -0
@@ -0,0 +1,26 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ + +#include <xen/bug.h> +#include <xen/mm-frame.h> +#include <xen/types.h> +#include <xen/vmap.h> + +void *vmap_contig (mfn_t mfn,unsigned int nr) +{ +BUG_ON ("unimplemented" ); +return NULL ; +} + +void vunmap (const void *va) +{ +BUG_ON ("unimplemented" ); +} + +/* +* Local variables: +* mode: C +* c-file-style: "BSD" +* c-basic-offset: 4 +* indent-tabs-mode: nil +* End: +*/
Signature · 1 line
2.34.1