public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Dan Li <ashimida@linux.alibaba.com>
To: catalin.marinas@arm.com, will@kernel.org, mark.rutland@arm.com,
	samitolvanen@google.com, maz@kernel.org, joey.gouly@arm.com,
	pcc@google.com
Cc: linux-arm-kernel@lists.infradead.org,
	linux-kernel@vger.kernel.org, linux-hardening@vger.kernel.org,
	Dan Li <ashimida@linux.alibaba.com>
Subject: [PATCH] [RFC] aarch64: scs: reload shadow call stack in user exception entry
Date: Mon, 27 Dec 2021 17:06:04 -0800	[thread overview]
Message-ID: <20211228010604.109572-1-ashimida@linux.alibaba.com> (raw)

When el0 exception occurs, kernel_entry/exit will load/save tsk->scs_sp
to ensure scs working properly. AFAIK, the SCS offset should always be
0 at this time.

Is it reasonable to reload x18 to scs_base directly in kernel_entry
here, or am I missing something?

Signed-off-by: Dan Li <ashimida@linux.alibaba.com>
---
 arch/arm64/include/asm/scs.h | 7 +++++++
 arch/arm64/kernel/entry.S    | 3 +--
 2 files changed, 8 insertions(+), 2 deletions(-)

diff --git a/arch/arm64/include/asm/scs.h b/arch/arm64/include/asm/scs.h
index 8297bccf0784..2bc0d0575e75 100644
--- a/arch/arm64/include/asm/scs.h
+++ b/arch/arm64/include/asm/scs.h
@@ -9,6 +9,10 @@
 #ifdef CONFIG_SHADOW_CALL_STACK
 	scs_sp	.req	x18
 
+	.macro scs_reload tsk
+	ldr	scs_sp, [\tsk, #TSK_TI_SCS_BASE]
+	.endm
+
 	.macro scs_load tsk
 	ldr	scs_sp, [\tsk, #TSK_TI_SCS_SP]
 	.endm
@@ -17,6 +21,9 @@
 	str	scs_sp, [\tsk, #TSK_TI_SCS_SP]
 	.endm
 #else
+	.macro scs_reload tsk
+	.endm
+
 	.macro scs_load tsk
 	.endm
 
diff --git a/arch/arm64/kernel/entry.S b/arch/arm64/kernel/entry.S
index bc6d5a970a13..57547a3e4f7c 100644
--- a/arch/arm64/kernel/entry.S
+++ b/arch/arm64/kernel/entry.S
@@ -265,7 +265,7 @@ alternative_if ARM64_HAS_ADDRESS_AUTH
 alternative_else_nop_endif
 1:
 
-	scs_load tsk
+	scs_reload tsk
 	.else
 	add	x21, sp, #PT_REGS_SIZE
 	get_current_task tsk
@@ -365,7 +365,6 @@ alternative_if ARM64_WORKAROUND_845719
 alternative_else_nop_endif
 #endif
 3:
-	scs_save tsk
 
 	/* Ignore asynchronous tag check faults in the uaccess routines */
 	ldr	x0, [tsk, THREAD_SCTLR_USER]
-- 
2.17.1


             reply	other threads:[~2021-12-28  1:06 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-12-28  1:06 Dan Li [this message]
2022-01-04 10:40 ` [PATCH] [RFC] aarch64: scs: reload shadow call stack in user exception entry Mark Rutland
2022-01-04 14:32   ` Dan Li

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=20211228010604.109572-1-ashimida@linux.alibaba.com \
    --to=ashimida@linux.alibaba.com \
    --cc=catalin.marinas@arm.com \
    --cc=joey.gouly@arm.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-hardening@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mark.rutland@arm.com \
    --cc=maz@kernel.org \
    --cc=pcc@google.com \
    --cc=samitolvanen@google.com \
    --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