Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1727755
| Path | csiph.com!news.redatomik.org!aioe.org!bofh.it!news.nic.it!robomod |
|---|---|
| From | Andy Lutomirski <luto@kernel.org> |
| Newsgroups | linux.kernel |
| Subject | [RFC 17/17] x86/traps: Use a new on_thread_stack() helper to clean up an assertion |
| Date | Wed, 06 Sep 2017 23:40:02 +0200 |
| Message-ID | <umQdc-7qi-7@gated-at.bofh.it> (permalink) |
| References | <umQdc-7qi-3@gated-at.bofh.it> |
| X-Original-To | x86@kernel.org |
| Dmarc-Filter | OpenDMARC Filter v1.3.2 mail.kernel.org 4DB7122A9D |
| Authentication-Results | mail.kernel.org; dmarc=none (p=none dis=none) header.from=kernel.org |
| Authentication-Results | mail.kernel.org; spf=none smtp.mailfrom=luto@kernel.org |
| X-Mailer | git-send-email 2.13.5 |
| Sender | robomod@news.nic.it |
| List-ID | <linux-kernel.vger.kernel.org> |
| X-Mailing-List | linux-kernel@vger.kernel.org |
| Approved | robomod@news.nic.it |
| Lines | 73 |
| Organization | linux.* mail to news gateway |
| X-Original-Cc | linux-kernel@vger.kernel.org, Borislav Petkov <bp@alien8.de>, Brian Gerst <brgerst@gmail.com>, Andrew Cooper <andrew.cooper3@citrix.com>, Juergen Gross <jgross@suse.com>, Boris Ostrovsky <boris.ostrovsky@oracle.com>, Kees Cook <keescook@chromium.org>, Andy Lutomirski <luto@kernel.org> |
| X-Original-Date | Wed, 6 Sep 2017 14:37:02 -0700 |
| X-Original-Message-ID | <eabfbaaf295473e4d6fda700bb346af766fcee80.1504733277.git.luto@kernel.org> |
| X-Original-References | <cover.1504733277.git.luto@kernel.org> |
| X-Original-Sender | linux-kernel-owner@vger.kernel.org |
| Xref | csiph.com linux.kernel:1727755 |
Show key headers only | View raw
Signed-off-by: Andy Lutomirski <luto@kernel.org>
---
arch/x86/include/asm/processor.h | 17 +++++++++++++++++
arch/x86/include/asm/thread_info.h | 11 -----------
arch/x86/kernel/traps.c | 3 +--
3 files changed, 18 insertions(+), 13 deletions(-)
diff --git a/arch/x86/include/asm/processor.h b/arch/x86/include/asm/processor.h
index 4c137472f530..b6f8dc11c222 100644
--- a/arch/x86/include/asm/processor.h
+++ b/arch/x86/include/asm/processor.h
@@ -534,6 +534,23 @@ static inline unsigned long current_top_of_stack(void)
#endif
}
+static inline unsigned long current_stack_pointer(void)
+{
+ unsigned long sp;
+#ifdef CONFIG_X86_64
+ asm("mov %%rsp,%0" : "=g" (sp));
+#else
+ asm("mov %%esp,%0" : "=g" (sp));
+#endif
+ return sp;
+}
+
+static inline bool on_thread_stack(void)
+{
+ return (unsigned long)(current_top_of_stack() -
+ current_stack_pointer()) < THREAD_SIZE;
+}
+
#ifdef CONFIG_PARAVIRT
#include <asm/paravirt.h>
#else
diff --git a/arch/x86/include/asm/thread_info.h b/arch/x86/include/asm/thread_info.h
index e00e1bd6e7b3..90e1f9b84534 100644
--- a/arch/x86/include/asm/thread_info.h
+++ b/arch/x86/include/asm/thread_info.h
@@ -155,17 +155,6 @@ struct thread_info {
*/
#ifndef __ASSEMBLY__
-static inline unsigned long current_stack_pointer(void)
-{
- unsigned long sp;
-#ifdef CONFIG_X86_64
- asm("mov %%rsp,%0" : "=g" (sp));
-#else
- asm("mov %%esp,%0" : "=g" (sp));
-#endif
- return sp;
-}
-
/*
* Walks up the stack frames to make sure that the specified object is
* entirely contained by a single stack frame.
diff --git a/arch/x86/kernel/traps.c b/arch/x86/kernel/traps.c
index bf54309b85da..0347ed41c92d 100644
--- a/arch/x86/kernel/traps.c
+++ b/arch/x86/kernel/traps.c
@@ -153,8 +153,7 @@ 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((unsigned long)(current_top_of_stack() -
- current_stack_pointer()) >= THREAD_SIZE);
+ BUG_ON(!on_thread_stack());
preempt_enable_no_resched();
}
--
2.13.5
Back to linux.kernel | Previous | Next | Find similar | Unroll thread
[RFC 17/17] x86/traps: Use a new on_thread_stack() helper to clean up an assertion Andy Lutomirski <luto@kernel.org> - 2017-09-06 23:40 +0200
csiph-web