From: tip-bot for Andy Lutomirski <tipbot@zytor.com>
To: linux-tip-commits@vger.kernel.org
Cc: mingo@kernel.org, torvalds@linux-foundation.org,
rusty@rustcorp.com.au, konrad.wilk@oracle.com,
linux-kernel@vger.kernel.org, dvlasenk@redhat.com,
boris.ostrovsky@oracle.com, hpa@zytor.com, bp@alien8.de,
tglx@linutronix.de, luto@amacapital.net, oleg@redhat.com
Subject: [tip:x86/asm] x86/asm/entry: Add this_cpu_sp0() to read sp0 for the current cpu
Date: Fri, 6 Mar 2015 00:37:41 -0800 [thread overview]
Message-ID: <tip-8ef46a672a7d852709561d10672b6eaa8a4acd82@git.kernel.org> (raw)
In-Reply-To: <8d675581859712bee09a055ed8f785d80dac1eca.1425611534.git.luto@amacapital.net>
Commit-ID: 8ef46a672a7d852709561d10672b6eaa8a4acd82
Gitweb: http://git.kernel.org/tip/8ef46a672a7d852709561d10672b6eaa8a4acd82
Author: Andy Lutomirski <luto@amacapital.net>
AuthorDate: Thu, 5 Mar 2015 19:19:02 -0800
Committer: Ingo Molnar <mingo@kernel.org>
CommitDate: Fri, 6 Mar 2015 08:32:57 +0100
x86/asm/entry: Add this_cpu_sp0() to read sp0 for the current cpu
We currently store references to the top of the kernel stack in
multiple places: kernel_stack (with an offset) and
init_tss.x86_tss.sp0 (no offset). The latter is defined by
hardware and is a clean canonical way to find the top of the
stack. Add an accessor so we can start using it.
This needs minor paravirt tweaks. On native, sp0 defines the
top of the kernel stack and is therefore always correct. On Xen
and lguest, the hypervisor tracks the top of the stack, but we
want to start reading sp0 in the kernel. Fixing this is simple:
just update our local copy of sp0 as well as the hypervisor's
copy on task switches.
Signed-off-by: Andy Lutomirski <luto@amacapital.net>
Cc: Boris Ostrovsky <boris.ostrovsky@oracle.com>
Cc: Borislav Petkov <bp@alien8.de>
Cc: Denys Vlasenko <dvlasenk@redhat.com>
Cc: H. Peter Anvin <hpa@zytor.com>
Cc: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Oleg Nesterov <oleg@redhat.com>
Cc: Rusty Russell <rusty@rustcorp.com.au>
Cc: Thomas Gleixner <tglx@linutronix.de>
Link: http://lkml.kernel.org/r/8d675581859712bee09a055ed8f785d80dac1eca.1425611534.git.luto@amacapital.net
Signed-off-by: Ingo Molnar <mingo@kernel.org>
---
arch/x86/include/asm/processor.h | 5 +++++
arch/x86/kernel/process.c | 1 +
arch/x86/lguest/boot.c | 1 +
arch/x86/xen/enlighten.c | 1 +
4 files changed, 8 insertions(+)
diff --git a/arch/x86/include/asm/processor.h b/arch/x86/include/asm/processor.h
index 7be2c9a..71c3a82 100644
--- a/arch/x86/include/asm/processor.h
+++ b/arch/x86/include/asm/processor.h
@@ -564,6 +564,11 @@ static inline void native_swapgs(void)
#endif
}
+static inline unsigned long this_cpu_sp0(void)
+{
+ return this_cpu_read_stable(init_tss.x86_tss.sp0);
+}
+
#ifdef CONFIG_PARAVIRT
#include <asm/paravirt.h>
#else
diff --git a/arch/x86/kernel/process.c b/arch/x86/kernel/process.c
index 046e2d6..ff5c908 100644
--- a/arch/x86/kernel/process.c
+++ b/arch/x86/kernel/process.c
@@ -38,6 +38,7 @@
* on exact cacheline boundaries, to eliminate cacheline ping-pong.
*/
__visible DEFINE_PER_CPU_SHARED_ALIGNED(struct tss_struct, init_tss) = INIT_TSS;
+EXPORT_PER_CPU_SYMBOL_GPL(init_tss);
#ifdef CONFIG_X86_64
static DEFINE_PER_CPU(unsigned char, is_idle);
diff --git a/arch/x86/lguest/boot.c b/arch/x86/lguest/boot.c
index ac4453d..8561585 100644
--- a/arch/x86/lguest/boot.c
+++ b/arch/x86/lguest/boot.c
@@ -1076,6 +1076,7 @@ static void lguest_load_sp0(struct tss_struct *tss,
{
lazy_hcall3(LHCALL_SET_STACK, __KERNEL_DS | 0x1, thread->sp0,
THREAD_SIZE / PAGE_SIZE);
+ tss->x86_tss.sp0 = thread->sp0;
}
/* Let's just say, I wouldn't do debugging under a Guest. */
diff --git a/arch/x86/xen/enlighten.c b/arch/x86/xen/enlighten.c
index 5240f56..81665c9 100644
--- a/arch/x86/xen/enlighten.c
+++ b/arch/x86/xen/enlighten.c
@@ -912,6 +912,7 @@ static void xen_load_sp0(struct tss_struct *tss,
mcs = xen_mc_entry(0);
MULTI_stack_switch(mcs.mc, __KERNEL_DS, thread->sp0);
xen_mc_issue(PARAVIRT_LAZY_CPU);
+ tss->x86_tss.sp0 = thread->sp0;
}
static void xen_set_iopl_mask(unsigned mask)
next prev parent reply other threads:[~2015-03-06 8:38 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-03-06 3:19 [PATCH v2 0/6] Baby steps toward cleaning up KERNEL_STACK_OFFSET Andy Lutomirski
2015-03-06 3:19 ` [PATCH v2 1/6] x86: Add this_cpu_sp0() to read sp0 for the current cpu Andy Lutomirski
2015-03-06 8:37 ` tip-bot for Andy Lutomirski [this message]
2015-03-06 3:19 ` [PATCH v2 2/6] x86: Switch all C consumers of kernel_stack to this_cpu_sp0 Andy Lutomirski
2015-03-06 8:38 ` [tip:x86/asm] x86/asm/entry: Switch all C consumers of kernel_stack to this_cpu_sp0() tip-bot for Andy Lutomirski
2015-03-06 3:19 ` [PATCH v2 3/6] x86, asm: Change the 32-bit sysenter code to use sp0 Andy Lutomirski
2015-03-06 8:38 ` [tip:x86/asm] x86/asm/entry/64/compat: " tip-bot for Andy Lutomirski
2015-03-06 3:19 ` [PATCH v2 4/6] x86: Rename init_tss to cpu_tss Andy Lutomirski
2015-03-06 8:38 ` [tip:x86/asm] x86/asm/entry: Rename 'init_tss' to 'cpu_tss' tip-bot for Andy Lutomirski
2015-03-06 3:19 ` [PATCH v2 5/6] x86: Remove INIT_TSS and fold the definitions into cpu_tss Andy Lutomirski
2015-03-06 8:39 ` [tip:x86/asm] x86/asm/entry: Remove INIT_TSS and fold the definitions into 'cpu_tss' tip-bot for Andy Lutomirski
2015-03-06 3:19 ` [PATCH v2 6/6] x86, asm: Rename INIT_TSS_IST to TSS_IST Andy Lutomirski
2015-03-06 7:30 ` Ingo Molnar
2015-03-06 8:39 ` [tip:x86/asm] x86/asm/entry: Rename 'INIT_TSS_IST' to ' CPU_TSS_IST' tip-bot 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=tip-8ef46a672a7d852709561d10672b6eaa8a4acd82@git.kernel.org \
--to=tipbot@zytor.com \
--cc=boris.ostrovsky@oracle.com \
--cc=bp@alien8.de \
--cc=dvlasenk@redhat.com \
--cc=hpa@zytor.com \
--cc=konrad.wilk@oracle.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-tip-commits@vger.kernel.org \
--cc=luto@amacapital.net \
--cc=mingo@kernel.org \
--cc=oleg@redhat.com \
--cc=rusty@rustcorp.com.au \
--cc=tglx@linutronix.de \
--cc=torvalds@linux-foundation.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