From ddc502f2c869b8e6ffdc3973d1047ee655cb7b60 Mon Sep 17 00:00:00 2001 From: Nathan Lynch Date: Thu, 26 Oct 2023 18:42:44 -0500 Subject: [PATCH] Revert "powerpc/rtas: Warn if per-function lock isn't held" This reverts commit 0298609c43fc02bd43cb9fff39e9b5a2206820b3 due to a boot-time oops: BUG: Kernel NULL pointer dereference on read at 0x00000018 Faulting instruction address: 0xc00000000004223c Oops: Kernel access of bad area, sig: 7 [#1] LE PAGE_SIZE=64K MMU=Radix SMP NR_CPUS=2048 NUMA pSeries Modules linked in: CPU: 0 PID: 0 Comm: swapper Tainted: G W 6.6.0-rc2+ #129 NIP: c00000000004223c LR: c000000000042238 CTR: 0000000000000000 REGS: c000000002c579d0 TRAP: 0300 Tainted: G W (6.6.0-rc2+) MSR: 8000000000001033 CR: 28000284 XER: 00000000 CFAR: c000000000042008 DAR: 0000000000000018 DSISR: 00080000 IRQMASK: 3 GPR00: c000000000042238 c000000002c57c70 c000000001f5eb00 0000000000000000 GPR04: c00000000294cd08 0000000000000002 c000000002c579b4 0000000000000000 GPR08: 0000000000000000 0000000000000002 c000000002c0da80 0000000000000000 GPR12: 0000000000000000 c000000005e40000 0000000000000000 0000000002097728 GPR16: 0000000000001111 0000000000000001 0000000002097b80 00000000020975b8 GPR20: 00000000020976f0 00000000020974e8 00000000030feb00 00000000030feb00 GPR24: 0000000000002008 0000000000000000 0000000000000001 c0000000028f3d70 GPR28: 0000000002d31020 c000000002cac268 c000000002d31020 0000000000000000 NIP [c00000000004223c] do_enter_rtas+0xcc/0x460 LR [c000000000042238] do_enter_rtas+0xc8/0x460 Call Trace: [c000000002c57c70] [c000000000042238] do_enter_rtas+0xc8/0x460 (unreliable) [c000000002c57cc0] [c000000000042e34] rtas_call+0x434/0x490 [c000000002c57d20] [c0000000000fd584] papr_sysparm_get+0xe4/0x230 [c000000002c57db0] [c0000000020267d0] pSeries_probe+0x2f0/0x5fc [c000000002c57e80] [c00000000200a318] setup_arch+0x11c/0x524 [c000000002c57f10] [c00000000200418c] start_kernel+0xcc/0xc1c [c000000002c57fe0] [c00000000000e788] start_here_common+0x1c/0x20 --- arch/powerpc/kernel/rtas.c | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/arch/powerpc/kernel/rtas.c b/arch/powerpc/kernel/rtas.c index 0a0ae81fac99..864d140e7247 100644 --- a/arch/powerpc/kernel/rtas.c +++ b/arch/powerpc/kernel/rtas.c @@ -670,25 +670,28 @@ static void __do_enter_rtas(struct rtas_args *args) static void __do_enter_rtas_trace(struct rtas_args *args) { - struct rtas_function *func = rtas_token_to_function(be32_to_cpu(args->token)); + const char *name = NULL; + if (args == &rtas_args) + lockdep_assert_held(&rtas_lock); /* - * If there is a per-function lock, it must be held by the - * caller. + * If the tracepoints that consume the function name aren't + * active, avoid the lookup. */ - if (func->lock) - WARN_ON(!mutex_is_locked(func->lock)); + if ((trace_rtas_input_enabled() || trace_rtas_output_enabled())) { + const s32 token = be32_to_cpu(args->token); + const struct rtas_function *func = rtas_token_to_function(token); - if (args == &rtas_args) - lockdep_assert_held(&rtas_lock); + name = func->name; + } - trace_rtas_input(args, func->name); + trace_rtas_input(args, name); trace_rtas_ll_entry(args); __do_enter_rtas(args); trace_rtas_ll_exit(args); - trace_rtas_output(args, func->name); + trace_rtas_output(args, name); } static void do_enter_rtas(struct rtas_args *args)