From: Wei Liu <wei.liu2@citrix.com>
To: Xen-devel <xen-devel@lists.xenproject.org>
Cc: Juergen Gross <jgross@suse.com>,
Andrew Cooper <andrew.cooper3@citrix.com>,
Wei Liu <wei.liu2@citrix.com>, Jan Beulich <JBeulich@suse.com>
Subject: [PATCH RFC 4/4] x86: use invpcid to do global flush
Date: Thu, 15 Feb 2018 12:10:40 +0000 [thread overview]
Message-ID: <20180215121040.20585-5-wei.liu2@citrix.com> (raw)
In-Reply-To: <20180215121040.20585-1-wei.liu2@citrix.com>
Signed-off-by: Wei Liu <wei.liu2@citrix.com>
---
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@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel
next prev parent reply other threads:[~2018-02-15 12:13 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-02-15 12:10 [PATCH RFC 0/4] Use INVPCID to flush global mappings Wei Liu
2018-02-15 12:10 ` [PATCH RFC 1/4] x86: introduce cpu_has_invpcid Wei Liu
2018-02-15 12:31 ` Jan Beulich
2018-02-15 12:10 ` [PATCH RFC 2/4] x86: report if PCID and INVPCID are supported Wei Liu
2018-02-15 12:10 ` [PATCH RFC 3/4] x86: add invpcid.h Wei Liu
2018-02-15 12:15 ` Andrew Cooper
2018-02-15 12:24 ` Wei Liu
2018-02-15 12:26 ` Andrew Cooper
2018-02-15 12:34 ` Jan Beulich
2018-02-15 12:35 ` Wei Liu
2018-02-15 13:23 ` Jan Beulich
2018-02-15 12:10 ` Wei Liu [this message]
2018-02-15 15:38 ` [PATCH RFC 0/4] Use INVPCID to flush global mappings Juergen Gross
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20180215121040.20585-5-wei.liu2@citrix.com \
--to=wei.liu2@citrix.com \
--cc=JBeulich@suse.com \
--cc=andrew.cooper3@citrix.com \
--cc=jgross@suse.com \
--cc=xen-devel@lists.xenproject.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).