]> xenbits.xensource.com Git - xen.git/commitdiff
x86: use CLFLUSHOPT when available
authorJan Beulich <jbeulich@suse.com>
Thu, 11 Feb 2016 15:46:11 +0000 (16:46 +0100)
committerJan Beulich <jbeulich@suse.com>
Thu, 11 Feb 2016 15:46:11 +0000 (16:46 +0100)
Also drop an unnecessary va adjustment in the code being touched.

Signed-off-by: Jan Beulich <jbeulich@suse.com>
Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>
xen/arch/x86/flushtlb.c
xen/include/asm-x86/cpufeature.h

index 5d5d79c40105f5765646b99562d18ef053e95789..90a004f88ffe7e26af172ba73d18652f3fb34842 100644 (file)
@@ -139,10 +139,12 @@ void flush_area_local(const void *va, unsigned int flags)
              c->x86_clflush_size && c->x86_cache_size && sz &&
              ((sz >> 10) < c->x86_cache_size) )
         {
-            va = (const void *)((unsigned long)va & ~(sz - 1));
+            alternative(ASM_NOP3, "sfence", X86_FEATURE_CLFLUSHOPT);
             for ( i = 0; i < sz; i += c->x86_clflush_size )
-                 asm volatile ( "clflush %0"
-                                : : "m" (((const char *)va)[i]) );
+                 alternative_input("rex clflush %0",
+                                   "data16 clflush %0",
+                                   X86_FEATURE_CLFLUSHOPT,
+                                   "m" (((const char *)va)[i]));
         }
         else
         {
index e7e369b3137f0b3b9c292b99e3081b61b21b7f77..442f0a80453461bfeb7ecaea5b56445aade508e8 100644 (file)
 #define X86_FEATURE_ADX                (7*32+19) /* ADCX, ADOX instructions */
 #define X86_FEATURE_SMAP       (7*32+20) /* Supervisor Mode Access Prevention */
 #define X86_FEATURE_PCOMMIT    (7*32+22) /* PCOMMIT instruction */
+#define X86_FEATURE_CLFLUSHOPT (7*32+23) /* CLFLUSHOPT instruction */
 
 /* Intel-defined CPU features, CPUID level 0x00000007:0 (ecx), word 8 */
 #define X86_FEATURE_PKU        (8*32+ 3) /* Protection Keys for Userspace */