Re: [PATCH 3/3] arm64: head: set __entry_task along with task setup

From: Vladimir Murzin

Date: Wed Nov 18 2026 - 06:02:08 EST


Hi Ada,

On 11/17/26 17:48, Ada Couprie Diaz wrote:
> `__entry_task` is only set after the first `switch_to()`, despite
> a proper task being set up in SP_EL0 as soon as CPUs go through
> `__{primary,secondary}_switched()`.
>
> As SDEI can interrupt execution at any time, it can interrupt before
> the first `switch_to()` and use a null `__entry_task` to set
> its current task.
>

TBH I do not know much about SDEI, but don't we need opt-in for
SDEI before we can get any SDEI events? If so, can we really
receive SDEI event before first switch_to()?

Cheers
Vladimir


> Set `__entry_task` as soon as we have a proper task set up in
> `init_cpu_task()` in case we get interrupted before switching threads.
>
> Remove the second paragraph of the comment on `__entry_task`, as it has
> been incorrect since the introduction of SDEI, and even more so
> with this change.
>
> Fixes: f5df26961853 ("arm64: kernel: Add arch-specific SDEI entry code and CPU masking")
> Cc: stable@xxxxxxxxxxxxxxx
> Signed-off-by: Ada Couprie Diaz <ada.coupriediaz@xxxxxxx>
> ---
> arch/arm64/kernel/head.S | 3 +++
> arch/arm64/kernel/process.c | 3 ---
> 2 files changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/arch/arm64/kernel/head.S b/arch/arm64/kernel/head.S
> index d6ba3c0af811..e53a9c6fec83 100644
> --- a/arch/arm64/kernel/head.S
> +++ b/arch/arm64/kernel/head.S
> @@ -209,6 +209,9 @@ SYM_CODE_END(preserve_boot_args)
> ldr w\tmp2, [\tsk, #TSK_TI_CPU]
> ldr \tmp1, [\tmp1, \tmp2, lsl #3]
> set_this_cpu_offset \tmp1
> +
> + adr_l \tmp2, __entry_task
> + str \tsk, [\tmp2, \tmp1]
> .endm
>
> /*
> diff --git a/arch/arm64/kernel/process.c b/arch/arm64/kernel/process.c
> index 42b15b0c069f..c3d194676efc 100644
> --- a/arch/arm64/kernel/process.c
> +++ b/arch/arm64/kernel/process.c
> @@ -584,9 +584,6 @@ static void ssbs_thread_switch(struct task_struct *next)
> /*
> * We store our current task in sp_el0, which is clobbered by userspace. Keep a
> * shadow copy so that we can restore this upon entry from userspace.
> - *
> - * This is *only* for exception entry from EL0, and is not valid until we
> - * __switch_to() a user task.
> */
> DEFINE_PER_CPU(struct task_struct *, __entry_task);
>
> -- 2.43.0
>