From: Andy Lutomirski <luto@kernel.org>
To: x86@kernel.org
Cc: Sasha Levin <sashal@kernel.org>,
linux-kernel@vger.kernel.org,
Andrew Cooper <andrew.cooper3@citrix.com>,
Juergen Gross <jgross@suse.com>,
Andy Lutomirski <luto@kernel.org>,
Boris Ostrovsky <boris.ostrovsky@oracle.com>,
Stefano Stabellini <sstabellini@kernel.org>,
xen-devel@lists.xenproject.org
Subject: [PATCH fsgsbase v2 4/4] x86/fsgsbase: Fix Xen PV support
Date: Fri, 26 Jun 2020 10:24:30 -0700 [thread overview]
Message-ID: <f07c08f178fe9711915862b656722a207cd52c28.1593192140.git.luto@kernel.org> (raw)
In-Reply-To: <cover.1593192140.git.luto@kernel.org>
On Xen PV, SWAPGS doesn't work. Teach __rdfsbase_inactive() and
__wrgsbase_inactive() to use rdmsrl()/wrmsrl() on Xen PV. The Xen
pvop code will understand this and issue the correct hypercalls.
Cc: Boris Ostrovsky <boris.ostrovsky@oracle.com>
Cc: Juergen Gross <jgross@suse.com>
Cc: Stefano Stabellini <sstabellini@kernel.org>
Cc: xen-devel@lists.xenproject.org
Signed-off-by: Andy Lutomirski <luto@kernel.org>
---
arch/x86/kernel/process_64.c | 20 ++++++++++++++------
1 file changed, 14 insertions(+), 6 deletions(-)
diff --git a/arch/x86/kernel/process_64.c b/arch/x86/kernel/process_64.c
index cb8e37d3acaa..457d02aa10d8 100644
--- a/arch/x86/kernel/process_64.c
+++ b/arch/x86/kernel/process_64.c
@@ -163,9 +163,13 @@ static noinstr unsigned long __rdgsbase_inactive(void)
lockdep_assert_irqs_disabled();
- native_swapgs();
- gsbase = rdgsbase();
- native_swapgs();
+ if (!static_cpu_has(X86_FEATURE_XENPV)) {
+ native_swapgs();
+ gsbase = rdgsbase();
+ native_swapgs();
+ } else {
+ rdmsrl(MSR_KERNEL_GS_BASE, gsbase);
+ }
return gsbase;
}
@@ -182,9 +186,13 @@ static noinstr void __wrgsbase_inactive(unsigned long gsbase)
{
lockdep_assert_irqs_disabled();
- native_swapgs();
- wrgsbase(gsbase);
- native_swapgs();
+ if (!static_cpu_has(X86_FEATURE_XENPV)) {
+ native_swapgs();
+ wrgsbase(gsbase);
+ native_swapgs();
+ } else {
+ wrmsrl(MSR_KERNEL_GS_BASE, gsbase);
+ }
}
/*
--
2.25.4
next prev parent reply other threads:[~2020-06-26 17:24 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-06-26 17:24 [PATCH fsgsbase v2 0/4] x86/fsgsbase: Some fixes Andy Lutomirski
2020-06-26 17:24 ` [PATCH fsgsbase v2 1/4] selftests/x86/fsgsbase: Fix a comment in the ptrace_write_gsbase test Andy Lutomirski
2020-07-01 13:33 ` [tip: x86/fsgsbase] " tip-bot2 for Andy Lutomirski
2020-06-26 17:24 ` [PATCH fsgsbase v2 2/4] selftests/x86/fsgsbase: Add a missing memory constraint Andy Lutomirski
2020-07-01 13:33 ` [tip: x86/fsgsbase] " tip-bot2 for Andy Lutomirski
2020-06-26 17:24 ` [PATCH fsgsbase v2 3/4] x86/ptrace: Fix 32-bit PTRACE_SETREGS vs fsbase and gsbase Andy Lutomirski
2020-07-01 13:33 ` [tip: x86/fsgsbase] " tip-bot2 for Andy Lutomirski
2020-06-26 17:24 ` Andy Lutomirski [this message]
2020-06-29 5:17 ` [PATCH fsgsbase v2 4/4] x86/fsgsbase: Fix Xen PV support Jürgen Groß
2020-06-29 11:07 ` Andrew Cooper
2020-07-01 13:33 ` [tip: x86/fsgsbase] " tip-bot2 for Andy Lutomirski
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=f07c08f178fe9711915862b656722a207cd52c28.1593192140.git.luto@kernel.org \
--to=luto@kernel.org \
--cc=andrew.cooper3@citrix.com \
--cc=boris.ostrovsky@oracle.com \
--cc=jgross@suse.com \
--cc=linux-kernel@vger.kernel.org \
--cc=sashal@kernel.org \
--cc=sstabellini@kernel.org \
--cc=x86@kernel.org \
--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
all inboxes | Powered by JetHome®