[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Xen-devel] [PATCH RFC 4/4] x86: use invpcid to do global flush



Signed-off-by: Wei Liu <wei.liu2@xxxxxxxxxx>
---
 xen/arch/x86/flushtlb.c | 22 ++++++++++++++++++----
 1 file changed, 18 insertions(+), 4 deletions(-)

diff --git a/xen/arch/x86/flushtlb.c b/xen/arch/x86/flushtlb.c
index 8a7a76b8ff..e4ea4f3297 100644
--- a/xen/arch/x86/flushtlb.c
+++ b/xen/arch/x86/flushtlb.c
@@ -9,6 +9,7 @@
 
 #include <xen/sched.h>
 #include <xen/softirq.h>
+#include <asm/invpcid.h>
 #include <asm/flushtlb.h>
 #include <asm/page.h>
 
@@ -120,11 +121,24 @@ unsigned int flush_area_local(const void *va, unsigned 
int flags)
         else
         {
             u32 t = pre_flush();
-            unsigned long cr4 = read_cr4();
 
-            write_cr4(cr4 & ~X86_CR4_PGE);
-            barrier();
-            write_cr4(cr4);
+            if ( !cpu_has_invpcid )
+            {
+                unsigned long cr4 = read_cr4();
+
+                write_cr4(cr4 & ~X86_CR4_PGE);
+                barrier();
+                write_cr4(cr4);
+            }
+            else
+            {
+                /*
+                 * Using invpcid to flush all mappings works
+                 * regardless of whether PCID is enabled or not.
+                 * It is faster than read-modify-write CR4.
+                 */
+                invpcid_flush_all();
+            }
 
             post_flush(t);
         }
-- 
2.11.0


_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxxx
https://lists.xenproject.org/mailman/listinfo/xen-devel

 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.