Linux-ARM-Kernel Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Qinxin Xia <xiaqinxin@huawei.com>
To: <catalin.marinas@arm.com>, <will@kernel.org>,
	<anshuman.khandual@arm.com>, <BenNiu@meta.com>,
	<robin.murphy@arm.com>, <xiqi2@huawei.com>,
	<xiaqinxin@huawei.com>
Cc: <linux-arm-kernel@lists.infradead.org>,
	<linux-kernel@vger.kernel.org>, <linuxarm@huawei.com>,
	<wangzhou1@hisilicon.com>, <sunnanyong@huawei.com>,
	<prime.zeng@hisilicon.com>
Subject: [PATCH] arm64: uaccess: Optimize copy_to/from_user with LSUI extension
Date: Wed, 5 Aug 2026 11:52:51 +0800	[thread overview]
Message-ID: <20260805035251.2813306-1-xiaqinxin@huawei.com> (raw)

Add support for the ARMv9.6/LSUI (Load/Store Unprivileged Immediate)
extension to optimize copy_from_user operations. The implementation
uses the alternative mechanism to select between the standard unprivileged
load-pair sequence and the new ldtp/sttp instruction at runtime based on
hardware capability.

Co-developed-by: Qi Xi <xiqi2@huawei.com>
Signed-off-by: Qi Xi <xiqi2@huawei.com>
Signed-off-by: Qinxin Xia <xiaqinxin@huawei.com>
---
 arch/arm64/include/asm/asm-uaccess.h |  6 ++++++
 arch/arm64/lib/copy_from_user.S      | 11 +++++++++++
 arch/arm64/lib/copy_to_user.S        | 11 +++++++++++
 3 files changed, 28 insertions(+)

diff --git a/arch/arm64/include/asm/asm-uaccess.h b/arch/arm64/include/asm/asm-uaccess.h
index 12aa6a283249..4c1b94b275e9 100644
--- a/arch/arm64/include/asm/asm-uaccess.h
+++ b/arch/arm64/include/asm/asm-uaccess.h
@@ -94,4 +94,10 @@ alternative_else_nop_endif
 
 		_asm_extable_uaccess	8888b, \l;
 	.endm
+
+	.macro user_ldst_pair l, inst, reg1, reg2, addr, post_inc
+8888:		\inst		\reg1, \reg2, [\addr], \post_inc;
+
+		_asm_extable_uaccess    8888b, \l;
+	.endm
 #endif
diff --git a/arch/arm64/lib/copy_from_user.S b/arch/arm64/lib/copy_from_user.S
index 400057d607ec..f561a9c07345 100644
--- a/arch/arm64/lib/copy_from_user.S
+++ b/arch/arm64/lib/copy_from_user.S
@@ -45,7 +45,18 @@
 	.endm
 
 	.macro ldp1 reg1, reg2, ptr, val
+#ifdef CONFIG_ARM64_LSUI
+	alternative_if_not ARM64_HAS_LSUI
+		user_ldp 9997f, \reg1, \reg2, \ptr, \val
+	alternative_else
+		.arch_extension lsui
+		user_ldst_pair 9997f, ldtp, \reg1, \reg2, \ptr, \val
+		nop
+		nop
+	alternative_endif
+#else
 	user_ldp 9997f, \reg1, \reg2, \ptr, \val
+#endif
 	.endm
 
 	.macro stp1 reg1, reg2, ptr, val
diff --git a/arch/arm64/lib/copy_to_user.S b/arch/arm64/lib/copy_to_user.S
index 819f2e3fc7a9..a77dd153566f 100644
--- a/arch/arm64/lib/copy_to_user.S
+++ b/arch/arm64/lib/copy_to_user.S
@@ -48,7 +48,18 @@
 	.endm
 
 	.macro stp1 reg1, reg2, ptr, val
+#ifdef CONFIG_ARM64_LSUI
+	alternative_if_not ARM64_HAS_LSUI
+		user_stp 9997f, \reg1, \reg2, \ptr, \val
+	alternative_else
+		.arch_extension lsui
+		user_ldst_pair 9997f, sttp, \reg1, \reg2, \ptr, \val
+		nop
+		nop
+	alternative_endif
+#else
 	user_stp 9997f, \reg1, \reg2, \ptr, \val
+#endif
 	.endm
 
 	.macro cpy1 dst, src, count
-- 
2.33.0



                 reply	other threads:[~2026-08-05  3:53 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=20260805035251.2813306-1-xiaqinxin@huawei.com \
    --to=xiaqinxin@huawei.com \
    --cc=BenNiu@meta.com \
    --cc=anshuman.khandual@arm.com \
    --cc=catalin.marinas@arm.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linuxarm@huawei.com \
    --cc=prime.zeng@hisilicon.com \
    --cc=robin.murphy@arm.com \
    --cc=sunnanyong@huawei.com \
    --cc=wangzhou1@hisilicon.com \
    --cc=will@kernel.org \
    --cc=xiqi2@huawei.com \
    /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