]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
arm64: armv8_deprecated: Disable swp emulation when FEAT_LSUI present
authorYeoreum Yun <yeoreum.yun@arm.com>
Sat, 14 Mar 2026 17:51:31 +0000 (17:51 +0000)
committerCatalin Marinas <catalin.marinas@arm.com>
Fri, 27 Mar 2026 17:29:10 +0000 (17:29 +0000)
The purpose of supporting LSUI is to eliminate PAN toggling. CPUs that
support LSUI are unlikely to support a 32-bit runtime. Rather than
emulating the SWP instruction using LSUI instructions in order to remove
PAN toggling, simply disable SWP emulation.

Signed-off-by: Yeoreum Yun <yeoreum.yun@arm.com>
[catalin.marinas@arm.com: some tweaks to the in-code comment]
Signed-off-by: Catalin Marinas <catalin.marinas@arm.com>
arch/arm64/kernel/armv8_deprecated.c

index e737c6295ec759ad6abe7949a03fb86b5d0e45b1..b7a1f8b788bbe7c12ccce829f7babffdc4b66bdd 100644 (file)
@@ -610,6 +610,20 @@ static int __init armv8_deprecated_init(void)
        }
 
 #endif
+
+#ifdef CONFIG_SWP_EMULATION
+       /*
+        * The purpose of supporting LSUI is to eliminate PAN toggling. CPUs
+        * that support LSUI are unlikely to support a 32-bit runtime. Rather
+        * than emulating the SWP instruction using LSUI instructions, simply
+        * disable SWP emulation.
+        */
+       if (cpus_have_final_cap(ARM64_HAS_LSUI)) {
+               insn_swp.status = INSN_UNAVAILABLE;
+               pr_info("swp/swpb instruction emulation is not supported on this system\n");
+       }
+#endif
+
        for (int i = 0; i < ARRAY_SIZE(insn_emulations); i++) {
                struct insn_emulation *ie = insn_emulations[i];