x86: don't flush the whole cache when changing cachability
authorDavid Vrabel <david.vrabel@citrix.com>
Thu, 10 Mar 2016 15:51:03 +0000 (16:51 +0100)
committerJan Beulich <jbeulich@suse.com>
Thu, 10 Mar 2016 15:51:03 +0000 (16:51 +0100)
commitdff593c7b6eb1cfd4591b662a880a0c9325cce40
treef917056f008ae7b67d81c812ef4e2199928aebd4
parent119f09734a75c65c3084eeff6698bb3f357b4f96
x86: don't flush the whole cache when changing cachability

Introduce the FLUSH_VA_VALID flag to flush_area_mask() and friends to
say that it is safe to use CLFLUSH (i.e., the virtual address is still
valid).

Use this when changing the cachability of the Xen direct mappings (in
response to the guest changing the cachability of its mappings). This
significantly improves performance by avoiding an expensive WBINVD.

This fixes a performance regression introduced by
c61a6f74f80eb36ed83a82f713db3143159b9009 (x86: enforce consistent
cachability of MMIO mappings), the fix for XSA-154.

e.g., A set_memory_wc() call in Linux:

before: 4097 us
after:    47 us

Signed-off-by: David Vrabel <david.vrabel@citrix.com>
Reviewed-by: Jan Beulich <jbeulich@suse.com>
xen/arch/x86/flushtlb.c
xen/arch/x86/mm.c
xen/include/asm-x86/flushtlb.h