Subject: [PATCH 17/28] arm64: module: Use RCU in all users of __module_text_address().
From: Sebastian Andrzej Siewior <[email-masked]>
Date: Wed, 8 Jan 2025 10:04:46 +0100

__module_text_address() can be invoked within a RCU section, there is no
requirement to have preemption disabled.

Replace the preempt_disable() section around __module_text_address()
with RCU.

Cc: Catalin Marinas <[email-masked]>
Cc: Mark Rutland <[email-masked]>
Cc: Masami Hiramatsu <[email-masked]>
Cc: Steven Rostedt <[email-masked]>
Cc: Will Deacon <[email-masked]>
Cc: [email-masked]
Cc: [email-masked]
Acked-by: Peter Zijlstra (Intel) <[email-masked]>
Link: https://lore.kernel.org/r/[email-masked]
Signed-off-by: Sebastian Andrzej Siewior <[email-masked]>
---
 arch/arm64/kernel/ftrace.c |    7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)

--- a/arch/arm64/kernel/ftrace.c
+++ b/arch/arm64/kernel/ftrace.c
@@ -320,14 +320,13 @@ static bool ftrace_find_callable_addr(st
 	 * dealing with an out-of-range condition, we can assume it
 	 * is due to a module being loaded far away from the kernel.
 	 *
-	 * NOTE: __module_text_address() must be called with preemption
-	 * disabled, but we can rely on ftrace_lock to ensure that 'mod'
+	 * NOTE: __module_text_address() must be called within a RCU read
+	 * section, but we can rely on ftrace_lock to ensure that 'mod'
 	 * retains its validity throughout the remainder of this code.
 	 */
 	if (!mod) {
-		preempt_disable();
+		guard(rcu)();
 		mod = __module_text_address(pc);
-		preempt_enable();
 	}
 
 	if (WARN_ON(!mod))