From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754332AbbGWWh7 (ORCPT ); Thu, 23 Jul 2015 18:37:59 -0400 Received: from mail.kernel.org ([198.145.29.136]:45771 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753851AbbGWWh4 (ORCPT ); Thu, 23 Jul 2015 18:37:56 -0400 From: Andy Lutomirski To: X86 ML , linux-kernel@vger.kernel.org Cc: Brian Gerst , Steven Rostedt , Willy Tarreau , Borislav Petkov , Thomas Gleixner , Peter Zijlstra , Linus Torvalds , Andy Lutomirski Subject: [PATCH 2/3] x86/entry/64: Teach idtentry to use the IRQ stack Date: Thu, 23 Jul 2015 15:37:47 -0700 Message-Id: <7503dddb38779353769130fe88e85fde948ce788.1437690860.git.luto@kernel.org> X-Mailer: git-send-email 2.4.3 In-Reply-To: References: In-Reply-To: References: Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.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 --- 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