mirror of
https://github.com/torvalds/linux.git
synced 2026-06-07 05:55:44 +02:00
UPSTREAM: arm64: sdei: Push IS_ENABLED() checks down to callee functions
Handling all combinations of the VMAP_STACK and SHADOW_CALL_STACK options
in sdei_arch_get_entry_point() makes the code difficult to read,
particularly when considering the error and cleanup paths.
Move the checking of these options into the callee functions, so that
they return early if the relevant option is not enabled.
Bug: 169781940
Change-Id: I3daf8a409d3544fa4e76a28c2b2ae9efb82001ba
(cherry picked from commit eec3bf6861)
Signed-off-by: Will Deacon <will@kernel.org>
Signed-off-by: Sami Tolvanen <samitolvanen@google.com>
This commit is contained in:
parent
1868c4c8cb
commit
0b24bdb73c
|
|
@ -62,6 +62,9 @@ static void free_sdei_stacks(void)
|
|||
{
|
||||
int cpu;
|
||||
|
||||
if (!IS_ENABLED(CONFIG_VMAP_STACK))
|
||||
return;
|
||||
|
||||
for_each_possible_cpu(cpu) {
|
||||
_free_sdei_stack(&sdei_stack_normal_ptr, cpu);
|
||||
_free_sdei_stack(&sdei_stack_critical_ptr, cpu);
|
||||
|
|
@ -85,6 +88,9 @@ static int init_sdei_stacks(void)
|
|||
int cpu;
|
||||
int err = 0;
|
||||
|
||||
if (!IS_ENABLED(CONFIG_VMAP_STACK))
|
||||
return 0;
|
||||
|
||||
for_each_possible_cpu(cpu) {
|
||||
err = _init_sdei_stack(&sdei_stack_normal_ptr, cpu);
|
||||
if (err)
|
||||
|
|
@ -138,6 +144,9 @@ static int init_sdei_scs(void)
|
|||
int cpu;
|
||||
int err = 0;
|
||||
|
||||
if (!IS_ENABLED(CONFIG_SHADOW_CALL_STACK))
|
||||
return 0;
|
||||
|
||||
for_each_possible_cpu(cpu) {
|
||||
err = _init_sdei_scs(&sdei_shadow_call_stack_normal_ptr, cpu);
|
||||
if (err)
|
||||
|
|
@ -193,21 +202,14 @@ unsigned long sdei_arch_get_entry_point(int conduit)
|
|||
*/
|
||||
if (is_hyp_mode_available() && !is_kernel_in_hyp_mode()) {
|
||||
pr_err("Not supported on this hardware/boot configuration\n");
|
||||
return 0;
|
||||
goto out_err;
|
||||
}
|
||||
|
||||
if (IS_ENABLED(CONFIG_VMAP_STACK)) {
|
||||
if (init_sdei_stacks())
|
||||
return 0;
|
||||
}
|
||||
if (init_sdei_stacks())
|
||||
goto out_err;
|
||||
|
||||
if (IS_ENABLED(CONFIG_SHADOW_CALL_STACK)) {
|
||||
if (init_sdei_scs()) {
|
||||
if (IS_ENABLED(CONFIG_VMAP_STACK))
|
||||
free_sdei_stacks();
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
if (init_sdei_scs())
|
||||
goto out_err_free_stacks;
|
||||
|
||||
sdei_exit_mode = (conduit == SMCCC_CONDUIT_HVC) ? SDEI_EXIT_HVC : SDEI_EXIT_SMC;
|
||||
|
||||
|
|
@ -222,6 +224,10 @@ unsigned long sdei_arch_get_entry_point(int conduit)
|
|||
#endif /* CONFIG_UNMAP_KERNEL_AT_EL0 */
|
||||
return (unsigned long)__sdei_asm_handler;
|
||||
|
||||
out_err_free_stacks:
|
||||
free_sdei_stacks();
|
||||
out_err:
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user