From: Vladimir Murzin <vladimir.murzin@arm.com>
To: Mark Brown <broonie@kernel.org>,
Catalin Marinas <catalin.marinas@arm.com>,
Will Deacon <will@kernel.org>,
Mark Rutland <mark.rutland@arm.com>,
Anshuman Khandual <anshuman.khandual@arm.com>,
Joey Gouly <joey.gouly@arm.com>
Cc: linux-arm-kernel@lists.infradead.org,
linux-kernel@vger.kernel.org, stable@vger.kernel.org
Subject: Re: [PATCH 2/2] arm64: suspend: Save GCS state over suspend
Date: Wed, 11 Nov 2026 13:44:40 +0000 [thread overview]
Message-ID: <282608f5-a13b-4695-aa17-f834bf5d8272@arm.com> (raw)
In-Reply-To: <20261105-arm64-fix-sysreg-suspend-v1-2-f4d9a99fec46@kernel.org>
On 11/5/26 16:05, Mark Brown wrote:
> GCSCRE0_EL1 and GCSPR_EL0 are live registers for EL0 on systems with GCS
> but are not saved and restored by cpu_do_suspend()/cpu_do_resume(). This
> means that the task that initiated suspend can return to userspace with
> UNKNOWN or incorrect values for GCSPR_EL0 and GCSCRE0_EL1 (many fields
> in GCSCRE0_EL1 reset to 0). This will in turn lead to ongoing
> corruption, including not restoring mode until a task with a different
> GCS mode is run. Fix this by saving and restoring the values over
> suspend.
>
> This increases the size of struct cpu_suspend_ctx by 16 bytes.
>
> Fixes: 5d8b172e7005 ("arm64: Add Kconfig for Guarded Control Stack (GCS)")
> Signed-off-by: Mark Brown <broonie@kernel.org>
> Cc: stable@vger.kernel.org
> ---
> arch/arm64/include/asm/suspend.h | 2 +-
> arch/arm64/mm/proc.S | 12 ++++++++++++
> 2 files changed, 13 insertions(+), 1 deletion(-)
>
> diff --git a/arch/arm64/include/asm/suspend.h b/arch/arm64/include/asm/suspend.h
> index eb9ce315f146..8e9c97aab15a 100644
> --- a/arch/arm64/include/asm/suspend.h
> +++ b/arch/arm64/include/asm/suspend.h
> @@ -2,7 +2,7 @@
> #ifndef __ASM_SUSPEND_H
> #define __ASM_SUSPEND_H
>
> -#define NR_CTX_REGS 16
> +#define NR_CTX_REGS 18
> #define NR_CALLEE_SAVED_REGS 12
>
> /*
> diff --git a/arch/arm64/mm/proc.S b/arch/arm64/mm/proc.S
> index 664ea9e3b9ad..99aacf03367d 100644
> --- a/arch/arm64/mm/proc.S
> +++ b/arch/arm64/mm/proc.S
> @@ -121,6 +121,12 @@ alternative_else_nop_endif
> alternative_if ARM64_HAS_S1POE
> mrs x2, REG_POR_EL0
> str x2, [x0, #120]
> +alternative_else_nop_endif
> +alternative_if ARM64_HAS_GCS
> + mrs x2, REG_GCSPR_EL0
> + str x2, [x0, #128]
> + mrs x2, REG_GCSCRE0_EL1
> + str x2, [x0, #136]
Have you considered using stp?
> alternative_else_nop_endif
> ret
> SYM_FUNC_END(cpu_do_suspend)
> @@ -168,6 +174,12 @@ alternative_if ARM64_HAS_S1POE
> ldr x2, [x0, #120]
> msr REG_POR_EL0, x2
> alternative_else_nop_endif
> +alternative_if ARM64_HAS_GCS
> + ldr x2, [x0, #128]
> + msr REG_GCSPR_EL0, x2
> + ldr x2, [x0, #136]
> + msr REG_GCSCRE0_EL1, x2
Have you considered using ldp?
Cheers
Vladimir
next prev parent reply other threads:[~2026-11-11 13:44 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-05 16:05 [PATCH 0/2] arm64/suspend: Save more registers " Mark Brown
2026-11-05 16:05 ` [PATCH 1/2] arm64: suspend: Save POR_EL0 " Mark Brown
2026-11-11 13:33 ` Vladimir Murzin
2026-11-11 13:52 ` Mark Brown
2026-11-05 16:05 ` [PATCH 2/2] arm64: suspend: Save GCS state " Mark Brown
2026-11-11 13:44 ` Vladimir Murzin [this message]
2026-11-11 13:55 ` Mark Brown
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=282608f5-a13b-4695-aa17-f834bf5d8272@arm.com \
--to=vladimir.murzin@arm.com \
--cc=anshuman.khandual@arm.com \
--cc=broonie@kernel.org \
--cc=catalin.marinas@arm.com \
--cc=joey.gouly@arm.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mark.rutland@arm.com \
--cc=stable@vger.kernel.org \
--cc=will@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®