xen/arm: Memory subsystem clean-up
v4 cover xen/arm: Memory subsystem clean-up
Hi all,
This patch series contains clean-up for the ARM memory subsystem in preparation of reworking the page tables handling.
For all changes, see in each patch.
Cheers,
Julien Grall (10):
xen/arm: page: Use ARMv8 naming to improve readability xen/arm: page: Clean-up the definition of MAIRVAL
xen/arm: mm: Rename and clarify AP[1] in the stage-1 page table xen/arm: Switch to SYS_STATE_boot just after end_boot_allocator() xen/arm: mm: Rename 'ai' into 'flags' in create_xen_entries xen/arm: mm: Use PAGE_HYPERVISOR_* instead of MT_* when calling
set_fixmap
xen/arm: page: Describe the layout of flags used to update page tables xen/arm: mm: Embed permission in the flags
xen/arm: mm: Handle permission flags when adding a new mapping xen/arm: mm: Use memory flags for modify_xen_mappings rather than
custom one
xen/arch/arm/kernel.c | 2 +- xen/arch/arm/livepatch.c | 6 +-- xen/arch/arm/mm.c | 54 ++++++++++++------------ xen/arch/arm/platforms/vexpress.c | 3 +- xen/arch/arm/setup.c | 8 +++- xen/drivers/video/arm_hdlcd.c | 2 +- xen/include/asm-arm/lpae.h | 2 +- xen/include/asm-arm/page.h | 88 +++++++++++++++++++++++++-------------- 8 files changed, 99 insertions(+), 66 deletions(-)
Signature · 7 lines
2.11.0 _______________________________________________ Xen-devel mailing list [email protected] https://lists.xen.org/xen-devel
PATCH v4 1/10 xen/arm: page: Use ARMv8 naming to improve readability
This is based on the Linux ARMv8 naming scheme (see arch/arm64/mm/proc.S). Each type will contain "NORMAL" or "DEVICE" to make clear whether each attribute targets device or normal memory.
---
Changes in v3:
- The ai '000' is named MT_DEVICE_nGnRnE and not MT_DEVICE_nGnRE. The definition is still valid.
- Expand the comment to point to "Device Memory" section in the ARM ARM.
Changes in v2:
* Move the patch before "xen/arm: page: Clean-up the definition of MAIRVAL"
--- xen/arch/arm/kernel.c | 2 +- xen/arch/arm/mm.c | 28 ++++++++++++++-------------- xen/arch/arm/platforms/vexpress.c | 2 +- xen/drivers/video/arm_hdlcd.c | 2 +- xen/include/asm-arm/page.h | 35 +++++++++++++++++++---------------- 5 files changed, 36 insertions(+), 33 deletions(-)
xen/arch/arm/kernel.c +1 -1
@@ -54,7 +54,7 @@ void copy_from_paddr(void *dst, paddr_t paddr, unsigned long len) s = paddr & (PAGE_SIZE -1 ); l =min (PAGE_SIZE - s, len); -set_fixmap (FIXMAP_MISC ,maddr_to_mfn (paddr),MT_BUFFERABLE ); +set_fixmap (FIXMAP_MISC ,maddr_to_mfn (paddr),MT_NORMAL_NC );memcpy (dst, src + s, l);clean_dcache_va_range (dst, l);
xen/arch/arm/mm.c +14 -14
@@ -290,7 +290,7 @@ static inline lpae_t mfn_to_xen_entry(mfn_t mfn, unsigned attr)switch ( attr ) { -case MT_BUFFERABLE : +case MT_NORMAL_NC :/* * ARM ARM: Overlaying the shareability attribute (DDI * 0406C.b B3-1376 to 1377)
@@ -305,8 +305,8 @@ static inline lpae_t mfn_to_xen_entry(mfn_t mfn, unsigned attr)*/ e.pt.sh =LPAE_SH_OUTER ;break ; -case MT_UNCACHED : -case MT_DEV_SHARED : +case MT_DEVICE_nGnRnE: +case MT_DEVICE_nGnRE:/* * Shareability is ignored for non-Normal memory, Outer is as * good as anything.
@@ -369,7 +369,7 @@ static void __init create_mappings(lpae_t *second, count = nr_mfns /LPAE_ENTRIES ; p = second +second_linear_offset (virt_offset); - pte =mfn_to_xen_entry (_mfn (base_mfn),MT_WRITEALLOC ); + pte =mfn_to_xen_entry (_mfn (base_mfn),MT_NORMAL );if ( granularity ==16 *LPAE_ENTRIES ) pte.pt.contig =1 ;/* These maps are in 16-entry contiguous chunks. */ for ( i =0 ; i < count; i++ )
@@ -422,7 +422,7 @@ void *map_domain_page(mfn_t mfn)else if ( map[slot].pt.avail ==0 ) {/* Commandeer this 2MB slot */ - pte =mfn_to_xen_entry (_mfn (slot_mfn),MT_WRITEALLOC ); + pte =mfn_to_xen_entry (_mfn (slot_mfn),MT_NORMAL ); pte.pt.avail =1 ;write_pte (map + slot, pte);break ;
@@ -543,7 +543,7 @@ static inline lpae_t pte_of_xenaddr(vaddr_t va) {paddr_t ma = va + phys_offset; -return mfn_to_xen_entry (maddr_to_mfn (ma),MT_WRITEALLOC ); +return mfn_to_xen_entry (maddr_to_mfn (ma),MT_NORMAL ); }/* Map the FDT in the early boot page table */
@@ -652,7 +652,7 @@ void __init setup_pagetables(unsigned long boot_phys_offset, paddr_t xen_paddr)/* Initialise xen second level entries ... */ /* ... Xen's text etc */ - pte =mfn_to_xen_entry (maddr_to_mfn (xen_paddr),MT_WRITEALLOC ); + pte =mfn_to_xen_entry (maddr_to_mfn (xen_paddr),MT_NORMAL ); pte.pt.xn =0 ;/* Contains our text mapping! */ xen_second[second_table_offset (XEN_VIRT_START )] = pte;
@@ -669,7 +669,7 @@ void __init setup_pagetables(unsigned long boot_phys_offset, paddr_t xen_paddr)/* ... Boot Misc area for xen relocation */ dest_va =BOOT_RELOC_VIRT_START ; - pte =mfn_to_xen_entry (maddr_to_mfn (xen_paddr),MT_WRITEALLOC ); + pte =mfn_to_xen_entry (maddr_to_mfn (xen_paddr),MT_NORMAL );/* Map the destination in xen_second. */ xen_second[second_table_offset (dest_va)] = pte;/* Map the destination in boot_second. */
@@ -700,7 +700,7 @@ void __init setup_pagetables(unsigned long boot_phys_offset, paddr_t xen_paddr)unsigned long va =XEN_VIRT_START + (i <<PAGE_SHIFT );if ( !is_kernel (va) )break ; - pte =mfn_to_xen_entry (mfn,MT_WRITEALLOC ); + pte =mfn_to_xen_entry (mfn,MT_NORMAL ); pte.pt.table =1 ;/* 4k mappings always have this bit set */ if (is_kernel_text (va) ||is_kernel_inittext (va) ) {
@@ -771,7 +771,7 @@ int init_secondary_pagetables(int cpu)for ( i =0 ; i <DOMHEAP_SECOND_PAGES ; i++ ) { pte =mfn_to_xen_entry (virt_to_mfn (domheap+i*LPAE_ENTRIES ), -MT_WRITEALLOC ); +MT_NORMAL ); pte.pt.table =1 ;write_pte (&first[first_table_offset (DOMHEAP_VIRT_START +i*FIRST_SIZE )], pte); }
@@ -869,13 +869,13 @@ void __init setup_xenheap_mappings(unsigned long base_mfn,mfn_t first_mfn =alloc_boot_pages (1 ,1 );clear_page (mfn_to_virt (first_mfn)); - pte =mfn_to_xen_entry (first_mfn,MT_WRITEALLOC ); + pte =mfn_to_xen_entry (first_mfn,MT_NORMAL ); pte.pt.table =1 ;write_pte (p, pte); first =mfn_to_virt (first_mfn); } - pte =mfn_to_xen_entry (_mfn (mfn),MT_WRITEALLOC ); + pte =mfn_to_xen_entry (_mfn (mfn),MT_NORMAL );/* TODO: Set pte.pt.contig when appropriate. */ write_pte (&first[first_table_offset (vaddr)], pte);
@@ -915,7 +915,7 @@ void __init setup_frametable_mappings(paddr_t ps, paddr_t pe)for ( i =0 ; i < nr_second; i++ ) {clear_page (mfn_to_virt (mfn_add (second_base, i))); - pte =mfn_to_xen_entry (mfn_add (second_base, i),MT_WRITEALLOC ); + pte =mfn_to_xen_entry (mfn_add (second_base, i),MT_NORMAL ); pte.pt.table =1 ;write_pte (&xen_first[first_table_offset (FRAMETABLE_VIRT_START )+i], pte); }
@@ -969,7 +969,7 @@ static int create_xen_table(lpae_t *entry)if ( p ==NULL )return -ENOMEM ;clear_page (p); - pte =mfn_to_xen_entry (virt_to_mfn (p),MT_WRITEALLOC ); + pte =mfn_to_xen_entry (virt_to_mfn (p),MT_NORMAL ); pte.pt.table =1 ;write_pte (entry, pte);return 0 ;
xen/arch/arm/platforms/vexpress.c +1 -1
@@ -65,7 +65,7 @@ int vexpress_syscfg(int write, int function, int device, uint32_t *data)uint32_t *syscfg = (uint32_t *)FIXMAP_ADDR (FIXMAP_MISC );int ret =-1 ; -set_fixmap (FIXMAP_MISC ,maddr_to_mfn (V2M_SYS_MMIO_BASE ),MT_DEV_SHARED ); +set_fixmap (FIXMAP_MISC ,maddr_to_mfn (V2M_SYS_MMIO_BASE ), MT_DEVICE_nGnRE);if ( syscfg[V2M_SYS_CFGCTRL /4 ] &V2M_SYS_CFG_START ) goto out;
xen/drivers/video/arm_hdlcd.c +1 -1
@@ -227,7 +227,7 @@ void __init video_init(void)/* uses FIXMAP_MISC */ set_pixclock (videomode->pixclock); -set_fixmap (FIXMAP_MISC ,maddr_to_mfn (hdlcd_start),MT_DEV_SHARED ); +set_fixmap (FIXMAP_MISC ,maddr_to_mfn (hdlcd_start), MT_DEVICE_nGnRE);HDLCD [HDLCD_COMMAND ] =0 ;HDLCD [HDLCD_LINELENGTH ] = videomode->xres * bytes_per_pixel;
xen/include/asm-arm/page.h +19 -16
@@ -25,15 +25,18 @@* LPAE Memory region attributes. Indexed by the AttrIndex bits of a * LPAE entry; the 8-bit fields are packed little-endian into MAIR0 and MAIR1. * +* See section "Device memory" B2.7.2 in ARM DDI 0487B.a for more +* details about the meaning of *G*R*E. +* * ai encoding -* MT_UNCACHED 000 0000 0000 -- Strongly Ordered -* MT_BUFFERABLE 001 0100 0100 -- Non-Cacheable -* MT_WRITETHROUGH 010 1010 1010 -- Write-through -* MT_WRITEBACK 011 1110 1110 -- Write-back -* MT_DEV_SHARED 100 0000 0100 -- Device +* MT_DEVICE_nGnRnE 000 0000 0000 -- Strongly Ordered/Device nGnRnE +* MT_NORMAL_NC 001 0100 0100 -- Non-Cacheable +* MT_NORMAL_WT 010 1010 1010 -- Write-through +* MT_NORMAL_WB 011 1110 1110 -- Write-back +* MT_DEVICE_nGnRE 100 0000 0100 -- Device nGnRE * ?? 101 * reserved 110 -* MT_WRITEALLOC 111 1111 1111 -- Write-back write-allocate +* MT_NORMAL 111 1111 1111 -- Write-back write-allocate */ #define MAIR0VAL 0xeeaa4400#define MAIR1VAL 0xff000004
@@ -47,16 +50,16 @@* registers, as defined above. * */ -#define MT_UNCACHED 0x0 -#define MT_BUFFERABLE 0x1 -#define MT_WRITETHROUGH 0x2 -#define MT_WRITEBACK 0x3 -#define MT_DEV_SHARED 0x4 -#define MT_WRITEALLOC 0x7 - -#define PAGE_HYPERVISOR (MT_WRITEALLOC) -#define PAGE_HYPERVISOR_NOCACHE (MT_DEV_SHARED) -#define PAGE_HYPERVISOR_WC (MT_BUFFERABLE) +#define MT_DEVICE_nGnRnE 0x0 +#define MT_NORMAL_NC 0x1 +#define MT_NORMAL_WT 0x2 +#define MT_NORMAL_WB 0x3 +#define MT_DEVICE_nGnRE 0x4 +#define MT_NORMAL 0x7 + +#define PAGE_HYPERVISOR (MT_NORMAL) +#define PAGE_HYPERVISOR_NOCACHE (MT_DEVICE_nGnRE) +#define PAGE_HYPERVISOR_WC (MT_NORMAL_NC)/* * Defines for changing the hypervisor PTE .ro and .nx bits. This is only to be
Signature · 7 lines
2.11.0 _______________________________________________ Xen-devel mailing list [email protected] https://lists.xen.org/xen-devel
Re: [PATCH v4 01/10] xen/arm: page: Use ARMv8 naming to improve readability
Quoted 5 lines · Julien Grall
This is based on the Linux ARMv8 naming scheme (see
arch/arm64/mm/proc.S). Each type will contain "NORMAL" or "DEVICE" to make clear whether each attribute targets device or normal memory.Signed-off-by Julien Grall <[email protected]>
Quoted 238 lines
---
Changes in v3:
- The ai '000' is namedMT_DEVICE_nGnRnEand notMT_DEVICE_nGnRE. The definition is still valid.
- Expand the comment to point to "Device Memory" section in the ARM ARM.Changes in v2:
* Move the patch before "xen/arm: page: Clean-up the definition of MAIRVAL"--- xen/arch/arm/kernel.c | 2 +- xen/arch/arm/mm.c | 28 ++++++++++++++-------------- xen/arch/arm/platforms/vexpress.c | 2 +- xen/drivers/video/arm_hdlcd.c | 2 +- xen/include/asm-arm/page.h | 35 +++++++++++++++++++---------------- 5 files changed, 36 insertions(+), 33 deletions(-)xen/arch/arm/kernel.c +1
-1@@ -54,7 +54,7 @@ void copy_from_paddr(void *dst, paddr_t paddr, unsigned long len) s = paddr & (PAGE_SIZE -1 ); l =min (PAGE_SIZE - s, len); -set_fixmap (FIXMAP_MISC ,maddr_to_mfn (paddr),MT_BUFFERABLE ); +set_fixmap (FIXMAP_MISC ,maddr_to_mfn (paddr),MT_NORMAL_NC );memcpy (dst, src + s, l);clean_dcache_va_range (dst, l);xen/arch/arm/mm.c +14
-14@@ -290,7 +290,7 @@ static inline lpae_t mfn_to_xen_entry(mfn_t mfn, unsigned attr)switch ( attr ) { -case MT_BUFFERABLE : +case MT_NORMAL_NC :/* * ARM ARM: Overlaying the shareability attribute (DDI * 0406C.b B3-1376 to 1377) @@ -305,8 +305,8 @@ static inline lpae_t mfn_to_xen_entry(mfn_t mfn, unsigned attr)*/ e.pt.sh =LPAE_SH_OUTER ;break ; -case MT_UNCACHED : -case MT_DEV_SHARED : +case MT_DEVICE_nGnRnE: +case MT_DEVICE_nGnRE:/* * Shareability is ignored for non-Normal memory, Outer is as * good as anything. @@ -369,7 +369,7 @@ static void __init create_mappings(lpae_t *second, count = nr_mfns /LPAE_ENTRIES ; p = second +second_linear_offset (virt_offset); - pte =mfn_to_xen_entry (_mfn (base_mfn),MT_WRITEALLOC ); + pte =mfn_to_xen_entry (_mfn (base_mfn),MT_NORMAL );if ( granularity ==16 *LPAE_ENTRIES ) pte.pt.contig =1 ;/* These maps are in 16-entry contiguous chunks. */ for ( i =0 ; i < count; i++ )@@ -422,7 +422,7 @@ void *map_domain_page(mfn_t mfn)else if ( map[slot].pt.avail ==0 ) {/* Commandeer this 2MB slot */ - pte =mfn_to_xen_entry (_mfn (slot_mfn),MT_WRITEALLOC ); + pte =mfn_to_xen_entry (_mfn (slot_mfn),MT_NORMAL ); pte.pt.avail =1 ;write_pte (map + slot, pte);break ;@@ -543,7 +543,7 @@ static inline lpae_t pte_of_xenaddr(vaddr_t va) {paddr_t ma = va + phys_offset; -return mfn_to_xen_entry (maddr_to_mfn (ma),MT_WRITEALLOC ); +return mfn_to_xen_entry (maddr_to_mfn (ma),MT_NORMAL ); }/* Map the FDT in the early boot page table */ @@ -652,7 +652,7 @@ void __init setup_pagetables(unsigned long boot_phys_offset, paddr_t xen_paddr)/* Initialise xen second level entries ... */ /* ... Xen's text etc */ - pte =mfn_to_xen_entry (maddr_to_mfn (xen_paddr),MT_WRITEALLOC ); + pte =mfn_to_xen_entry (maddr_to_mfn (xen_paddr),MT_NORMAL ); pte.pt.xn =0 ;/* Contains our text mapping! */ xen_second[second_table_offset (XEN_VIRT_START )] = pte;@@ -669,7 +669,7 @@ void __init setup_pagetables(unsigned long boot_phys_offset, paddr_t xen_paddr)/* ... Boot Misc area for xen relocation */ dest_va =BOOT_RELOC_VIRT_START ; - pte =mfn_to_xen_entry (maddr_to_mfn (xen_paddr),MT_WRITEALLOC ); + pte =mfn_to_xen_entry (maddr_to_mfn (xen_paddr),MT_NORMAL );/* Map the destination in xen_second. */ xen_second[second_table_offset (dest_va)] = pte;/* Map the destination in boot_second. */ @@ -700,7 +700,7 @@ void __init setup_pagetables(unsigned long boot_phys_offset, paddr_t xen_paddr)unsigned long va =XEN_VIRT_START + (i <<PAGE_SHIFT );if ( !is_kernel (va) )break ; - pte =mfn_to_xen_entry (mfn,MT_WRITEALLOC ); + pte =mfn_to_xen_entry (mfn,MT_NORMAL ); pte.pt.table =1 ;/* 4k mappings always have this bit set */ if (is_kernel_text (va) ||is_kernel_inittext (va) ) {@@ -771,7 +771,7 @@ int init_secondary_pagetables(int cpu)for ( i =0 ; i <DOMHEAP_SECOND_PAGES ; i++ ) { pte =mfn_to_xen_entry (virt_to_mfn (domheap+i*LPAE_ENTRIES ), -MT_WRITEALLOC ); +MT_NORMAL ); pte.pt.table =1 ;write_pte (&first[first_table_offset (DOMHEAP_VIRT_START +i*FIRST_SIZE )], pte); }@@ -869,13 +869,13 @@ void __init setup_xenheap_mappings(unsigned long base_mfn,mfn_t first_mfn =alloc_boot_pages (1 ,1 );clear_page (mfn_to_virt (first_mfn)); - pte =mfn_to_xen_entry (first_mfn,MT_WRITEALLOC ); + pte =mfn_to_xen_entry (first_mfn,MT_NORMAL ); pte.pt.table =1 ;write_pte (p, pte); first =mfn_to_virt (first_mfn); } - pte =mfn_to_xen_entry (_mfn (mfn),MT_WRITEALLOC ); + pte =mfn_to_xen_entry (_mfn (mfn),MT_NORMAL );/* TODO: Set pte.pt.contig when appropriate. */ write_pte (&first[first_table_offset (vaddr)], pte);@@ -915,7 +915,7 @@ void __init setup_frametable_mappings(paddr_t ps, paddr_t pe)for ( i =0 ; i < nr_second; i++ ) {clear_page (mfn_to_virt (mfn_add (second_base, i))); - pte =mfn_to_xen_entry (mfn_add (second_base, i),MT_WRITEALLOC ); + pte =mfn_to_xen_entry (mfn_add (second_base, i),MT_NORMAL ); pte.pt.table =1 ;write_pte (&xen_first[first_table_offset (FRAMETABLE_VIRT_START )+i], pte); }@@ -969,7 +969,7 @@ static int create_xen_table(lpae_t *entry)if ( p ==NULL )return -ENOMEM ;clear_page (p); - pte =mfn_to_xen_entry (virt_to_mfn (p),MT_WRITEALLOC ); + pte =mfn_to_xen_entry (virt_to_mfn (p),MT_NORMAL ); pte.pt.table =1 ;write_pte (entry, pte);return 0 ;xen/arch/arm/platforms/vexpress.c +1
-1@@ -65,7 +65,7 @@ int vexpress_syscfg(int write, int function, int device, uint32_t *data)uint32_t *syscfg = (uint32_t *)FIXMAP_ADDR (FIXMAP_MISC );int ret =-1 ; -set_fixmap (FIXMAP_MISC ,maddr_to_mfn (V2M_SYS_MMIO_BASE ),MT_DEV_SHARED ); +set_fixmap (FIXMAP_MISC ,maddr_to_mfn (V2M_SYS_MMIO_BASE ), MT_DEVICE_nGnRE);if ( syscfg[V2M_SYS_CFGCTRL /4 ] &V2M_SYS_CFG_START ) goto out;xen/drivers/video/arm_hdlcd.c +1
-1@@ -227,7 +227,7 @@ void __init video_init(void)/* uses FIXMAP_MISC */ set_pixclock (videomode->pixclock); -set_fixmap (FIXMAP_MISC ,maddr_to_mfn (hdlcd_start),MT_DEV_SHARED ); +set_fixmap (FIXMAP_MISC ,maddr_to_mfn (hdlcd_start), MT_DEVICE_nGnRE);HDLCD [HDLCD_COMMAND ] =0 ;HDLCD [HDLCD_LINELENGTH ] = videomode->xres * bytes_per_pixel;xen/include/asm-arm/page.h +19
-16@@ -25,15 +25,18 @@* LPAE Memory region attributes. Indexed by the AttrIndex bits of a * LPAE entry; the 8-bit fields are packed little-endian into MAIR0 and MAIR1. * +* See section "Device memory" B2.7.2 in ARM DDI 0487B.a for more +* details about the meaning of *G*R*E. +* * ai encoding -* MT_UNCACHED 000 0000 0000 -- Strongly Ordered -* MT_BUFFERABLE 001 0100 0100 -- Non-Cacheable -* MT_WRITETHROUGH 010 1010 1010 -- Write-through -* MT_WRITEBACK 011 1110 1110 -- Write-back -* MT_DEV_SHARED 100 0000 0100 -- Device +* MT_DEVICE_nGnRnE 000 0000 0000 -- Strongly Ordered/Device nGnRnE +* MT_NORMAL_NC 001 0100 0100 -- Non-Cacheable +* MT_NORMAL_WT 010 1010 1010 -- Write-through +* MT_NORMAL_WB 011 1110 1110 -- Write-back +* MT_DEVICE_nGnRE 100 0000 0100 -- Device nGnRE * ?? 101 * reserved 110 -* MT_WRITEALLOC 111 1111 1111 -- Write-back write-allocate +* MT_NORMAL 111 1111 1111 -- Write-back write-allocate */ #define MAIR0VAL 0xeeaa4400#define MAIR1VAL 0xff000004@@ -47,16 +50,16 @@* registers, as defined above. * */ -#define MT_UNCACHED 0x0 -#define MT_BUFFERABLE 0x1 -#define MT_WRITETHROUGH 0x2 -#define MT_WRITEBACK 0x3 -#define MT_DEV_SHARED 0x4 -#define MT_WRITEALLOC 0x7 - -#define PAGE_HYPERVISOR (MT_WRITEALLOC) -#define PAGE_HYPERVISOR_NOCACHE (MT_DEV_SHARED) -#define PAGE_HYPERVISOR_WC (MT_BUFFERABLE) +#define MT_DEVICE_nGnRnE 0x0 +#define MT_NORMAL_NC 0x1 +#define MT_NORMAL_WT 0x2 +#define MT_NORMAL_WB 0x3 +#define MT_DEVICE_nGnRE 0x4 +#define MT_NORMAL 0x7 + +#define PAGE_HYPERVISOR (MT_NORMAL) +#define PAGE_HYPERVISOR_NOCACHE (MT_DEVICE_nGnRE) +#define PAGE_HYPERVISOR_WC (MT_NORMAL_NC)/* * Defines for changing the hypervisor PTE .ro and .nx bits. This is only to be Signature · 1 line
2.11.0
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
PATCH v4 2/10 xen/arm: page: Clean-up the definition of MAIRVAL
In reply to Julien GrallCurrently MAIRVAL is defined in term of MAIR0VAL and MAIR1VAL which are both hardcoded value. This makes quite difficult to understand the value written in both registers.
Rework the definition by using value of each attribute shifted by their associated index.
---
Changes in v3:
- s/above/below/ in the comment
- Add Stefano's reviewed-by
Changes in v2:
- Move this patch after "xen/arm: page: Use ARMv8 naming to improve readability"
--- xen/include/asm-arm/page.h | 42 +++++++++++++++++++++++++----------------- 1 file changed, 25 insertions(+), 17 deletions(-)
xen/include/asm-arm/page.h +25 -17
@@ -22,6 +22,21 @@#define LPAE_SH_INNER 0x3/* +* Attribute Indexes. +* +* These are valid in the AttrIndx[2:0] field of an LPAE stage 1 page +* table entry. They are indexes into the bytes of the MAIR* +* registers, as defined below. +* +*/ +#define MT_DEVICE_nGnRnE 0x0 +#define MT_NORMAL_NC 0x1 +#define MT_NORMAL_WT 0x2 +#define MT_NORMAL_WB 0x3 +#define MT_DEVICE_nGnRE 0x4 +#define MT_NORMAL 0x7 + +/* * LPAE Memory region attributes. Indexed by the AttrIndex bits of a * LPAE entry; the 8-bit fields are packed little-endian into MAIR0 and MAIR1. *
@@ -38,24 +53,17 @@* reserved 110 * MT_NORMAL 111 1111 1111 -- Write-back write-allocate */ -#define MAIR0VAL 0xeeaa4400 -#define MAIR1VAL 0xff000004 -#define MAIRVAL (MAIR0VAL|MAIR1VAL<<32) +#define MAIR (attr, mt) (_AC(attr, ULL) << ((mt) * 8)) -/* -* Attribute Indexes. -* -* These are valid in the AttrIndx[2:0] field of an LPAE stage 1 page -* table entry. They are indexes into the bytes of the MAIR* -* registers, as defined above. -* -*/ -#define MT_DEVICE_nGnRnE 0x0 -#define MT_NORMAL_NC 0x1 -#define MT_NORMAL_WT 0x2 -#define MT_NORMAL_WB 0x3 -#define MT_DEVICE_nGnRE 0x4 -#define MT_NORMAL 0x7 +#define MAIRVAL (MAIR(0x00, MT_DEVICE_nGnRnE)| \ + MAIR(0x44, MT_NORMAL_NC) | \ + MAIR(0xaa, MT_NORMAL_WT) | \ + MAIR(0xee, MT_NORMAL_WB) | \ + MAIR(0x04, MT_DEVICE_nGnRE) | \ + MAIR(0xff, MT_NORMAL)) + +#define MAIR0VAL (MAIRVAL & 0xffffffff) +#define MAIR1VAL (MAIRVAL >> 32)#define PAGE_HYPERVISOR (MT_NORMAL)#define PAGE_HYPERVISOR_NOCACHE (MT_DEVICE_nGnRE)
Signature · 7 lines
2.11.0 _______________________________________________ Xen-devel mailing list [email protected] https://lists.xen.org/xen-devel
PATCH v4 3/10 xen/arm: mm: Rename and clarify AP[1] in the stage-1 page table
In reply to Julien GrallThe description of AP[1] in Xen is based on testing rather than the ARM ARM.
Per the ARM ARM, on EL2 stage-1 page table, AP[1] is RES1 as the translation regime applies to only one exception level (see D4.4.4 and G4.6.1 in ARM DDI 0487B.a).
Update the comment and also rename the field to match the description in the ARM ARM.
---
Changes in v3:
- Add Stefano's acked-by
Changes in v2:
- Add Andre's reviewed-by
--- xen/arch/arm/mm.c | 10 +++++----- xen/include/asm-arm/lpae.h | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-)
xen/arch/arm/mm.c +5 -5
@@ -273,7 +273,7 @@ static inline lpae_t mfn_to_xen_entry(mfn_t mfn, unsigned attr) .table = 0, /* Set to 1 for links and 4k maps */ .ai = attr, .ns = 1, /* Hyp mode is in the non-secure world */ - .user = 1, /* See below */ + .up = 1, /* See below */ .ro = 0, /* Assume read-write */ .af = 1, /* No need for access tracking */ .ng = 1, /* Makes TLB flushes easier */
@@ -282,10 +282,10 @@ static inline lpae_t mfn_to_xen_entry(mfn_t mfn, unsigned attr) .avail = 0, /* Reference count for domheap mapping */ }};/* -* Setting the User bit is strange, but the ATS1H[RW] instructions -* don't seem to work otherwise, and since we never run on Xen -* pagetables in User mode it's OK. If this changes, remember -* to update the hard-coded values in head.S too. +* For EL2 stage-1 page table, up (aka AP[1]) is RES1 as the translation +* regime applies to only one exception level (see D4.4.4 and G4.6.1 +* in ARM DDI 0487B.a). If this changes, remember to update the +* hard-coded values in head.S too. */ switch ( attr )
xen/include/asm-arm/lpae.h +1 -1
@@ -35,7 +35,7 @@ typedef struct __packed {*/ unsigned long ai:3; /* Attribute Index */ unsigned long ns:1; /* Not-Secure */ - unsigned long user:1; /* User-visible */ + unsigned long up:1; /* Unpriviledged access */ unsigned long ro:1; /* Read-Only */ unsigned long sh:2; /* Shareability */ unsigned long af:1; /* Access Flag */
Signature · 7 lines
2.11.0 _______________________________________________ Xen-devel mailing list [email protected] https://lists.xen.org/xen-devel
PATCH v4 4/10 xen/arm: Switch to SYS_STATE_boot just after end_boot_allocator()
In reply to Julien GrallWe should consider the early boot period to end when we stop using the boot allocator. This is inline with x86 and will be helpful to know whether we should allocate memory from the boot allocator or xenheap.
---
Changes in v3:
- Add Stefano's reviewed-by
Changes in v2:
- Add Andre's reviewed-by
--- xen/arch/arm/setup.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-)
xen/arch/arm/setup.c +6 -2
@@ -757,6 +757,12 @@ void __init start_xen(unsigned long boot_phys_offset,end_boot_allocator (); +/* +* The memory subsystem has been initialized, we can now switch from +* early_boot -> boot. +*/ + system_state = SYS_STATE_boot; +vm_init ();if ( acpi_disabled )
@@ -779,8 +785,6 @@ void __init start_xen(unsigned long boot_phys_offset,console_init_preirq ();console_init_ring (); - system_state = SYS_STATE_boot; -processor_id ();smp_init_cpus ();
Signature · 7 lines
2.11.0 _______________________________________________ Xen-devel mailing list [email protected] https://lists.xen.org/xen-devel
PATCH v4 5/10 xen/arm: mm: Rename 'ai' into 'flags' in create_xen_entries
In reply to Julien GrallThe parameter 'ai' is used either for attribute index or for permissions. Follow-up patch will rework that parameters to carry more information. So rename the parameter to 'flags'.
---
Changes in v3:
- Add Stefano's reviewed-by
Changes in v2:
- Add Andre's reviewed-by
--- xen/arch/arm/mm.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
xen/arch/arm/mm.c +4 -4
@@ -986,7 +986,7 @@ static int create_xen_entries(enum xenmap_operation op,unsigned long virt, mfn_t mfn, unsigned long nr_mfns, - unsigned int ai) + unsigned int flags) { int rc;unsigned long addr = virt, addr_end = addr + nr_mfns *PAGE_SIZE ;
@@ -1021,7 +1021,7 @@ static int create_xen_entries(enum xenmap_operation op, }if ( op ==RESERVE )break ; - pte =mfn_to_xen_entry (mfn, ai); + pte =mfn_to_xen_entry (mfn, flags); pte.pt.table =1 ;write_pte (entry, pte);break ;
@@ -1038,8 +1038,8 @@ static int create_xen_entries(enum xenmap_operation op,else { pte = *entry; - pte.pt.ro =PTE_RO_MASK (ai); - pte.pt.xn =PTE_NX_MASK (ai); + pte.pt.ro =PTE_RO_MASK (flags); + pte.pt.xn =PTE_NX_MASK (flags);if ( !pte.pt.ro && !pte.pt.xn ) { printk("%s: Incorrect combination for addr=%lx\n",
Signature · 7 lines
2.11.0 _______________________________________________ Xen-devel mailing list [email protected] https://lists.xen.org/xen-devel
PATCH v4 6/10 xen/arm: mm: Use PAGE_HYPERVISOR_* instead of MT_* when calling set_fixmap
In reply to Julien GrallAt the moment, PAGE_HYPERVISOR_* and MT_* have exactly the same value. In a follow-up patch the former will be extended to carry more information.
It looks like the caller of set_fixmap are mixing the both. Stay consistent and only use PAGE_HYPERVISOR_*. This is also match the behavior of create_xen_entries and would potentially allow to share some part in the future.
Also rename the parameter 'attributes' to 'flags' so it is clearer what is the interface.
---
Changes in v4:
- Patch added.
--- xen/arch/arm/kernel.c | 2 +- xen/arch/arm/mm.c | 4 ++-- xen/arch/arm/platforms/vexpress.c | 3 ++- xen/drivers/video/arm_hdlcd.c | 2 +- 4 files changed, 6 insertions(+), 5 deletions(-)
xen/arch/arm/kernel.c +1 -1
@@ -54,7 +54,7 @@ void copy_from_paddr(void *dst, paddr_t paddr, unsigned long len) s = paddr & (PAGE_SIZE -1 ); l =min (PAGE_SIZE - s, len); -set_fixmap (FIXMAP_MISC ,maddr_to_mfn (paddr),MT_NORMAL_NC ); +set_fixmap (FIXMAP_MISC ,maddr_to_mfn (paddr),PAGE_HYPERVISOR_WC );memcpy (dst, src + s, l);clean_dcache_va_range (dst, l);
xen/arch/arm/mm.c +2 -2
@@ -329,9 +329,9 @@ static inline lpae_t mfn_to_xen_entry(mfn_t mfn, unsigned attr) }/* Map a 4k page in a fixmap entry */ -void set_fixmap (unsigned map,mfn_t mfn,unsigned attributes) +void set_fixmap (unsigned map,mfn_t mfn,unsigned int flags) { -lpae_t pte =mfn_to_xen_entry (mfn, attributes); +lpae_t pte =mfn_to_xen_entry (mfn, flags); pte.pt.table =1 ;/* 4k mappings always have this bit set */ pte.pt.xn =1 ;write_pte (xen_fixmap +third_table_offset (FIXMAP_ADDR (map)), pte);
xen/arch/arm/platforms/vexpress.c +2 -1
@@ -65,7 +65,8 @@ int vexpress_syscfg(int write, int function, int device, uint32_t *data)uint32_t *syscfg = (uint32_t *)FIXMAP_ADDR (FIXMAP_MISC );int ret =-1 ; -set_fixmap (FIXMAP_MISC ,maddr_to_mfn (V2M_SYS_MMIO_BASE ), MT_DEVICE_nGnRE); +set_fixmap (FIXMAP_MISC ,maddr_to_mfn (V2M_SYS_MMIO_BASE ), +PAGE_HYPERVISOR_NOCACHE );if ( syscfg[V2M_SYS_CFGCTRL /4 ] &V2M_SYS_CFG_START ) goto out;
xen/drivers/video/arm_hdlcd.c +1 -1
@@ -227,7 +227,7 @@ void __init video_init(void)/* uses FIXMAP_MISC */ set_pixclock (videomode->pixclock); -set_fixmap (FIXMAP_MISC ,maddr_to_mfn (hdlcd_start), MT_DEVICE_nGnRE); +set_fixmap (FIXMAP_MISC ,maddr_to_mfn (hdlcd_start),PAGE_HYPERVISOR_NOCACHE );HDLCD [HDLCD_COMMAND ] =0 ;HDLCD [HDLCD_LINELENGTH ] = videomode->xres * bytes_per_pixel;
Signature · 7 lines
2.11.0 _______________________________________________ Xen-devel mailing list [email protected] https://lists.xen.org/xen-devel
Re: [PATCH v4 06/10] xen/arm: mm: Use PAGE_HYPERVISOR_* instead of MT_* when calling set_fixmap
Quoted 9 lines · Julien Grall
At the moment, PAGE_HYPERVISOR_* and MT_* have exactly the same value. In a follow-up patch the former will be extended to carry more information.
It looks like the caller of
set_fixmapare mixing the both. Stay consistent and only use PAGE_HYPERVISOR_*. This is also match the behavior ofcreate_xen_entriesand would potentially allow to share some part in the future.
Quoted 4 lines
Also rename the parameter 'attributes' to 'flags' so it is clearer what is the interface.
Signed-off-by Julien Grall <[email protected]>
Quoted 69 lines
---
Changes in v4:
- Patch added.--- xen/arch/arm/kernel.c | 2 +- xen/arch/arm/mm.c | 4 ++-- xen/arch/arm/platforms/vexpress.c | 3 ++- xen/drivers/video/arm_hdlcd.c | 2 +- 4 files changed, 6 insertions(+), 5 deletions(-)xen/arch/arm/kernel.c +1
-1@@ -54,7 +54,7 @@ void copy_from_paddr(void *dst, paddr_t paddr, unsigned long len) s = paddr & (PAGE_SIZE -1 ); l =min (PAGE_SIZE - s, len); -set_fixmap (FIXMAP_MISC ,maddr_to_mfn (paddr),MT_NORMAL_NC ); +set_fixmap (FIXMAP_MISC ,maddr_to_mfn (paddr),PAGE_HYPERVISOR_WC );memcpy (dst, src + s, l);clean_dcache_va_range (dst, l);xen/arch/arm/mm.c +2
-2@@ -329,9 +329,9 @@ static inline lpae_t mfn_to_xen_entry(mfn_t mfn, unsigned attr) }/* Map a 4k page in a fixmap entry */ -void set_fixmap (unsigned map,mfn_t mfn,unsigned attributes) +void set_fixmap (unsigned map,mfn_t mfn,unsigned int flags) { -lpae_t pte =mfn_to_xen_entry (mfn, attributes); +lpae_t pte =mfn_to_xen_entry (mfn, flags); pte.pt.table =1 ;/* 4k mappings always have this bit set */ pte.pt.xn =1 ;write_pte (xen_fixmap +third_table_offset (FIXMAP_ADDR (map)), pte);xen/arch/arm/platforms/vexpress.c +2
-1@@ -65,7 +65,8 @@ int vexpress_syscfg(int write, int function, int device, uint32_t *data)uint32_t *syscfg = (uint32_t *)FIXMAP_ADDR (FIXMAP_MISC );int ret =-1 ; -set_fixmap (FIXMAP_MISC ,maddr_to_mfn (V2M_SYS_MMIO_BASE ), MT_DEVICE_nGnRE); +set_fixmap (FIXMAP_MISC ,maddr_to_mfn (V2M_SYS_MMIO_BASE ), +PAGE_HYPERVISOR_NOCACHE );if ( syscfg[V2M_SYS_CFGCTRL /4 ] &V2M_SYS_CFG_START ) goto out;xen/drivers/video/arm_hdlcd.c +1
-1@@ -227,7 +227,7 @@ void __init video_init(void)/* uses FIXMAP_MISC */ set_pixclock (videomode->pixclock); -set_fixmap (FIXMAP_MISC ,maddr_to_mfn (hdlcd_start), MT_DEVICE_nGnRE); +set_fixmap (FIXMAP_MISC ,maddr_to_mfn (hdlcd_start),PAGE_HYPERVISOR_NOCACHE );HDLCD [HDLCD_COMMAND ] =0 ;HDLCD [HDLCD_LINELENGTH ] = videomode->xres * bytes_per_pixel;Signature · 1 line
2.11.0
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
PATCH v4 7/10 xen/arm: page: Describe the layout of flags used to update page tables
In reply to Julien GrallCurrently, the flags used to update page tables (i.e PAGE_HYPERVISOR_*) only contains the memory attribute index. Follow-up patches will add more information in it. So document the current layout.
At the same time introduce PAGE_AI_MASK to get the memory attribute index easily.
---
Changes in v4:
- Use PAGE_AI_MASK in set_fixmap
Changes in v3:
- Add Stefano's reviewed-by
Changes in v2:
- Slightly update the commit message to specify we describe the current layout.
- Add Andre's reviewed-by
--- xen/arch/arm/mm.c | 4 ++-- xen/include/asm-arm/page.h | 7 +++++++ 2 files changed, 9 insertions(+), 2 deletions(-)
xen/arch/arm/mm.c +2 -2
@@ -331,7 +331,7 @@ static inline lpae_t mfn_to_xen_entry(mfn_t mfn, unsigned attr)/* Map a 4k page in a fixmap entry */ void set_fixmap (unsigned map,mfn_t mfn,unsigned int flags) { -lpae_t pte =mfn_to_xen_entry (mfn, flags); +lpae_t pte =mfn_to_xen_entry (mfn,PAGE_AI_MASK (flags)); pte.pt.table =1 ;/* 4k mappings always have this bit set */ pte.pt.xn =1 ;write_pte (xen_fixmap +third_table_offset (FIXMAP_ADDR (map)), pte);
@@ -1021,7 +1021,7 @@ static int create_xen_entries(enum xenmap_operation op, }if ( op ==RESERVE )break ; - pte =mfn_to_xen_entry (mfn, flags); + pte =mfn_to_xen_entry (mfn,PAGE_AI_MASK (flags)); pte.pt.table =1 ;write_pte (entry, pte);break ;
xen/include/asm-arm/page.h +7 -0
@@ -65,6 +65,13 @@#define MAIR0VAL (MAIRVAL & 0xffffffff)#define MAIR1VAL (MAIRVAL >> 32) +/* +* Layout of the flags used for updating the hypervisor page tables +* +* [0:2] Memory Attribute Index +*/ +#define PAGE_AI_MASK (x) ((x) & 0x7U) +#define PAGE_HYPERVISOR (MT_NORMAL)#define PAGE_HYPERVISOR_NOCACHE (MT_DEVICE_nGnRE)#define PAGE_HYPERVISOR_WC (MT_NORMAL_NC)
Signature · 7 lines
2.11.0 _______________________________________________ Xen-devel mailing list [email protected] https://lists.xen.org/xen-devel
PATCH v4 8/10 xen/arm: mm: Embed permission in the flags
In reply to Julien GrallCurrently, it is not possible to specify the permission of a new mapping. It would be necessary to use the function modify_xen_mappings with a different set of flags.
Introduce a couple of new flags for the permissions (Non-eXecutable, Read-Only) and also provides definition that combine the memory attribute and permission for common combinations.
PAGE_HYPERVISOR is now an alias to PAGE_HYPERVISOR_RW (read-write, non-executable mappings). This does not affect the current mapping using PAGE_HYPERVISOR because Xen is currently forcing all the mapping to be non-executable by default (see mfn_to_xen_entry).
A follow-up patch will change modify_xen_mappings to use the new flags.
---
Changes in v3:
- Add a comment about _PAGE_DEVICE and _PAGE_NORMAL
Changes in v2:
- Update the commit message
--- xen/include/asm-arm/page.h | 25 ++++++++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-)
xen/include/asm-arm/page.h +22 -3
@@ -69,12 +69,31 @@* Layout of the flags used for updating the hypervisor page tables * * [0:2] Memory Attribute Index +* [3:4] Permission flags */ #define PAGE_AI_MASK (x) ((x) & 0x7U) -#define PAGE_HYPERVISOR (MT_NORMAL) -#define PAGE_HYPERVISOR_NOCACHE (MT_DEVICE_nGnRE) -#define PAGE_HYPERVISOR_WC (MT_NORMAL_NC) +#define _PAGE_XN_BIT 3 +#define _PAGE_RO_BIT 4 +#define _PAGE_XN (1U << _PAGE_XN_BIT) +#define _PAGE_RO (1U << _PAGE_RO_BIT) +#define PAGE_XN_MASK (x) (((x) >> _PAGE_XN_BIT) & 0x1U) +#define PAGE_RO_MASK (x) (((x) >> _PAGE_RO_BIT) & 0x1U) + +/* +* _PAGE_DEVICE and _PAGE_NORMAL are conveniences defines. They are not +* meant to be used outside of the headers. +*/ +#define _PAGE_DEVICE _PAGE_XN +#define _PAGE_NORMAL MT_NORMAL + +#define PAGE_HYPERVISOR_RO (_PAGE_NORMAL|_PAGE_RO|_PAGE_XN) +#define PAGE_HYPERVISOR_RX (_PAGE_NORMAL|_PAGE_RO) +#define PAGE_HYPERVISOR_RW (_PAGE_NORMAL|_PAGE_XN) + +#define PAGE_HYPERVISOR PAGE_HYPERVISOR_RW +#define PAGE_HYPERVISOR_NOCACHE (_PAGE_DEVICE|MT_DEVICE_nGnRE) +#define PAGE_HYPERVISOR_WC (_PAGE_DEVICE|MT_NORMAL_NC)/* * Defines for changing the hypervisor PTE .ro and .nx bits. This is only to be
Signature · 7 lines
2.11.0 _______________________________________________ Xen-devel mailing list [email protected] https://lists.xen.org/xen-devel
Re: [PATCH v4 08/10] xen/arm: mm: Embed permission in the flags
Quoted 43 lines · Julien Grall
Currently, it is not possible to specify the permission of a new mapping. It would be necessary to use the function
modify_xen_mappingswith a different set of flags.Introduce a couple of new flags for the permissions (Non-eXecutable, Read-Only) and also provides definition that combine the memory attribute and permission for common combinations.
PAGE_HYPERVISORis now an alias toPAGE_HYPERVISOR_RW(read-write, non-executable mappings). This does not affect the current mapping usingPAGE_HYPERVISORbecause Xen is currently forcing all the mapping to be non-executable by default (seemfn_to_xen_entry).A follow-up patch will change
modify_xen_mappingsto use the new flags.Signed-off-by Julien Grall <[email protected]>---
Changes in v3:
- Add a comment about_PAGE_DEVICEand_PAGE_NORMALChanges in v2:
- Update the commit message--- xen/include/asm-arm/page.h | 25 ++++++++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-)xen/include/asm-arm/page.h +1
-3@@ -69,12 +69,31 @@* Layout of the flags used for updating the hypervisor page tables * * [0:2] Memory Attribute Index +* [3:4] Permission flags */ #define PAGE_AI_MASK (x) ((x) & 0x7U) -#define PAGE_HYPERVISOR (MT_NORMAL) -#define PAGE_HYPERVISOR_NOCACHE (MT_DEVICE_nGnRE) -#define PAGE_HYPERVISOR_WC (MT_NORMAL_NC)
xen/include/asm-arm/page.h line 85
Quoted 10 lines
xen/include/asm-arm/page.h +10
-0+#define _PAGE_XN_BIT 3 +#define _PAGE_RO_BIT 4 +#define _PAGE_XN (1U << _PAGE_XN_BIT) +#define _PAGE_RO (1U << _PAGE_RO_BIT) +#define PAGE_XN_MASK (x) (((x) >> _PAGE_XN_BIT) & 0x1U) +#define PAGE_RO_MASK (x) (((x) >> _PAGE_RO_BIT) & 0x1U) + +/* +* _PAGE_DEVICE and _PAGE_NORMAL are conveniences defines. They are not +* meant to be used outside of the headers.
just grammar NITs:
_PAGE_DEVICE and _PAGE_NORMAL are convenience defines. They are not meant to be used outside of this header.
I'll fix on commit
Quoted 17 lines
xen/include/asm-arm/page.h +11
-0+*/ +#define _PAGE_DEVICE _PAGE_XN +#define _PAGE_NORMAL MT_NORMAL + +#define PAGE_HYPERVISOR_RO (_PAGE_NORMAL|_PAGE_RO|_PAGE_XN) +#define PAGE_HYPERVISOR_RX (_PAGE_NORMAL|_PAGE_RO) +#define PAGE_HYPERVISOR_RW (_PAGE_NORMAL|_PAGE_XN) + +#define PAGE_HYPERVISOR PAGE_HYPERVISOR_RW +#define PAGE_HYPERVISOR_NOCACHE (_PAGE_DEVICE|MT_DEVICE_nGnRE) +#define PAGE_HYPERVISOR_WC (_PAGE_DEVICE|MT_NORMAL_NC)/* * Defines for changing the hypervisor PTE .ro and .nx bits. This is only to be Signature · 1 line
2.11.0
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
PATCH v4 9/10 xen/arm: mm: Handle permission flags when adding a new mapping
In reply to Julien GrallCurrently, all the new mappings will be read-write non-executable. Allow the caller to use other permissions.
---
Changes in v2:
- Switch the runtime check to a BUG_ON()
--- xen/arch/arm/mm.c | 3 +++ 1 file changed, 3 insertions(+)
xen/arch/arm/mm.c +3 -0
@@ -1022,6 +1022,9 @@ static int create_xen_entries(enum xenmap_operation op,if ( op ==RESERVE )break ; pte =mfn_to_xen_entry (mfn,PAGE_AI_MASK (flags)); + pte.pt.ro =PAGE_RO_MASK (flags); + pte.pt.xn =PAGE_XN_MASK (flags); +BUG_ON (!pte.pt.ro && !pte.pt.xn); pte.pt.table =1 ;write_pte (entry, pte);break ;
Signature · 7 lines
2.11.0 _______________________________________________ Xen-devel mailing list [email protected] https://lists.xen.org/xen-devel
Re: [PATCH v4 09/10] xen/arm: mm: Handle permission flags when adding a new mapping
Quoted 4 lines · Julien Grall
Currently, all the new mappings will be read-write non-executable. Allow the caller to use other permissions.
Signed-off-by Julien Grall <[email protected]>
Quoted 24 lines
---
Changes in v2:
- Switch the runtime check to aBUG_ON()--- xen/arch/arm/mm.c | 3 +++ 1 file changed, 3 insertions(+)xen/arch/arm/mm.c +3
-0@@ -1022,6 +1022,9 @@ static int create_xen_entries(enum xenmap_operation op,if ( op ==RESERVE )break ; pte =mfn_to_xen_entry (mfn,PAGE_AI_MASK (flags)); + pte.pt.ro =PAGE_RO_MASK (flags); + pte.pt.xn =PAGE_XN_MASK (flags); +BUG_ON (!pte.pt.ro && !pte.pt.xn); pte.pt.table =1 ;write_pte (entry, pte);break ;Signature · 1 line
2.11.0
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
PATCH v4 10/10 xen/arm: mm: Use memory flags for modify_xen_mappings rather than custom one
In reply to Julien GrallThis will help to consolidate the page-table code and avoid different path depending on the action to perform.
---
arch_livepatch_secure is now the same as on x86. It might be possible to combine both, but I left that alone for now.
Changes in v4:
- Add Konrad's reviewed-by
Changes in v3:
- Add Stefano's reviewed-by
Changes in v2:
- Add Andre's reviewed-by
--- xen/arch/arm/livepatch.c | 6 +++--- xen/arch/arm/mm.c | 5 ++--- xen/include/asm-arm/page.h | 11 ----------- 3 files changed, 5 insertions(+), 17 deletions(-)
xen/arch/arm/livepatch.c +3 -3
@@ -146,15 +146,15 @@ int arch_livepatch_secure(const void *va, unsigned int pages, enum va_type type)switch ( type ) {case LIVEPATCH_VA_RX : - flags =PTE_RO ;/* R set, NX clear */ + flags =PAGE_HYPERVISOR_RX ;break ;case LIVEPATCH_VA_RW : - flags =PTE_NX ;/* R clear, NX set */ + flags =PAGE_HYPERVISOR_RW ;break ;case LIVEPATCH_VA_RO : - flags =PTE_NX |PTE_RO ;/* R set, NX set */ + flags =PAGE_HYPERVISOR_RO ;break ;default :
xen/arch/arm/mm.c +2 -3
@@ -1041,8 +1041,8 @@ static int create_xen_entries(enum xenmap_operation op,else { pte = *entry; - pte.pt.ro =PTE_RO_MASK (flags); - pte.pt.xn =PTE_NX_MASK (flags); + pte.pt.ro =PAGE_RO_MASK (flags); + pte.pt.xn =PAGE_XN_MASK (flags);if ( !pte.pt.ro && !pte.pt.xn ) { printk("%s: Incorrect combination for addr=%lx\n",
@@ -1085,7 +1085,6 @@ int destroy_xen_mappings(unsigned long v, unsigned long e)int modify_xen_mappings (unsigned long s,unsigned long e,unsigned int flags) { -ASSERT ((flags & (PTE_NX |PTE_RO )) == flags);return create_xen_entries (MODIFY , s,INVALID_MFN , (e - s) >>PAGE_SHIFT , flags); }
xen/include/asm-arm/page.h +0 -11
@@ -96,17 +96,6 @@#define PAGE_HYPERVISOR_WC (_PAGE_DEVICE|MT_NORMAL_NC)/* -* Defines for changing the hypervisor PTE .ro and .nx bits. This is only to be -* used with modify_xen_mappings. -*/ -#define _PTE_NX_BIT 0U -#define _PTE_RO_BIT 1U -#define PTE_NX (1U << _PTE_NX_BIT) -#define PTE_RO (1U << _PTE_RO_BIT) -#define PTE_NX_MASK (x) (((x) >> _PTE_NX_BIT) & 0x1U) -#define PTE_RO_MASK (x) (((x) >> _PTE_RO_BIT) & 0x1U) - -/* * Stage 2 Memory Type. * * These are valid in the MemAttr[3:0] field of an LPAE stage 2 page
Signature · 7 lines
2.11.0 _______________________________________________ Xen-devel mailing list [email protected] https://lists.xen.org/xen-devel
Quoted 6 lines · Julien Grall
Hi all,
This patch series contains clean-up for the ARM memory subsystem in preparation of reworking the page tables handling.
For all changes, see in each patch.
The series is committed, thanks!
Quoted 16 lines
Cheers,
Julien Grall (10):
xen/arm: page: Use ARMv8 naming to improve readability xen/arm: page: Clean-up the definition of MAIRVAL
xen/arm: mm: Rename and clarify AP[1] in the stage-1 page table xen/arm: Switch toSYS_STATE_bootjust afterend_boot_allocator()xen/arm: mm: Rename 'ai' into 'flags' increate_xen_entriesxen/arm: mm: Use PAGE_HYPERVISOR_* instead of MT_* when calling
set_fixmap
xen/arm: page: Describe the layout of flags used to update page tables xen/arm: mm: Embed permission in the flags
xen/arm: mm: Handle permission flags when adding a new mapping xen/arm: mm: Use memory flags formodify_xen_mappingsrather than
custom one
Quoted 13 lines
xen/arch/arm/kernel.c | 2 +- xen/arch/arm/livepatch.c | 6 +-- xen/arch/arm/mm.c | 54 ++++++++++++------------ xen/arch/arm/platforms/vexpress.c | 3 +- xen/arch/arm/setup.c | 8 +++- xen/drivers/video/arm_hdlcd.c | 2 +- xen/include/asm-arm/lpae.h | 2 +- xen/include/asm-arm/page.h | 88 +++++++++++++++++++++++++-------------- 8 files changed, 99 insertions(+), 66 deletions(-)Signature · 1 line
2.11.0
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel