arm64: suspend: Save and restore TPIDR2_EL0 across CPU suspend
Subsystems (3)
PATCH v2 1/1 arm64: suspend: Save and restore TPIDR2_EL0 across CPU suspend
TPIDR2_EL0 is a live EL0 register on systems with SME, but cpu_do_suspend()/cpu_do_resume() don't preserve it. Its value is UNKNOWN after a warm reset, so the task that initiates suspend can return to userspace with a corrupted TPIDR2_EL0.
Save and restore it alongside TPIDR_EL0 and TPIDRRO_EL0. The new slot fits in existing padding, so sizeof(struct cpu_suspend_ctx) is unchanged.
---
v2:
- Trim commit message (Will)
- Keep mrs_s/msr_s as TPIDR2_EL0 isn't in tools/sysreg yet (Catalin)
- Collect Acked-by/Reviewed-by tags
v1: https://lore.kernel.org/r/[email protected]
arch/arm64/include/asm/suspend.h | 2 +- arch/arm64/mm/proc.S | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-)
arch/arm64/include/asm/suspend.h +1 -1
@@ -2,7 +2,7 @@#ifndef __ASM_SUSPEND_H#define __ASM_SUSPEND_H -#define NR_CTX_REGS 14 +#define NR_CTX_REGS 15#define NR_CALLEE_SAVED_REGS 12/*
arch/arm64/mm/proc.S +8 -0
@@ -103,6 +103,10 @@ SYM_FUNC_START(cpu_do_suspend) alternative_if ARM64_HAS_TCR2 mrs x2, REG_TCR2_EL1 str x2, [x0, #104] +alternative_else_nop_endif +alternative_if ARM64_SME + mrs_s x2, SYS_TPIDR2_EL0 + str x2, [x0, #112] alternative_else_nop_endif ret SYM_FUNC_END(cpu_do_suspend)
@@ -142,6 +146,10 @@ alternative_if ARM64_HAS_TCR2 ldr x2, [x0, #104] msr REG_TCR2_EL1, x2 alternative_else_nop_endif +alternative_if ARM64_SME + ldr x2, [x0, #112] + msr_s SYS_TPIDR2_EL0, x2 +alternative_else_nop_endif msr sctlr_el1, x12 set_this_cpu_offset x13
Signature · 1 line
2.56.0.385.gac671c819a-goog
Quoted 10 lines · Wei Wang
TPIDR2_EL0is a live EL0 register on systems with SME, but cpu_do_suspend()/cpu_do_resume() don't preserve it. Its value is UNKNOWN after a warm reset, so the task that initiates suspend can return to userspace with a corruptedTPIDR2_EL0.Save and restore it alongside
TPIDR_EL0andTPIDRRO_EL0. The new slot fits in existing padding, sosizeof(struct cpu_suspend_ctx)is unchanged.[...]
Applied to arm64 (for-next/fixes), thanks!
[1/1] arm64: suspend: Save and restore TPIDR2_EL0 across CPU suspend
https://git.kernel.org/arm64/c/beeec0404622