[PATCH v2 11/20] arm64: entry: sdei: Restore all clobberable GPRs

Mark Rutland mark.rutland at arm.com
Fri Aug 7 04:35:52 PDT 2026


On Tue, Aug 04, 2026 at 06:04:54PM +0100, Mark Rutland wrote:
> Currently __sdei_asm_handler() avoids restoring x20 to x27, as these are
> not be clobbered by existing code. This is correct today, but it makes
> it awkward to rework __sdei_asm_handler(). Given the rarity of SDEI
> events, restoring x20 to x27 should not have a measurable impact.
> 
> Restore x20 to x27 when returning from an SDEI event handler. This will
> free up those GPRs for usage in __sdei_asm_handler() prior to return.

Sashiko noticed an error below that I'll fix for v3.

> -	/* restore regs >x17 that we clobbered */
> +	/* restore regs >x17 that firmware won't restore */
>  	mov	x4, x19         // keep x4 for __sdei_asm_exit_trampoline
> -	ldp	x28, x29, [x4, #SDEI_EVENT_INTREGS + 16 * 14]
>  	ldp	x18, x19, [x4, #SDEI_EVENT_INTREGS + 16 * 9]
> +	ldp	x20, x21, [x4, #SDEI_EVENT_INTREGS + 16 * 10]
> +	ldp	x22, x23, [x4, #SDEI_EVENT_INTREGS + 16 * 11]
> +	ldp	x24, x25, [x4, #SDEI_EVENT_INTREGS + 16 * 12]
> +	ldp	x22, x27, [x4, #SDEI_EVENT_INTREGS + 16 * 13]
                ^^^

That should be 'x26'.

Mark.

> +	ldp	x28, x29, [x4, #SDEI_EVENT_INTREGS + 16 * 14]
>  	ldp	lr, x1, [x4, #SDEI_EVENT_INTREGS + S_LR]
>  	mov	sp, x1
>  
> -- 
> 2.30.2
> 



More information about the linux-arm-kernel mailing list