xen: arm: map normal memory as inner shareable, reduce scope of various barriers
cover xen: arm: map normal memory as inner shareable, reduce scope of various barriers
Currently Xen maps all RAM as Outer-Shareable, since that seemed like the most conservative option early on when we didn't really know what Inner- vs. Outer-Shareable meant. However we have long suspected that actually Inner-Shareable would be the correct type to use.
After reading the docs many times, getting more confused each time, I finally got a reasonable explanation from a man (and a dog) down the
pub: Inner-Shareable == the processors in an SMP system, while Outer-Shareable == devices. (NB: Not a random man, he knew what he was talking about...). With that in mind switch all of Xen's memory mapping, page table walks, TLB flushes and an appropriate subset of the barriers to be inner shareable.
In addition I have switched barriers to use the correct read/write/any variants for their types. Note that I have only tackled the generic mb/rmb/wmb and smp_* barriers (mainly used by common code) here. There are also quite a few open-coded full-system dsb's in the arch code which I will look at separately (10 patches is quite enough for now). Since those deal with e.g. pagetable updates they will be fun ;-)
I have tested this series on Cortex A15 and AEMv8 fast models in both cases with 2 CPUs and I can start a guest in both cases. I have not tested on any real hardware at all.
These changes should result in a performance improvement, although only having models to go on I haven't actually bothered to measure.
I would appreciate anyone with access to real hardware giving it a go. I have pushed the patches to:
git://xenbits.xen.org/people/ianc/xen.git inner-shareable-v1
Ian Campbell (10):
xen: arm: map memory as inner shareable.
xen: arm: Only upgrade guest barriers to inner shareable.
xen: arm: reduce instruction cache and tlb flushes to inner-shareable.
xen: arm: consolidate barrier definitions
xen: use SMP barrier in common code dealing with shared memory protocols
xen: arm: Use SMP barriers when that is all which is required.
xen: arm: Use dmb for smp barriers
xen: arm: add scope to dsb and dmb macros
xen: arm: weaken SMP barriers to inner shareable.
xen: arm: use more specific barriers for read and write barriers.
xen/arch/arm/arm32/head.S | 8 +++--- xen/arch/arm/arm64/head.S | 8 +++--- xen/arch/arm/domain.c | 2 +- xen/arch/arm/gic.c | 8 +++--- xen/arch/arm/mm.c | 28 ++++++++++------------ xen/arch/arm/platforms/vexpress.c | 6 ++-- xen/arch/arm/smpboot.c | 6 ++-- xen/arch/arm/time.c | 2 +- xen/arch/arm/traps.c | 2 +- xen/common/domain.c | 2 +- xen/common/domctl.c | 2 +- xen/common/grant_table.c | 4 +- xen/common/page_alloc.c | 2 +- xen/common/smp.c | 4 +- xen/common/spinlock.c | 6 ++-- xen/common/tmem_xen.c | 10 ++++---- xen/common/trace.c | 8 +++--- xen/drivers/char/console.c | 2 +- xen/drivers/video/arm_hdlcd.c | 2 +- xen/include/asm-arm/arm32/flushtlb.h | 12 +++++----- xen/include/asm-arm/arm32/io.h | 4 +- xen/include/asm-arm/arm32/page.h | 12 +++++----- xen/include/asm-arm/arm32/system.h | 16 ------------- xen/include/asm-arm/arm64/flushtlb.h | 4 +- xen/include/asm-arm/arm64/io.h | 4 +- xen/include/asm-arm/arm64/page.h | 10 ++++---- xen/include/asm-arm/arm64/system.h | 17 ------------- xen/include/asm-arm/page.h | 42 +++++++++++++++++++++++++++++----- xen/include/asm-arm/system.h | 21 +++++++++++++++++ xen/include/xen/event.h | 4 +- xen/xsm/flask/ss/sidtab.c | 4 +- 31 files changed, 139 insertions(+), 123 deletions(-)
Ian.
PATCH 1/10 xen: arm: map memory as inner shareable.
The inner shareable domain contains all SMP processors, including different clusters (e.g. big.LITTLE). Therefore this is the correct thing to use for Xen memory mappings. The outer shareable domain is for devices on busses which are barriers (e.g. AMBA4). While the system domain is for things behind bridges which do not.
One wrinkle is that Normal memory with attributes Inner Non-cacheable, Outer Non-cacheable (which we call BUFFERABLE) must be mapped Outer Shareable on ARM v7. Therefore change the prototype of mfn_to_xen_entry to take the attribute index so we can DTRT. On ARMv8 the sharability is ignored and considered to always be Outer Shareable.
While I'm here change all the dmb/dsb with an implicit sy to an explicit sy, to make future changes simpler. Other than that don't adjust the barriers, flushes etc, those remain as they were (which is more than is now required). I'll change those in a later patch.
Many thanks to Leif for explaining the difference between Inner- and Outer-Shareable in words of two or less syllables, I hope I've replicated that explanation properly above!
--- xen/arch/arm/arm32/head.S | 8 +++--- xen/arch/arm/arm64/head.S | 8 +++--- xen/arch/arm/mm.c | 24 ++++++++++------------ xen/include/asm-arm/arm32/system.h | 4 +- xen/include/asm-arm/page.h | 38 ++++++++++++++++++++++++++++++++--- 5 files changed, 55 insertions(+), 27 deletions(-)
xen/arch/arm/arm32/head.S +4 -4
@@ -24,8 +24,8 @@ #define ZIMAGE_MAGIC_NUMBER 0x016f2818 -#define PT_PT 0xe7f /* nG=1 AF=1 SH=10 AP=01 NS=1 ATTR=111 T=1 P=1 */ -#define PT_MEM 0xe7d /* nG=1 AF=1 SH=10 AP=01 NS=1 ATTR=111 T=0 P=1 */ +#define PT_PT 0xf7f /* nG=1 AF=1 SH=11 AP=01 NS=1 ATTR=111 T=1 P=1 */ +#define PT_MEM 0xf7d /* nG=1 AF=1 SH=11 AP=01 NS=1 ATTR=111 T=0 P=1 */ #define PT_DEV 0xe71 /* nG=1 AF=1 SH=10 AP=01 NS=1 ATTR=100 T=0 P=1 */ #define PT_DEV_L3 0xe73 /* nG=1 AF=1 SH=10 AP=01 NS=1 ATTR=100 T=1 P=1 */
@@ -206,10 +206,10 @@ skip_bss: mcr CP32(r1, HMAIR1) /* Set up the HTCR: - * PT walks use Outer-Shareable accesses, + * PT walks use Inner-Shareable accesses, * PT walks are write-back, write-allocate in both cache levels, * Full 32-bit address space goes through this table. */ - ldr r0, =0x80002500 + ldr r0, =0x80003500 mcr CP32(r0, HTCR) /* Set up the HSCTLR:
xen/arch/arm/arm64/head.S +4 -4
@@ -24,8 +24,8 @@ #include <asm/page.h> #include <asm/asm_defns.h> -#define PT_PT 0xe7f /* nG=1 AF=1 SH=10 AP=01 NS=1 ATTR=111 T=1 P=1 */ -#define PT_MEM 0xe7d /* nG=1 AF=1 SH=10 AP=01 NS=1 ATTR=111 T=0 P=1 */ +#define PT_PT 0xf7f /* nG=1 AF=1 SH=11 AP=01 NS=1 ATTR=111 T=1 P=1 */ +#define PT_MEM 0xf7d /* nG=1 AF=1 SH=11 AP=01 NS=1 ATTR=111 T=0 P=1 */ #define PT_DEV 0xe71 /* nG=1 AF=1 SH=10 AP=01 NS=1 ATTR=100 T=0 P=1 */ #define PT_DEV_L3 0xe73 /* nG=1 AF=1 SH=10 AP=01 NS=1 ATTR=100 T=1 P=1 */
@@ -178,10 +178,10 @@ skip_bss: /* Set up the HTCR: * PASize -- 4G * Top byte is used - * PT walks use Outer-Shareable accesses, + * PT walks use Inner-Shareable accesses, * PT walks are write-back, write-allocate in both cache levels, * Full 64-bit address space goes through this table. */ - ldr x0, =0x80802500 + ldr x0, =0x80803500 msr tcr_el2, x0 /* Set up the HSCTLR:
xen/arch/arm/mm.c +11 -13
@@ -163,9 +163,8 @@ void dump_hyp_walk(vaddr_t addr)/* Map a 4k page in a fixmap entry */ void set_fixmap (unsigned map,unsigned long mfn,unsigned attributes) { -lpae_t pte =mfn_to_xen_entry (mfn); +lpae_t pte =mfn_to_xen_entry (mfn, attributes); pte.pt.table =1 ;/* 4k mappings always have this bit set */ - pte.pt.ai = attributes; pte.pt.xn =1 ;write_pte (xen_fixmap +third_table_offset (FIXMAP_ADDR (map)), pte);flush_xen_data_tlb_range_va (FIXMAP_ADDR (map),PAGE_SIZE );
@@ -212,7 +211,7 @@ void *map_domain_page(unsigned long mfn)if ( map[slot].pt.avail ==0 ) {/* Commandeer this 2MB slot */ - pte =mfn_to_xen_entry (slot_mfn); + pte =mfn_to_xen_entry (slot_mfn,WRITEALLOC ); pte.pt.avail =1 ;write_pte (map + slot, pte);break ;
@@ -340,7 +339,7 @@ void __init setup_pagetables(unsigned long boot_phys_offset, paddr_t xen_paddr)/* Map the destination in the boot misc area. */ dest_va =BOOT_MISC_VIRT_START ; - pte =mfn_to_xen_entry (xen_paddr >>PAGE_SHIFT ); + pte =mfn_to_xen_entry (xen_paddr >>PAGE_SHIFT ,WRITEALLOC );write_pte (xen_second +second_table_offset (dest_va), pte);flush_xen_data_tlb_range_va (dest_va,SECOND_SIZE );
@@ -387,7 +386,7 @@ void __init setup_pagetables(unsigned long boot_phys_offset, paddr_t xen_paddr)/* Link in the fixmap pagetable */ pte =mfn_to_xen_entry ((((unsigned long ) xen_fixmap) + phys_offset) - >>PAGE_SHIFT ); + >>PAGE_SHIFT ,WRITEALLOC ); pte.pt.table =1 ;write_pte (xen_second +second_table_offset (FIXMAP_ADDR (0 )), pte);/*
@@ -402,7 +401,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); + pte =mfn_to_xen_entry (mfn,WRITEALLOC ); pte.pt.table =1 ;/* 4k mappings always have this bit set */ if (is_kernel_text (va) ||is_kernel_inittext (va) ) {
@@ -415,7 +414,7 @@ void __init setup_pagetables(unsigned long boot_phys_offset, paddr_t xen_paddr)/* No flush required here as page table is not hooked in yet. */ } pte =mfn_to_xen_entry ((((unsigned long ) xen_xenmap) + phys_offset) - >>PAGE_SHIFT ); + >>PAGE_SHIFT ,WRITEALLOC ); pte.pt.table =1 ;write_pte (xen_second +second_linear_offset (XEN_VIRT_START ), pte);/* TLBFLUSH and ISB would be needed here, but wait until we set WXN */
@@ -467,7 +466,7 @@ int init_secondary_pagetables(int cpu)/* Initialise first pagetable from first level of boot tables, and * hook into the new root. */ memcpy (first, boot_first,PAGE_SIZE ); - pte =mfn_to_xen_entry (virt_to_mfn (first)); + pte =mfn_to_xen_entry (virt_to_mfn (first),WRITEALLOC ); pte.pt.table =1 ;write_pte (root, pte);#endif
@@ -479,7 +478,7 @@ int init_secondary_pagetables(int cpu)* domheap mapping pages. */ for ( i =0 ; i <DOMHEAP_SECOND_PAGES ; i++ ) { - pte =mfn_to_xen_entry (virt_to_mfn (domheap+i*LPAE_ENTRIES )); + pte =mfn_to_xen_entry (virt_to_mfn (domheap+i*LPAE_ENTRIES ),WRITEALLOC ); pte.pt.table =1 ;write_pte (&first[first_table_offset (DOMHEAP_VIRT_START +i*FIRST_SIZE )], pte); }
@@ -525,7 +524,7 @@ static void __init create_mappings(unsigned long virt, count = nr_mfns /LPAE_ENTRIES ; p = xen_second +second_linear_offset (virt); - pte =mfn_to_xen_entry (base_mfn); + pte =mfn_to_xen_entry (base_mfn,WRITEALLOC ); pte.pt.hint =1 ;/* These maps are in 16-entry contiguous chunks. */ for ( i =0 ; i < count; i++ ) {
@@ -595,7 +594,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)); + pte =mfn_to_xen_entry (virt_to_mfn (p),WRITEALLOC ); pte.pt.table =1 ;write_pte (entry, pte);return 0 ;
@@ -641,9 +640,8 @@ static int create_xen_entries(enum xenmap_operation op, addr, mfn);return -EINVAL ; } - pte =mfn_to_xen_entry (mfn); + pte =mfn_to_xen_entry (mfn, ai); pte.pt.table =1 ; - pte.pt.ai = ai;write_pte (&third[third_table_offset (addr)], pte);break ;case REMOVE :
xen/include/asm-arm/arm32/system.h +2 -2
@@ -7,8 +7,8 @@#define wfi () __asm__ __volatile__ ("wfi" : : : "memory")#define isb () __asm__ __volatile__ ("isb" : : : "memory") -#define dsb () __asm__ __volatile__ ("dsb" : : : "memory") -#define dmb () __asm__ __volatile__ ("dmb" : : : "memory") +#define dsb () __asm__ __volatile__ ("dsb sy" : : : "memory") +#define dmb () __asm__ __volatile__ ("dmb sy" : : : "memory")#define mb () dsb()#define rmb () dsb()
xen/include/asm-arm/page.h +34 -4
@@ -185,7 +185,7 @@ typedef union {/* Standard entry type that we'll use to build Xen's own pagetables. * We put the same permissions at every level, because they're ignored * by the walker in non-leaf entries. */ -static inline lpae_t mfn_to_xen_entry (unsigned long mfn) +static inline lpae_t mfn_to_xen_entry (unsigned long mfn,unsigned attr) {paddr_t pa = ((paddr_t ) mfn) <<PAGE_SHIFT ;lpae_t e = (lpae_t ) {
@@ -193,10 +193,9 @@ static inline lpae_t mfn_to_xen_entry(unsigned long mfn) .xn = 1, /* No need to execute outside .text */ .ng = 1, /* Makes TLB flushes easier */ .af = 1, /* No need for access tracking */ - .sh = LPAE_SH_OUTER, /* Xen mappings are globally coherent */ .ns = 1, /* Hyp mode is in the non-secure world */ .user = 1, /* See below */ - .ai = WRITEALLOC, + .ai = attr, .table = 0, /* Set to 1 for links and 4k maps */ .valid = 1, /* Mappings are present */ }};;
@@ -205,6 +204,37 @@ static inline lpae_t mfn_to_xen_entry(unsigned long mfn)* pagetables un User mode it's OK. If this changes, remember * to update the hard-coded values in head.S too */ +switch ( attr ) + { +case BUFFERABLE : +/* +* ARM ARM: Overlaying the shareability attribute (B3-1376 to 1377) +* +* A memory region with a resultant memory type attribute of Normal, +* and a resultant cacheability attribute of Inner Non-cacheable, +* Outer Non-cacheable, must have a resultant shareability attribute +* of Outer Shareable, otherwise shareability is UNPREDICTABLE. +* +* On ARMv8 sharability is ignored and explicitly treated as Outer +* Shareable for Normal Inner Non_cacheable, Outer Non-cacheable. +*/ + e.pt.sh =LPAE_SH_OUTER ; +break ; +case UNCACHED : +case DEV_SHARED : +/* Shareability is ignored for non-Normal memory, Outer is as +* good as anything. +* +* On ARMv8 sharability is ignored and explicitly treated as Outer +* Shareable for any device memory type. +*/ + e.pt.sh =LPAE_SH_OUTER ; +break ; +default : + e.pt.sh =LPAE_SH_INNER ;/* Xen mappings are SMP coherent */ +break ; + } +ASSERT (!(pa & ~PAGE_MASK ));ASSERT (!(pa & ~PADDR_MASK ));
@@ -219,7 +249,7 @@ static inline lpae_t mfn_to_p2m_entry(unsigned long mfn, unsigned int mattr)lpae_t e = (lpae_t ) { .p2m.xn =0 , .p2m.af =1 , - .p2m.sh =LPAE_SH_OUTER , + .p2m.sh =LPAE_SH_INNER , .p2m.write =1 , .p2m.read =1 , .p2m.mattr = mattr,
Signature · 1 line
1.7.2.5
Re: [PATCH 01/10] xen: arm: map memory as inner shareable.
Quoted 17 lines · Ian Campbell
The inner shareable domain contains all SMP processors, including different clusters (e.g. big.LITTLE). Therefore this is the correct thing to use for Xen memory mappings. The outer shareable domain is for devices on busses which are barriers (e.g. AMBA4). While the system domain is for things behind bridges which do not.
One wrinkle is that Normal memory with attributes Inner Non-cacheable, Outer Non-cacheable (which we call BUFFERABLE) must be mapped Outer Shareable on ARM v7. Therefore change the prototype of
mfn_to_xen_entryto take the attribute index so we can DTRT. On ARMv8 the sharability is ignored and considered to always be Outer Shareable.While I'm here change all the dmb/dsb with an implicit sy to an explicit sy, to make future changes simpler. Other than that don't adjust the barriers, flushes etc, those remain as they were (which is more than is now required). I'll change those in a later patch.
Quoted 6 lines
Many thanks to Leif for explaining the difference between Inner- and Outer-Shareable in words of two or less syllables, I hope I've replicated that explanation properly above!
Signed-off-by Ian Campbell <[email protected]>Cc Leif Lindholm <[email protected]>
It looks OK. I would have kept the dsb sy changes separate.
Quoted 260 lines
xen/arch/arm/arm32/head.S | 8 +++--- xen/arch/arm/arm64/head.S | 8 +++--- xen/arch/arm/mm.c | 24 ++++++++++------------ xen/include/asm-arm/arm32/system.h | 4 +- xen/include/asm-arm/page.h | 38 ++++++++++++++++++++++++++++++++--- 5 files changed, 55 insertions(+), 27 deletions(-)xen/arch/arm/arm32/head.S +4
-4@@ -24,8 +24,8 @@ #define ZIMAGE_MAGIC_NUMBER 0x016f2818 -#define PT_PT 0xe7f /* nG=1 AF=1 SH=10 AP=01 NS=1 ATTR=111 T=1 P=1 */ -#define PT_MEM 0xe7d /* nG=1 AF=1 SH=10 AP=01 NS=1 ATTR=111 T=0 P=1 */ +#define PT_PT 0xf7f /* nG=1 AF=1 SH=11 AP=01 NS=1 ATTR=111 T=1 P=1 */ +#define PT_MEM 0xf7d /* nG=1 AF=1 SH=11 AP=01 NS=1 ATTR=111 T=0 P=1 */ #define PT_DEV 0xe71 /* nG=1 AF=1 SH=10 AP=01 NS=1 ATTR=100 T=0 P=1 */ #define PT_DEV_L3 0xe73 /* nG=1 AF=1 SH=10 AP=01 NS=1 ATTR=100 T=1 P=1 */@@ -206,10 +206,10 @@ skip_bss: mcr CP32(r1, HMAIR1) /* Set up the HTCR: - * PT walks use Outer-Shareable accesses, + * PT walks use Inner-Shareable accesses, * PT walks are write-back, write-allocate in both cache levels, * Full 32-bit address space goes through this table. */ - ldr r0, =0x80002500 + ldr r0, =0x80003500 mcr CP32(r0, HTCR) /* Set up the HSCTLR:xen/arch/arm/arm64/head.S +4
-4@@ -24,8 +24,8 @@ #include <asm/page.h> #include <asm/asm_defns.h> -#define PT_PT 0xe7f /* nG=1 AF=1 SH=10 AP=01 NS=1 ATTR=111 T=1 P=1 */ -#define PT_MEM 0xe7d /* nG=1 AF=1 SH=10 AP=01 NS=1 ATTR=111 T=0 P=1 */ +#define PT_PT 0xf7f /* nG=1 AF=1 SH=11 AP=01 NS=1 ATTR=111 T=1 P=1 */ +#define PT_MEM 0xf7d /* nG=1 AF=1 SH=11 AP=01 NS=1 ATTR=111 T=0 P=1 */ #define PT_DEV 0xe71 /* nG=1 AF=1 SH=10 AP=01 NS=1 ATTR=100 T=0 P=1 */ #define PT_DEV_L3 0xe73 /* nG=1 AF=1 SH=10 AP=01 NS=1 ATTR=100 T=1 P=1 */@@ -178,10 +178,10 @@ skip_bss: /* Set up the HTCR: * PASize -- 4G * Top byte is used - * PT walks use Outer-Shareable accesses, + * PT walks use Inner-Shareable accesses, * PT walks are write-back, write-allocate in both cache levels, * Full 64-bit address space goes through this table. */ - ldr x0, =0x80802500 + ldr x0, =0x80803500 msr tcr_el2, x0 /* Set up the HSCTLR:xen/arch/arm/mm.c +11
-13@@ -163,9 +163,8 @@ void dump_hyp_walk(vaddr_t addr)/* Map a 4k page in a fixmap entry */ void set_fixmap (unsigned map,unsigned long mfn,unsigned attributes) { -lpae_t pte =mfn_to_xen_entry (mfn); +lpae_t pte =mfn_to_xen_entry (mfn, attributes); pte.pt.table =1 ;/* 4k mappings always have this bit set */ - pte.pt.ai = attributes; pte.pt.xn =1 ;write_pte (xen_fixmap +third_table_offset (FIXMAP_ADDR (map)), pte);flush_xen_data_tlb_range_va (FIXMAP_ADDR (map),PAGE_SIZE );@@ -212,7 +211,7 @@ void *map_domain_page(unsigned long mfn)if ( map[slot].pt.avail ==0 ) {/* Commandeer this 2MB slot */ - pte =mfn_to_xen_entry (slot_mfn); + pte =mfn_to_xen_entry (slot_mfn,WRITEALLOC ); pte.pt.avail =1 ;write_pte (map + slot, pte);break ;@@ -340,7 +339,7 @@ void __init setup_pagetables(unsigned long boot_phys_offset, paddr_t xen_paddr)/* Map the destination in the boot misc area. */ dest_va =BOOT_MISC_VIRT_START ; - pte =mfn_to_xen_entry (xen_paddr >>PAGE_SHIFT ); + pte =mfn_to_xen_entry (xen_paddr >>PAGE_SHIFT ,WRITEALLOC );write_pte (xen_second +second_table_offset (dest_va), pte);flush_xen_data_tlb_range_va (dest_va,SECOND_SIZE );@@ -387,7 +386,7 @@ void __init setup_pagetables(unsigned long boot_phys_offset, paddr_t xen_paddr)/* Link in the fixmap pagetable */ pte =mfn_to_xen_entry ((((unsigned long ) xen_fixmap) + phys_offset) - >>PAGE_SHIFT ); + >>PAGE_SHIFT ,WRITEALLOC ); pte.pt.table =1 ;write_pte (xen_second +second_table_offset (FIXMAP_ADDR (0 )), pte);/* @@ -402,7 +401,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); + pte =mfn_to_xen_entry (mfn,WRITEALLOC ); pte.pt.table =1 ;/* 4k mappings always have this bit set */ if (is_kernel_text (va) ||is_kernel_inittext (va) ) {@@ -415,7 +414,7 @@ void __init setup_pagetables(unsigned long boot_phys_offset, paddr_t xen_paddr)/* No flush required here as page table is not hooked in yet. */ } pte =mfn_to_xen_entry ((((unsigned long ) xen_xenmap) + phys_offset) - >>PAGE_SHIFT ); + >>PAGE_SHIFT ,WRITEALLOC ); pte.pt.table =1 ;write_pte (xen_second +second_linear_offset (XEN_VIRT_START ), pte);/* TLBFLUSH and ISB would be needed here, but wait until we set WXN */ @@ -467,7 +466,7 @@ int init_secondary_pagetables(int cpu)/* Initialise first pagetable from first level of boot tables, and * hook into the new root. */ memcpy (first, boot_first,PAGE_SIZE ); - pte =mfn_to_xen_entry (virt_to_mfn (first)); + pte =mfn_to_xen_entry (virt_to_mfn (first),WRITEALLOC ); pte.pt.table =1 ;write_pte (root, pte);#endif @@ -479,7 +478,7 @@ int init_secondary_pagetables(int cpu)* domheap mapping pages. */ for ( i =0 ; i <DOMHEAP_SECOND_PAGES ; i++ ) { - pte =mfn_to_xen_entry (virt_to_mfn (domheap+i*LPAE_ENTRIES )); + pte =mfn_to_xen_entry (virt_to_mfn (domheap+i*LPAE_ENTRIES ),WRITEALLOC ); pte.pt.table =1 ;write_pte (&first[first_table_offset (DOMHEAP_VIRT_START +i*FIRST_SIZE )], pte); }@@ -525,7 +524,7 @@ static void __init create_mappings(unsigned long virt, count = nr_mfns /LPAE_ENTRIES ; p = xen_second +second_linear_offset (virt); - pte =mfn_to_xen_entry (base_mfn); + pte =mfn_to_xen_entry (base_mfn,WRITEALLOC ); pte.pt.hint =1 ;/* These maps are in 16-entry contiguous chunks. */ for ( i =0 ; i < count; i++ ) {@@ -595,7 +594,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)); + pte =mfn_to_xen_entry (virt_to_mfn (p),WRITEALLOC ); pte.pt.table =1 ;write_pte (entry, pte);return 0 ;@@ -641,9 +640,8 @@ static int create_xen_entries(enum xenmap_operation op, addr, mfn);return -EINVAL ; } - pte =mfn_to_xen_entry (mfn); + pte =mfn_to_xen_entry (mfn, ai); pte.pt.table =1 ; - pte.pt.ai = ai;write_pte (&third[third_table_offset (addr)], pte);break ;case REMOVE :xen/include/asm-arm/arm32/system.h +2
-2@@ -7,8 +7,8 @@#define wfi () __asm__ __volatile__ ("wfi" : : : "memory")#define isb () __asm__ __volatile__ ("isb" : : : "memory") -#define dsb () __asm__ __volatile__ ("dsb" : : : "memory") -#define dmb () __asm__ __volatile__ ("dmb" : : : "memory") +#define dsb () __asm__ __volatile__ ("dsb sy" : : : "memory") +#define dmb () __asm__ __volatile__ ("dmb sy" : : : "memory")#define mb () dsb()#define rmb () dsb()xen/include/asm-arm/page.h +34
-4@@ -185,7 +185,7 @@ typedef union {/* Standard entry type that we'll use to build Xen's own pagetables. * We put the same permissions at every level, because they're ignored * by the walker in non-leaf entries. */ -static inline lpae_t mfn_to_xen_entry (unsigned long mfn) +static inline lpae_t mfn_to_xen_entry (unsigned long mfn,unsigned attr) {paddr_t pa = ((paddr_t ) mfn) <<PAGE_SHIFT ;lpae_t e = (lpae_t ) {@@ -193,10 +193,9 @@ static inline lpae_t mfn_to_xen_entry(unsigned long mfn) .xn = 1, /* No need to execute outside .text */ .ng = 1, /* Makes TLB flushes easier */ .af = 1, /* No need for access tracking */ - .sh = LPAE_SH_OUTER, /* Xen mappings are globally coherent */ .ns = 1, /* Hyp mode is in the non-secure world */ .user = 1, /* See below */ - .ai = WRITEALLOC, + .ai = attr, .table = 0, /* Set to 1 for links and 4k maps */ .valid = 1, /* Mappings are present */ }};;@@ -205,6 +204,37 @@ static inline lpae_t mfn_to_xen_entry(unsigned long mfn)* pagetables un User mode it's OK. If this changes, remember * to update the hard-coded values in head.S too */ +switch ( attr ) + { +case BUFFERABLE : +/* +* ARM ARM: Overlaying the shareability attribute (B3-1376 to 1377) +* +* A memory region with a resultant memory type attribute of Normal, +* and a resultant cacheability attribute of Inner Non-cacheable, +* Outer Non-cacheable, must have a resultant shareability attribute +* of Outer Shareable, otherwise shareability is UNPREDICTABLE. +* +* On ARMv8 sharability is ignored and explicitly treated as Outer +* Shareable for Normal Inner Non_cacheable, Outer Non-cacheable. +*/ + e.pt.sh =LPAE_SH_OUTER ; +break ; +case UNCACHED : +case DEV_SHARED : +/* Shareability is ignored for non-Normal memory, Outer is as +* good as anything. +* +* On ARMv8 sharability is ignored and explicitly treated as Outer +* Shareable for any device memory type. +*/ + e.pt.sh =LPAE_SH_OUTER ; +break ; +default : + e.pt.sh =LPAE_SH_INNER ;/* Xen mappings are SMP coherent */ +break ; + } +ASSERT (!(pa & ~PAGE_MASK ));ASSERT (!(pa & ~PADDR_MASK ));@@ -219,7 +249,7 @@ static inline lpae_t mfn_to_p2m_entry(unsigned long mfn, unsigned int mattr)lpae_t e = (lpae_t ) { .p2m.xn =0 , .p2m.af =1 , - .p2m.sh =LPAE_SH_OUTER , + .p2m.sh =LPAE_SH_INNER , .p2m.write =1 , .p2m.read =1 , .p2m.mattr = mattr,Signature · 1 line
1.7.2.5
Re: [PATCH 01/10] xen: arm: map memory as inner shareable.
Quoted 18 lines · Stefano Stabellini
Quoted 17 lines · Ian Campbell
The inner shareable domain contains all SMP processors, including different clusters (e.g. big.LITTLE). Therefore this is the correct thing to use for Xen memory mappings. The outer shareable domain is for devices on busses which are barriers (e.g. AMBA4). While the system domain is for things behind bridges which do not.
One wrinkle is that Normal memory with attributes Inner Non-cacheable, Outer Non-cacheable (which we call BUFFERABLE) must be mapped Outer Shareable on ARM v7. Therefore change the prototype of
mfn_to_xen_entryto take the attribute index so we can DTRT. On ARMv8 the sharability is ignored and considered to always be Outer Shareable.While I'm here change all the dmb/dsb with an implicit sy to an explicit sy, to make future changes simpler. Other than that don't adjust the barriers, flushes etc, those remain as they were (which is more than is now required). I'll change those in a later patch.
Quoted 8 lines
Quoted 6 lines
Many thanks to Leif for explaining the difference between Inner- and Outer-Shareable in words of two or less syllables, I hope I've replicated that explanation properly above!
Signed-off-by Ian Campbell <[email protected]>Cc Leif Lindholm <[email protected]>It looks OK.
Thanks.
Quoted 1 line
I would have kept the dsb sy changes separate.
So would I if I'd have know then that it was going end up being so many patches. I'll split them out when I resend.
Re: [PATCH 01/10] xen: arm: map memory as inner shareable.
In reply to Ian CampbellQuoted 4 lines · Ian Campbell
The inner shareable domain contains all SMP processors, including different clusters (e.g. big.LITTLE). Therefore this is the correct thing to use for Xen memory mappings. The outer shareable domain is for devices on busses which are barriers (e.g. AMBA4).
I think this should say something like "which are coherent and barrier-aware".
And to be technically correct, the example should say "AMBA4 AXI with ACE").
Quoted 1 line
While the system domain is for things behind bridges > which do not.
And given the above ... -> which "are" not.
Quoted 6 lines
One wrinkle is that Normal memory with attributes Inner Non-cacheable, Outer Non-cacheable (which we call BUFFERABLE) must be mapped Outer Shareable on ARM v7. Therefore change the prototype of
mfn_to_xen_entryto take the attribute index so we can DTRT. On ARMv8 the sharability is ignored and considered to always be Outer Shareable.
Quoted 8 lines
While I'm here change all the dmb/dsb with an implicit sy to an explicit sy, to make future changes simpler. Other than that don't adjust the barriers, flushes etc, those remain as they were (which is more than is now required). I'll change those in a later patch.
Many thanks to Leif for explaining the difference between Inner- and Outer-Shareable in words of two or less syllables, I hope I've replicated that explanation properly above!
Apart from my usual nitpicking, indeed :)
Quoted 214 lines
Signed-off-by Ian Campbell <[email protected]>Cc Leif Lindholm <[email protected]>--- xen/arch/arm/arm32/head.S | 8 +++--- xen/arch/arm/arm64/head.S | 8 +++--- xen/arch/arm/mm.c | 24 ++++++++++------------ xen/include/asm-arm/arm32/system.h | 4 +- xen/include/asm-arm/page.h | 38 ++++++++++++++++++++++++++++++++--- 5 files changed, 55 insertions(+), 27 deletions(-)xen/arch/arm/arm32/head.S +4
-4@@ -24,8 +24,8 @@ #define ZIMAGE_MAGIC_NUMBER 0x016f2818 -#define PT_PT 0xe7f /* nG=1 AF=1 SH=10 AP=01 NS=1 ATTR=111 T=1 P=1 */ -#define PT_MEM 0xe7d /* nG=1 AF=1 SH=10 AP=01 NS=1 ATTR=111 T=0 P=1 */ +#define PT_PT 0xf7f /* nG=1 AF=1 SH=11 AP=01 NS=1 ATTR=111 T=1 P=1 */ +#define PT_MEM 0xf7d /* nG=1 AF=1 SH=11 AP=01 NS=1 ATTR=111 T=0 P=1 */ #define PT_DEV 0xe71 /* nG=1 AF=1 SH=10 AP=01 NS=1 ATTR=100 T=0 P=1 */ #define PT_DEV_L3 0xe73 /* nG=1 AF=1 SH=10 AP=01 NS=1 ATTR=100 T=1 P=1 */@@ -206,10 +206,10 @@ skip_bss: mcr CP32(r1, HMAIR1) /* Set up the HTCR: - * PT walks use Outer-Shareable accesses, + * PT walks use Inner-Shareable accesses, * PT walks are write-back, write-allocate in both cache levels, * Full 32-bit address space goes through this table. */ - ldr r0, =0x80002500 + ldr r0, =0x80003500 mcr CP32(r0, HTCR) /* Set up the HSCTLR:xen/arch/arm/arm64/head.S +4
-4@@ -24,8 +24,8 @@ #include <asm/page.h> #include <asm/asm_defns.h> -#define PT_PT 0xe7f /* nG=1 AF=1 SH=10 AP=01 NS=1 ATTR=111 T=1 P=1 */ -#define PT_MEM 0xe7d /* nG=1 AF=1 SH=10 AP=01 NS=1 ATTR=111 T=0 P=1 */ +#define PT_PT 0xf7f /* nG=1 AF=1 SH=11 AP=01 NS=1 ATTR=111 T=1 P=1 */ +#define PT_MEM 0xf7d /* nG=1 AF=1 SH=11 AP=01 NS=1 ATTR=111 T=0 P=1 */ #define PT_DEV 0xe71 /* nG=1 AF=1 SH=10 AP=01 NS=1 ATTR=100 T=0 P=1 */ #define PT_DEV_L3 0xe73 /* nG=1 AF=1 SH=10 AP=01 NS=1 ATTR=100 T=1 P=1 */@@ -178,10 +178,10 @@ skip_bss: /* Set up the HTCR: * PASize -- 4G * Top byte is used - * PT walks use Outer-Shareable accesses, + * PT walks use Inner-Shareable accesses, * PT walks are write-back, write-allocate in both cache levels, * Full 64-bit address space goes through this table. */ - ldr x0, =0x80802500 + ldr x0, =0x80803500 msr tcr_el2, x0 /* Set up the HSCTLR:xen/arch/arm/mm.c +11
-13@@ -163,9 +163,8 @@ void dump_hyp_walk(vaddr_t addr)/* Map a 4k page in a fixmap entry */ void set_fixmap (unsigned map,unsigned long mfn,unsigned attributes) { -lpae_t pte =mfn_to_xen_entry (mfn); +lpae_t pte =mfn_to_xen_entry (mfn, attributes); pte.pt.table =1 ;/* 4k mappings always have this bit set */ - pte.pt.ai = attributes; pte.pt.xn =1 ;write_pte (xen_fixmap +third_table_offset (FIXMAP_ADDR (map)), pte);flush_xen_data_tlb_range_va (FIXMAP_ADDR (map),PAGE_SIZE );@@ -212,7 +211,7 @@ void *map_domain_page(unsigned long mfn)if ( map[slot].pt.avail ==0 ) {/* Commandeer this 2MB slot */ - pte =mfn_to_xen_entry (slot_mfn); + pte =mfn_to_xen_entry (slot_mfn,WRITEALLOC ); pte.pt.avail =1 ;write_pte (map + slot, pte);break ;@@ -340,7 +339,7 @@ void __init setup_pagetables(unsigned long boot_phys_offset, paddr_t xen_paddr)/* Map the destination in the boot misc area. */ dest_va =BOOT_MISC_VIRT_START ; - pte =mfn_to_xen_entry (xen_paddr >>PAGE_SHIFT ); + pte =mfn_to_xen_entry (xen_paddr >>PAGE_SHIFT ,WRITEALLOC );write_pte (xen_second +second_table_offset (dest_va), pte);flush_xen_data_tlb_range_va (dest_va,SECOND_SIZE );@@ -387,7 +386,7 @@ void __init setup_pagetables(unsigned long boot_phys_offset, paddr_t xen_paddr)/* Link in the fixmap pagetable */ pte =mfn_to_xen_entry ((((unsigned long ) xen_fixmap) + phys_offset) - >>PAGE_SHIFT ); + >>PAGE_SHIFT ,WRITEALLOC ); pte.pt.table =1 ;write_pte (xen_second +second_table_offset (FIXMAP_ADDR (0 )), pte);/* @@ -402,7 +401,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); + pte =mfn_to_xen_entry (mfn,WRITEALLOC ); pte.pt.table =1 ;/* 4k mappings always have this bit set */ if (is_kernel_text (va) ||is_kernel_inittext (va) ) {@@ -415,7 +414,7 @@ void __init setup_pagetables(unsigned long boot_phys_offset, paddr_t xen_paddr)/* No flush required here as page table is not hooked in yet. */ } pte =mfn_to_xen_entry ((((unsigned long ) xen_xenmap) + phys_offset) - >>PAGE_SHIFT ); + >>PAGE_SHIFT ,WRITEALLOC ); pte.pt.table =1 ;write_pte (xen_second +second_linear_offset (XEN_VIRT_START ), pte);/* TLBFLUSH and ISB would be needed here, but wait until we set WXN */ @@ -467,7 +466,7 @@ int init_secondary_pagetables(int cpu)/* Initialise first pagetable from first level of boot tables, and * hook into the new root. */ memcpy (first, boot_first,PAGE_SIZE ); - pte =mfn_to_xen_entry (virt_to_mfn (first)); + pte =mfn_to_xen_entry (virt_to_mfn (first),WRITEALLOC ); pte.pt.table =1 ;write_pte (root, pte);#endif @@ -479,7 +478,7 @@ int init_secondary_pagetables(int cpu)* domheap mapping pages. */ for ( i =0 ; i <DOMHEAP_SECOND_PAGES ; i++ ) { - pte =mfn_to_xen_entry (virt_to_mfn (domheap+i*LPAE_ENTRIES )); + pte =mfn_to_xen_entry (virt_to_mfn (domheap+i*LPAE_ENTRIES ),WRITEALLOC ); pte.pt.table =1 ;write_pte (&first[first_table_offset (DOMHEAP_VIRT_START +i*FIRST_SIZE )], pte); }@@ -525,7 +524,7 @@ static void __init create_mappings(unsigned long virt, count = nr_mfns /LPAE_ENTRIES ; p = xen_second +second_linear_offset (virt); - pte =mfn_to_xen_entry (base_mfn); + pte =mfn_to_xen_entry (base_mfn,WRITEALLOC ); pte.pt.hint =1 ;/* These maps are in 16-entry contiguous chunks. */ for ( i =0 ; i < count; i++ ) {@@ -595,7 +594,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)); + pte =mfn_to_xen_entry (virt_to_mfn (p),WRITEALLOC ); pte.pt.table =1 ;write_pte (entry, pte);return 0 ;@@ -641,9 +640,8 @@ static int create_xen_entries(enum xenmap_operation op, addr, mfn);return -EINVAL ; } - pte =mfn_to_xen_entry (mfn); + pte =mfn_to_xen_entry (mfn, ai); pte.pt.table =1 ; - pte.pt.ai = ai;write_pte (&third[third_table_offset (addr)], pte);break ;case REMOVE :xen/include/asm-arm/arm32/system.h +2
-2@@ -7,8 +7,8 @@#define wfi () __asm__ __volatile__ ("wfi" : : : "memory")#define isb () __asm__ __volatile__ ("isb" : : : "memory") -#define dsb () __asm__ __volatile__ ("dsb" : : : "memory") -#define dmb () __asm__ __volatile__ ("dmb" : : : "memory") +#define dsb () __asm__ __volatile__ ("dsb sy" : : : "memory") +#define dmb () __asm__ __volatile__ ("dmb sy" : : : "memory")#define mb () dsb()#define rmb () dsb()xen/include/asm-arm/page.h +2
-3@@ -185,7 +185,7 @@ typedef union {/* Standard entry type that we'll use to build Xen's own pagetables. * We put the same permissions at every level, because they're ignored * by the walker in non-leaf entries. */ -static inline lpae_t mfn_to_xen_entry (unsigned long mfn) +static inline lpae_t mfn_to_xen_entry (unsigned long mfn,unsigned attr) {paddr_t pa = ((paddr_t ) mfn) <<PAGE_SHIFT ;lpae_t e = (lpae_t ) {@@ -193,10 +193,9 @@ static inline lpae_t mfn_to_xen_entry(unsigned long mfn) .xn = 1, /* No need to execute outside .text */ .ng = 1, /* Makes TLB flushes easier */ .af = 1, /* No need for access tracking */ - .sh = LPAE_SH_OUTER, /* Xen mappings are globally coherent */ .ns = 1, /* Hyp mode is in the non-secure world */ .user = 1, /* See below */ - .ai = WRITEALLOC, + .ai = attr, .table = 0, /* Set to 1 for links and 4k maps */ .valid = 1, /* Mappings are present */ }};;
xen/include/asm-arm/page.h static inline lpae_t mfn_to_xen_entry(unsigned long mfn) · line 211
Quoted 8 lines
xen/include/asm-arm/page.h +5
-0@@ -205,6 +204,37 @@ static inline lpae_t mfn_to_xen_entry(unsigned long mfn)* pagetables un User mode it's OK. If this changes, remember * to update the hard-coded values in head.S too */ +switch ( attr ) + { +case BUFFERABLE : +/* +* ARM ARM: Overlaying the shareability attribute (B3-1376 to 1377)
It would be worth to indicate the revision of the ARM ARM here (in this instance DDI 0406C.b).
Quoted 41 lines
xen/include/asm-arm/page.h +27
-1+* +* A memory region with a resultant memory type attribute of Normal, +* and a resultant cacheability attribute of Inner Non-cacheable, +* Outer Non-cacheable, must have a resultant shareability attribute +* of Outer Shareable, otherwise shareability is UNPREDICTABLE. +* +* On ARMv8 sharability is ignored and explicitly treated as Outer +* Shareable for Normal Inner Non_cacheable, Outer Non-cacheable. +*/ + e.pt.sh =LPAE_SH_OUTER ; +break ; +case UNCACHED : +case DEV_SHARED : +/* Shareability is ignored for non-Normal memory, Outer is as +* good as anything. +* +* On ARMv8 sharability is ignored and explicitly treated as Outer +* Shareable for any device memory type. +*/ + e.pt.sh =LPAE_SH_OUTER ; +break ; +default : + e.pt.sh =LPAE_SH_INNER ;/* Xen mappings are SMP coherent */ +break ; + } +ASSERT (!(pa & ~PAGE_MASK ));ASSERT (!(pa & ~PADDR_MASK ));@@ -219,7 +249,7 @@ static inline lpae_t mfn_to_p2m_entry(unsigned long mfn, unsigned int mattr)lpae_t e = (lpae_t ) { .p2m.xn =0 , .p2m.af =1 , - .p2m.sh =LPAE_SH_OUTER , + .p2m.sh =LPAE_SH_INNER , .p2m.write =1 , .p2m.read =1 , .p2m.mattr = mattr,Signature · 1 line
1.7.2.5
Re: [PATCH 01/10] xen: arm: map memory as inner shareable.
Quoted 27 lines · Leif Lindholm
Quoted 4 lines · Ian Campbell
The inner shareable domain contains all SMP processors, including different clusters (e.g. big.LITTLE). Therefore this is the correct thing to use for Xen memory mappings. The outer shareable domain is for devices on busses which are barriers (e.g. AMBA4).
I think this should say something like "which are coherent and barrier-aware".
And to be technically correct, the example should say "AMBA4 AXI with ACE").
Quoted 1 line
While the system domain is for things behind bridges > which do not.
And given the above ... -> which "are" not.
Quoted 11 lines
One wrinkle is that Normal memory with attributes Inner Non-cacheable, Outer Non-cacheable (which we call BUFFERABLE) must be mapped Outer Shareable on ARM v7. Therefore change the prototype of
mfn_to_xen_entryto take the attribute index so we can DTRT. On ARMv8 the sharability is ignored and considered to always be Outer Shareable.While I'm here change all the dmb/dsb with an implicit sy to an explicit sy, to make future changes simpler. Other than that don't adjust the barriers, flushes etc, those remain as they were (which is more than is now required). I'll change those in a later patch.
Quoted 5 lines
Quoted 3 lines
Many thanks to Leif for explaining the difference between Inner- and Outer-Shareable in words of two or less syllables, I hope I've replicated that explanation properly above!
Apart from my usual nitpicking, indeed :)
Thanks, I was sure I was playing a bit fast and loose with the specifics!
Quoted 9 lines
[...]
xen/include/asm-arm/page.h static inline lpae_t mfn_to_xen_entry(unsigned long mfn) · line 211
Quoted 5 lines
xen/include/asm-arm/page.h +5
-0+switch ( attr ) + { +case BUFFERABLE : +/* +* ARM ARM: Overlaying the shareability attribute (B3-1376 to 1377) It would be worth to indicate the revision of the ARM ARM here (in this instance DDI 0406C.b).
Good idea, thanks.
Ian.
Re: [PATCH 01/10] xen: arm: map memory as inner shareable.
In reply to Ian Campbellxen/include/asm-arm/page.h static inline lpae_t mfn_to_p2m_entry(unsigned long mfn, unsigned int mattr) · line 255
Quoted 9 lines · Ian Campbell
xen/include/asm-arm/page.h +1
-1@@ -219,7 +249,7 @@ static inline lpae_t mfn_to_p2m_entry(unsigned long mfn, unsigned int mattr)lpae_t e = (lpae_t ) { .p2m.xn =0 , .p2m.af =1 , - .p2m.sh =LPAE_SH_OUTER , + .p2m.sh =LPAE_SH_INNER , .p2m.write =1 , .p2m.read =1 , .p2m.mattr = mattr,
I think we need to leave MMIO mappings outer-shareable (or full-system as appropriate), which means adding the same mechanism that you did for the xen PT mappings.
Otherwise, this looks fine.
Cheers,
Tim.
Re: [PATCH 01/10] xen: arm: map memory as inner shareable.
Quoted 14 lines · Tim Deegan
xen/include/asm-arm/page.h static inline lpae_t mfn_to_p2m_entry(unsigned long mfn, unsigned int mattr) · line 255
Quoted 9 lines · Ian Campbell
xen/include/asm-arm/page.h +1
-1@@ -219,7 +249,7 @@ static inline lpae_t mfn_to_p2m_entry(unsigned long mfn, unsigned int mattr)lpae_t e = (lpae_t ) { .p2m.xn =0 , .p2m.af =1 , - .p2m.sh =LPAE_SH_OUTER , + .p2m.sh =LPAE_SH_INNER , .p2m.write =1 , .p2m.read =1 , .p2m.mattr = mattr,I think we need to leave MMIO mappings outer-shareable (or full-system as appropriate), which means adding the same mechanism that you did for the xen PT mappings.
Yes, good catch.
THanks
Quoted 7 lines
Otherwise, this looks fine.
Cheers,
Tim.
PATCH 2/10 xen: arm: Only upgrade guest barriers to inner shareable.
In reply to Ian Campbell--- xen/arch/arm/traps.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)
xen/arch/arm/traps.c +1 -1
@@ -62,7 +62,7 @@ void __cpuinit init_traps(void)WRITE_SYSREG ((vaddr_t )hyp_traps_vector,VBAR_EL2 );/* Setup hypervisor traps */ -WRITE_SYSREG (HCR_PTW |HCR_BSU_OUTER |HCR_AMO |HCR_IMO |HCR_VM |HCR_TWI |HCR_TSC ,HCR_EL2 ); +WRITE_SYSREG (HCR_PTW |HCR_BSU_INNER |HCR_AMO |HCR_IMO |HCR_VM |HCR_TWI |HCR_TSC ,HCR_EL2 );isb (); }
Signature · 1 line
1.7.2.5
Re: [PATCH 02/10] xen: arm: Only upgrade guest barriers to inner shareable.
Quoted 1 line · Ian Campbell
Signed-off-by Ian Campbell <[email protected]>
Quoted 15 lines
xen/arch/arm/traps.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)xen/arch/arm/traps.c +1
-1@@ -62,7 +62,7 @@ void __cpuinit init_traps(void)WRITE_SYSREG ((vaddr_t )hyp_traps_vector,VBAR_EL2 );/* Setup hypervisor traps */ -WRITE_SYSREG (HCR_PTW |HCR_BSU_OUTER |HCR_AMO |HCR_IMO |HCR_VM |HCR_TWI |HCR_TSC ,HCR_EL2 ); +WRITE_SYSREG (HCR_PTW |HCR_BSU_INNER |HCR_AMO |HCR_IMO |HCR_VM |HCR_TWI |HCR_TSC ,HCR_EL2 );isb (); }
Re: [PATCH 02/10] xen: arm: Only upgrade guest barriers to inner shareable.
In reply to Ian CampbellQuoted 1 line · Ian Campbell
Signed-off-by Ian Campbell <[email protected]>
Quoted 16 lines
--- xen/arch/arm/traps.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)xen/arch/arm/traps.c +1
-1@@ -62,7 +62,7 @@ void __cpuinit init_traps(void)WRITE_SYSREG ((vaddr_t )hyp_traps_vector,VBAR_EL2 );/* Setup hypervisor traps */ -WRITE_SYSREG (HCR_PTW |HCR_BSU_OUTER |HCR_AMO |HCR_IMO |HCR_VM |HCR_TWI |HCR_TSC ,HCR_EL2 ); +WRITE_SYSREG (HCR_PTW |HCR_BSU_INNER |HCR_AMO |HCR_IMO |HCR_VM |HCR_TWI |HCR_TSC ,HCR_EL2 );isb (); }
PATCH 3/10 xen: arm: reduce instruction cache and tlb flushes to inner-shareable.
In reply to Ian CampbellNow that Xen maps memory and performs pagetable walks as inner shareable we don't need to push updates down so far when modifying page tables etc.
--- xen/include/asm-arm/arm32/flushtlb.h | 4 ++-- xen/include/asm-arm/arm32/page.h | 8 ++++---- xen/include/asm-arm/arm64/flushtlb.h | 4 ++-- xen/include/asm-arm/arm64/page.h | 6 +++--- 4 files changed, 11 insertions(+), 11 deletions(-)
xen/include/asm-arm/arm32/flushtlb.h +2 -2
@@ -6,7 +6,7 @@ static inline void flush_tlb_local(void) {dsb (); -WRITE_CP32 ((uint32_t )0 ,TLBIALL ); +WRITE_CP32 ((uint32_t )0 ,TLBIALLIS );dsb ();isb ();
@@ -17,7 +17,7 @@ static inline void flush_tlb_all_local(void) {dsb (); -WRITE_CP32 ((uint32_t )0 ,TLBIALLNSNH ); +WRITE_CP32 ((uint32_t )0 ,TLBIALLNSNHIS );dsb ();isb ();
xen/include/asm-arm/arm32/page.h +4 -4
@@ -39,8 +39,8 @@ static inline void flush_xen_text_tlb(void) asmvolatile ("isb;" /* Ensure synchronization with previous changes to text */ STORE_CP32(0, TLBIALLH) /* Flush hypervisor TLB */ - STORE_CP32(0, ICIALLU) /* Flush I-cache */ - STORE_CP32(0, BPIALL) /* Flush branch predictor */ + STORE_CP32(0, ICIALLUIS) /* Flush I-cache */ + STORE_CP32(0, BPIALLIS) /* Flush branch predictor */ "dsb;" /* Ensure completion of TLB+BP flush */ "isb;" : : "r" (r0) /*dummy*/ : "memory");
@@ -54,7 +54,7 @@ static inline void flush_xen_data_tlb(void) { registerunsigned long r0 asm ("r0" ); asmvolatile ("dsb;" /* Ensure preceding are visible */ - STORE_CP32(0, TLBIALLH) + STORE_CP32(0, TLBIALLHIS) "dsb;" /* Ensure completion of the TLB flush */ "isb;" : : "r" (r0) /* dummy */: "memory");
@@ -69,7 +69,7 @@ static inline void flush_xen_data_tlb_range_va(unsigned long va, unsigned long sunsigned long end = va + size;dsb ();/* Ensure preceding are visible */ while ( va < end ) { - asm volatile(STORE_CP32(0, TLBIMVAH) + asm volatile(STORE_CP32(0, TLBIMVAHIS) : : "r" (va) : "memory"); va += PAGE_SIZE; }
xen/include/asm-arm/arm64/flushtlb.h +2 -2
@@ -6,7 +6,7 @@ static inline void flush_tlb_local(void) { asmvolatile ("dsb sy;" -"tlbi vmalle1;" +"tlbi vmalle1is;" "dsb sy;" "isb;" : : :"memory" );
@@ -17,7 +17,7 @@ static inline void flush_tlb_all_local(void) { asmvolatile ("dsb sy;" -"tlbi alle1;" +"tlbi alle1is;" "dsb sy;" "isb;" : : :"memory" );
xen/include/asm-arm/arm64/page.h +3 -3
@@ -33,7 +33,7 @@ static inline void flush_xen_text_tlb(void) asmvolatile ("isb;" /* Ensure synchronization with previous changes to text */ "tlbi alle2;" /* Flush hypervisor TLB */ -"ic iallu;" /* Flush I-cache */ +"ic ialluis;" /* Flush I-cache */ "dsb sy;" /* Ensure completion of TLB flush */ "isb;" : : :"memory" );
@@ -47,7 +47,7 @@ static inline void flush_xen_data_tlb(void) { asmvolatile ("dsb sy;" /* Ensure visibility of PTE writes */ -"tlbi alle2;" /* Flush hypervisor TLB */ +"tlbi alle2is;" /* Flush hypervisor TLB */ "dsb sy;" /* Ensure completion of TLB flush */ "isb;" : : :"memory" );
@@ -62,7 +62,7 @@ static inline void flush_xen_data_tlb_range_va(unsigned long va, unsigned long sunsigned long end = va + size;dsb ();/* Ensure preceding are visible */ while ( va < end ) { - asmvolatile ("tlbi vae2, %0;" + asmvolatile ("tlbi vae2is, %0;" : :"r" (va>>PAGE_SHIFT ) :"memory" ); va +=PAGE_SIZE ; }
Signature · 1 line
1.7.2.5
Re: [PATCH 03/10] xen: arm: reduce instruction cache and tlb flushes to inner-shareable.
Quoted 4 lines · Ian Campbell
Now that Xen maps memory and performs pagetable walks as inner shareable we don't need to push updates down so far when modifying page tables etc.
Signed-off-by Ian Campbell <[email protected]>
Quoted 117 lines
xen/include/asm-arm/arm32/flushtlb.h | 4 ++-- xen/include/asm-arm/arm32/page.h | 8 ++++---- xen/include/asm-arm/arm64/flushtlb.h | 4 ++-- xen/include/asm-arm/arm64/page.h | 6 +++--- 4 files changed, 11 insertions(+), 11 deletions(-)xen/include/asm-arm/arm32/flushtlb.h +2
-2@@ -6,7 +6,7 @@ static inline void flush_tlb_local(void) {dsb (); -WRITE_CP32 ((uint32_t )0 ,TLBIALL ); +WRITE_CP32 ((uint32_t )0 ,TLBIALLIS );dsb ();isb ();@@ -17,7 +17,7 @@ static inline void flush_tlb_all_local(void) {dsb (); -WRITE_CP32 ((uint32_t )0 ,TLBIALLNSNH ); +WRITE_CP32 ((uint32_t )0 ,TLBIALLNSNHIS );dsb ();isb ();xen/include/asm-arm/arm32/page.h +4
-4@@ -39,8 +39,8 @@ static inline void flush_xen_text_tlb(void) asmvolatile ("isb;" /* Ensure synchronization with previous changes to text */ STORE_CP32(0, TLBIALLH) /* Flush hypervisor TLB */ - STORE_CP32(0, ICIALLU) /* Flush I-cache */ - STORE_CP32(0, BPIALL) /* Flush branch predictor */ + STORE_CP32(0, ICIALLUIS) /* Flush I-cache */ + STORE_CP32(0, BPIALLIS) /* Flush branch predictor */ "dsb;" /* Ensure completion of TLB+BP flush */ "isb;" : : "r" (r0) /*dummy*/ : "memory");@@ -54,7 +54,7 @@ static inline void flush_xen_data_tlb(void) { registerunsigned long r0 asm ("r0" ); asmvolatile ("dsb;" /* Ensure preceding are visible */ - STORE_CP32(0, TLBIALLH) + STORE_CP32(0, TLBIALLHIS) "dsb;" /* Ensure completion of the TLB flush */ "isb;" : : "r" (r0) /* dummy */: "memory");@@ -69,7 +69,7 @@ static inline void flush_xen_data_tlb_range_va(unsigned long va, unsigned long sunsigned long end = va + size;dsb ();/* Ensure preceding are visible */ while ( va < end ) { - asm volatile(STORE_CP32(0, TLBIMVAH) + asm volatile(STORE_CP32(0, TLBIMVAHIS) : : "r" (va) : "memory"); va += PAGE_SIZE; }xen/include/asm-arm/arm64/flushtlb.h +2
-2@@ -6,7 +6,7 @@ static inline void flush_tlb_local(void) { asmvolatile ("dsb sy;" -"tlbi vmalle1;" +"tlbi vmalle1is;" "dsb sy;" "isb;" : : :"memory" );@@ -17,7 +17,7 @@ static inline void flush_tlb_all_local(void) { asmvolatile ("dsb sy;" -"tlbi alle1;" +"tlbi alle1is;" "dsb sy;" "isb;" : : :"memory" );xen/include/asm-arm/arm64/page.h +3
-3@@ -33,7 +33,7 @@ static inline void flush_xen_text_tlb(void) asmvolatile ("isb;" /* Ensure synchronization with previous changes to text */ "tlbi alle2;" /* Flush hypervisor TLB */ -"ic iallu;" /* Flush I-cache */ +"ic ialluis;" /* Flush I-cache */ "dsb sy;" /* Ensure completion of TLB flush */ "isb;" : : :"memory" );@@ -47,7 +47,7 @@ static inline void flush_xen_data_tlb(void) { asmvolatile ("dsb sy;" /* Ensure visibility of PTE writes */ -"tlbi alle2;" /* Flush hypervisor TLB */ +"tlbi alle2is;" /* Flush hypervisor TLB */ "dsb sy;" /* Ensure completion of TLB flush */ "isb;" : : :"memory" );@@ -62,7 +62,7 @@ static inline void flush_xen_data_tlb_range_va(unsigned long va, unsigned long sunsigned long end = va + size;dsb ();/* Ensure preceding are visible */ while ( va < end ) { - asmvolatile ("tlbi vae2, %0;" + asmvolatile ("tlbi vae2is, %0;" : :"r" (va>>PAGE_SHIFT ) :"memory" ); va +=PAGE_SIZE ; }Signature · 1 line
1.7.2.5
Re: [PATCH 03/10] xen: arm: reduce instruction cache and tlb flushes to inner-shareable.
In reply to Ian CampbellQuoted 28 lines · Ian Campbell
Now that Xen maps memory and performs pagetable walks as inner shareable we don't need to push updates down so far when modifying page tables etc.
Signed-off-by Ian Campbell <[email protected]>xen/include/asm-arm/arm32/page.h +3
-3@@ -39,8 +39,8 @@ static inline void flush_xen_text_tlb(void) asmvolatile ("isb;" /* Ensure synchronization with previous changes to text */ STORE_CP32(0, TLBIALLH) /* Flush hypervisor TLB */ - STORE_CP32(0, ICIALLU) /* Flush I-cache */ - STORE_CP32(0, BPIALL) /* Flush branch predictor */ + STORE_CP32(0, ICIALLUIS) /* Flush I-cache */ + STORE_CP32(0, BPIALLIS) /* Flush branch predictor */ "dsb;" /* Ensure completion of TLB+BP flush */ "isb;" : : "r" (r0) /*dummy*/ : "memory");@@ -54,7 +54,7 @@ static inline void flush_xen_data_tlb(void) { registerunsigned long r0 asm ("r0" ); asmvolatile ("dsb;" /* Ensure preceding are visible */ - STORE_CP32(0, TLBIALLH) + STORE_CP32(0, TLBIALLHIS) "dsb;" /* Ensure completion of the TLB flush */ "isb;" : : "r" (r0) /* dummy */: "memory");
xen/include/asm-arm/arm32/page.h static inline void flush_xen_data_tlb_range_va(unsigned long va, unsigned long s · line 75
Quoted 8 lines
xen/include/asm-arm/arm32/page.h +1
-1@@ -69,7 +69,7 @@ static inline void flush_xen_data_tlb_range_va(unsigned long va, unsigned long sunsigned long end = va + size;dsb ();/* Ensure preceding are visible */ while ( va < end ) { - asm volatile(STORE_CP32(0, TLBIMVAH) + asm volatile(STORE_CP32(0, TLBIMVAHIS) : : "r" (va) : "memory"); va += PAGE_SIZE; }
That's OK for actual Xen data mappings, map_domain_page() &c., but now set_fixmap() and clear_fixmap() need to use a stronger flush whenever they map device memory. The same goes for create_xen_entries() when ai != WRITEALLOC.
Quoted 14 lines
xen/include/asm-arm/arm64/flushtlb.h +1
-1@@ -6,7 +6,7 @@ static inline void flush_tlb_local(void) { asmvolatile ("dsb sy;" -"tlbi vmalle1;" +"tlbi vmalle1is;" "dsb sy;" "isb;" : : :"memory" );
xen/include/asm-arm/arm64/flushtlb.h static inline void flush_tlb_all_local(void) · line 23
Quoted 8 lines
xen/include/asm-arm/arm64/flushtlb.h +1
-1@@ -17,7 +17,7 @@ static inline void flush_tlb_all_local(void) { asmvolatile ("dsb sy;" -"tlbi alle1;" +"tlbi alle1is;" "dsb sy;" "isb;" : : :"memory" );
Might these need to be stronger if we're using them on context switch and guests have MMIO/outer-shareable mappings?
Tim.
Re: [PATCH 03/10] xen: arm: reduce instruction cache and tlb flushes to inner-shareable.
Quoted 34 lines · Tim Deegan
Quoted 33 lines · Ian Campbell
Now that Xen maps memory and performs pagetable walks as inner shareable we don't need to push updates down so far when modifying page tables etc.
Signed-off-by Ian Campbell <[email protected]>xen/include/asm-arm/arm32/page.h +4
-4@@ -39,8 +39,8 @@ static inline void flush_xen_text_tlb(void) asmvolatile ("isb;" /* Ensure synchronization with previous changes to text */ STORE_CP32(0, TLBIALLH) /* Flush hypervisor TLB */ - STORE_CP32(0, ICIALLU) /* Flush I-cache */ - STORE_CP32(0, BPIALL) /* Flush branch predictor */ + STORE_CP32(0, ICIALLUIS) /* Flush I-cache */ + STORE_CP32(0, BPIALLIS) /* Flush branch predictor */ "dsb;" /* Ensure completion of TLB+BP flush */ "isb;" : : "r" (r0) /*dummy*/ : "memory");@@ -54,7 +54,7 @@ static inline void flush_xen_data_tlb(void) { registerunsigned long r0 asm ("r0" ); asmvolatile ("dsb;" /* Ensure preceding are visible */ - STORE_CP32(0, TLBIALLH) + STORE_CP32(0, TLBIALLHIS) "dsb;" /* Ensure completion of the TLB flush */ "isb;" : : "r" (r0) /* dummy */: "memory");@@ -69,7 +69,7 @@ static inline void flush_xen_data_tlb_range_va(unsigned long va, unsigned long sunsigned long end = va + size;dsb ();/* Ensure preceding are visible */ while ( va < end ) { - asm volatile(STORE_CP32(0, TLBIMVAH) + asm volatile(STORE_CP32(0, TLBIMVAHIS)
Quoted 8 lines
xen/include/asm-arm/arm32/page.h static inline void flush_xen_data_tlb_range_va(unsigned long va, unsigned long s · line 75
Quoted 3 lines
xen/include/asm-arm/arm32/page.h +0
-0: : "r" (va) : "memory"); va +=PAGE_SIZE ; }That's OK for actual Xen data mappings,
map_domain_page()&c., but nowset_fixmap()andclear_fixmap()need to use a stronger flush whenever they map device memory. The same goes forcreate_xen_entries()when ai != WRITEALLOC.
Ian has pointed out that this is actually making the flushes _stronger_ (and that in general the TLB flush operations need a bit of attention).
So I suggest that we drop the TLB-flush parts of this patch for now, and address that whole area separately. In the meantime, the cache-flush parts are Acked-by: Tim Deegan <[email protected]>.
Cheers,
Tim.
Re: [PATCH 03/10] xen: arm: reduce instruction cache and tlb flushes to inner-shareable.
Quoted 44 lines · Tim Deegan
Quoted 34 lines · Tim Deegan
Quoted 33 lines · Ian Campbell
Now that Xen maps memory and performs pagetable walks as inner shareable we don't need to push updates down so far when modifying page tables etc.
Signed-off-by Ian Campbell <[email protected]>xen/include/asm-arm/arm32/page.h +4
-4@@ -39,8 +39,8 @@ static inline void flush_xen_text_tlb(void) asmvolatile ("isb;" /* Ensure synchronization with previous changes to text */ STORE_CP32(0, TLBIALLH) /* Flush hypervisor TLB */ - STORE_CP32(0, ICIALLU) /* Flush I-cache */ - STORE_CP32(0, BPIALL) /* Flush branch predictor */ + STORE_CP32(0, ICIALLUIS) /* Flush I-cache */ + STORE_CP32(0, BPIALLIS) /* Flush branch predictor */ "dsb;" /* Ensure completion of TLB+BP flush */ "isb;" : : "r" (r0) /*dummy*/ : "memory");@@ -54,7 +54,7 @@ static inline void flush_xen_data_tlb(void) { registerunsigned long r0 asm ("r0" ); asmvolatile ("dsb;" /* Ensure preceding are visible */ - STORE_CP32(0, TLBIALLH) + STORE_CP32(0, TLBIALLHIS) "dsb;" /* Ensure completion of the TLB flush */ "isb;" : : "r" (r0) /* dummy */: "memory");@@ -69,7 +69,7 @@ static inline void flush_xen_data_tlb_range_va(unsigned long va, unsigned long sunsigned long end = va + size;dsb ();/* Ensure preceding are visible */ while ( va < end ) { - asm volatile(STORE_CP32(0, TLBIMVAH) + asm volatile(STORE_CP32(0, TLBIMVAHIS)Quoted 8 lines
xen/include/asm-arm/arm32/page.h static inline void flush_xen_data_tlb_range_va(unsigned long va, unsigned long s · line 75
Quoted 3 lines
xen/include/asm-arm/arm32/page.h +0
-0: : "r" (va) : "memory"); va +=PAGE_SIZE ; }That's OK for actual Xen data mappings,
map_domain_page()&c., but nowset_fixmap()andclear_fixmap()need to use a stronger flush whenever they map device memory. The same goes forcreate_xen_entries()when ai != WRITEALLOC.
Quoted 6 lines
Ian has pointed out that this is actually making the flushes _stronger_ (and that in general the TLB flush operations need a bit of attention).
So I suggest that we drop the TLB-flush parts of this patch for now, and address that whole area separately. In the meantime, the cache-flush parts are Acked-by: Tim Deegan <[email protected]>.
Wait, no - that made no sense. :) I retract the ack, and let's start again with the TLB-flush ops. I don't think anything else in this series relies on this patch.
Tim.
PATCH 4/10 xen: arm: consolidate barrier definitions
In reply to Ian CampbellThese are effectively identical on both 32- and 64-bit.
--- xen/include/asm-arm/arm32/system.h | 16 ---------------- xen/include/asm-arm/arm64/system.h | 17 ----------------- xen/include/asm-arm/system.h | 16 ++++++++++++++++ 3 files changed, 16 insertions(+), 33 deletions(-)
xen/include/asm-arm/arm32/system.h +0 -16
@@ -2,22 +2,6 @@#ifndef __ASM_ARM32_SYSTEM_H#define __ASM_ARM32_SYSTEM_H -#define sev () __asm__ __volatile__ ("sev" : : : "memory") -#define wfe () __asm__ __volatile__ ("wfe" : : : "memory") -#define wfi () __asm__ __volatile__ ("wfi" : : : "memory") - -#define isb () __asm__ __volatile__ ("isb" : : : "memory") -#define dsb () __asm__ __volatile__ ("dsb sy" : : : "memory") -#define dmb () __asm__ __volatile__ ("dmb sy" : : : "memory") - -#define mb () dsb() -#define rmb () dsb() -#define wmb () mb() - -#define smp_mb () mb() -#define smp_rmb () rmb() -#define smp_wmb () wmb() -extern void __bad_xchg (volatile void *,int );static inline unsigned long __xchg (unsigned long x,volatile void *ptr,int size)
xen/include/asm-arm/arm64/system.h +0 -17
@@ -2,23 +2,6 @@#ifndef __ASM_ARM64_SYSTEM_H#define __ASM_ARM64_SYSTEM_H -#define sev () asm volatile("sev" : : : "memory") -#define wfe () asm volatile("wfe" : : : "memory") -#define wfi () asm volatile("wfi" : : : "memory") - -#define isb () asm volatile("isb" : : : "memory") -#define dsb () asm volatile("dsb sy" : : : "memory") -#define dmb () asm volatile("dmb sy" : : : "memory") - -#define mb () dsb() -#define rmb () dsb() -#define wmb () mb() - -#define smp_mb () mb() -#define smp_rmb () rmb() -#define smp_wmb () wmb() - -extern void __bad_xchg (volatile void *,int );static inline unsigned long __xchg (unsigned long x,volatile void *ptr,int size)
xen/include/asm-arm/system.h +16 -0
@@ -8,6 +8,22 @@#define nop () \ asm volatile ( "nop" ) +#define sev () asm volatile("sev" : : : "memory") +#define wfe () asm volatile("wfe" : : : "memory") +#define wfi () asm volatile("wfi" : : : "memory") + +#define isb () asm volatile("isb" : : : "memory") +#define dsb () asm volatile("dsb sy" : : : "memory") +#define dmb () asm volatile("dmb sy" : : : "memory") + +#define mb () dsb() +#define rmb () dsb() +#define wmb () mb() + +#define smp_mb () mb() +#define smp_rmb () rmb() +#define smp_wmb () wmb() +#define xchg (ptr,x) \ ((__typeof__(*(ptr)))__xchg((unsigned long)(x),(ptr),sizeof(*(ptr))))
Signature · 1 line
1.7.2.5
Re: [PATCH 04/10] xen: arm: consolidate barrier definitions
Quoted 3 lines · Ian Campbell
These are effectively identical on both 32- and 64-bit.
Signed-off-by Ian Campbell <[email protected]>
Quoted 90 lines
xen/include/asm-arm/arm32/system.h | 16 ---------------- xen/include/asm-arm/arm64/system.h | 17 ----------------- xen/include/asm-arm/system.h | 16 ++++++++++++++++ 3 files changed, 16 insertions(+), 33 deletions(-)xen/include/asm-arm/arm32/system.h +0
-16@@ -2,22 +2,6 @@#ifndef __ASM_ARM32_SYSTEM_H#define __ASM_ARM32_SYSTEM_H -#define sev () __asm__ __volatile__ ("sev" : : : "memory") -#define wfe () __asm__ __volatile__ ("wfe" : : : "memory") -#define wfi () __asm__ __volatile__ ("wfi" : : : "memory") - -#define isb () __asm__ __volatile__ ("isb" : : : "memory") -#define dsb () __asm__ __volatile__ ("dsb sy" : : : "memory") -#define dmb () __asm__ __volatile__ ("dmb sy" : : : "memory") - -#define mb () dsb() -#define rmb () dsb() -#define wmb () mb() - -#define smp_mb () mb() -#define smp_rmb () rmb() -#define smp_wmb () wmb() -extern void __bad_xchg (volatile void *,int );static inline unsigned long __xchg (unsigned long x,volatile void *ptr,int size)xen/include/asm-arm/arm64/system.h +0
-17@@ -2,23 +2,6 @@#ifndef __ASM_ARM64_SYSTEM_H#define __ASM_ARM64_SYSTEM_H -#define sev () asm volatile("sev" : : : "memory") -#define wfe () asm volatile("wfe" : : : "memory") -#define wfi () asm volatile("wfi" : : : "memory") - -#define isb () asm volatile("isb" : : : "memory") -#define dsb () asm volatile("dsb sy" : : : "memory") -#define dmb () asm volatile("dmb sy" : : : "memory") - -#define mb () dsb() -#define rmb () dsb() -#define wmb () mb() - -#define smp_mb () mb() -#define smp_rmb () rmb() -#define smp_wmb () wmb() - -extern void __bad_xchg (volatile void *,int );static inline unsigned long __xchg (unsigned long x,volatile void *ptr,int size)xen/include/asm-arm/system.h +16
-0@@ -8,6 +8,22 @@#define nop () \ asm volatile ( "nop" ) +#define sev () asm volatile("sev" : : : "memory") +#define wfe () asm volatile("wfe" : : : "memory") +#define wfi () asm volatile("wfi" : : : "memory") + +#define isb () asm volatile("isb" : : : "memory") +#define dsb () asm volatile("dsb sy" : : : "memory") +#define dmb () asm volatile("dmb sy" : : : "memory") + +#define mb () dsb() +#define rmb () dsb() +#define wmb () mb() + +#define smp_mb () mb() +#define smp_rmb () rmb() +#define smp_wmb () wmb() +#define xchg (ptr,x) \ ((__typeof__(*(ptr)))__xchg((unsigned long)(x),(ptr),sizeof(*(ptr))))Signature · 1 line
1.7.2.5
Re: [PATCH 04/10] xen: arm: consolidate barrier definitions
In reply to Ian CampbellQuoted 3 lines · Ian Campbell
These are effectively identical on both 32- and 64-bit.
Signed-off-by Ian Campbell <[email protected]>
PATCH 5/10 xen: use SMP barrier in common code dealing with shared memory protocols
In reply to Ian CampbellXen currently makes no strong distinction between the SMP barriers (smp_mb etc) and the regular barrier (mb etc). In Linux, where we inherited these names from having imported Linux code which uses them, the SMP barriers are intended to be sufficient for implementing shared-memory protocols between processors in an SMP system while the standard barriers are useful for MMIO etc.
On x86 with the stronger ordering model there is not much practical difference here but ARM has weaker barriers available which are suitable for use as SMP barriers.
Therefore ensure that common code uses the SMP barriers when that is all which is required.
On both ARM and x86 both types of barrier are currently identical so there is no actual change. A future patch will change smp_mb to a weaker barrier on ARM.
---
I'm not convinced some of these mb() couldn't actually be wmb(), but I didn't think to hard about this or make any changes along those lines.
--- xen/common/domain.c | 2 +- xen/common/domctl.c | 2 +- xen/common/grant_table.c | 4 ++-- xen/common/page_alloc.c | 2 +- xen/common/smp.c | 4 ++-- xen/common/spinlock.c | 6 +++--- xen/common/tmem_xen.c | 10 +++++----- xen/common/trace.c | 8 ++++---- xen/drivers/char/console.c | 2 +- xen/include/xen/event.h | 4 ++-- xen/xsm/flask/ss/sidtab.c | 4 ++-- 11 files changed, 24 insertions(+), 24 deletions(-)
xen/common/domain.c +1 -1
@@ -932,7 +932,7 @@ int map_vcpu_info(struct vcpu *v, unsigned long gfn, unsigned offset) v->vcpu_info_mfn =page_to_mfn (page);/* Set new vcpu_info pointer /before/ setting pending flags. */ -wmb (); +smp_wmb ();/* * Mark everything as being pending just to make sure nothing gets
xen/common/domctl.c +1 -1
@@ -533,7 +533,7 @@ long do_domctl(XEN_GUEST_HANDLE_PARAM(xen_domctl_t) u_domctl)/* Install vcpu array /then/ update max_vcpus. */ d->vcpu = vcpus; -wmb (); +smp_wmb (); d->max_vcpus = max; }
xen/common/grant_table.c +2 -2
@@ -426,7 +426,7 @@ static int _set_status_v2(domid_t domid,/* Make sure guest sees status update before checking if flags are still valid */ -mb (); +smp_mb (); scombo.word = *(u32 *)shah;barrier ();
@@ -1670,7 +1670,7 @@ gnttab_transfer(guest_physmap_add_page (e, sha->full_page.frame, mfn,0 ); sha->full_page.frame = mfn; } -wmb (); +smp_wmb ();shared_entry_header (e->grant_table, gop.ref)->flags |= GTF_transfer_completed;
xen/common/page_alloc.c +1 -1
@@ -1472,7 +1472,7 @@ int assign_pages(ASSERT (page_get_owner (&pg[i]) ==NULL );ASSERT ((pg[i].count_info & ~(PGC_allocated |1 )) ==0 );page_set_owner (&pg[i], d); -wmb ();/* Domain pointer must be visible before updating refcnt. */ +smp_wmb ();/* Domain pointer must be visible before updating refcnt. */ pg[i].count_info = PGC_allocated |1 ;page_list_add_tail (&pg[i], &d->page_list); }
xen/common/smp.c +2 -2
@@ -89,12 +89,12 @@ void smp_call_function_interrupt(void)if ( call_data.wait ) { (*func)(info); -mb (); +smp_mb ();cpumask_clear_cpu (cpu, &call_data.selected); }else { -mb (); +smp_mb ();cpumask_clear_cpu (cpu, &call_data.selected); (*func)(info); }
xen/common/spinlock.c +3 -3
@@ -218,7 +218,7 @@ void _spin_barrier(spinlock_t *lock)u64 loop =0 ;check_barrier (&lock->debug); -do {mb (); loop++;}while (_raw_spin_is_locked (&lock->raw) ); +do {smp_mb (); loop++;}while (_raw_spin_is_locked (&lock->raw) );if ((loop >1 ) && lock->profile) { lock->profile->time_block +=NOW () - block;
@@ -226,9 +226,9 @@ void _spin_barrier(spinlock_t *lock) }#else check_barrier (&lock->debug); -do {mb (); }while (_raw_spin_is_locked (&lock->raw) ); +do {smp_mb (); }while (_raw_spin_is_locked (&lock->raw) );#endif -mb (); +smp_mb (); }int _spin_trylock_recursive (spinlock_t *lock)
xen/common/tmem_xen.c +5 -5
@@ -173,7 +173,7 @@ EXPORT int tmh_copy_from_client(pfp_t *pfp,return -EFAULT ; } } -mb (); +smp_mb ();if ( len ==PAGE_SIZE && !tmem_offset && !pfn_offset && cli_va )tmh_copy_page (tmem_va, cli_va); else if ( (tmem_offset+len <= PAGE_SIZE) &&
@@ -216,7 +216,7 @@ EXPORT int tmh_compress_from_client(tmem_cli_mfn_t cmfn,return 0 ; else if ( copy_from_guest(scratch, clibuf, PAGE_SIZE) ) return -EFAULT; -mb (); +smp_mb (); ret =lzo1x_1_compress (cli_va ?: scratch,PAGE_SIZE , dmem, out_len, wmem);ASSERT (ret ==LZO_E_OK ); *out_va = dmem;
@@ -260,7 +260,7 @@ EXPORT int tmh_copy_to_client(tmem_cli_mfn_t cmfn, pfp_t *pfp,unmap_domain_page (tmem_va);if ( cli_va )cli_put_page (cli_va, cli_pfp, cli_mfn,1 ); -mb (); +smp_mb ();return rc; }
@@ -289,7 +289,7 @@ EXPORT int tmh_decompress_to_client(tmem_cli_mfn_t cmfn, void *tmem_va,cli_put_page (cli_va, cli_pfp, cli_mfn,1 ); else if ( copy_to_guest(clibuf, scratch, PAGE_SIZE) ) return -EFAULT; -mb (); +smp_mb ();return 1 ; }
@@ -311,7 +311,7 @@ EXPORT int tmh_copy_tze_to_client(tmem_cli_mfn_t cmfn, void *tmem_va,if ( len <PAGE_SIZE )memset ((char *)cli_va+len,0 ,PAGE_SIZE -len);cli_put_page (cli_va, cli_pfp, cli_mfn,1 ); -mb (); +smp_mb ();return 1 ; }
xen/common/trace.c +4 -4
@@ -255,7 +255,7 @@ static int alloc_trace_bufs(unsigned int pages) opt_tbuf_size = pages;printk ("xentrace: initialised\n" ); -wmb ();/* above must be visible before tb_init_done flag set */ +smp_wmb ();/* above must be visible before tb_init_done flag set */ tb_init_done =1 ;return 0 ;
@@ -414,7 +414,7 @@ int tb_control(xen_sysctl_tbuf_op_t *tbc)int i; tb_init_done =0 ; -wmb (); +smp_wmb ();/* Clear any lost-record info so we don't get phantom lost records next time we * start tracing. Grab the lock to make sure we're not racing anyone. After this * hypercall returns, no more records should be placed into the buffers. */
@@ -607,7 +607,7 @@ static inline void __insert_record(struct t_buf *buf,memcpy (next_page, (char *)rec + remaining, rec_size - remaining); } -wmb (); +smp_wmb (); next += rec_size;if ( next >=2 *data_size )
@@ -718,7 +718,7 @@ void __trace_var(u32 event, bool_t cycles, unsigned int extra,return ;/* Read tb_init_done /before/ t_bufs. */ -rmb (); +smp_rmb ();spin_lock_irqsave (&this_cpu (t_lock), flags);
xen/drivers/char/console.c +1 -1
@@ -648,7 +648,7 @@ void __init console_init_postirq(void)for ( i = conringc ; i != conringp; i++ ) ring[i & (opt_conring_size -1 )] = conring[i & (conring_size -1 )]; conring = ring; -wmb ();/* Allow users of console_force_unlock() to see larger buffer. */ +smp_wmb ();/* Allow users of console_force_unlock() to see larger buffer. */ conring_size = opt_conring_size;spin_unlock_irq (&console_lock);
xen/include/xen/event.h +2 -2
@@ -85,7 +85,7 @@ void notify_via_xen_event_channel(struct domain *ld, int lport);if ( condition ) \break ; \set_bit (_VPF_blocked_in_xen, ¤t->pause_flags); \ -mb ();/* set blocked status /then/ re-evaluate condition */ \ +smp_mb ();/* set blocked status /then/ re-evaluate condition */ \if ( condition ) \ { \clear_bit (_VPF_blocked_in_xen, ¤t->pause_flags); \
@@ -99,7 +99,7 @@ void notify_via_xen_event_channel(struct domain *ld, int lport);do { \set_bit (_VPF_blocked_in_xen, ¤t->pause_flags); \raise_softirq (SCHEDULE_SOFTIRQ ); \ -mb ();/* set blocked status /then/ caller does his work */ \ +smp_mb ();/* set blocked status /then/ caller does his work */ \ } while ( 0 )#endif /* __XEN_EVENT_H__ */
xen/xsm/flask/ss/sidtab.c +2 -2
@@ -79,13 +79,13 @@ int sidtab_insert(struct sidtab *s, u32 sid, struct context *context)if ( prev ) { newnode->next = prev->next; -wmb (); +smp_wmb (); prev->next = newnode; }else { newnode->next = s->htable[hvalue]; -wmb (); +smp_wmb (); s->htable[hvalue] = newnode; }
Signature · 1 line
1.7.2.5
Re: [PATCH 05/10] xen: use SMP barrier in common code dealing with shared memory protocols
Quoted 14 lines · Ian Campbell
Xen currently makes no strong distinction between the SMP barriers (
smp_mbetc) and the regular barrier (mb etc). In Linux, where we inherited these names from having imported Linux code which uses them, the SMP barriers are intended to be sufficient for implementing shared-memory protocols between processors in an SMP system while the standard barriers are useful for MMIO etc.On x86 with the stronger ordering model there is not much practical difference here but ARM has weaker barriers available which are suitable for use as SMP barriers.
Therefore ensure that common code uses the SMP barriers when that is all which is required.
Quoted 6 lines
On both ARM and x86 both types of barrier are currently identical so there is no actual change. A future patch will change
smp_mbto a weaker barrier on ARM.Signed-off-by Ian Campbell <[email protected]>
I knew something was up here, and double checked "eu" vs "ue", but failed to notice the entire missing letter. Sorry Jan. CC line corrected.
Quoted 267 lines
---
I'm not convinced some of thesemb()couldn't actually bewmb(), but I didn't think to hard about this or make any changes along those lines.--- xen/common/domain.c | 2 +- xen/common/domctl.c | 2 +- xen/common/grant_table.c | 4 ++-- xen/common/page_alloc.c | 2 +- xen/common/smp.c | 4 ++-- xen/common/spinlock.c | 6 +++--- xen/common/tmem_xen.c | 10 +++++----- xen/common/trace.c | 8 ++++---- xen/drivers/char/console.c | 2 +- xen/include/xen/event.h | 4 ++-- xen/xsm/flask/ss/sidtab.c | 4 ++-- 11 files changed, 24 insertions(+), 24 deletions(-)xen/common/domain.c +1
-1@@ -932,7 +932,7 @@ int map_vcpu_info(struct vcpu *v, unsigned long gfn, unsigned offset) v->vcpu_info_mfn =page_to_mfn (page);/* Set new vcpu_info pointer /before/ setting pending flags. */ -wmb (); +smp_wmb ();/* * Mark everything as being pending just to make sure nothing gets xen/common/domctl.c +1
-1@@ -533,7 +533,7 @@ long do_domctl(XEN_GUEST_HANDLE_PARAM(xen_domctl_t) u_domctl)/* Install vcpu array /then/ update max_vcpus. */ d->vcpu = vcpus; -wmb (); +smp_wmb (); d->max_vcpus = max; }xen/common/grant_table.c +2
-2@@ -426,7 +426,7 @@ static int _set_status_v2(domid_t domid,/* Make sure guest sees status update before checking if flags are still valid */ -mb (); +smp_mb (); scombo.word = *(u32 *)shah;barrier ();@@ -1670,7 +1670,7 @@ gnttab_transfer(guest_physmap_add_page (e, sha->full_page.frame, mfn,0 ); sha->full_page.frame = mfn; } -wmb (); +smp_wmb ();shared_entry_header (e->grant_table, gop.ref)->flags |= GTF_transfer_completed;xen/common/page_alloc.c +1
-1@@ -1472,7 +1472,7 @@ int assign_pages(ASSERT (page_get_owner (&pg[i]) ==NULL );ASSERT ((pg[i].count_info & ~(PGC_allocated |1 )) ==0 );page_set_owner (&pg[i], d); -wmb ();/* Domain pointer must be visible before updating refcnt. */ +smp_wmb ();/* Domain pointer must be visible before updating refcnt. */ pg[i].count_info = PGC_allocated |1 ;page_list_add_tail (&pg[i], &d->page_list); }xen/common/smp.c +2
-2@@ -89,12 +89,12 @@ void smp_call_function_interrupt(void)if ( call_data.wait ) { (*func)(info); -mb (); +smp_mb ();cpumask_clear_cpu (cpu, &call_data.selected); }else { -mb (); +smp_mb ();cpumask_clear_cpu (cpu, &call_data.selected); (*func)(info); }xen/common/spinlock.c +3
-3@@ -218,7 +218,7 @@ void _spin_barrier(spinlock_t *lock)u64 loop =0 ;check_barrier (&lock->debug); -do {mb (); loop++;}while (_raw_spin_is_locked (&lock->raw) ); +do {smp_mb (); loop++;}while (_raw_spin_is_locked (&lock->raw) );if ((loop >1 ) && lock->profile) { lock->profile->time_block +=NOW () - block;@@ -226,9 +226,9 @@ void _spin_barrier(spinlock_t *lock) }#else check_barrier (&lock->debug); -do {mb (); }while (_raw_spin_is_locked (&lock->raw) ); +do {smp_mb (); }while (_raw_spin_is_locked (&lock->raw) );#endif -mb (); +smp_mb (); }int _spin_trylock_recursive (spinlock_t *lock)xen/common/tmem_xen.c +5
-5@@ -173,7 +173,7 @@ EXPORT int tmh_copy_from_client(pfp_t *pfp,return -EFAULT ; } } -mb (); +smp_mb ();if ( len ==PAGE_SIZE && !tmem_offset && !pfn_offset && cli_va )tmh_copy_page (tmem_va, cli_va); else if ( (tmem_offset+len <= PAGE_SIZE) &&@@ -216,7 +216,7 @@ EXPORT int tmh_compress_from_client(tmem_cli_mfn_t cmfn,return 0 ; else if ( copy_from_guest(scratch, clibuf, PAGE_SIZE) ) return -EFAULT; -mb (); +smp_mb (); ret =lzo1x_1_compress (cli_va ?: scratch,PAGE_SIZE , dmem, out_len, wmem);ASSERT (ret ==LZO_E_OK ); *out_va = dmem;@@ -260,7 +260,7 @@ EXPORT int tmh_copy_to_client(tmem_cli_mfn_t cmfn, pfp_t *pfp,unmap_domain_page (tmem_va);if ( cli_va )cli_put_page (cli_va, cli_pfp, cli_mfn,1 ); -mb (); +smp_mb ();return rc; }@@ -289,7 +289,7 @@ EXPORT int tmh_decompress_to_client(tmem_cli_mfn_t cmfn, void *tmem_va,cli_put_page (cli_va, cli_pfp, cli_mfn,1 ); else if ( copy_to_guest(clibuf, scratch, PAGE_SIZE) ) return -EFAULT; -mb (); +smp_mb ();return 1 ; }@@ -311,7 +311,7 @@ EXPORT int tmh_copy_tze_to_client(tmem_cli_mfn_t cmfn, void *tmem_va,if ( len <PAGE_SIZE )memset ((char *)cli_va+len,0 ,PAGE_SIZE -len);cli_put_page (cli_va, cli_pfp, cli_mfn,1 ); -mb (); +smp_mb ();return 1 ; }xen/common/trace.c +4
-4@@ -255,7 +255,7 @@ static int alloc_trace_bufs(unsigned int pages) opt_tbuf_size = pages;printk ("xentrace: initialised\n" ); -wmb ();/* above must be visible before tb_init_done flag set */ +smp_wmb ();/* above must be visible before tb_init_done flag set */ tb_init_done =1 ;return 0 ;@@ -414,7 +414,7 @@ int tb_control(xen_sysctl_tbuf_op_t *tbc)int i; tb_init_done =0 ; -wmb (); +smp_wmb ();/* Clear any lost-record info so we don't get phantom lost records next time we * start tracing. Grab the lock to make sure we're not racing anyone. After this * hypercall returns, no more records should be placed into the buffers. */ @@ -607,7 +607,7 @@ static inline void __insert_record(struct t_buf *buf,memcpy (next_page, (char *)rec + remaining, rec_size - remaining); } -wmb (); +smp_wmb (); next += rec_size;if ( next >=2 *data_size )@@ -718,7 +718,7 @@ void __trace_var(u32 event, bool_t cycles, unsigned int extra,return ;/* Read tb_init_done /before/ t_bufs. */ -rmb (); +smp_rmb ();spin_lock_irqsave (&this_cpu (t_lock), flags);xen/drivers/char/console.c +1
-1@@ -648,7 +648,7 @@ void __init console_init_postirq(void)for ( i = conringc ; i != conringp; i++ ) ring[i & (opt_conring_size -1 )] = conring[i & (conring_size -1 )]; conring = ring; -wmb ();/* Allow users of console_force_unlock() to see larger buffer. */ +smp_wmb ();/* Allow users of console_force_unlock() to see larger buffer. */ conring_size = opt_conring_size;spin_unlock_irq (&console_lock);xen/include/xen/event.h +2
-2@@ -85,7 +85,7 @@ void notify_via_xen_event_channel(struct domain *ld, int lport);if ( condition ) \break ; \set_bit (_VPF_blocked_in_xen, ¤t->pause_flags); \ -mb ();/* set blocked status /then/ re-evaluate condition */ \ +smp_mb ();/* set blocked status /then/ re-evaluate condition */ \if ( condition ) \ { \clear_bit (_VPF_blocked_in_xen, ¤t->pause_flags); \@@ -99,7 +99,7 @@ void notify_via_xen_event_channel(struct domain *ld, int lport);do { \set_bit (_VPF_blocked_in_xen, ¤t->pause_flags); \raise_softirq (SCHEDULE_SOFTIRQ ); \ -mb ();/* set blocked status /then/ caller does his work */ \ +smp_mb ();/* set blocked status /then/ caller does his work */ \ } while ( 0 )#endif /* __XEN_EVENT_H__ */ xen/xsm/flask/ss/sidtab.c +2
-2@@ -79,13 +79,13 @@ int sidtab_insert(struct sidtab *s, u32 sid, struct context *context)if ( prev ) { newnode->next = prev->next; -wmb (); +smp_wmb (); prev->next = newnode; }else { newnode->next = s->htable[hvalue]; -wmb (); +smp_wmb (); s->htable[hvalue] = newnode; }
Re: [PATCH 05/10] xen: use SMP barrier in common code dealing with shared memory protocols
In reply to Ian CampbellQuoted 14 lines · Ian Campbell
Xen currently makes no strong distinction between the SMP barriers (
smp_mbetc) and the regular barrier (mb etc). In Linux, where we inherited these names from having imported Linux code which uses them, the SMP barriers are intended to be sufficient for implementing shared-memory protocols between processors in an SMP system while the standard barriers are useful for MMIO etc.On x86 with the stronger ordering model there is not much practical difference here but ARM has weaker barriers available which are suitable for use as SMP barriers.
Therefore ensure that common code uses the SMP barriers when that is all which is required.
Quoted 8 lines
On both ARM and x86 both types of barrier are currently identical so there is no actual change. A future patch will change
smp_mbto a weaker barrier on ARM.---
Quoted 2 lines
I'm not convinced some of these
mb()couldn't actually bewmb(), but I didn't think to hard about this or make any changes along those lines.
Would logically be a separate patch anyway.
-- Keir
Quoted 278 lines
--- xen/common/domain.c | 2 +- xen/common/domctl.c | 2 +- xen/common/grant_table.c | 4 ++-- xen/common/page_alloc.c | 2 +- xen/common/smp.c | 4 ++-- xen/common/spinlock.c | 6 +++--- xen/common/tmem_xen.c | 10 +++++----- xen/common/trace.c | 8 ++++---- xen/drivers/char/console.c | 2 +- xen/include/xen/event.h | 4 ++-- xen/xsm/flask/ss/sidtab.c | 4 ++-- 11 files changed, 24 insertions(+), 24 deletions(-)xen/common/domain.c +1
-1@@ -932,7 +932,7 @@ int map_vcpu_info(struct vcpu *v, unsigned long gfn, unsigned offset) v->vcpu_info_mfn = page_to_mfn(page);/* Set new vcpu_info pointer /before/ setting pending flags. */ -wmb (); +smp_wmb ();/* * Mark everything as being pending just to make sure nothing gets
xen/common/domctl.c +1
-1@@ -533,7 +533,7 @@ long do_domctl(XEN_GUEST_HANDLE_PARAM(xen_domctl_t) u_domctl)/* Install vcpu array /then/ update max_vcpus. */ d->vcpu = vcpus; -wmb (); +smp_wmb (); d->max_vcpus = max; }xen/common/grant_table.c +2
-2@@ -426,7 +426,7 @@ static int _set_status_v2(domid_t domid,/* Make sure guest sees status update before checking if flags are still valid */ -mb (); +smp_mb (); scombo.word = *(u32 *)shah;barrier ();@@ -1670,7 +1670,7 @@ gnttab_transfer(guest_physmap_add_page (e, sha->full_page.frame, mfn,0 ); sha->full_page.frame = mfn; } -wmb (); +smp_wmb ();shared_entry_header (e->grant_table, gop.ref)->flags |= GTF_transfer_completed;xen/common/page_alloc.c +1
-1@@ -1472,7 +1472,7 @@ int assign_pages(ASSERT (page_get_owner (&pg[i]) ==NULL );ASSERT ((pg[i].count_info & ~(PGC_allocated |1 )) ==0 );page_set_owner (&pg[i], d); -wmb(); /* Domain pointer must be visible before updating refcnt. */ +smp_wmb ();/* Domain pointer must be visible before updating refcnt. */ pg[i].count_info = PGC_allocated |1 ;page_list_add_tail (&pg[i], &d->page_list);}xen/common/smp.c +2
-2@@ -89,12 +89,12 @@ void smp_call_function_interrupt(void)if ( call_data.wait ) { (*func)(info); -mb (); +smp_mb ();cpumask_clear_cpu (cpu, &call_data.selected); }else { -mb (); +smp_mb ();cpumask_clear_cpu (cpu, &call_data.selected); (*func)(info); }xen/common/spinlock.c +3
-3@@ -218,7 +218,7 @@ void _spin_barrier(spinlock_t *lock)u64 loop =0 ;check_barrier (&lock->debug); -do {mb (); loop++;}while (_raw_spin_is_locked (&lock->raw) ); +do {smp_mb (); loop++;}while (_raw_spin_is_locked (&lock->raw) );if ((loop >1 ) && lock->profile) { lock->profile->time_block +=NOW () - block;@@ -226,9 +226,9 @@ void _spin_barrier(spinlock_t *lock) }#else check_barrier (&lock->debug); -do {mb (); }while (_raw_spin_is_locked (&lock->raw) ); +do {smp_mb (); }while (_raw_spin_is_locked (&lock->raw) );#endif -mb (); +smp_mb (); }int _spin_trylock_recursive (spinlock_t *lock)xen/common/tmem_xen.c +2
-2@@ -173,7 +173,7 @@ EXPORT int tmh_copy_from_client(pfp_t *pfp,return -EFAULT ; } } -mb (); +smp_mb ();if ( len ==PAGE_SIZE && !tmem_offset && !pfn_offset && cli_va )tmh_copy_page (tmem_va, cli_va); else if ( (tmem_offset+len <= PAGE_SIZE) &&@@ -216,7 +216,7 @@ EXPORT int tmh_compress_from_client(tmem_cli_mfn_t cmfn,return 0 ; else if ( copy_from_guest(scratch, clibuf, PAGE_SIZE) ) return -EFAULT; -mb (); +smp_mb (); ret =lzo1x_1_compress (cli_va ?: scratch,PAGE_SIZE , dmem, out_len, wmem);ASSERT (ret ==LZO_E_OK );*out_va = dmem;xen/common/tmem_xen.c +3
-3@@ -260,7 +260,7 @@ EXPORT int tmh_copy_to_client(tmem_cli_mfn_t cmfn, pfp_t *pfp,unmap_domain_page (tmem_va);if ( cli_va )cli_put_page (cli_va, cli_pfp, cli_mfn,1 ); -mb (); +smp_mb ();return rc; }@@ -289,7 +289,7 @@ EXPORT int tmh_decompress_to_client(tmem_cli_mfn_t cmfn,void *tmem_va, cli_put_page(cli_va, cli_pfp, cli_mfn, 1); else if ( copy_to_guest(clibuf, scratch, PAGE_SIZE) ) return -EFAULT; -mb (); +smp_mb ();return 1 ; }@@ -311,7 +311,7 @@ EXPORT int tmh_copy_tze_to_client(tmem_cli_mfn_t cmfn, void *tmem_va, if ( len < PAGE_SIZE ) memset((char *)cli_va+len,0,PAGE_SIZE-len);cli_put_page (cli_va, cli_pfp, cli_mfn,1 ); -mb (); +smp_mb ();return 1 ; }xen/common/trace.c +2
-2@@ -255,7 +255,7 @@ static int alloc_trace_bufs(unsigned int pages) opt_tbuf_size = pages;printk ("xentrace: initialised\n" ); -wmb ();/* above must be visible before tb_init_done flag set */ +smp_wmb ();/* above must be visible before tb_init_done flag set */ tb_init_done =1 ;return 0 ;@@ -414,7 +414,7 @@ int tb_control(xen_sysctl_tbuf_op_t *tbc)int i; tb_init_done =0 ; -wmb (); +smp_wmb ();/* Clear any lost-record info so we don't get phantom lost records next time we
* start tracing. Grab the lock to make sure we're not racing
anyone. After this
* hypercall returns, no more records should be placed into the
buffers. */xen/common/trace.c +2
-2@@ -607,7 +607,7 @@ static inline void __insert_record(struct t_buf *buf,memcpy (next_page, (char *)rec + remaining, rec_size - remaining); } -wmb (); +smp_wmb (); next += rec_size;if ( next >=2 *data_size )@@ -718,7 +718,7 @@ void __trace_var(u32 event, bool_t cycles, unsigned int extra, return;/* Read tb_init_done /before/ t_bufs. */ -rmb (); +smp_rmb ();spin_lock_irqsave (&this_cpu (t_lock), flags);xen/drivers/char/console.c +1
-1@@ -648,7 +648,7 @@ void __init console_init_postirq(void)for ( i = conringc ; i != conringp; i++ ) ring[i & (opt_conring_size -1 )] = conring[i & (conring_size -1 )]; conring = ring; -wmb(); /* Allow users of console_force_unlock() to see larger buffer. */ +smp_wmb ();/* Allow users of console_force_unlock() to see larger buffer. */ conring_size = opt_conring_size;spin_unlock_irq (&console_lock);xen/include/xen/event.h +1
-1@@ -85,7 +85,7 @@ void notify_via_xen_event_channel(struct domain *ld, int lport);if ( condition ) \break ; \set_bit (_VPF_blocked_in_xen, ¤t->pause_flags); \ -mb ();/* set blocked status /then/ re-evaluate condition */ \ +smp_mb ();/* set blocked status /then/ re-evaluate condition */ \if ( condition ) \ { \clear_bit(_VPF_blocked_in_xen, ¤t->pause_flags); \xen/include/xen/event.h +1
-1@@ -99,7 +99,7 @@ void notify_via_xen_event_channel(struct domain *ld, int lport);do { \set_bit (_VPF_blocked_in_xen, ¤t->pause_flags); \raise_softirq (SCHEDULE_SOFTIRQ ); \ -mb ();/* set blocked status /then/ caller does his work */ \ +smp_mb ();/* set blocked status /then/ caller does his work */ \ }while (0 )#endif /*
__XEN_EVENT_H__*/xen/xsm/flask/ss/sidtab.c +2
-2@@ -79,13 +79,13 @@ int sidtab_insert(struct sidtab *s, u32 sid, struct context *context) if ( prev ) { newnode->next = prev->next; -wmb (); +smp_wmb (); prev->next = newnode; } else { newnode->next = s->htable[hvalue]; -wmb (); +smp_wmb (); s->htable[hvalue] = newnode; }
Re: [PATCH 05/10] xen: use SMP barrier in common code dealing with shared memory protocols
In reply to Ian CampbellQuoted 11 lines · Ian Campbell
Xen currently makes no strong distinction between the SMP barriers (
smp_mbetc) and the regular barrier (mb etc). In Linux, where we inherited these names from having imported Linux code which uses them, the SMP barriers are intended to be sufficient for implementing shared-memory protocols between processors in an SMP system while the standard barriers are useful for MMIO etc.On x86 with the stronger ordering model there is not much practical difference here but ARM has weaker barriers available which are suitable for use as SMP barriers.
Quoted 8 lines
Therefore ensure that common code uses the SMP barriers when that is all which is required.
On both ARM and x86 both types of barrier are currently identical so there is no actual change. A future patch will change
smp_mbto a weaker barrier on ARM.Signed-off-by Ian Campbell <[email protected]>
PATCH 6/10 xen: arm: Use SMP barriers when that is all which is required.
In reply to Ian CampbellAs explained in the previous commit SMP barriers can be used when all we care about is synchronising against other processors.
--- xen/arch/arm/mm.c | 2 +- xen/arch/arm/smpboot.c | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-)
xen/arch/arm/mm.c +1 -1
@@ -776,7 +776,7 @@ void share_xen_page_with_guest(struct page_info *page, page->u.inuse.type_info |= PGT_validated |1 ;page_set_owner (page, d); -wmb ();/* install valid domain ptr before updating refcnt. */ +smp_wmb ();/* install valid domain ptr before updating refcnt. */ ASSERT ((page->count_info & ~PGC_xen_heap) ==0 );/* Only add to the allocation list if the domain isn't dying. */
xen/arch/arm/smpboot.c +2 -2
@@ -170,11 +170,11 @@ void __cpuinit start_secondary(unsigned long boot_phys_offset,/* Run local notifiers */ notify_cpu_starting (cpuid); -wmb (); +smp_wmb ();/* Now report this CPU is up */ cpumask_set_cpu (cpuid, &cpu_online_map); -wmb (); +smp_wmb ();local_irq_enable ();
Signature · 1 line
1.7.2.5
Re: [PATCH 06/10] xen: arm: Use SMP barriers when that is all which is required.
Quoted 29 lines · Ian Campbell
As explained in the previous commit SMP barriers can be used when all we care about is synchronising against other processors.
Signed-off-by Ian Campbell <[email protected]>--- xen/arch/arm/mm.c | 2 +- xen/arch/arm/smpboot.c | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-)xen/arch/arm/mm.c +1
-1@@ -776,7 +776,7 @@ void share_xen_page_with_guest(struct page_info *page, page->u.inuse.type_info |= PGT_validated |1 ;page_set_owner (page, d); -wmb ();/* install valid domain ptr before updating refcnt. */ +smp_wmb ();/* install valid domain ptr before updating refcnt. */ ASSERT ((page->count_info & ~PGC_xen_heap) ==0 );/* Only add to the allocation list if the domain isn't dying. */ xen/arch/arm/smpboot.c +0
-0@@ -170,11 +170,11 @@ void __cpuinit start_secondary(unsigned long boot_phys_offset,/* Run local notifiers */
xen/arch/arm/smpboot.c void __cpuinit start_secondary(unsigned long boot_phys_offset, · line 179
Quoted 10 lines
xen/arch/arm/smpboot.c +2
-2notify_cpu_starting (cpuid); -wmb (); +smp_wmb ();/* Now report this CPU is up */ cpumask_set_cpu (cpuid, &cpu_online_map); -wmb (); +smp_wmb ();local_irq_enable ();
Did you missed few mb() in smpboot.c?
Re: [PATCH 06/10] xen: arm: Use SMP barriers when that is all which is required.
Quoted 34 lines · Stefano Stabellini
Quoted 33 lines · Ian Campbell
As explained in the previous commit SMP barriers can be used when all we care about is synchronising against other processors.
Signed-off-by Ian Campbell <[email protected]>--- xen/arch/arm/mm.c | 2 +- xen/arch/arm/smpboot.c | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-)xen/arch/arm/mm.c +1
-1@@ -776,7 +776,7 @@ void share_xen_page_with_guest(struct page_info *page, page->u.inuse.type_info |= PGT_validated |1 ;page_set_owner (page, d); -wmb ();/* install valid domain ptr before updating refcnt. */ +smp_wmb ();/* install valid domain ptr before updating refcnt. */ ASSERT ((page->count_info & ~PGC_xen_heap) ==0 );/* Only add to the allocation list if the domain isn't dying. */ xen/arch/arm/smpboot.c +1
-1@@ -170,11 +170,11 @@ void __cpuinit start_secondary(unsigned long boot_phys_offset,/* Run local notifiers */ notify_cpu_starting (cpuid); -wmb (); +smp_wmb ();
Quoted 8 lines
xen/arch/arm/smpboot.c void __cpuinit start_secondary(unsigned long boot_phys_offset, · line 179
Quoted 6 lines
xen/arch/arm/smpboot.c +1
-1/* Now report this CPU is up */ cpumask_set_cpu (cpuid, &cpu_online_map); -wmb (); +smp_wmb ();local_irq_enable ();Did you missed few
mb()insmpboot.c?
The ones in __cpu_disable and __cpu_die?
I think I just wasn't 100% sure they might not be touching hardware (i.e. some platform register to shutdown a CPU) and since they weren't performance critical I punted on them.
Looking it again the first half of that logic seems to be bogus (that code goes nowhere near any peripheral).
Ian.
Tim Deegan
Acked-byRe: [PATCH 06/10] xen: arm: Use SMP barriers when that is all which is required.
Quoted 44 lines · Ian Campbell
Quoted 34 lines · Stefano Stabellini
Quoted 33 lines · Ian Campbell
As explained in the previous commit SMP barriers can be used when all we care about is synchronising against other processors.
Signed-off-by Ian Campbell <[email protected]>--- xen/arch/arm/mm.c | 2 +- xen/arch/arm/smpboot.c | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-)xen/arch/arm/mm.c +1
-1@@ -776,7 +776,7 @@ void share_xen_page_with_guest(struct page_info *page, page->u.inuse.type_info |= PGT_validated |1 ;page_set_owner (page, d); -wmb ();/* install valid domain ptr before updating refcnt. */ +smp_wmb ();/* install valid domain ptr before updating refcnt. */ ASSERT ((page->count_info & ~PGC_xen_heap) ==0 );/* Only add to the allocation list if the domain isn't dying. */ xen/arch/arm/smpboot.c +1
-1@@ -170,11 +170,11 @@ void __cpuinit start_secondary(unsigned long boot_phys_offset,/* Run local notifiers */ notify_cpu_starting (cpuid); -wmb (); +smp_wmb ();Quoted 8 lines
xen/arch/arm/smpboot.c void __cpuinit start_secondary(unsigned long boot_phys_offset, · line 179
Quoted 6 lines
xen/arch/arm/smpboot.c +1
-1/* Now report this CPU is up */ cpumask_set_cpu (cpuid, &cpu_online_map); -wmb (); +smp_wmb ();local_irq_enable ();Did you missed few
mb()insmpboot.c?
Quoted 8 lines
The ones in
__cpu_disableand__cpu_die?I think I just wasn't 100% sure they might not be touching hardware (i.e. some platform register to shutdown a CPU) and since they weren't performance critical I punted on them.
Looking it again the first half of that logic seems to be bogus (that code goes nowhere near any peripheral).
Yes, I think they can both be smp_mb(). With or without that change,
PATCH 7/10 xen: arm: Use dmb for smp barriers
In reply to Ian CampbellThe full power of dsb is not required in this context.
Also change wmb() to be dsb() directly instead of indirectly via mb(), for clarity.
--- xen/include/asm-arm/system.h | 8 ++++---- 1 files changed, 4 insertions(+), 4 deletions(-)
xen/include/asm-arm/system.h +4 -4
@@ -18,11 +18,11 @@#define mb () dsb()#define rmb () dsb() -#define wmb () mb() +#define wmb () dsb() -#define smp_mb () mb() -#define smp_rmb () rmb() -#define smp_wmb () wmb() +#define smp_mb () dmb() +#define smp_rmb () dmb() +#define smp_wmb () dmb()#define xchg (ptr,x) \ ((__typeof__(*(ptr)))__xchg((unsigned long)(x),(ptr),sizeof(*(ptr))))
Signature · 1 line
1.7.2.5
Re: [PATCH 07/10] xen: arm: Use dmb for smp barriers
Quoted 6 lines · Ian Campbell
The full power of dsb is not required in this context.
Also change
wmb()to bedsb()directly instead of indirectly viamb(), for clarity.Signed-off-by Ian Campbell <[email protected]>
Quoted 26 lines
xen/include/asm-arm/system.h | 8 ++++---- 1 files changed, 4 insertions(+), 4 deletions(-)xen/include/asm-arm/system.h +4
-4@@ -18,11 +18,11 @@#define mb () dsb()#define rmb () dsb() -#define wmb () mb() +#define wmb () dsb() -#define smp_mb () mb() -#define smp_rmb () rmb() -#define smp_wmb () wmb() +#define smp_mb () dmb() +#define smp_rmb () dmb() +#define smp_wmb () dmb()#define xchg (ptr,x) \ ((__typeof__(*(ptr)))__xchg((unsigned long)(x),(ptr),sizeof(*(ptr))))Signature · 1 line
1.7.2.5
Re: [PATCH 07/10] xen: arm: Use dmb for smp barriers
In reply to Ian CampbellQuoted 6 lines · Ian Campbell
The full power of dsb is not required in this context.
Also change
wmb()to bedsb()directly instead of indirectly viamb(), for clarity.Signed-off-by Ian Campbell <[email protected]>
PATCH 8/10 xen: arm: add scope to dsb and dmb macros
In reply to Ian CampbellEverywhere currently passes "sy"stem, so no actual change.
--- xen/arch/arm/domain.c | 2 +- xen/arch/arm/gic.c | 8 ++++---- xen/arch/arm/mm.c | 2 +- xen/arch/arm/platforms/vexpress.c | 6 +++--- xen/arch/arm/smpboot.c | 2 +- xen/arch/arm/time.c | 2 +- xen/drivers/video/arm_hdlcd.c | 2 +- xen/include/asm-arm/arm32/flushtlb.h | 8 ++++---- xen/include/asm-arm/arm32/io.h | 4 ++-- xen/include/asm-arm/arm32/page.h | 4 ++-- xen/include/asm-arm/arm64/io.h | 4 ++-- xen/include/asm-arm/arm64/page.h | 4 ++-- xen/include/asm-arm/page.h | 4 ++-- xen/include/asm-arm/system.h | 16 ++++++++-------- 14 files changed, 34 insertions(+), 34 deletions(-)
xen/arch/arm/domain.c +1 -1
@@ -44,7 +44,7 @@ void idle_loop(void)local_irq_disable ();if (cpu_is_haltable (smp_processor_id ()) ) { -dsb (); +dsb ("sy" );wfi (); }local_irq_enable ();
xen/arch/arm/gic.c +4 -4
@@ -432,7 +432,7 @@ void send_SGI_mask(const cpumask_t *cpumask, enum gic_sgi sgi)ASSERT (mask <0x100 );/* The target bitmap only supports 8 CPUs */ -dsb (); +dsb ("sy" );GICD [GICD_SGIR ] =GICD_SGI_TARGET_LIST | (mask<<GICD_SGI_TARGET_SHIFT )
@@ -449,7 +449,7 @@ void send_SGI_self(enum gic_sgi sgi) {ASSERT (sgi <16 );/* There are only 16 SGIs */ -dsb (); +dsb ("sy" );GICD [GICD_SGIR ] =GICD_SGI_TARGET_SELF | sgi;
@@ -459,7 +459,7 @@ void send_SGI_allbutself(enum gic_sgi sgi) {ASSERT (sgi <16 );/* There are only 16 SGIs */ -dsb (); +dsb ("sy" );GICD [GICD_SGIR ] =GICD_SGI_TARGET_OTHERS | sgi;
@@ -546,7 +546,7 @@ static int __setup_irq(struct irq_desc *desc, unsigned int irq, desc->action = new; desc->status &= ~IRQ_DISABLED ; -dsb (); +dsb ("sy" ); desc->handler->startup (desc);
xen/arch/arm/mm.c +1 -1
@@ -324,7 +324,7 @@ void __cpuinit setup_virt_paging(void)#define WRITE_TTBR (ttbr) \ flush_xen_text_tlb(); \ WRITE_SYSREG64(ttbr, TTBR0_EL2); \ - dsb();/* ensure memory accesses do not cross over the TTBR0 write */ \ + dsb("sy");/* ensure memory accesses do not cross over the TTBR0 write */ \/* flush_xen_text_tlb contains an initial isb which ensures the \ * write to TTBR0 has completed. */ \flush_xen_text_tlb ()
xen/arch/arm/platforms/vexpress.c +3 -3
@@ -46,7 +46,7 @@ static inline int vexpress_ctrl_start(uint32_t *syscfg, int write,/* wait for complete flag to be set */ do { stat = syscfg[V2M_SYS_CFGSTAT /4 ]; -dsb (); +dsb ("sy" ); }while ( !(stat &V2M_SYS_CFG_COMPLETE ) );/* check error status and return error flag if set */
@@ -111,10 +111,10 @@ static void vexpress_reset(void)/* switch to slow mode */ iowritel (sp810,0x3 ); -dsb ();isb (); +dsb ("sy" );isb ();/* writing any value to SCSYSSTAT reg will reset the system */ iowritel (sp810 +4 ,0x1 ); -dsb ();isb (); +dsb ("sy" );isb ();iounmap (sp810); }
xen/arch/arm/smpboot.c +1 -1
@@ -211,7 +211,7 @@ void stop_cpu(void)local_irq_disable (); cpu_is_dead =1 ;/* Make sure the write happens before we sleep forever */ -dsb (); +dsb ("sy" );isb ();while (1 )wfi ();
xen/arch/arm/time.c +1 -1
@@ -252,7 +252,7 @@ void udelay(unsigned long usecs)s_time_t deadline =get_s_time () +1000 * (s_time_t ) usecs;while (get_s_time () - deadline <0 ) ; -dsb (); +dsb ("sy" );isb (); }
xen/drivers/video/arm_hdlcd.c +1 -1
@@ -77,7 +77,7 @@ void (*video_puts)(const char *) = vga_noop_puts;static void hdlcd_flush (void ) { -dsb (); +dsb ("sy" ); }static int __init get_color_masks (const char * bpp,struct color_masks **masks)
xen/include/asm-arm/arm32/flushtlb.h +4 -4
@@ -4,22 +4,22 @@/* Flush local TLBs, current VMID only */ static inline void flush_tlb_local (void ) { -dsb (); +dsb ("sy" );WRITE_CP32 ((uint32_t )0 ,TLBIALLIS ); -dsb (); +dsb ("sy" );isb (); }/* Flush local TLBs, all VMIDs, non-hypervisor mode */ static inline void flush_tlb_all_local (void ) { -dsb (); +dsb ("sy" );WRITE_CP32 ((uint32_t )0 ,TLBIALLNSNHIS ); -dsb (); +dsb ("sy" );isb (); }
xen/include/asm-arm/arm32/io.h +2 -2
@@ -30,14 +30,14 @@ static inline uint32_t ioreadl(const volatile void __iomem *addr) asmvolatile ("ldr %1, %0" :"+Qo" (*(volatile uint32_t __force *)addr),"=r" (val)); -dsb (); +dsb ("sy" );return val; }static inline void iowritel (const volatile void __iomem *addr,uint32_t val) { -dsb (); +dsb ("sy" ); asmvolatile ("str %1, %0" :"+Qo" (*(volatile uint32_t __force *)addr) :"r" (val));
xen/include/asm-arm/arm32/page.h +2 -2
@@ -67,13 +67,13 @@ static inline void flush_xen_data_tlb(void)static inline void flush_xen_data_tlb_range_va (unsigned long va,unsigned long size) {unsigned long end = va + size; -dsb ();/* Ensure preceding are visible */ +dsb ("sy" );/* Ensure preceding are visible */ while ( va < end ) { asm volatile(STORE_CP32(0, TLBIMVAHIS) : : "r" (va) : "memory"); va += PAGE_SIZE; } -dsb ();/* Ensure completion of the TLB flush */ +dsb ("sy" );/* Ensure completion of the TLB flush */ isb (); }
xen/include/asm-arm/arm64/io.h +2 -2
@@ -24,14 +24,14 @@ static inline uint32_t ioreadl(const volatile void __iomem *addr)uint32_t val; asmvolatile ("ldr %w0, [%1]" :"=r" (val) :"r" (addr)); -dsb (); +dsb ("sy" );return val; }static inline void iowritel (const volatile void __iomem *addr,uint32_t val) { -dsb (); +dsb ("sy" ); asmvolatile ("str %w0, [%1]" : :"r" (val),"r" (addr)); }
xen/include/asm-arm/arm64/page.h +2 -2
@@ -60,13 +60,13 @@ static inline void flush_xen_data_tlb(void)static inline void flush_xen_data_tlb_range_va (unsigned long va,unsigned long size) {unsigned long end = va + size; -dsb ();/* Ensure preceding are visible */ +dsb ("sy" );/* Ensure preceding are visible */ while ( va < end ) { asmvolatile ("tlbi vae2is, %0;" : :"r" (va>>PAGE_SHIFT ) :"memory" ); va +=PAGE_SIZE ; } -dsb ();/* Ensure completion of the TLB flush */ +dsb ("sy" );/* Ensure completion of the TLB flush */ isb (); }
xen/include/asm-arm/page.h +2 -2
@@ -284,10 +284,10 @@ extern size_t cacheline_bytes;static inline void flush_xen_dcache_va_range (void *p,unsigned long size) {void *end; -dsb ();/* So the CPU issues all writes to the range */ +dsb ("sy" );/* So the CPU issues all writes to the range */ for ( end = p + size; p < end; p += cacheline_bytes ) asm volatile (__flush_xen_dcache_one(0) : : "r" (p)); -dsb ();/* So we know the flushes happen before continuing */ +dsb ("sy" );/* So we know the flushes happen before continuing */ }/* Macro for flushing a single small item. The predicate is always
xen/include/asm-arm/system.h +8 -8
@@ -13,16 +13,16 @@#define wfi () asm volatile("wfi" : : : "memory")#define isb () asm volatile("isb" : : : "memory") -#define dsb () asm volatile("dsb sy" : : : "memory") -#define dmb () asm volatile("dmb sy" : : : "memory") +#define dsb (scope) asm volatile("dsb " scope : : : "memory") +#define dmb (scope) asm volatile("dmb " scope : : : "memory") -#define mb () dsb() -#define rmb () dsb() -#define wmb () dsb() +#define mb () dsb("sy") +#define rmb () dsb("sy") +#define wmb () dsb("sy") -#define smp_mb () dmb() -#define smp_rmb () dmb() -#define smp_wmb () dmb() +#define smp_mb () dmb("sy") +#define smp_rmb () dmb("sy") +#define smp_wmb () dmb("sy")#define xchg (ptr,x) \ ((__typeof__(*(ptr)))__xchg((unsigned long)(x),(ptr),sizeof(*(ptr))))
Signature · 1 line
1.7.2.5
Re: [PATCH 08/10] xen: arm: add scope to dsb and dmb macros
Quoted 3 lines · Ian Campbell
Everywhere currently passes "sy"stem, so no actual change.
Signed-off-by Ian Campbell <[email protected]>
Quoted 309 lines
xen/arch/arm/domain.c | 2 +- xen/arch/arm/gic.c | 8 ++++---- xen/arch/arm/mm.c | 2 +- xen/arch/arm/platforms/vexpress.c | 6 +++--- xen/arch/arm/smpboot.c | 2 +- xen/arch/arm/time.c | 2 +- xen/drivers/video/arm_hdlcd.c | 2 +- xen/include/asm-arm/arm32/flushtlb.h | 8 ++++---- xen/include/asm-arm/arm32/io.h | 4 ++-- xen/include/asm-arm/arm32/page.h | 4 ++-- xen/include/asm-arm/arm64/io.h | 4 ++-- xen/include/asm-arm/arm64/page.h | 4 ++-- xen/include/asm-arm/page.h | 4 ++-- xen/include/asm-arm/system.h | 16 ++++++++-------- 14 files changed, 34 insertions(+), 34 deletions(-)xen/arch/arm/domain.c +1
-1@@ -44,7 +44,7 @@ void idle_loop(void)local_irq_disable ();if (cpu_is_haltable (smp_processor_id ()) ) { -dsb (); +dsb ("sy" );wfi (); }local_irq_enable ();xen/arch/arm/gic.c +4
-4@@ -432,7 +432,7 @@ void send_SGI_mask(const cpumask_t *cpumask, enum gic_sgi sgi)ASSERT (mask <0x100 );/* The target bitmap only supports 8 CPUs */ -dsb (); +dsb ("sy" );GICD [GICD_SGIR ] =GICD_SGI_TARGET_LIST | (mask<<GICD_SGI_TARGET_SHIFT )@@ -449,7 +449,7 @@ void send_SGI_self(enum gic_sgi sgi) {ASSERT (sgi <16 );/* There are only 16 SGIs */ -dsb (); +dsb ("sy" );GICD [GICD_SGIR ] =GICD_SGI_TARGET_SELF | sgi;@@ -459,7 +459,7 @@ void send_SGI_allbutself(enum gic_sgi sgi) {ASSERT (sgi <16 );/* There are only 16 SGIs */ -dsb (); +dsb ("sy" );GICD [GICD_SGIR ] =GICD_SGI_TARGET_OTHERS | sgi;@@ -546,7 +546,7 @@ static int __setup_irq(struct irq_desc *desc, unsigned int irq, desc->action = new; desc->status &= ~IRQ_DISABLED ; -dsb (); +dsb ("sy" ); desc->handler->startup (desc);xen/arch/arm/mm.c +1
-1@@ -324,7 +324,7 @@ void __cpuinit setup_virt_paging(void)#define WRITE_TTBR (ttbr) \ flush_xen_text_tlb(); \ WRITE_SYSREG64(ttbr, TTBR0_EL2); \ - dsb();/* ensure memory accesses do not cross over the TTBR0 write */ \ + dsb("sy");/* ensure memory accesses do not cross over the TTBR0 write */ \/* flush_xen_text_tlb contains an initial isb which ensures the \ * write to TTBR0 has completed. */ \flush_xen_text_tlb ()xen/arch/arm/platforms/vexpress.c +3
-3@@ -46,7 +46,7 @@ static inline int vexpress_ctrl_start(uint32_t *syscfg, int write,/* wait for complete flag to be set */ do { stat = syscfg[V2M_SYS_CFGSTAT /4 ]; -dsb (); +dsb ("sy" ); }while ( !(stat &V2M_SYS_CFG_COMPLETE ) );/* check error status and return error flag if set */ @@ -111,10 +111,10 @@ static void vexpress_reset(void)/* switch to slow mode */ iowritel (sp810,0x3 ); -dsb ();isb (); +dsb ("sy" );isb ();/* writing any value to SCSYSSTAT reg will reset the system */ iowritel (sp810 +4 ,0x1 ); -dsb ();isb (); +dsb ("sy" );isb ();iounmap (sp810); }xen/arch/arm/smpboot.c +1
-1@@ -211,7 +211,7 @@ void stop_cpu(void)local_irq_disable (); cpu_is_dead =1 ;/* Make sure the write happens before we sleep forever */ -dsb (); +dsb ("sy" );isb ();while (1 )wfi ();xen/arch/arm/time.c +1
-1@@ -252,7 +252,7 @@ void udelay(unsigned long usecs)s_time_t deadline =get_s_time () +1000 * (s_time_t ) usecs;while (get_s_time () - deadline <0 ) ; -dsb (); +dsb ("sy" );isb (); }xen/drivers/video/arm_hdlcd.c +1
-1@@ -77,7 +77,7 @@ void (*video_puts)(const char *) = vga_noop_puts;static void hdlcd_flush (void ) { -dsb (); +dsb ("sy" ); }static int __init get_color_masks (const char * bpp,struct color_masks **masks)xen/include/asm-arm/arm32/flushtlb.h +4
-4@@ -4,22 +4,22 @@/* Flush local TLBs, current VMID only */ static inline void flush_tlb_local (void ) { -dsb (); +dsb ("sy" );WRITE_CP32 ((uint32_t )0 ,TLBIALLIS ); -dsb (); +dsb ("sy" );isb (); }/* Flush local TLBs, all VMIDs, non-hypervisor mode */ static inline void flush_tlb_all_local (void ) { -dsb (); +dsb ("sy" );WRITE_CP32 ((uint32_t )0 ,TLBIALLNSNHIS ); -dsb (); +dsb ("sy" );isb (); }xen/include/asm-arm/arm32/io.h +2
-2@@ -30,14 +30,14 @@ static inline uint32_t ioreadl(const volatile void __iomem *addr) asmvolatile ("ldr %1, %0" :"+Qo" (*(volatile uint32_t __force *)addr),"=r" (val)); -dsb (); +dsb ("sy" );return val; }static inline void iowritel (const volatile void __iomem *addr,uint32_t val) { -dsb (); +dsb ("sy" ); asmvolatile ("str %1, %0" :"+Qo" (*(volatile uint32_t __force *)addr) :"r" (val));xen/include/asm-arm/arm32/page.h +2
-2@@ -67,13 +67,13 @@ static inline void flush_xen_data_tlb(void)static inline void flush_xen_data_tlb_range_va (unsigned long va,unsigned long size) {unsigned long end = va + size; -dsb ();/* Ensure preceding are visible */ +dsb ("sy" );/* Ensure preceding are visible */ while ( va < end ) { asm volatile(STORE_CP32(0, TLBIMVAHIS) : : "r" (va) : "memory"); va += PAGE_SIZE; } -dsb ();/* Ensure completion of the TLB flush */ +dsb ("sy" );/* Ensure completion of the TLB flush */ isb (); }xen/include/asm-arm/arm64/io.h +2
-2@@ -24,14 +24,14 @@ static inline uint32_t ioreadl(const volatile void __iomem *addr)uint32_t val; asmvolatile ("ldr %w0, [%1]" :"=r" (val) :"r" (addr)); -dsb (); +dsb ("sy" );return val; }static inline void iowritel (const volatile void __iomem *addr,uint32_t val) { -dsb (); +dsb ("sy" ); asmvolatile ("str %w0, [%1]" : :"r" (val),"r" (addr)); }xen/include/asm-arm/arm64/page.h +2
-2@@ -60,13 +60,13 @@ static inline void flush_xen_data_tlb(void)static inline void flush_xen_data_tlb_range_va (unsigned long va,unsigned long size) {unsigned long end = va + size; -dsb ();/* Ensure preceding are visible */ +dsb ("sy" );/* Ensure preceding are visible */ while ( va < end ) { asmvolatile ("tlbi vae2is, %0;" : :"r" (va>>PAGE_SHIFT ) :"memory" ); va +=PAGE_SIZE ; } -dsb ();/* Ensure completion of the TLB flush */ +dsb ("sy" );/* Ensure completion of the TLB flush */ isb (); }xen/include/asm-arm/page.h +2
-2@@ -284,10 +284,10 @@ extern size_t cacheline_bytes;static inline void flush_xen_dcache_va_range (void *p,unsigned long size) {void *end; -dsb ();/* So the CPU issues all writes to the range */ +dsb ("sy" );/* So the CPU issues all writes to the range */ for ( end = p + size; p < end; p += cacheline_bytes ) asm volatile (__flush_xen_dcache_one(0) : : "r" (p)); -dsb ();/* So we know the flushes happen before continuing */ +dsb ("sy" );/* So we know the flushes happen before continuing */ }/* Macro for flushing a single small item. The predicate is always xen/include/asm-arm/system.h +8
-8@@ -13,16 +13,16 @@#define wfi () asm volatile("wfi" : : : "memory")#define isb () asm volatile("isb" : : : "memory") -#define dsb () asm volatile("dsb sy" : : : "memory") -#define dmb () asm volatile("dmb sy" : : : "memory") +#define dsb (scope) asm volatile("dsb " scope : : : "memory") +#define dmb (scope) asm volatile("dmb " scope : : : "memory") -#define mb () dsb() -#define rmb () dsb() -#define wmb () dsb() +#define mb () dsb("sy") +#define rmb () dsb("sy") +#define wmb () dsb("sy") -#define smp_mb () dmb() -#define smp_rmb () dmb() -#define smp_wmb () dmb() +#define smp_mb () dmb("sy") +#define smp_rmb () dmb("sy") +#define smp_wmb () dmb("sy")#define xchg (ptr,x) \ ((__typeof__(*(ptr)))__xchg((unsigned long)(x),(ptr),sizeof(*(ptr))))Signature · 1 line
1.7.2.5
Re: [PATCH 08/10] xen: arm: add scope to dsb and dmb macros
Quoted 6 lines · Stefano Stabellini
Quoted 3 lines · Ian Campbell
Everywhere currently passes "sy"stem, so no actual change.
Signed-off-by Ian Campbell <[email protected]>Signed-off-by Stefano Stabellini <[email protected]>
sorry I meant Acked-by
Quoted 311 lines
Quoted 310 lines
xen/arch/arm/domain.c | 2 +- xen/arch/arm/gic.c | 8 ++++---- xen/arch/arm/mm.c | 2 +- xen/arch/arm/platforms/vexpress.c | 6 +++--- xen/arch/arm/smpboot.c | 2 +- xen/arch/arm/time.c | 2 +- xen/drivers/video/arm_hdlcd.c | 2 +- xen/include/asm-arm/arm32/flushtlb.h | 8 ++++---- xen/include/asm-arm/arm32/io.h | 4 ++-- xen/include/asm-arm/arm32/page.h | 4 ++-- xen/include/asm-arm/arm64/io.h | 4 ++-- xen/include/asm-arm/arm64/page.h | 4 ++-- xen/include/asm-arm/page.h | 4 ++-- xen/include/asm-arm/system.h | 16 ++++++++-------- 14 files changed, 34 insertions(+), 34 deletions(-)xen/arch/arm/domain.c +1
-1@@ -44,7 +44,7 @@ void idle_loop(void)local_irq_disable ();if (cpu_is_haltable (smp_processor_id ()) ) { -dsb (); +dsb ("sy" );wfi (); }local_irq_enable ();xen/arch/arm/gic.c +4
-4@@ -432,7 +432,7 @@ void send_SGI_mask(const cpumask_t *cpumask, enum gic_sgi sgi)ASSERT (mask <0x100 );/* The target bitmap only supports 8 CPUs */ -dsb (); +dsb ("sy" );GICD [GICD_SGIR ] =GICD_SGI_TARGET_LIST | (mask<<GICD_SGI_TARGET_SHIFT )@@ -449,7 +449,7 @@ void send_SGI_self(enum gic_sgi sgi) {ASSERT (sgi <16 );/* There are only 16 SGIs */ -dsb (); +dsb ("sy" );GICD [GICD_SGIR ] =GICD_SGI_TARGET_SELF | sgi;@@ -459,7 +459,7 @@ void send_SGI_allbutself(enum gic_sgi sgi) {ASSERT (sgi <16 );/* There are only 16 SGIs */ -dsb (); +dsb ("sy" );GICD [GICD_SGIR ] =GICD_SGI_TARGET_OTHERS | sgi;@@ -546,7 +546,7 @@ static int __setup_irq(struct irq_desc *desc, unsigned int irq, desc->action = new; desc->status &= ~IRQ_DISABLED ; -dsb (); +dsb ("sy" ); desc->handler->startup (desc);xen/arch/arm/mm.c +1
-1@@ -324,7 +324,7 @@ void __cpuinit setup_virt_paging(void)#define WRITE_TTBR (ttbr) \ flush_xen_text_tlb(); \ WRITE_SYSREG64(ttbr, TTBR0_EL2); \ - dsb();/* ensure memory accesses do not cross over the TTBR0 write */ \ + dsb("sy");/* ensure memory accesses do not cross over the TTBR0 write */ \/* flush_xen_text_tlb contains an initial isb which ensures the \ * write to TTBR0 has completed. */ \flush_xen_text_tlb ()xen/arch/arm/platforms/vexpress.c +3
-3@@ -46,7 +46,7 @@ static inline int vexpress_ctrl_start(uint32_t *syscfg, int write,/* wait for complete flag to be set */ do { stat = syscfg[V2M_SYS_CFGSTAT /4 ]; -dsb (); +dsb ("sy" ); }while ( !(stat &V2M_SYS_CFG_COMPLETE ) );/* check error status and return error flag if set */ @@ -111,10 +111,10 @@ static void vexpress_reset(void)/* switch to slow mode */ iowritel (sp810,0x3 ); -dsb ();isb (); +dsb ("sy" );isb ();/* writing any value to SCSYSSTAT reg will reset the system */ iowritel (sp810 +4 ,0x1 ); -dsb ();isb (); +dsb ("sy" );isb ();iounmap (sp810); }xen/arch/arm/smpboot.c +1
-1@@ -211,7 +211,7 @@ void stop_cpu(void)local_irq_disable (); cpu_is_dead =1 ;/* Make sure the write happens before we sleep forever */ -dsb (); +dsb ("sy" );isb ();while (1 )wfi ();xen/arch/arm/time.c +1
-1@@ -252,7 +252,7 @@ void udelay(unsigned long usecs)s_time_t deadline =get_s_time () +1000 * (s_time_t ) usecs;while (get_s_time () - deadline <0 ) ; -dsb (); +dsb ("sy" );isb (); }xen/drivers/video/arm_hdlcd.c +1
-1@@ -77,7 +77,7 @@ void (*video_puts)(const char *) = vga_noop_puts;static void hdlcd_flush (void ) { -dsb (); +dsb ("sy" ); }static int __init get_color_masks (const char * bpp,struct color_masks **masks)xen/include/asm-arm/arm32/flushtlb.h +4
-4@@ -4,22 +4,22 @@/* Flush local TLBs, current VMID only */ static inline void flush_tlb_local (void ) { -dsb (); +dsb ("sy" );WRITE_CP32 ((uint32_t )0 ,TLBIALLIS ); -dsb (); +dsb ("sy" );isb (); }/* Flush local TLBs, all VMIDs, non-hypervisor mode */ static inline void flush_tlb_all_local (void ) { -dsb (); +dsb ("sy" );WRITE_CP32 ((uint32_t )0 ,TLBIALLNSNHIS ); -dsb (); +dsb ("sy" );isb (); }xen/include/asm-arm/arm32/io.h +2
-2@@ -30,14 +30,14 @@ static inline uint32_t ioreadl(const volatile void __iomem *addr) asmvolatile ("ldr %1, %0" :"+Qo" (*(volatile uint32_t __force *)addr),"=r" (val)); -dsb (); +dsb ("sy" );return val; }static inline void iowritel (const volatile void __iomem *addr,uint32_t val) { -dsb (); +dsb ("sy" ); asmvolatile ("str %1, %0" :"+Qo" (*(volatile uint32_t __force *)addr) :"r" (val));xen/include/asm-arm/arm32/page.h +2
-2@@ -67,13 +67,13 @@ static inline void flush_xen_data_tlb(void)static inline void flush_xen_data_tlb_range_va (unsigned long va,unsigned long size) {unsigned long end = va + size; -dsb ();/* Ensure preceding are visible */ +dsb ("sy" );/* Ensure preceding are visible */ while ( va < end ) { asm volatile(STORE_CP32(0, TLBIMVAHIS) : : "r" (va) : "memory"); va += PAGE_SIZE; } -dsb ();/* Ensure completion of the TLB flush */ +dsb ("sy" );/* Ensure completion of the TLB flush */ isb (); }xen/include/asm-arm/arm64/io.h +2
-2@@ -24,14 +24,14 @@ static inline uint32_t ioreadl(const volatile void __iomem *addr)uint32_t val; asmvolatile ("ldr %w0, [%1]" :"=r" (val) :"r" (addr)); -dsb (); +dsb ("sy" );return val; }static inline void iowritel (const volatile void __iomem *addr,uint32_t val) { -dsb (); +dsb ("sy" ); asmvolatile ("str %w0, [%1]" : :"r" (val),"r" (addr)); }xen/include/asm-arm/arm64/page.h +2
-2@@ -60,13 +60,13 @@ static inline void flush_xen_data_tlb(void)static inline void flush_xen_data_tlb_range_va (unsigned long va,unsigned long size) {unsigned long end = va + size; -dsb ();/* Ensure preceding are visible */ +dsb ("sy" );/* Ensure preceding are visible */ while ( va < end ) { asmvolatile ("tlbi vae2is, %0;" : :"r" (va>>PAGE_SHIFT ) :"memory" ); va +=PAGE_SIZE ; } -dsb ();/* Ensure completion of the TLB flush */ +dsb ("sy" );/* Ensure completion of the TLB flush */ isb (); }xen/include/asm-arm/page.h +2
-2@@ -284,10 +284,10 @@ extern size_t cacheline_bytes;static inline void flush_xen_dcache_va_range (void *p,unsigned long size) {void *end; -dsb ();/* So the CPU issues all writes to the range */ +dsb ("sy" );/* So the CPU issues all writes to the range */ for ( end = p + size; p < end; p += cacheline_bytes ) asm volatile (__flush_xen_dcache_one(0) : : "r" (p)); -dsb ();/* So we know the flushes happen before continuing */ +dsb ("sy" );/* So we know the flushes happen before continuing */ }/* Macro for flushing a single small item. The predicate is always xen/include/asm-arm/system.h +8
-8@@ -13,16 +13,16 @@#define wfi () asm volatile("wfi" : : : "memory")#define isb () asm volatile("isb" : : : "memory") -#define dsb () asm volatile("dsb sy" : : : "memory") -#define dmb () asm volatile("dmb sy" : : : "memory") +#define dsb (scope) asm volatile("dsb " scope : : : "memory") +#define dmb (scope) asm volatile("dmb " scope : : : "memory") -#define mb () dsb() -#define rmb () dsb() -#define wmb () dsb() +#define mb () dsb("sy") +#define rmb () dsb("sy") +#define wmb () dsb("sy") -#define smp_mb () dmb() -#define smp_rmb () dmb() -#define smp_wmb () dmb() +#define smp_mb () dmb("sy") +#define smp_rmb () dmb("sy") +#define smp_wmb () dmb("sy")#define xchg (ptr,x) \ ((__typeof__(*(ptr)))__xchg((unsigned long)(x),(ptr),sizeof(*(ptr))))Signature · 1 line
1.7.2.5
Re: (no subject)
In reply to Ian CampbellOops, a wandering newline seems to have got into the headers here. :)
Tim.
Quoted 16 lines · Tim Deegan
Bcc: Tim Deegan <[email protected]>
Subject: Re: [Xen-devel] [PATCH 08/10] xen: arm: add scope to dsb and dmb macros Reply-To:
In-Reply-To: <[email protected]>Quoted 3 lines · Ian Campbell
Everywhere currently passes "sy"stem, so no actual change.
Signed-off-by Ian Campbell <[email protected]>Acked-by Tim Deegan <[email protected]>_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
PATCH 9/10 xen: arm: weaken SMP barriers to inner shareable.
In reply to Ian CampbellSince all processors are in the inner-shareable domain and we map everything that way this is sufficient.
The non-SMP barriers remain full system. Although in principal they could become outer shareable barriers for some hardware this would require us to know which class a given device is. Given the small number of device drivers in Xen itself its probably not worth worrying over, although maybe someone will benchmark at some point.
--- xen/include/asm-arm/system.h | 6 +++--- 1 files changed, 3 insertions(+), 3 deletions(-)
xen/include/asm-arm/system.h +3 -3
@@ -20,9 +20,9 @@#define rmb () dsb("sy")#define wmb () dsb("sy") -#define smp_mb () dmb("sy") -#define smp_rmb () dmb("sy") -#define smp_wmb () dmb("sy") +#define smp_mb () dmb("ish") +#define smp_rmb () dmb("ish") +#define smp_wmb () dmb("ish")#define xchg (ptr,x) \ ((__typeof__(*(ptr)))__xchg((unsigned long)(x),(ptr),sizeof(*(ptr))))
Signature · 1 line
1.7.2.5
Re: [PATCH 09/10] xen: arm: weaken SMP barriers to inner shareable.
Quoted 10 lines · Ian Campbell
Since all processors are in the inner-shareable domain and we map everything that way this is sufficient.
The non-SMP barriers remain full system. Although in principal they could become outer shareable barriers for some hardware this would require us to know which class a given device is. Given the small number of device drivers in Xen itself its probably not worth worrying over, although maybe someone will benchmark at some point.
Signed-off-by Ian Campbell <[email protected]>
Quoted 23 lines
xen/include/asm-arm/system.h | 6 +++--- 1 files changed, 3 insertions(+), 3 deletions(-)xen/include/asm-arm/system.h +3
-3@@ -20,9 +20,9 @@#define rmb () dsb("sy")#define wmb () dsb("sy") -#define smp_mb () dmb("sy") -#define smp_rmb () dmb("sy") -#define smp_wmb () dmb("sy") +#define smp_mb () dmb("ish") +#define smp_rmb () dmb("ish") +#define smp_wmb () dmb("ish")#define xchg (ptr,x) \ ((__typeof__(*(ptr)))__xchg((unsigned long)(x),(ptr),sizeof(*(ptr))))Signature · 1 line
1.7.2.5
Re: [PATCH 09/10] xen: arm: weaken SMP barriers to inner shareable.
Quoted 10 lines · Stefano Stabellini
Quoted 9 lines · Ian Campbell
Since all processors are in the inner-shareable domain and we map everything that way this is sufficient.
The non-SMP barriers remain full system. Although in principal they could become outer shareable barriers for some hardware this would require us to know which class a given device is. Given the small number of device drivers in Xen itself its probably not worth worrying over, although maybe someone will benchmark at some point.
Quoted 4 lines
Quoted 1 line
Signed-off-by Ian Campbell <[email protected]>Signed-off-by Stefano Stabellini <[email protected]>
same here
Quoted 24 lines
Quoted 23 lines
xen/include/asm-arm/system.h | 6 +++--- 1 files changed, 3 insertions(+), 3 deletions(-)xen/include/asm-arm/system.h +3
-3@@ -20,9 +20,9 @@#define rmb () dsb("sy")#define wmb () dsb("sy") -#define smp_mb () dmb("sy") -#define smp_rmb () dmb("sy") -#define smp_wmb () dmb("sy") +#define smp_mb () dmb("ish") +#define smp_rmb () dmb("ish") +#define smp_wmb () dmb("ish")#define xchg (ptr,x) \ ((__typeof__(*(ptr)))__xchg((unsigned long)(x),(ptr),sizeof(*(ptr))))Signature · 1 line
1.7.2.5
Re: [PATCH 09/10] xen: arm: weaken SMP barriers to inner shareable.
In reply to Ian CampbellQuoted 4 lines · Ian Campbell
Since all processors are in the inner-shareable domain and we map everything that way this is sufficient.
The non-SMP barriers remain full system. Although in principal they could
s/principal/principle/.
Quoted 6 lines
become outer shareable barriers for some hardware this would require us to know which class a given device is. Given the small number of device drivers in Xen itself its probably not worth worrying over, although maybe someone will benchmark at some point.
Signed-off-by Ian Campbell <[email protected]>
PATCH 10/10 xen: arm: use more specific barriers for read and write barriers.
In reply to Ian CampbellNote that 32-bit does not provide a load variant of the inner shareable barrier, so that remains a full any-any barrier.
--- xen/include/asm-arm/system.h | 13 +++++++++---- 1 files changed, 9 insertions(+), 4 deletions(-)
xen/include/asm-arm/system.h +9 -4
@@ -17,12 +17,17 @@#define dmb (scope) asm volatile("dmb " scope : : : "memory")#define mb () dsb("sy") -#define rmb () dsb("sy") -#define wmb () dsb("sy") +#define rmb () dsb("ld") +#define wmb () dsb("st")#define smp_mb () dmb("ish") -#define smp_rmb () dmb("ish") -#define smp_wmb () dmb("ish") +#ifdef CONFIG_ARM_64 +#define smp_rmb () dmb("ishld") +#else +#define smp_rmb () dmb("ish")/* 32-bit has no ishld variant. */ +#endif + +#define smp_wmb () dmb("ishst")#define xchg (ptr,x) \ ((__typeof__(*(ptr)))__xchg((unsigned long)(x),(ptr),sizeof(*(ptr))))
Signature · 1 line
1.7.2.5
Re: [PATCH 10/10] xen: arm: use more specific barriers for read and write barriers.
Quoted 4 lines · Ian Campbell
Note that 32-bit does not provide a load variant of the inner shareable barrier, so that remains a full any-any barrier.
Signed-off-by Ian Campbell <[email protected]>
Quoted 32 lines
xen/include/asm-arm/system.h | 13 +++++++++---- 1 files changed, 9 insertions(+), 4 deletions(-)xen/include/asm-arm/system.h +9
-4@@ -17,12 +17,17 @@#define dmb (scope) asm volatile("dmb " scope : : : "memory")#define mb () dsb("sy") -#define rmb () dsb("sy") -#define wmb () dsb("sy") +#define rmb () dsb("ld") +#define wmb () dsb("st")#define smp_mb () dmb("ish") -#define smp_rmb () dmb("ish") -#define smp_wmb () dmb("ish") +#ifdef CONFIG_ARM_64 +#define smp_rmb () dmb("ishld") +#else +#define smp_rmb () dmb("ish")/* 32-bit has no ishld variant. */ +#endif + +#define smp_wmb () dmb("ishst")#define xchg (ptr,x) \ ((__typeof__(*(ptr)))__xchg((unsigned long)(x),(ptr),sizeof(*(ptr))))Signature · 1 line
1.7.2.5
Re: [PATCH 10/10] xen: arm: use more specific barriers for read and write barriers.
In reply to Ian CampbellQuoted 13 lines · Ian Campbell
Note that 32-bit does not provide a load variant of the inner shareable barrier, so that remains a full any-any barrier.
Signed-off-by Ian Campbell <[email protected]>--- xen/include/asm-arm/system.h | 13 +++++++++---- 1 files changed, 9 insertions(+), 4 deletions(-)xen/include/asm-arm/system.h +0
-0
xen/include/asm-arm/system.h line 20
Quoted 6 lines
xen/include/asm-arm/system.h +1
-2@@ -17,12 +17,17 @@#define dmb (scope) asm volatile("dmb " scope : : : "memory")#define mb () dsb("sy") -#define rmb () dsb("sy") -#define wmb () dsb("sy") +#define rmb () dsb("ld")
This doesn't exist on arm32; it'll have to be dsb("sy") there, just like you've done for smb_rmb() below.
With that change, Acked-by: Tim Deegan <[email protected]>
Quoted 23 lines
xen/include/asm-arm/system.h +8
-2+#define wmb () dsb("st")#define smp_mb () dmb("ish") -#define smp_rmb () dmb("ish") -#define smp_wmb () dmb("ish") +#ifdef CONFIG_ARM_64 +#define smp_rmb () dmb("ishld") +#else +#define smp_rmb () dmb("ish")/* 32-bit has no ishld variant. */ +#endif + +#define smp_wmb () dmb("ishst")#define xchg (ptr,x) \ ((__typeof__(*(ptr)))__xchg((unsigned long)(x),(ptr),sizeof(*(ptr))))Signature · 7 lines
1.7.2.5 _______________________________________________ Xen-devel mailing list [email protected] http://lists.xen.org/xen-devel
Re: [PATCH 10/10] xen: arm: use more specific barriers for read and write barriers.
Quoted 16 lines · Tim Deegan
Quoted 15 lines · Ian Campbell
Note that 32-bit does not provide a load variant of the inner shareable barrier, so that remains a full any-any barrier.
Signed-off-by Ian Campbell <[email protected]>--- xen/include/asm-arm/system.h | 13 +++++++++---- 1 files changed, 9 insertions(+), 4 deletions(-)xen/include/asm-arm/system.h +0
-0@@ -17,12 +17,17 @@#define dmb (scope) asm volatile("dmb " scope : : : "memory")
Quoted 7 lines
xen/include/asm-arm/system.h line 20
Quoted 4 lines
xen/include/asm-arm/system.h +1
-2#define mb () dsb("sy") -#define rmb () dsb("sy") -#define wmb () dsb("sy") +#define rmb () dsb("ld")This doesn't exist on arm32; it'll have to be
dsb("sy")there, just like you've done forsmb_rmb()below.
Right, suggests that rmb isn't actually used anywhere (since I'm sure I compile tested) but lets at least make it correct...
Quoted 2 lines
With that change, Acked-by: Tim Deegan <[email protected]>
Thanks,
Ian.
Quoted 24 lines
Quoted 24 lines
xen/include/asm-arm/system.h +8
-2+#define wmb () dsb("st")#define smp_mb () dmb("ish") -#define smp_rmb () dmb("ish") -#define smp_wmb () dmb("ish") +#ifdef CONFIG_ARM_64 +#define smp_rmb () dmb("ishld") +#else +#define smp_rmb () dmb("ish")/* 32-bit has no ishld variant. */ +#endif + +#define smp_wmb () dmb("ishst")#define xchg (ptr,x) \ ((__typeof__(*(ptr)))__xchg((unsigned long)(x),(ptr),sizeof(*(ptr))))Signature · 7 lines
1.7.2.5 _______________________________________________ Xen-devel mailing list [email protected] http://lists.xen.org/xen-devel
I forgot to add an "RFC" to the subject line. I'm sure I don't need to point out that this isn't for 4.3!
Quoted 79 lines · Ian Campbell
Currently Xen maps all RAM as Outer-Shareable, since that seemed like the most conservative option early on when we didn't really know what Inner- vs. Outer-Shareable meant. However we have long suspected that actually Inner-Shareable would be the correct type to use.
After reading the docs many times, getting more confused each time, I finally got a reasonable explanation from a man (and a dog) down the
pub: Inner-Shareable == the processors in an SMP system, while Outer-Shareable == devices. (NB: Not a random man, he knew what he was talking about...). With that in mind switch all of Xen's memory mapping, page table walks, TLB flushes and an appropriate subset of the barriers to be inner shareable.In addition I have switched barriers to use the correct read/write/any variants for their types. Note that I have only tackled the generic mb/rmb/wmb and smp_* barriers (mainly used by common code) here. There are also quite a few open-coded full-system dsb's in the arch code which I will look at separately (10 patches is quite enough for now). Since those deal with e.g. pagetable updates they will be fun ;-)
I have tested this series on Cortex A15 and AEMv8 fast models in both cases with 2 CPUs and I can start a guest in both cases. I have not tested on any real hardware at all.
These changes should result in a performance improvement, although only having models to go on I haven't actually bothered to measure.
I would appreciate anyone with access to real hardware giving it a go. I have pushed the patches to:
git://xenbits.xen.org/people/ianc/xen.gitinner-shareable-v1Ian Campbell (10):
xen: arm: map memory as inner shareable.
xen: arm: Only upgrade guest barriers to inner shareable.
xen: arm: reduce instruction cache and tlb flushes to inner-shareable.
xen: arm: consolidate barrier definitions
xen: use SMP barrier in common code dealing with shared memory protocols
xen: arm: Use SMP barriers when that is all which is required.
xen: arm: Use dmb for smp barriers
xen: arm: add scope to dsb and dmb macros
xen: arm: weaken SMP barriers to inner shareable.
xen: arm: use more specific barriers for read and write barriers.xen/arch/arm/arm32/head.S | 8 +++--- xen/arch/arm/arm64/head.S | 8 +++--- xen/arch/arm/domain.c | 2 +- xen/arch/arm/gic.c | 8 +++--- xen/arch/arm/mm.c | 28 ++++++++++------------ xen/arch/arm/platforms/vexpress.c | 6 ++-- xen/arch/arm/smpboot.c | 6 ++-- xen/arch/arm/time.c | 2 +- xen/arch/arm/traps.c | 2 +- xen/common/domain.c | 2 +- xen/common/domctl.c | 2 +- xen/common/grant_table.c | 4 +- xen/common/page_alloc.c | 2 +- xen/common/smp.c | 4 +- xen/common/spinlock.c | 6 ++-- xen/common/tmem_xen.c | 10 ++++---- xen/common/trace.c | 8 +++--- xen/drivers/char/console.c | 2 +- xen/drivers/video/arm_hdlcd.c | 2 +- xen/include/asm-arm/arm32/flushtlb.h | 12 +++++----- xen/include/asm-arm/arm32/io.h | 4 +- xen/include/asm-arm/arm32/page.h | 12 +++++----- xen/include/asm-arm/arm32/system.h | 16 ------------- xen/include/asm-arm/arm64/flushtlb.h | 4 +- xen/include/asm-arm/arm64/io.h | 4 +- xen/include/asm-arm/arm64/page.h | 10 ++++---- xen/include/asm-arm/arm64/system.h | 17 ------------- xen/include/asm-arm/page.h | 42 +++++++++++++++++++++++++++++----- xen/include/asm-arm/system.h | 21 +++++++++++++++++ xen/include/xen/event.h | 4 +- xen/xsm/flask/ss/sidtab.c | 4 +- 31 files changed, 139 insertions(+), 123 deletions(-)Ian.
Tim Deegan
Acked-by(no subject)
Bcc: Tim Deegan <[email protected]>
Subject: Re: [Xen-devel] [PATCH 08/10] xen: arm: add scope to dsb and dmb macros Reply-To:
In-Reply-To: <[email protected]>
Quoted 3 lines · Ian Campbell
Everywhere currently passes "sy"stem, so no actual change.
Signed-off-by Ian Campbell <[email protected]>