x86: add support for domain initiated global cache flush
PATCH 1/1 x86: add support for domain initiated global cache flush
Newer Linux' AGP code wants to flush caches on all CPUs under certain circumstances. Since doing this on all vCPU-s of the domain in question doesn't yield the intended effect, this needs to be done in the hypervisor. Add a new MMUEXT operation for this.
While looking at the pre-existing flush implementation, I also noticed an off-by-one error in the cache flush portion of flush_area_local().
xen/arch/x86/flushtlb.c +1 -1
@@ -149,7 +149,7 @@ void flush_area_local(const void *va, un {unsigned long i, sz =0 ; -if ( order < (BITS_PER_LONG -PAGE_SHIFT -1 ) ) +if ( order < (BITS_PER_LONG -PAGE_SHIFT ) ) sz =1UL << (order +PAGE_SHIFT ); if ( c->x86_clflush_size && c->x86_cache_size && sz &&
xen/arch/x86/mm.c +21 -0
@@ -2889,6 +2889,27 @@ int do_mmuext_op( }break ; +case MMUEXT_FLUSH_CACHE_GLOBAL : +if (unlikely (foreigndom !=DOMID_SELF ) ) + okay =0 ; +else if (likely (cache_flush_permitted (d)) ) + { +unsigned int cpu; +cpumask_t mask =CPU_MASK_NONE ; + +for_each_online_cpu (cpu) +if ( !cpus_intersects (mask, +per_cpu (cpu_sibling_map, cpu)) ) +cpu_set (cpu, mask); +flush_mask (&mask,FLUSH_CACHE ); + } +else + { +MEM_LOG ("Non-physdev domain tried to FLUSH_CACHE_GLOBAL" ); + okay =0 ; + } +break ; +case MMUEXT_SET_LDT : {unsigned long ptr = op.arg1.linear_addr;
xen/include/public/xen.h +5 -0
@@ -239,6 +239,10 @@ DEFINE_XEN_GUEST_HANDLE(xen_pfn_t);* * cmd: MMUEXT_FLUSH_CACHE * No additional arguments. Writes back and flushes cache contents. +* +* cmd: MMUEXT_FLUSH_CACHE_GLOBAL +* No additional arguments. Writes back and flushes cache contents +* on all CPUs in the system. * * cmd: MMUEXT_SET_LDT * linear_addr: Linear address of LDT base (NB. must be page-aligned).
@@ -268,6 +272,7 @@ DEFINE_XEN_GUEST_HANDLE(xen_pfn_t);#define MMUEXT_NEW_USER_BASEPTR 15#define MMUEXT_CLEAR_PAGE 16#define MMUEXT_COPY_PAGE 17 +#define MMUEXT_FLUSH_CACHE_GLOBAL 18#ifndef __ASSEMBLY__ struct mmuext_op {
Newer Linux' AGP code wants to flush caches on all CPUs under certain circumstances. Since doing this on all vCPU-s of the domain in question doesn't yield the intended effect, this needs to be done in the hypervisor. Add a new MMUEXT operation for this.
While looking at the pre-existing flush implementation, I also noticed an off-by-one error in the cache flush portion of flush_area_local().
xen/arch/x86/flushtlb.c +1 -1
@@ -149,7 +149,7 @@ void flush_area_local(const void *va, un {unsigned long i, sz =0 ; -if ( order < (BITS_PER_LONG -PAGE_SHIFT -1 ) ) +if ( order < (BITS_PER_LONG -PAGE_SHIFT ) ) sz =1UL << (order +PAGE_SHIFT ); if ( c->x86_clflush_size && c->x86_cache_size && sz &&
xen/arch/x86/mm.c +21 -0
@@ -2889,6 +2889,27 @@ int do_mmuext_op( }break ; +case MMUEXT_FLUSH_CACHE_GLOBAL : +if (unlikely (foreigndom !=DOMID_SELF ) ) + okay =0 ; +else if (likely (cache_flush_permitted (d)) ) + { +unsigned int cpu; +cpumask_t mask =CPU_MASK_NONE ; + +for_each_online_cpu (cpu) +if ( !cpus_intersects (mask, +per_cpu (cpu_sibling_map, cpu)) ) +cpu_set (cpu, mask); +flush_mask (&mask,FLUSH_CACHE ); + } +else + { +MEM_LOG ("Non-physdev domain tried to FLUSH_CACHE_GLOBAL" ); + okay =0 ; + } +break ; +case MMUEXT_SET_LDT : {unsigned long ptr = op.arg1.linear_addr;
xen/include/public/xen.h +5 -0
@@ -239,6 +239,10 @@ DEFINE_XEN_GUEST_HANDLE(xen_pfn_t);* * cmd: MMUEXT_FLUSH_CACHE * No additional arguments. Writes back and flushes cache contents. +* +* cmd: MMUEXT_FLUSH_CACHE_GLOBAL +* No additional arguments. Writes back and flushes cache contents +* on all CPUs in the system. * * cmd: MMUEXT_SET_LDT * linear_addr: Linear address of LDT base (NB. must be page-aligned).
@@ -268,6 +272,7 @@ DEFINE_XEN_GUEST_HANDLE(xen_pfn_t);#define MMUEXT_NEW_USER_BASEPTR 15#define MMUEXT_CLEAR_PAGE 16#define MMUEXT_COPY_PAGE 17 +#define MMUEXT_FLUSH_CACHE_GLOBAL 18#ifndef __ASSEMBLY__ struct mmuext_op {
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel
Quoted 4 lines · Jan Beulich
Newer Linux' AGP code wants to flush caches on all CPUs under certain circumstances. Since doing this on all vCPU-s of the domain in question doesn't yield the intended effect, this needs to be done in the hypervisor. Add a new MMUEXT operation for this.
Is there a corresponding patch for this new hypercall API?
Quoted 4 lines
While looking at the pre-existing flush implementation, I also noticed an off-by-one error in the cache flush portion of
flush_area_local().