Skip to content

Commit f87d286

Browse files
jpoimboeKAGA-KOKO
authored andcommitted
entry: Fix noinstr warning in __enter_from_user_mode()
__enter_from_user_mode() is triggering noinstr warnings with CONFIG_DEBUG_PREEMPT due to its call of preempt_count_add() via ct_state(). The preemption disable isn't needed as interrupts are already disabled. And the context_tracking_enabled() check in ct_state() also isn't needed as that's already being done by the CT_WARN_ON(). Just use __ct_state() instead. Fixes the following warnings: vmlinux.o: warning: objtool: enter_from_user_mode+0xba: call to preempt_count_add() leaves .noinstr.text section vmlinux.o: warning: objtool: syscall_enter_from_user_mode+0xf9: call to preempt_count_add() leaves .noinstr.text section vmlinux.o: warning: objtool: syscall_enter_from_user_mode_prepare+0xc7: call to preempt_count_add() leaves .noinstr.text section vmlinux.o: warning: objtool: irqentry_enter_from_user_mode+0xba: call to preempt_count_add() leaves .noinstr.text section Fixes: 1714767 ("context_tracking: Convert state to atomic_t") Signed-off-by: Josh Poimboeuf <jpoimboe@kernel.org> Signed-off-by: Thomas Gleixner <tglx@linutronix.de> Link: https://lore.kernel.org/r/d8955fa6d68dc955dda19baf13ae014ae27926f5.1677369694.git.jpoimboe@kernel.org
1 parent e8d018d commit f87d286

File tree

3 files changed

+4
-1
lines changed

3 files changed

+4
-1
lines changed

include/linux/context_tracking.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,7 @@ static inline void user_exit_irqoff(void) { }
9696
static inline int exception_enter(void) { return 0; }
9797
static inline void exception_exit(enum ctx_state prev_ctx) { }
9898
static inline int ct_state(void) { return -1; }
99+
static inline int __ct_state(void) { return -1; }
99100
static __always_inline bool context_tracking_guest_enter(void) { return false; }
100101
static inline void context_tracking_guest_exit(void) { }
101102
#define CT_WARN_ON(cond) do { } while (0)

include/linux/context_tracking_state.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,9 @@ struct context_tracking {
4646

4747
#ifdef CONFIG_CONTEXT_TRACKING
4848
DECLARE_PER_CPU(struct context_tracking, context_tracking);
49+
#endif
4950

51+
#ifdef CONFIG_CONTEXT_TRACKING_USER
5052
static __always_inline int __ct_state(void)
5153
{
5254
return arch_atomic_read(this_cpu_ptr(&context_tracking.state)) & CT_STATE_MASK;

kernel/entry/common.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ static __always_inline void __enter_from_user_mode(struct pt_regs *regs)
2121
arch_enter_from_user_mode(regs);
2222
lockdep_hardirqs_off(CALLER_ADDR0);
2323

24-
CT_WARN_ON(ct_state() != CONTEXT_USER);
24+
CT_WARN_ON(__ct_state() != CONTEXT_USER);
2525
user_exit_irqoff();
2626

2727
instrumentation_begin();

0 commit comments

Comments
 (0)