From: tip-bot for Andy Lutomirski <tipbot@zytor.com>
To: linux-tip-commits@vger.kernel.org
Cc: bp@alien8.de, mingo@kernel.org, oleg@redhat.com,
torvalds@linux-foundation.org, linux-kernel@vger.kernel.org,
hpa@zytor.com, tglx@linutronix.de, luto@amacapital.net,
dvlasenk@redhat.com
Subject: [tip:x86/asm] x86/asm/entry: Switch all C consumers of kernel_stack to this_cpu_sp0()
Date: Fri, 6 Mar 2015 00:38:00 -0800 [thread overview]
Message-ID: <tip-75182b1632a89f12540baa1806a7c5c180db620c@git.kernel.org> (raw)
In-Reply-To: <ef8254ad414cbb8034c9a56396eeb24f5dd5b0de.1425611534.git.luto@amacapital.net>
Commit-ID: 75182b1632a89f12540baa1806a7c5c180db620c
Gitweb: http://git.kernel.org/tip/75182b1632a89f12540baa1806a7c5c180db620c
Author: Andy Lutomirski <luto@amacapital.net>
AuthorDate: Thu, 5 Mar 2015 19:19:03 -0800
Committer: Ingo Molnar <mingo@kernel.org>
CommitDate: Fri, 6 Mar 2015 08:32:57 +0100
x86/asm/entry: Switch all C consumers of kernel_stack to this_cpu_sp0()
This will make modifying the semantics of kernel_stack easier.
The change to ist_begin_non_atomic() is necessary because sp0 no
longer points to the same THREAD_SIZE-aligned region as RSP;
it's one byte too high for that. At Denys' suggestion, rather
than offsetting it, just check explicitly that we're in the
correct range ending at sp0. This has the added benefit that we
no longer assume that the thread stack is aligned to
THREAD_SIZE.
Suggested-by: Denys Vlasenko <dvlasenk@redhat.com>
Signed-off-by: Andy Lutomirski <luto@amacapital.net>
Cc: Borislav Petkov <bp@alien8.de>
Cc: H. Peter Anvin <hpa@zytor.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Oleg Nesterov <oleg@redhat.com>
Cc: Thomas Gleixner <tglx@linutronix.de>
Link: http://lkml.kernel.org/r/ef8254ad414cbb8034c9a56396eeb24f5dd5b0de.1425611534.git.luto@amacapital.net
Signed-off-by: Ingo Molnar <mingo@kernel.org>
---
arch/x86/include/asm/thread_info.h | 3 +--
arch/x86/kernel/traps.c | 4 ++--
2 files changed, 3 insertions(+), 4 deletions(-)
diff --git a/arch/x86/include/asm/thread_info.h b/arch/x86/include/asm/thread_info.h
index 1d4e4f2..a2fa189 100644
--- a/arch/x86/include/asm/thread_info.h
+++ b/arch/x86/include/asm/thread_info.h
@@ -159,8 +159,7 @@ DECLARE_PER_CPU(unsigned long, kernel_stack);
static inline struct thread_info *current_thread_info(void)
{
struct thread_info *ti;
- ti = (void *)(this_cpu_read_stable(kernel_stack) +
- KERNEL_STACK_OFFSET - THREAD_SIZE);
+ ti = (void *)(this_cpu_sp0() - THREAD_SIZE);
return ti;
}
diff --git a/arch/x86/kernel/traps.c b/arch/x86/kernel/traps.c
index 9965bd1..fa29058 100644
--- a/arch/x86/kernel/traps.c
+++ b/arch/x86/kernel/traps.c
@@ -174,8 +174,8 @@ void ist_begin_non_atomic(struct pt_regs *regs)
* will catch asm bugs and any attempt to use ist_preempt_enable
* from double_fault.
*/
- BUG_ON(((current_stack_pointer() ^ this_cpu_read_stable(kernel_stack))
- & ~(THREAD_SIZE - 1)) != 0);
+ BUG_ON((unsigned long)(this_cpu_sp0() - current_stack_pointer()) >=
+ THREAD_SIZE);
preempt_count_sub(HARDIRQ_OFFSET);
}
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:x86/asm] x86/asm/entry: " tip-bot for Andy Lutomirski
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-bot for Andy Lutomirski [this message]
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-75182b1632a89f12540baa1806a7c5c180db620c@git.kernel.org \
--to=tipbot@zytor.com \
--cc=bp@alien8.de \
--cc=dvlasenk@redhat.com \
--cc=hpa@zytor.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=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