Skip to content

Commit e368110

Browse files
nathanlynchmpe
authored andcommitted
powerpc/rtas: Warn if per-function lock isn't held
If the function descriptor has a populated lock member, then callers are required to hold it across calls. Now that the firmware activation sequence is appropriately guarded, we can warn when the requirement isn't satisfied. __do_enter_rtas_trace() gets reorganized a bit as a result of performing the function descriptor lookup unconditionally now. Reviewed-by: "Aneesh Kumar K.V (IBM)" <[email protected]> Signed-off-by: Nathan Lynch <[email protected]> Signed-off-by: Michael Ellerman <[email protected]> Link: https://msgid.link/20231212-papr-sys_rtas-vs-lockdown-v6-8-e9eafd0c8c6c@linux.ibm.com
1 parent dc7637c commit e368110

File tree

1 file changed

+9
-12
lines changed

1 file changed

+9
-12
lines changed

arch/powerpc/kernel/rtas.c

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -671,28 +671,25 @@ static void __do_enter_rtas(struct rtas_args *args)
671671

672672
static void __do_enter_rtas_trace(struct rtas_args *args)
673673
{
674-
const char *name = NULL;
674+
const struct rtas_function *func = rtas_token_to_function(be32_to_cpu(args->token));
675675

676-
if (args == &rtas_args)
677-
lockdep_assert_held(&rtas_lock);
678676
/*
679-
* If the tracepoints that consume the function name aren't
680-
* active, avoid the lookup.
677+
* If there is a per-function lock, it must be held by the
678+
* caller.
681679
*/
682-
if ((trace_rtas_input_enabled() || trace_rtas_output_enabled())) {
683-
const s32 token = be32_to_cpu(args->token);
684-
const struct rtas_function *func = rtas_token_to_function(token);
680+
if (func->lock)
681+
lockdep_assert_held(func->lock);
685682

686-
name = func->name;
687-
}
683+
if (args == &rtas_args)
684+
lockdep_assert_held(&rtas_lock);
688685

689-
trace_rtas_input(args, name);
686+
trace_rtas_input(args, func->name);
690687
trace_rtas_ll_entry(args);
691688

692689
__do_enter_rtas(args);
693690

694691
trace_rtas_ll_exit(args);
695-
trace_rtas_output(args, name);
692+
trace_rtas_output(args, func->name);
696693
}
697694

698695
static void do_enter_rtas(struct rtas_args *args)

0 commit comments

Comments
 (0)