Skip to contentSkip to conversation

arm64: uaccess: Optimize copy_to/from_user with LSUI extension

PATCH In review Qinxin Xia 2 participants 2 messages Aug 5 – Aug 7 arm64

lore
Share & tools
lore

Qinxin Xia

author
#0 lore raw

PATCH 1/1 arm64: uaccess: Optimize copy_to/from_user with LSUI extension

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.

---
 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(+)
arch/arm64/include/asm/asm-uaccess.h +6 -0
index 12aa6a283249..4c1b94b275e9 100644
@@ -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
arch/arm64/lib/copy_from_user.S +11 -0
index 400057d607ec..f561a9c07345 100644
@@ -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
arch/arm64/lib/copy_to_user.S +11 -0
index 819f2e3fc7a9..a77dd153566f 100644
@@ -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
Signature · 1 line
2.33.0
maintainer
#1 lore raw
Quoted 5 lines · Qinxin Xia

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.

That's all good but do you have any numbers to back the change up?

Signature · 1 line
Catalin