x86/asm changes for v3.20
Subsystems (3)
Linus,
Please pull the latest x86-asm-for-linus git tree from:
git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip.git x86-asm-for-linus
# HEAD: b57c0b5175ddbe9b477801f9994a5b330702c1ba Merge tag 'pr-20150201-x86-entry' of git://git.kernel.org/pub/scm/linux/kernel/git/luto/linux into x86/asm
[ NOTE: there's a (single) RCU commit this tree depends on
semantically (734d16801349), which is also present in the RCU tree, which might throw off your diffstat. ]
The main changes in this cycle were the x86/entry and sysret enhancements from Andy Lutomirski, see merge commits 772a9aca125 and b57c0b5175dd for details.
out-of-topic modifications in x86-asm-for-linus:
--------------------------------------------------
kernel/rcu/tree.c # 734d16801349: rcu: Make rcu_nmi_enter() ha
Thanks,
Ingo
------------------>
Andrey Skvortsov (1):
x86, vdso: teach 'make clean' remove vdso64 binaries
Andy Lutomirski (8):
x86, entry: Switch stacks on a paranoid entry from userspace x86, traps: Track entry into and exit from IST context
x86: Clean up current_stack_pointer
x86, traps: Add ist_begin_non_atomic and ist_end_non_atomic x86_64 entry: Fix RCX for ptraced syscalls
x86, traps: Fix ist_enter from userspace
x86_64, entry: Use sysret to return to userspace when possible x86_64, entry: Remove the syscall exit audit and schedule optimizations
Denys Vlasenko (3):
x86: entry_64.S: delete unused code
x86: ia32entry.S: fix wrong symbolic constant usage: R11->ARGOFFSET
x86: entry_64.S: fold SAVE_ARGS_IRQ macro into its sole user
Paul E. McKenney (1):
rcu: Make rcu_nmi_enter() handle nesting
Tony Luck (1):
x86, mce: Get rid of TIF_MCE_NOTIFY and associated mce tricks
Documentation/x86/entry_64.txt | 18 +- Documentation/x86/x86_64/kernel-stacks | 8 +- arch/x86/ia32/ia32entry.S | 4 +- arch/x86/include/asm/calling.h | 1 - arch/x86/include/asm/mce.h | 1 - arch/x86/include/asm/thread_info.h | 15 +- arch/x86/include/asm/traps.h | 6 + arch/x86/kernel/cpu/mcheck/mce.c | 114 ++++-------- arch/x86/kernel/cpu/mcheck/p5.c | 6 + arch/x86/kernel/cpu/mcheck/winchip.c | 5 + arch/x86/kernel/entry_64.S | 317 +++++++++++++++------------------ arch/x86/kernel/irq_32.c | 13 +- arch/x86/kernel/signal.c | 6 - arch/x86/kernel/traps.c | 119 ++++++++++--- arch/x86/vdso/Makefile | 2 +- kernel/rcu/tree.c | 66 +++++-- 16 files changed, 374 insertions(+), 327 deletions(-)
Documentation/x86/entry_64.txt +12 -6
@@ -78,9 +78,6 @@ The expensive (paranoid) way is to read back the MSR_GS_BASE value xorl %ebx,%ebx 1: ret -and the whole paranoid non-paranoid macro complexity is about whether -to suffer that RDMSR cost. - If we are at an interrupt or user-trap/gate-alike boundary then we can use the faster check: the stack will be a reliable indicator of whether SWAPGS was already done: if we see that we are a secondary
@@ -93,6 +90,15 @@ which might have triggered right after a normal entry wrote CS to the stack but before we executed SWAPGS, then the only safe way to check for GS is the slower method: the RDMSR. -So we try only to mark those entry methods 'paranoid' that absolutely -need the more expensive check for the GS base - and we generate all -'normal' entry points with the regular (faster) entry macros. +Therefore, super-atomic entries (except NMI, which is handled separately) +must use idtentry with paranoid=1 to handle gsbase correctly. This +triggers three main behavior changes: + + - Interrupt entry will use the slower gsbase check. + - Interrupt entry from user mode will switch off the IST stack. + - Interrupt exit to kernel mode will not attempt to reschedule. + +We try to only use IST entries and the paranoid entry code for vectors +that absolutely need the more expensive check for the GS base - and we +generate all 'normal' entry points with the regular (faster) paranoid=0 +variant.
Documentation/x86/x86_64/kernel-stacks +5 -3
@@ -40,9 +40,11 @@ An IST is selected by a non-zero value in the IST field of an interrupt-gate descriptor. When an interrupt occurs and the hardware loads such a descriptor, the hardware automatically sets the new stack pointer based on the IST value, then invokes the interrupt handler. If -software wants to allow nested IST interrupts then the handler must -adjust the IST values on entry to and exit from the interrupt handler. -(This is occasionally done, e.g. for debug exceptions.) +the interrupt came from user mode, then the interrupt handler prologue +will switch back to the per-thread stack. If software wants to allow +nested IST interrupts then the handler must adjust the IST values on +entry to and exit from the interrupt handler. (This is occasionally +done, e.g. for debug exceptions.) Events with different IST codes (i.e. with different stacks) can be nested. For example, a debug interrupt can safely be interrupted by an
arch/x86/ia32/ia32entry.S +2 -2
@@ -179,8 +179,8 @@ ENTRY(ia32_sysenter_target) sysexit_from_sys_call: andl $~TS_COMPAT,TI_status+THREAD_INFO(%rsp,RIP-ARGOFFSET) /* clear IF, that popfq doesn't enable interrupts early */ - andl $~0x200,EFLAGS-R11(%rsp) - movl RIP-R11(%rsp),%edx /* User %eip */ + andl $~0x200,EFLAGS-ARGOFFSET(%rsp) + movl RIP-ARGOFFSET(%rsp),%edx /* User %eip */ CFI_REGISTER rip,rdx RESTORE_ARGS 0,24,0,0,0,0 xorq %r8,%r8
arch/x86/include/asm/calling.h +0 -1
@@ -83,7 +83,6 @@ For 32-bit we have the following conventions - kernel is built with#define SS 160#define ARGOFFSET R11 -#define SWFRAME ORIG_RAX .macro SAVE_ARGS addskip=0, save_rcx=1, save_r891011=1, rax_enosys=0 subq $9*8+\addskip, %rsp
arch/x86/include/asm/mce.h +0 -1
@@ -190,7 +190,6 @@ enum mcp_flags {void machine_check_poll (enum mcp_flags flags,mce_banks_t *b);int mce_notify_irq (void ); -void mce_notify_process (void ); DECLARE_PER_CPU(struct mce, injectm);
arch/x86/include/asm/thread_info.h +12 -3
@@ -75,7 +75,6 @@ struct thread_info {#define TIF_SYSCALL_EMU 6/* syscall emulation active */ #define TIF_SYSCALL_AUDIT 7/* syscall auditing active */ #define TIF_SECCOMP 8/* secure computing */ -#define TIF_MCE_NOTIFY 10/* notify userspace of an MCE */ #define TIF_USER_RETURN_NOTIFY 11/* notify kernel of userspace return */ #define TIF_UPROBE 12/* breakpointed or singlestepping */ #define TIF_NOTSC 16/* TSC is not accessible in userland */
@@ -100,7 +99,6 @@ struct thread_info {#define _TIF_SYSCALL_EMU (1 << TIF_SYSCALL_EMU)#define _TIF_SYSCALL_AUDIT (1 << TIF_SYSCALL_AUDIT)#define _TIF_SECCOMP (1 << TIF_SECCOMP) -#define _TIF_MCE_NOTIFY (1 << TIF_MCE_NOTIFY)#define _TIF_USER_RETURN_NOTIFY (1 << TIF_USER_RETURN_NOTIFY)#define _TIF_UPROBE (1 << TIF_UPROBE)#define _TIF_NOTSC (1 << TIF_NOTSC)
@@ -140,7 +138,7 @@ struct thread_info {/* Only used for 64 bit */ #define _TIF_DO_NOTIFY_MASK \ - (_TIF_SIGPENDING | _TIF_MCE_NOTIFY | _TIF_NOTIFY_RESUME | \ + (_TIF_SIGPENDING | _TIF_NOTIFY_RESUME | \ _TIF_USER_RETURN_NOTIFY | _TIF_UPROBE)/* flags to check in __switch_to() */
@@ -170,6 +168,17 @@ static inline struct thread_info *current_thread_info(void) return ti; } +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; +} +#else /* !__ASSEMBLY__ */ /* how to get the thread information struct from ASM */
arch/x86/include/asm/traps.h +6 -0
@@ -1,6 +1,7 @@#ifndef _ASM_X86_TRAPS_H#define _ASM_X86_TRAPS_H +#include <linux/context_tracking_state.h> #include <linux/kprobes.h> #include <asm/debugreg.h>
@@ -110,6 +111,11 @@ asmlinkage void smp_thermal_interrupt(void); asmlinkage void mce_threshold_interrupt(void);#endif +extern enum ctx_state ist_enter (struct pt_regs *regs); +extern void ist_exit (struct pt_regs *regs,enum ctx_state prev_state); +extern void ist_begin_non_atomic (struct pt_regs *regs); +extern void ist_end_non_atomic (void ); +/* Interrupts/Exceptions */ enum {X86_TRAP_DE =0 ,/* 0, Divide-by-zero */
arch/x86/kernel/cpu/mcheck/mce.c +30 -84
156 lines not on this page · raw message
arch/x86/kernel/cpu/mcheck/p5.c +6 -0
@@ -8,6 +8,7 @@#include <linux/smp.h> #include <asm/processor.h> +#include <asm/traps.h> #include <asm/mce.h> #include <asm/msr.h>
@@ -17,8 +18,11 @@ int mce_p5_enabled __read_mostly;/* Machine check handler for Pentium class Intel CPUs: */ static void pentium_machine_check (struct pt_regs *regs,long error_code) { +enum ctx_state prev_state;u32 loaddr, hi, lotype; + prev_state =ist_enter (regs); +rdmsr (MSR_IA32_P5_MC_ADDR , loaddr, hi);rdmsr (MSR_IA32_P5_MC_TYPE , lotype, hi);
@@ -33,6 +37,8 @@ static void pentium_machine_check(struct pt_regs *regs, long error_code) }add_taint (TAINT_MACHINE_CHECK ,LOCKDEP_NOW_UNRELIABLE ); + +ist_exit (regs, prev_state); }/* Set up machine check reporting for processors with Intel style MCE: */
arch/x86/kernel/cpu/mcheck/winchip.c +5 -0
@@ -7,14 +7,19 @@#include <linux/types.h> #include <asm/processor.h> +#include <asm/traps.h> #include <asm/mce.h> #include <asm/msr.h> /* Machine check handler for WinChip C6: */ static void winchip_machine_check (struct pt_regs *regs,long error_code) { +enum ctx_state prev_state =ist_enter (regs); +printk (KERN_EMERG "CPU0: Machine Check Exception.\n" );add_taint (TAINT_MACHINE_CHECK ,LOCKDEP_NOW_UNRELIABLE ); + +ist_exit (regs, prev_state); }/* Set up machine check reporting on the Winchip C6 series */
arch/x86/kernel/entry_64.S +148 -169
407 lines not on this page · raw message
arch/x86/kernel/irq_32.c +3 -10
@@ -69,16 +69,9 @@ static void call_on_stack(void *func, void *stack) : "memory", "cc", "edx", "ecx", "eax"); } -/* how to get the current stack pointer from C */ -#define current_stack_pointer ({ \ - unsigned long sp; \ - asm("mov %%esp,%0" : "=g" (sp)); \ - sp; \ -}) -static inline void *current_stack (void ) { -return (void *)(current_stack_pointer & ~(THREAD_SIZE -1 )); +return (void *)(current_stack_pointer () & ~(THREAD_SIZE -1 )); } static inline int
@@ -103,7 +96,7 @@ execute_on_irq_stack(int overflow, struct irq_desc *desc, int irq)/* Save the next esp at the bottom of the stack */ prev_esp = (u32 *)irqstk; - *prev_esp = current_stack_pointer; + *prev_esp =current_stack_pointer ();if (unlikely (overflow))call_on_stack (print_stack_overflow, isp);
@@ -156,7 +149,7 @@ void do_softirq_own_stack(void)/* Push the previous esp onto the stack */ prev_esp = (u32 *)irqstk; - *prev_esp = current_stack_pointer; + *prev_esp =current_stack_pointer ();call_on_stack (__do_softirq, isp); }
arch/x86/kernel/signal.c +0 -6
@@ -740,12 +740,6 @@ do_notify_resume(struct pt_regs *regs, void *unused, __u32 thread_info_flags) {user_exit (); -#ifdef CONFIG_X86_MCE -/* notify userspace of pending MCEs */ -if (thread_info_flags & _TIF_MCE_NOTIFY) -mce_notify_process (); -#endif /* CONFIG_X86_64 && CONFIG_X86_MCE */ -if (thread_info_flags & _TIF_UPROBE)uprobe_notify_resume (regs);
arch/x86/kernel/traps.c +95 -24
173 lines not on this page · raw message
arch/x86/vdso/Makefile +1 -1
@@ -205,4 +205,4 @@ $(vdso_img_insttargets): install_%: $(obj)/%.dbg $(MODLIB)/vdso FORCE PHONY += vdso_install $(vdso_img_insttargets) vdso_install: $(vdso_img_insttargets) FORCE -clean-files := vdso32-syscall* vdso32-sysenter* vdso32-int80* +clean-files := vdso32-syscall* vdso32-sysenter* vdso32-int80* vdso64*
kernel/rcu/tree.c +49 -17
88 lines not on this page · raw message