From: Andy Lutomirski <luto@kernel.org>
To: X86 ML <x86@kernel.org>, linux-kernel@vger.kernel.org
Cc: Brian Gerst <brgerst@gmail.com>,
Steven Rostedt <rostedt@goodmis.org>, Willy Tarreau <w@1wt.eu>,
Borislav Petkov <bp@alien8.de>,
Thomas Gleixner <tglx@linutronix.de>,
Peter Zijlstra <peterz@infradead.org>,
Linus Torvalds <torvalds@linux-foundation.org>,
Andy Lutomirski <luto@kernel.org>
Subject: [PATCH 2/3] x86/entry/64: Teach idtentry to use the IRQ stack
Date: Thu, 23 Jul 2015 15:37:47 -0700 [thread overview]
Message-ID: <7503dddb38779353769130fe88e85fde948ce788.1437690860.git.luto@kernel.org> (raw)
In-Reply-To: <cover.1437690860.git.luto@kernel.org>
In-Reply-To: <cover.1437690860.git.luto@kernel.org>
We don't specifically need IST for things like kprobes, but we do
want to avoid rare, surprising extra stack usage if a kprobe hits
with a deep stack.
Teach idtentry to use the IRQ stack for selected entries.
This implementation uses the IRQ stack even if we entered from user
mode. This disallows tricks like ist_begin_non_atomic. If we ever
need such a trick in one of these entries, we can rework this. For
now, let's keep it simple.
Signed-off-by: Andy Lutomirski <luto@kernel.org>
---
arch/x86/entry/entry_64.S | 14 +++++++++++++-
1 file changed, 13 insertions(+), 1 deletion(-)
diff --git a/arch/x86/entry/entry_64.S b/arch/x86/entry/entry_64.S
index 5f7df8949fa7..ce72beba6045 100644
--- a/arch/x86/entry/entry_64.S
+++ b/arch/x86/entry/entry_64.S
@@ -739,13 +739,17 @@ apicinterrupt IRQ_WORK_VECTOR irq_work_interrupt smp_irq_work_interrupt
*/
#define CPU_TSS_IST(x) PER_CPU_VAR(cpu_tss) + (TSS_ist + ((x) - 1) * 8)
-.macro idtentry sym do_sym has_error_code:req paranoid=0 shift_ist=-1
+.macro idtentry sym do_sym has_error_code:req irqstack=0 paranoid=0 shift_ist=-1
ENTRY(\sym)
/* Sanity check */
.if \shift_ist != -1 && \paranoid == 0
.error "using shift_ist requires paranoid=1"
.endif
+ .if \irqstack && \paranoid
+ .error "using irqstack requires !paranoid"
+ .endif
+
ASM_CLAC
PARAVIRT_ADJUST_EXCEPTION_FRAME
@@ -787,8 +791,16 @@ ENTRY(\sym)
subq $EXCEPTION_STKSZ, CPU_TSS_IST(\shift_ist)
.endif
+ .if \irqstack
+ ENTER_IRQ_STACK old_rsp=%rcx
+ .endif
+
call \do_sym
+ .if \irqstack
+ LEAVE_IRQ_STACK
+ .endif
+
.if \shift_ist != -1
addq $EXCEPTION_STKSZ, CPU_TSS_IST(\shift_ist)
.endif
--
2.4.3
next prev parent reply other threads:[~2015-07-23 22:37 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-07-23 22:37 [PATCH 0/3] x86_64: Make int3 non-magical Andy Lutomirski
2015-07-23 22:37 ` [PATCH 1/3] x86/entry/64: Refactor IRQ stacks and make then NMI-safe Andy Lutomirski
2015-07-24 6:08 ` Andy Lutomirski
2015-07-24 10:25 ` Borislav Petkov
2015-07-24 18:02 ` Andy Lutomirski
2015-07-25 4:16 ` Borislav Petkov
2015-07-25 4:28 ` Andy Lutomirski
2015-07-25 4:32 ` Borislav Petkov
2015-07-25 4:59 ` Andy Lutomirski
2015-07-25 8:39 ` Borislav Petkov
2015-07-25 17:56 ` Linus Torvalds
2015-07-25 17:59 ` Andy Lutomirski
2015-07-25 18:12 ` Linus Torvalds
2015-08-05 8:59 ` Ingo Molnar
2015-08-05 18:24 ` Andy Lutomirski
2015-08-05 18:27 ` Steven Rostedt
2015-08-05 18:32 ` Andy Lutomirski
2015-08-22 13:55 ` Ingo Molnar
2015-07-23 22:37 ` Andy Lutomirski [this message]
2015-07-23 22:37 ` [PATCH 3/3] x86/entry/64: Move #BP from IST to the IRQ stack Andy Lutomirski
2015-07-24 11:02 ` Borislav Petkov
2015-07-23 22:39 ` [PATCH 0/3] x86_64: Make int3 non-magical 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=7503dddb38779353769130fe88e85fde948ce788.1437690860.git.luto@kernel.org \
--to=luto@kernel.org \
--cc=bp@alien8.de \
--cc=brgerst@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=peterz@infradead.org \
--cc=rostedt@goodmis.org \
--cc=tglx@linutronix.de \
--cc=torvalds@linux-foundation.org \
--cc=w@1wt.eu \
--cc=x86@kernel.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®