Skip to content

Commit 14daa3b

Browse files
Sebastian Andrzej Siewiorpetrpavlu
authored andcommitted
x86: Use RCU in all users of __module_address().
__module_address() can be invoked within a RCU section, there is no requirement to have preemption disabled. Replace the preempt_disable() section around __module_address() with RCU. Cc: H. Peter Anvin <hpa@zytor.com> Cc: Borislav Petkov <bp@alien8.de> Cc: Dave Hansen <dave.hansen@linux.intel.com> Cc: Ingo Molnar <mingo@redhat.com> Cc: Josh Poimboeuf <jpoimboe@kernel.org> Cc: Peter Zijlstra <peterz@infradead.org> Cc: Thomas Gleixner <tglx@linutronix.de> Cc: x86@kernel.org Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de> Acked-by: Peter Zijlstra (Intel) <peterz@infradead.org> Link: https://lore.kernel.org/r/20250108090457.512198-23-bigeasy@linutronix.de Signed-off-by: Petr Pavlu <petr.pavlu@suse.com>
1 parent e151955 commit 14daa3b

File tree

2 files changed

+2
-5
lines changed

2 files changed

+2
-5
lines changed

arch/x86/kernel/callthunks.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -98,11 +98,10 @@ static inline bool within_module_coretext(void *addr)
9898
#ifdef CONFIG_MODULES
9999
struct module *mod;
100100

101-
preempt_disable();
101+
guard(rcu)();
102102
mod = __module_address((unsigned long)addr);
103103
if (mod && within_module_core((unsigned long)addr, mod))
104104
ret = true;
105-
preempt_enable();
106105
#endif
107106
return ret;
108107
}

arch/x86/kernel/unwind_orc.c

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -476,7 +476,7 @@ bool unwind_next_frame(struct unwind_state *state)
476476
return false;
477477

478478
/* Don't let modules unload while we're reading their ORC data. */
479-
preempt_disable();
479+
guard(rcu)();
480480

481481
/* End-of-stack check for user tasks: */
482482
if (state->regs && user_mode(state->regs))
@@ -669,14 +669,12 @@ bool unwind_next_frame(struct unwind_state *state)
669669
goto err;
670670
}
671671

672-
preempt_enable();
673672
return true;
674673

675674
err:
676675
state->error = true;
677676

678677
the_end:
679-
preempt_enable();
680678
state->stack_info.type = STACK_TYPE_UNKNOWN;
681679
return false;
682680
}

0 commit comments

Comments
 (0)