Commit fa95d7dc authored by Thomas Gleixner's avatar Thomas Gleixner

x86/idtentry: Switch to conditional RCU handling

Switch all idtentry_enter/exit() users over to the new conditional RCU
handling scheme and make the user mode entries in #DB, #INT3 and #MCE use
the user mode idtentry functions.
Signed-off-by: default avatarThomas Gleixner <tglx@linutronix.de>
Signed-off-by: default avatarIngo Molnar <mingo@kernel.org>
Acked-by: default avatarAndy Lutomirski <luto@kernel.org>
Link: https://lore.kernel.org/r/20200521202117.382387286@linutronix.de
parent 9f9781b6
...@@ -61,11 +61,12 @@ static __always_inline void __##func(struct pt_regs *regs); \ ...@@ -61,11 +61,12 @@ static __always_inline void __##func(struct pt_regs *regs); \
\ \
__visible noinstr void func(struct pt_regs *regs) \ __visible noinstr void func(struct pt_regs *regs) \
{ \ { \
idtentry_enter(regs); \ bool rcu_exit = idtentry_enter_cond_rcu(regs); \
\
instrumentation_begin(); \ instrumentation_begin(); \
__##func (regs); \ __##func (regs); \
instrumentation_end(); \ instrumentation_end(); \
idtentry_exit(regs); \ idtentry_exit_cond_rcu(regs, rcu_exit); \
} \ } \
\ \
static __always_inline void __##func(struct pt_regs *regs) static __always_inline void __##func(struct pt_regs *regs)
...@@ -107,11 +108,12 @@ static __always_inline void __##func(struct pt_regs *regs, \ ...@@ -107,11 +108,12 @@ static __always_inline void __##func(struct pt_regs *regs, \
__visible noinstr void func(struct pt_regs *regs, \ __visible noinstr void func(struct pt_regs *regs, \
unsigned long error_code) \ unsigned long error_code) \
{ \ { \
idtentry_enter(regs); \ bool rcu_exit = idtentry_enter_cond_rcu(regs); \
\
instrumentation_begin(); \ instrumentation_begin(); \
__##func (regs, error_code); \ __##func (regs, error_code); \
instrumentation_end(); \ instrumentation_end(); \
idtentry_exit(regs); \ idtentry_exit_cond_rcu(regs, rcu_exit); \
} \ } \
\ \
static __always_inline void __##func(struct pt_regs *regs, \ static __always_inline void __##func(struct pt_regs *regs, \
......
...@@ -1929,11 +1929,11 @@ static __always_inline void exc_machine_check_kernel(struct pt_regs *regs) ...@@ -1929,11 +1929,11 @@ static __always_inline void exc_machine_check_kernel(struct pt_regs *regs)
static __always_inline void exc_machine_check_user(struct pt_regs *regs) static __always_inline void exc_machine_check_user(struct pt_regs *regs)
{ {
idtentry_enter(regs); idtentry_enter_user(regs);
instrumentation_begin(); instrumentation_begin();
machine_check_vector(regs); machine_check_vector(regs);
instrumentation_end(); instrumentation_end();
idtentry_exit(regs); idtentry_exit_user(regs);
} }
#ifdef CONFIG_X86_64 #ifdef CONFIG_X86_64
......
...@@ -619,18 +619,18 @@ DEFINE_IDTENTRY_RAW(exc_int3) ...@@ -619,18 +619,18 @@ DEFINE_IDTENTRY_RAW(exc_int3)
return; return;
/* /*
* idtentry_enter() uses static_branch_{,un}likely() and therefore * idtentry_enter_user() uses static_branch_{,un}likely() and therefore
* can trigger INT3, hence poke_int3_handler() must be done * can trigger INT3, hence poke_int3_handler() must be done
* before. If the entry came from kernel mode, then use nmi_enter() * before. If the entry came from kernel mode, then use nmi_enter()
* because the INT3 could have been hit in any context including * because the INT3 could have been hit in any context including
* NMI. * NMI.
*/ */
if (user_mode(regs)) { if (user_mode(regs)) {
idtentry_enter(regs); idtentry_enter_user(regs);
instrumentation_begin(); instrumentation_begin();
do_int3_user(regs); do_int3_user(regs);
instrumentation_end(); instrumentation_end();
idtentry_exit(regs); idtentry_exit_user(regs);
} else { } else {
nmi_enter(); nmi_enter();
instrumentation_begin(); instrumentation_begin();
...@@ -877,7 +877,7 @@ static __always_inline void exc_debug_kernel(struct pt_regs *regs, ...@@ -877,7 +877,7 @@ static __always_inline void exc_debug_kernel(struct pt_regs *regs,
static __always_inline void exc_debug_user(struct pt_regs *regs, static __always_inline void exc_debug_user(struct pt_regs *regs,
unsigned long dr6) unsigned long dr6)
{ {
idtentry_enter(regs); idtentry_enter_user(regs);
clear_thread_flag(TIF_BLOCKSTEP); clear_thread_flag(TIF_BLOCKSTEP);
/* /*
...@@ -886,7 +886,7 @@ static __always_inline void exc_debug_user(struct pt_regs *regs, ...@@ -886,7 +886,7 @@ static __always_inline void exc_debug_user(struct pt_regs *regs,
* User wants a sigtrap for that. * User wants a sigtrap for that.
*/ */
handle_debug(regs, dr6, !dr6); handle_debug(regs, dr6, !dr6);
idtentry_exit(regs); idtentry_exit_user(regs);
} }
#ifdef CONFIG_X86_64 #ifdef CONFIG_X86_64
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment