arm64: uaccess: Optimize copy_to/from_user with LSUI extension
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.
Co-developed-by Qi Xi <[email protected]>
Signed-off-by Qi Xi <[email protected]>
Signed-off-by Qinxin Xia <[email protected]>
--- 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
@@ -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
@@ -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
@@ -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
Catalin Marinas
maintainerQuoted 5 lines · Qinxin Xia
Add support for the ARMv9.6/LSUI (Load/Store Unprivileged Immediate) extension to optimize
copy_from_useroperations. 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