]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
arm64: Unconditionally enable PAN support
authorMarc Zyngier <maz@kernel.org>
Wed, 7 Jan 2026 18:07:00 +0000 (18:07 +0000)
committerWill Deacon <will@kernel.org>
Thu, 22 Jan 2026 10:16:42 +0000 (10:16 +0000)
FEAT_PAN has been around since ARMv8.1 (over 11 years ago), has no compiler
dependency (we have our own accessors), and is a great security benefit.

Drop CONFIG_ARM64_PAN, and make the support unconditionnal.

Signed-off-by: Marc Zyngier <maz@kernel.org>
Signed-off-by: Will Deacon <will@kernel.org>
arch/arm64/Kconfig
arch/arm64/include/asm/cpucaps.h
arch/arm64/include/asm/uaccess.h
arch/arm64/kernel/cpufeature.c
arch/arm64/kvm/hyp/entry.S

index b6f57cc1e4df82e9eadcbf891290e9ede56ee3a9..fcfb62ec4bae851662d55304a9ed1beff849bf4e 100644 (file)
@@ -1680,7 +1680,6 @@ config MITIGATE_SPECTRE_BRANCH_HISTORY
 config ARM64_SW_TTBR0_PAN
        bool "Emulate Privileged Access Never using TTBR0_EL1 switching"
        depends on !KCSAN
-       select ARM64_PAN
        help
          Enabling this option prevents the kernel from accessing
          user-space memory directly by pointing TTBR0_EL1 to a reserved
@@ -1859,20 +1858,6 @@ config ARM64_HW_AFDBM
          to work on pre-ARMv8.1 hardware and the performance impact is
          minimal. If unsure, say Y.
 
-config ARM64_PAN
-       bool "Enable support for Privileged Access Never (PAN)"
-       default y
-       help
-         Privileged Access Never (PAN; part of the ARMv8.1 Extensions)
-         prevents the kernel or hypervisor from accessing user-space (EL0)
-         memory directly.
-
-         Choosing this option will cause any unprotected (not using
-         copy_to_user et al) memory access to fail with a permission fault.
-
-         The feature is detected at runtime, and will remain as a 'nop'
-         instruction if the cpu does not implement the feature.
-
 endmenu # "ARMv8.1 architectural features"
 
 menu "ARMv8.2 architectural features"
@@ -2109,7 +2094,6 @@ config ARM64_MTE
        depends on ARM64_AS_HAS_MTE && ARM64_TAGGED_ADDR_ABI
        depends on AS_HAS_ARMV8_5
        # Required for tag checking in the uaccess routines
-       select ARM64_PAN
        select ARCH_HAS_SUBPAGE_FAULTS
        select ARCH_USES_HIGH_VMA_FLAGS
        select ARCH_USES_PG_ARCH_2
@@ -2141,7 +2125,6 @@ menu "ARMv8.7 architectural features"
 config ARM64_EPAN
        bool "Enable support for Enhanced Privileged Access Never (EPAN)"
        default y
-       depends on ARM64_PAN
        help
          Enhanced Privileged Access Never (EPAN) allows Privileged
          Access Never to be used with Execute-only mappings.
index 2c8029472ad4517adce2f46fd0bd98764f4a2b69..177c691914f8796f0e29710776c6fb0cddfe4e90 100644 (file)
@@ -19,8 +19,6 @@ cpucap_is_possible(const unsigned int cap)
                           "cap must be < ARM64_NCAPS");
 
        switch (cap) {
-       case ARM64_HAS_PAN:
-               return IS_ENABLED(CONFIG_ARM64_PAN);
        case ARM64_HAS_EPAN:
                return IS_ENABLED(CONFIG_ARM64_EPAN);
        case ARM64_SVE:
index 6490930deef84d89fb45808353a0f90dbbb23eb3..9810106a3f664a2df29851410e41079686f052c2 100644 (file)
@@ -124,14 +124,12 @@ static inline bool uaccess_ttbr0_enable(void)
 
 static inline void __uaccess_disable_hw_pan(void)
 {
-       asm(ALTERNATIVE("nop", SET_PSTATE_PAN(0), ARM64_HAS_PAN,
-                       CONFIG_ARM64_PAN));
+       asm(ALTERNATIVE("nop", SET_PSTATE_PAN(0), ARM64_HAS_PAN));
 }
 
 static inline void __uaccess_enable_hw_pan(void)
 {
-       asm(ALTERNATIVE("nop", SET_PSTATE_PAN(1), ARM64_HAS_PAN,
-                       CONFIG_ARM64_PAN));
+       asm(ALTERNATIVE("nop", SET_PSTATE_PAN(1), ARM64_HAS_PAN));
 }
 
 static inline void uaccess_disable_privileged(void)
index 547ccf28f2893c878d7e29e85126124246e1bff8..716440d147a2d711bec986d156bb6bf15f06246c 100644 (file)
@@ -2164,7 +2164,6 @@ static bool has_bbml2_noabort(const struct arm64_cpu_capabilities *caps, int sco
        return cpu_supports_bbml2_noabort();
 }
 
-#ifdef CONFIG_ARM64_PAN
 static void cpu_enable_pan(const struct arm64_cpu_capabilities *__unused)
 {
        /*
@@ -2176,7 +2175,6 @@ static void cpu_enable_pan(const struct arm64_cpu_capabilities *__unused)
        sysreg_clear_set(sctlr_el1, SCTLR_EL1_SPAN, 0);
        set_pstate_pan(1);
 }
-#endif /* CONFIG_ARM64_PAN */
 
 #ifdef CONFIG_ARM64_RAS_EXTN
 static void cpu_clear_disr(const struct arm64_cpu_capabilities *__unused)
@@ -2541,7 +2539,6 @@ static const struct arm64_cpu_capabilities arm64_features[] = {
                .matches = has_cpuid_feature,
                ARM64_CPUID_FIELDS(ID_AA64MMFR0_EL1, ECV, CNTPOFF)
        },
-#ifdef CONFIG_ARM64_PAN
        {
                .desc = "Privileged Access Never",
                .capability = ARM64_HAS_PAN,
@@ -2550,7 +2547,6 @@ static const struct arm64_cpu_capabilities arm64_features[] = {
                .cpu_enable = cpu_enable_pan,
                ARM64_CPUID_FIELDS(ID_AA64MMFR1_EL1, PAN, IMP)
        },
-#endif /* CONFIG_ARM64_PAN */
 #ifdef CONFIG_ARM64_EPAN
        {
                .desc = "Enhanced Privileged Access Never",
index 9f4e8d68ab505cf4a7aa8673643d9b47ca1bc7cb..11a10d8f5beb269632488016fb19cf56212e3855 100644 (file)
@@ -126,7 +126,7 @@ SYM_INNER_LABEL(__guest_exit, SYM_L_GLOBAL)
 
        add     x1, x1, #VCPU_CONTEXT
 
-       ALTERNATIVE(nop, SET_PSTATE_PAN(1), ARM64_HAS_PAN, CONFIG_ARM64_PAN)
+       ALTERNATIVE(nop, SET_PSTATE_PAN(1), ARM64_HAS_PAN)
 
        // Store the guest regs x2 and x3
        stp     x2, x3,   [x1, #CPU_XREG_OFFSET(2)]