From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from canpmsgout03.his.huawei.com (canpmsgout03.his.huawei.com [113.46.200.218]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 451081D9A5F for ; Wed, 5 Aug 2026 03:53:02 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=113.46.200.218 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785901985; cv=none; b=LG1LsPBqv74ArUgosXPSgOMwaSjO9SCXxTsFE+yJTkvPcXAAVkpMpUM5l51gvtJNPdN9nbsX6Ue7Na2fgOEdJf5I6mW+djYEb5mG8Fd5Gkqvnd8YCSDHEma2Amo1PCgh/8zWE2DhjKuUIaxmzkPRtGTtV2nSp1JUMX2D0xp3F5o= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785901985; c=relaxed/simple; bh=AZPWW4HxO404KhObdGQQku46Q3fK9JvUETqlwS2amqY=; h=From:To:CC:Subject:Date:Message-ID:MIME-Version:Content-Type; b=IslbPPF4HHwvq0aZ6EVumoa9VvvV5oLQqYJc0HCfeBRErl6rl4dAer2Ms9f3yiOMxVduW7DiunDTrxvOplraJckJDadbaLn+1xgY3FiXjM9A4IyxSr22g/Z8BEh9qye+4Ha6REo6uJIlloORd8SmfjgDbyLAvhkFUovfCj+Sonw= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=huawei.com; spf=pass smtp.mailfrom=huawei.com; dkim=pass (1024-bit key) header.d=huawei.com header.i=@huawei.com header.b=ciB7JbH2; arc=none smtp.client-ip=113.46.200.218 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=huawei.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=huawei.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=huawei.com header.i=@huawei.com header.b="ciB7JbH2" dkim-signature: v=1; a=rsa-sha256; d=huawei.com; s=dkim; c=relaxed/relaxed; q=dns/txt; h=From; bh=NTcBSlM5LuKCDc9Ov6EpGoH7qPKq43ytKlh8zg6LOU8=; b=ciB7JbH2jOtlsV83or6ZbFuGdUOa/oqJ1sMZT2E+QXFaGj3y9aEbYhCLtAe8hVKsZqPI8XLSO 7F/rXN8KdAlKXWGFzaALI38bXSleMd7DLPmVUdg0C45hIcZvDE5s64xPDAiiLCQSqSDF0zZDZbL WU9PmPjrBg6HwB/tgb33hsU= Received: from mail.maildlp.com (unknown [172.19.162.197]) by canpmsgout03.his.huawei.com (SkyGuard) with ESMTPS id 4hFGTl5JYjzpSvB; Wed, 5 Aug 2026 11:43:23 +0800 (CST) Received: from kwepemj200003.china.huawei.com (unknown [7.202.194.15]) by mail.maildlp.com (Postfix) with ESMTPS id 011704057D; Wed, 5 Aug 2026 11:52:53 +0800 (CST) Received: from localhost.huawei.com (10.90.31.46) by kwepemj200003.china.huawei.com (7.202.194.15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.11; Wed, 5 Aug 2026 11:52:52 +0800 From: Qinxin Xia To: , , , , , , CC: , , , , , Subject: [PATCH] arm64: uaccess: Optimize copy_to/from_user with LSUI extension Date: Wed, 5 Aug 2026 11:52:51 +0800 Message-ID: <20260805035251.2813306-1-xiaqinxin@huawei.com> X-Mailer: git-send-email 2.33.0 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-ClientProxiedBy: kwepems500002.china.huawei.com (7.221.188.17) To kwepemj200003.china.huawei.com (7.202.194.15) 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 Signed-off-by: Qi Xi Signed-off-by: Qinxin Xia --- 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