Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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)" <aneesh.kumar@kernel.org>
Signed-off-by: Nathan Lynch <nathanl@linux.ibm.com>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Link: https://msgid.link/20231212-papr-sys_rtas-vs-lockdown-v6-8-e9eafd0c8c6c@linux.ibm.com

authored by

Nathan Lynch and committed by
Michael Ellerman
e3681107 dc7637c4

+10 -13
+10 -13
arch/powerpc/kernel/rtas.c
··· 671 671 672 672 static void __do_enter_rtas_trace(struct rtas_args *args) 673 673 { 674 - const char *name = NULL; 674 + const struct rtas_function *func = rtas_token_to_function(be32_to_cpu(args->token)); 675 + 676 + /* 677 + * If there is a per-function lock, it must be held by the 678 + * caller. 679 + */ 680 + if (func->lock) 681 + lockdep_assert_held(func->lock); 675 682 676 683 if (args == &rtas_args) 677 684 lockdep_assert_held(&rtas_lock); 678 - /* 679 - * If the tracepoints that consume the function name aren't 680 - * active, avoid the lookup. 681 - */ 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); 685 685 686 - name = func->name; 687 - } 688 - 689 - trace_rtas_input(args, name); 686 + trace_rtas_input(args, func->name); 690 687 trace_rtas_ll_entry(args); 691 688 692 689 __do_enter_rtas(args); 693 690 694 691 trace_rtas_ll_exit(args); 695 - trace_rtas_output(args, name); 692 + trace_rtas_output(args, func->name); 696 693 } 697 694 698 695 static void do_enter_rtas(struct rtas_args *args)