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.
Unified · Split
| @@ -1680,7 +1680,6 @@ config MITIGATE_SPECTRE_BRANCH_HISTORY · 1679 unmodified lines | ||
| 1680 | 1680 | config ARM64_SW_TTBR0_PAN |
| 1681 | 1681 | bool "Emulate Privileged Access Never using TTBR0_EL1 switching" |
| 1682 | 1682 | depends on !KCSAN |
| 1683 | − select ARM64_PAN | |
| 1684 | 1683 | help |
| 1685 | 1684 | Enabling this option prevents the kernel from accessing |
| 1686 | 1685 | user-space memory directly by pointing TTBR0_EL1 to a reserved |
| @@ -1859,20 +1858,6 @@ config ARM64_HW_AFDBM · 172 unmodified lines | ||
| 1859 | 1858 | to work on pre-ARMv8.1 hardware and the performance impact is |
| 1860 | 1859 | minimal. If unsure, say Y. |
| 1861 | 1860 | |
| 1862 | −config ARM64_PAN | |
| 1863 | − bool "Enable support for Privileged Access Never (PAN)" | |
| 1864 | − default y | |
| 1865 | − help | |
| 1866 | − Privileged Access Never (PAN; part of the ARMv8.1 Extensions) | |
| 1867 | − prevents the kernel or hypervisor from accessing user-space (EL0) | |
| 1868 | − memory directly. | |
| 1869 | − | |
| 1870 | − Choosing this option will cause any unprotected (not using | |
| 1871 | − copy_to_user et al) memory access to fail with a permission fault. | |
| 1872 | − | |
| 1873 | − The feature is detected at runtime, and will remain as a 'nop' | |
| 1874 | − instruction if the cpu does not implement the feature. | |
| 1875 | − | |
| 1876 | 1861 | endmenu # "ARMv8.1 architectural features" |
| 1877 | 1862 | |
| 1878 | 1863 | menu "ARMv8.2 architectural features" |
| @@ -2109,7 +2094,6 @@ config ARM64_MTE · 230 unmodified lines | ||
| 2109 | 2094 | depends on ARM64_AS_HAS_MTE && ARM64_TAGGED_ADDR_ABI |
| 2110 | 2095 | depends on AS_HAS_ARMV8_5 |
| 2111 | 2096 | # Required for tag checking in the uaccess routines |
| 2112 | − select ARM64_PAN | |
| 2113 | 2097 | select ARCH_HAS_SUBPAGE_FAULTS |
| 2114 | 2098 | select ARCH_USES_HIGH_VMA_FLAGS |
| 2115 | 2099 | select ARCH_USES_PG_ARCH_2 |
| @@ -2141,7 +2125,6 @@ menu "ARMv8.7 architectural features" · 25 unmodified lines | ||
| 2141 | 2125 | config ARM64_EPAN |
| 2142 | 2126 | bool "Enable support for Enhanced Privileged Access Never (EPAN)" |
| 2143 | 2127 | default y |
| 2144 | − depends on ARM64_PAN | |
| 2145 | 2128 | help |
| 2146 | 2129 | Enhanced Privileged Access Never (EPAN) allows Privileged |
| 2147 | 2130 | Access Never to be used with Execute-only mappings. |
| @@ -19,8 +19,6 @@ cpucap_is_possible(const unsigned int cap) · 18 unmodified lines | ||
| 19 | 19 | "cap must be < ARM64_NCAPS"); |
| 20 | 20 | |
| 21 | 21 | switch (cap) { |
| 22 | − case ARM64_HAS_PAN: | |
| 23 | − return IS_ENABLED(CONFIG_ARM64_PAN); | |
| 24 | 22 | case ARM64_HAS_EPAN: |
| 25 | 23 | return IS_ENABLED(CONFIG_ARM64_EPAN); |
| 26 | 24 | case ARM64_SVE: |
| @@ -124,14 +124,12 @@ static inline bool uaccess_ttbr0_enable(void) · 123 unmodified lines | ||
| 124 | 124 | |
| 125 | 125 | static inline void __uaccess_disable_hw_pan(void) |
| 126 | 126 | { |
| 127 | − asm(ALTERNATIVE("nop", SET_PSTATE_PAN(0), ARM64_HAS_PAN, | |
| 128 | − CONFIG_ARM64_PAN)); | |
| 127 | + asm(ALTERNATIVE("nop", SET_PSTATE_PAN(0), ARM64_HAS_PAN)); | |
| 129 | 128 | } |
| 130 | 129 | |
| 131 | 130 | static inline void __uaccess_enable_hw_pan(void) |
| 132 | 131 | { |
| 133 | − asm(ALTERNATIVE("nop", SET_PSTATE_PAN(1), ARM64_HAS_PAN, | |
| 134 | − CONFIG_ARM64_PAN)); | |
| 132 | + asm(ALTERNATIVE("nop", SET_PSTATE_PAN(1), ARM64_HAS_PAN)); | |
| 135 | 133 | } |
| 136 | 134 | |
| 137 | 135 | static inline void uaccess_disable_privileged(void) |
| @@ -2164,7 +2164,6 @@ static bool has_bbml2_noabort(const struct arm64_cpu_capabilities *caps, int sco · 2163 unmodified lines | ||
| 2164 | 2164 | return cpu_supports_bbml2_noabort(); |
| 2165 | 2165 | } |
| 2166 | 2166 | |
| 2167 | −#ifdef CONFIG_ARM64_PAN | |
| 2168 | 2167 | static void cpu_enable_pan(const struct arm64_cpu_capabilities *__unused) |
| 2169 | 2168 | { |
| 2170 | 2169 | /* |
| @@ -2176,7 +2175,6 @@ static void cpu_enable_pan(const struct arm64_cpu_capabilities *__unused) · 5 unmodified lines | ||
| 2176 | 2175 | sysreg_clear_set(sctlr_el1, SCTLR_EL1_SPAN, 0); |
| 2177 | 2176 | set_pstate_pan(1); |
| 2178 | 2177 | } |
| 2179 | −#endif /* CONFIG_ARM64_PAN */ | |
| 2180 | 2178 | |
| 2181 | 2179 | #ifdef CONFIG_ARM64_RAS_EXTN |
| 2182 | 2180 | static void cpu_clear_disr(const struct arm64_cpu_capabilities *__unused) |
| @@ -2541,7 +2539,6 @@ static const struct arm64_cpu_capabilities arm64_features[] = { · 358 unmodified lines | ||
| 2541 | 2539 | .matches = has_cpuid_feature, |
| 2542 | 2540 | ARM64_CPUID_FIELDS(ID_AA64MMFR0_EL1, ECV, CNTPOFF) |
| 2543 | 2541 | }, |
| 2544 | −#ifdef CONFIG_ARM64_PAN | |
| 2545 | 2542 | { |
| 2546 | 2543 | .desc = "Privileged Access Never", |
| 2547 | 2544 | .capability = ARM64_HAS_PAN, |
| @@ -2550,7 +2547,6 @@ static const struct arm64_cpu_capabilities arm64_features[] = { · 2 unmodified lines | ||
| 2550 | 2547 | .cpu_enable = cpu_enable_pan, |
| 2551 | 2548 | ARM64_CPUID_FIELDS(ID_AA64MMFR1_EL1, PAN, IMP) |
| 2552 | 2549 | }, |
| 2553 | −#endif /* CONFIG_ARM64_PAN */ | |
| 2554 | 2550 | #ifdef CONFIG_ARM64_EPAN |
| 2555 | 2551 | { |
| 2556 | 2552 | .desc = "Enhanced Privileged Access Never", |
| @@ -126,7 +126,7 @@ SYM_INNER_LABEL(__guest_exit, SYM_L_GLOBAL) · 125 unmodified lines | ||
| 126 | 126 | |
| 127 | 127 | add x1, x1, #VCPU_CONTEXT |
| 128 | 128 | |
| 129 | − ALTERNATIVE(nop, SET_PSTATE_PAN(1), ARM64_HAS_PAN, CONFIG_ARM64_PAN) | |
| 129 | + ALTERNATIVE(nop, SET_PSTATE_PAN(1), ARM64_HAS_PAN) | |
| 130 | 130 | |
| 131 | 131 | // Store the guest regs x2 and x3 |
| 132 | 132 | stp x2, x3, [x1, #CPU_XREG_OFFSET(2)] |