Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

x86/traps: Weaken context tracking entry assertions

We were asserting that we were all the way in CONTEXT_KERNEL
when exception handlers were called. While having this be true
is, I think, a nice goal (or maybe a variant in which we assert
that we're in CONTEXT_KERNEL or some new IRQ context), we're not
quite there.

In particular, if an IRQ interrupts the SYSCALL prologue and the
IRQ handler in turn causes an exception, the exception entry
will be called in RCU IRQ mode but with CONTEXT_USER.

This is okay (nothing goes wrong), but until we fix up the
SYSCALL prologue, we need to avoid warning.

Signed-off-by: Andy Lutomirski <luto@kernel.org>
Acked-by: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Andy Lutomirski <luto@amacapital.net>
Cc: Borislav Petkov <bp@alien8.de>
Cc: Brian Gerst <brgerst@gmail.com>
Cc: Denys Vlasenko <dvlasenk@redhat.com>
Cc: H. Peter Anvin <hpa@zytor.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Oleg Nesterov <oleg@redhat.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Sasha Levin <sasha.levin@oracle.com>
Cc: Thomas Gleixner <tglx@linutronix.de>
Link: http://lkml.kernel.org/r/c81faf3916346c0e04346c441392974f49cd7184.1440133286.git.luto@kernel.org
Signed-off-by: Ingo Molnar <mingo@kernel.org>

authored by

Andy Lutomirski and committed by
Ingo Molnar
f0a97af8 99770737

+9 -9
+9 -9
arch/x86/kernel/traps.c
··· 112 112 void ist_enter(struct pt_regs *regs) 113 113 { 114 114 if (user_mode(regs)) { 115 - CT_WARN_ON(ct_state() != CONTEXT_KERNEL); 115 + rcu_lockdep_assert(rcu_is_watching(), "entry code didn't wake RCU"); 116 116 } else { 117 117 /* 118 118 * We might have interrupted pretty much anything. In ··· 282 282 { 283 283 siginfo_t info; 284 284 285 - CT_WARN_ON(ct_state() != CONTEXT_KERNEL); 285 + rcu_lockdep_assert(rcu_is_watching(), "entry code didn't wake RCU"); 286 286 287 287 if (notify_die(DIE_TRAP, str, regs, error_code, trapnr, signr) != 288 288 NOTIFY_STOP) { ··· 364 364 const struct bndcsr *bndcsr; 365 365 siginfo_t *info; 366 366 367 - CT_WARN_ON(ct_state() != CONTEXT_KERNEL); 367 + rcu_lockdep_assert(rcu_is_watching(), "entry code didn't wake RCU"); 368 368 if (notify_die(DIE_TRAP, "bounds", regs, error_code, 369 369 X86_TRAP_BR, SIGSEGV) == NOTIFY_STOP) 370 370 return; ··· 442 442 { 443 443 struct task_struct *tsk; 444 444 445 - CT_WARN_ON(ct_state() != CONTEXT_KERNEL); 445 + rcu_lockdep_assert(rcu_is_watching(), "entry code didn't wake RCU"); 446 446 conditional_sti(regs); 447 447 448 448 if (v8086_mode(regs)) { ··· 496 496 return; 497 497 498 498 ist_enter(regs); 499 - CT_WARN_ON(ct_state() != CONTEXT_KERNEL); 499 + rcu_lockdep_assert(rcu_is_watching(), "entry code didn't wake RCU"); 500 500 #ifdef CONFIG_KGDB_LOW_LEVEL_TRAP 501 501 if (kgdb_ll_trap(DIE_INT3, "int3", regs, error_code, X86_TRAP_BP, 502 502 SIGTRAP) == NOTIFY_STOP) ··· 729 729 730 730 dotraplinkage void do_coprocessor_error(struct pt_regs *regs, long error_code) 731 731 { 732 - CT_WARN_ON(ct_state() != CONTEXT_KERNEL); 732 + rcu_lockdep_assert(rcu_is_watching(), "entry code didn't wake RCU"); 733 733 math_error(regs, error_code, X86_TRAP_MF); 734 734 } 735 735 736 736 dotraplinkage void 737 737 do_simd_coprocessor_error(struct pt_regs *regs, long error_code) 738 738 { 739 - CT_WARN_ON(ct_state() != CONTEXT_KERNEL); 739 + rcu_lockdep_assert(rcu_is_watching(), "entry code didn't wake RCU"); 740 740 math_error(regs, error_code, X86_TRAP_XF); 741 741 } 742 742 ··· 749 749 dotraplinkage void 750 750 do_device_not_available(struct pt_regs *regs, long error_code) 751 751 { 752 - CT_WARN_ON(ct_state() != CONTEXT_KERNEL); 752 + rcu_lockdep_assert(rcu_is_watching(), "entry code didn't wake RCU"); 753 753 BUG_ON(use_eager_fpu()); 754 754 755 755 #ifdef CONFIG_MATH_EMULATION ··· 775 775 { 776 776 siginfo_t info; 777 777 778 - CT_WARN_ON(ct_state() != CONTEXT_KERNEL); 778 + rcu_lockdep_assert(rcu_is_watching(), "entry code didn't wake RCU"); 779 779 local_irq_enable(); 780 780 781 781 info.si_signo = SIGILL;