Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

Merge tag 'arm64-fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/arm64/linux

Pull arm64 fixes from Will Deacon:
"The major fix here is for a filesystem corruption issue reported on
Apple M1 as a result of buggy management of the floating point
register state introduced in 6.8. I initially reverted one of the
offending patches, but in the end Ard cooked a proper fix so there's a
revert+reapply in the series.

Aside from that, we've got some CPU errata workarounds and misc other
fixes.

- Fix broken FP register state tracking which resulted in filesystem
corruption when dm-crypt is used

- Workarounds for Arm CPU errata affecting the SSBS Spectre
mitigation

- Fix lockdep assertion in DMC620 memory controller PMU driver

- Fix alignment of BUG table when CONFIG_DEBUG_BUGVERBOSE is
disabled"

* tag 'arm64-fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/arm64/linux:
arm64/fpsimd: Avoid erroneous elide of user state reload
Reapply "arm64: fpsimd: Implement lazy restore for kernel mode FPSIMD"
arm64: asm-bug: Add .align 2 to the end of __BUG_ENTRY
perf/arm-dmc620: Fix lockdep assert in ->event_init()
Revert "arm64: fpsimd: Implement lazy restore for kernel mode FPSIMD"
arm64: errata: Add workaround for Arm errata 3194386 and 3312417
arm64: cputype: Add Neoverse-V3 definitions
arm64: cputype: Add Cortex-X4 definitions
arm64: barrier: Restore spec_bar() macro

+125 -25
+4
Documentation/arch/arm64/silicon-errata.rst
··· 140 140 +----------------+-----------------+-----------------+-----------------------------+ 141 141 | ARM | Cortex-X2 | #2224489 | ARM64_ERRATUM_2224489 | 142 142 +----------------+-----------------+-----------------+-----------------------------+ 143 + | ARM | Cortex-X4 | #3194386 | ARM64_ERRATUM_3194386 | 144 + +----------------+-----------------+-----------------+-----------------------------+ 143 145 | ARM | Neoverse-N1 | #1188873,1418040| ARM64_ERRATUM_1418040 | 144 146 +----------------+-----------------+-----------------+-----------------------------+ 145 147 | ARM | Neoverse-N1 | #1349291 | N/A | ··· 157 155 | ARM | Neoverse-N2 | #2253138 | ARM64_ERRATUM_2253138 | 158 156 +----------------+-----------------+-----------------+-----------------------------+ 159 157 | ARM | Neoverse-V1 | #1619801 | N/A | 158 + +----------------+-----------------+-----------------+-----------------------------+ 159 + | ARM | Neoverse-V3 | #3312417 | ARM64_ERRATUM_3312417 | 160 160 +----------------+-----------------+-----------------+-----------------------------+ 161 161 | ARM | MMU-500 | #841119,826419 | N/A | 162 162 +----------------+-----------------+-----------------+-----------------------------+
+42
arch/arm64/Kconfig
··· 1067 1067 1068 1068 If unsure, say Y. 1069 1069 1070 + config ARM64_WORKAROUND_SPECULATIVE_SSBS 1071 + bool 1072 + 1073 + config ARM64_ERRATUM_3194386 1074 + bool "Cortex-X4: 3194386: workaround for MSR SSBS not self-synchronizing" 1075 + select ARM64_WORKAROUND_SPECULATIVE_SSBS 1076 + default y 1077 + help 1078 + This option adds the workaround for ARM Cortex-X4 erratum 3194386. 1079 + 1080 + On affected cores "MSR SSBS, #0" instructions may not affect 1081 + subsequent speculative instructions, which may permit unexepected 1082 + speculative store bypassing. 1083 + 1084 + Work around this problem by placing a speculation barrier after 1085 + kernel changes to SSBS. The presence of the SSBS special-purpose 1086 + register is hidden from hwcaps and EL0 reads of ID_AA64PFR1_EL1, such 1087 + that userspace will use the PR_SPEC_STORE_BYPASS prctl to change 1088 + SSBS. 1089 + 1090 + If unsure, say Y. 1091 + 1092 + config ARM64_ERRATUM_3312417 1093 + bool "Neoverse-V3: 3312417: workaround for MSR SSBS not self-synchronizing" 1094 + select ARM64_WORKAROUND_SPECULATIVE_SSBS 1095 + default y 1096 + help 1097 + This option adds the workaround for ARM Neoverse-V3 erratum 3312417. 1098 + 1099 + On affected cores "MSR SSBS, #0" instructions may not affect 1100 + subsequent speculative instructions, which may permit unexepected 1101 + speculative store bypassing. 1102 + 1103 + Work around this problem by placing a speculation barrier after 1104 + kernel changes to SSBS. The presence of the SSBS special-purpose 1105 + register is hidden from hwcaps and EL0 reads of ID_AA64PFR1_EL1, such 1106 + that userspace will use the PR_SPEC_STORE_BYPASS prctl to change 1107 + SSBS. 1108 + 1109 + If unsure, say Y. 1110 + 1111 + 1070 1112 config CAVIUM_ERRATUM_22375 1071 1113 bool "Cavium erratum 22375, 24313" 1072 1114 default y
+1
arch/arm64/include/asm/asm-bug.h
··· 28 28 14470: .long 14471f - .; \ 29 29 _BUGVERBOSE_LOCATION(__FILE__, __LINE__) \ 30 30 .short flags; \ 31 + .align 2; \ 31 32 .popsection; \ 32 33 14471: 33 34 #else
+4
arch/arm64/include/asm/barrier.h
··· 40 40 */ 41 41 #define dgh() asm volatile("hint #6" : : : "memory") 42 42 43 + #define spec_bar() asm volatile(ALTERNATIVE("dsb nsh\nisb\n", \ 44 + SB_BARRIER_INSN"nop\n", \ 45 + ARM64_HAS_SB)) 46 + 43 47 #ifdef CONFIG_ARM64_PSEUDO_NMI 44 48 #define pmr_sync() \ 45 49 do { \
+2
arch/arm64/include/asm/cpucaps.h
··· 58 58 return IS_ENABLED(CONFIG_NVIDIA_CARMEL_CNP_ERRATUM); 59 59 case ARM64_WORKAROUND_REPEAT_TLBI: 60 60 return IS_ENABLED(CONFIG_ARM64_WORKAROUND_REPEAT_TLBI); 61 + case ARM64_WORKAROUND_SPECULATIVE_SSBS: 62 + return IS_ENABLED(CONFIG_ARM64_WORKAROUND_SPECULATIVE_SSBS); 61 63 } 62 64 63 65 return true;
+4
arch/arm64/include/asm/cputype.h
··· 87 87 #define ARM_CPU_PART_NEOVERSE_N2 0xD49 88 88 #define ARM_CPU_PART_CORTEX_A78C 0xD4B 89 89 #define ARM_CPU_PART_NEOVERSE_V2 0xD4F 90 + #define ARM_CPU_PART_CORTEX_X4 0xD82 91 + #define ARM_CPU_PART_NEOVERSE_V3 0xD84 90 92 91 93 #define APM_CPU_PART_XGENE 0x000 92 94 #define APM_CPU_VAR_POTENZA 0x00 ··· 163 161 #define MIDR_NEOVERSE_N2 MIDR_CPU_MODEL(ARM_CPU_IMP_ARM, ARM_CPU_PART_NEOVERSE_N2) 164 162 #define MIDR_CORTEX_A78C MIDR_CPU_MODEL(ARM_CPU_IMP_ARM, ARM_CPU_PART_CORTEX_A78C) 165 163 #define MIDR_NEOVERSE_V2 MIDR_CPU_MODEL(ARM_CPU_IMP_ARM, ARM_CPU_PART_NEOVERSE_V2) 164 + #define MIDR_CORTEX_X4 MIDR_CPU_MODEL(ARM_CPU_IMP_ARM, ARM_CPU_PART_CORTEX_X4) 165 + #define MIDR_NEOVERSE_V3 MIDR_CPU_MODEL(ARM_CPU_IMP_ARM, ARM_CPU_PART_NEOVERSE_V3) 166 166 #define MIDR_THUNDERX MIDR_CPU_MODEL(ARM_CPU_IMP_CAVIUM, CAVIUM_CPU_PART_THUNDERX) 167 167 #define MIDR_THUNDERX_81XX MIDR_CPU_MODEL(ARM_CPU_IMP_CAVIUM, CAVIUM_CPU_PART_THUNDERX_81XX) 168 168 #define MIDR_THUNDERX_83XX MIDR_CPU_MODEL(ARM_CPU_IMP_CAVIUM, CAVIUM_CPU_PART_THUNDERX_83XX)
+19
arch/arm64/kernel/cpu_errata.c
··· 432 432 }; 433 433 #endif 434 434 435 + #ifdef CONFIG_ARM64_WORKAROUND_SPECULATIVE_SSBS 436 + static const struct midr_range erratum_spec_ssbs_list[] = { 437 + #ifdef CONFIG_ARM64_ERRATUM_3194386 438 + MIDR_ALL_VERSIONS(MIDR_CORTEX_X4), 439 + #endif 440 + #ifdef CONFIG_ARM64_ERRATUM_3312417 441 + MIDR_ALL_VERSIONS(MIDR_NEOVERSE_V3), 442 + #endif 443 + {} 444 + }; 445 + #endif 446 + 435 447 const struct arm64_cpu_capabilities arm64_errata[] = { 436 448 #ifdef CONFIG_ARM64_WORKAROUND_CLEAN_CACHE 437 449 { ··· 739 727 /* Cortex-A510 r0p0 - r1p1 */ 740 728 ERRATA_MIDR_RANGE(MIDR_CORTEX_A510, 0, 0, 1, 1), 741 729 MIDR_FIXED(MIDR_CPU_VAR_REV(1,1), BIT(25)), 730 + }, 731 + #endif 732 + #ifdef CONFIG_ARM64_WORKAROUND_SPECULATIVE_SSBS 733 + { 734 + .desc = "ARM errata 3194386, 3312417", 735 + .capability = ARM64_WORKAROUND_SPECULATIVE_SSBS, 736 + ERRATA_MIDR_RANGE_LIST(erratum_spec_ssbs_list), 742 737 }, 743 738 #endif 744 739 #ifdef CONFIG_ARM64_WORKAROUND_SPECULATIVE_UNPRIV_LOAD
+8
arch/arm64/kernel/cpufeature.c
··· 2307 2307 if (regp) 2308 2308 regp->user_mask &= ~ID_AA64ISAR1_EL1_BF16_MASK; 2309 2309 } 2310 + 2311 + if (cpus_have_cap(ARM64_WORKAROUND_SPECULATIVE_SSBS)) { 2312 + struct arm64_ftr_reg *regp; 2313 + 2314 + regp = get_arm64_ftr_reg(SYS_ID_AA64PFR1_EL1); 2315 + if (regp) 2316 + regp->user_mask &= ~ID_AA64PFR1_EL1_SSBS_MASK; 2317 + } 2310 2318 } 2311 2319 2312 2320 static void elf_hwcap_fixup(void)
+22 -22
arch/arm64/kernel/fpsimd.c
··· 1535 1535 task->thread.kernel_fpsimd_cpu = smp_processor_id(); 1536 1536 } 1537 1537 1538 + /* 1539 + * Invalidate any task's FPSIMD state that is present on this cpu. 1540 + * The FPSIMD context should be acquired with get_cpu_fpsimd_context() 1541 + * before calling this function. 1542 + */ 1543 + static void fpsimd_flush_cpu_state(void) 1544 + { 1545 + WARN_ON(!system_supports_fpsimd()); 1546 + __this_cpu_write(fpsimd_last_state.st, NULL); 1547 + 1548 + /* 1549 + * Leaving streaming mode enabled will cause issues for any kernel 1550 + * NEON and leaving streaming mode or ZA enabled may increase power 1551 + * consumption. 1552 + */ 1553 + if (system_supports_sme()) 1554 + sme_smstop(); 1555 + 1556 + set_thread_flag(TIF_FOREIGN_FPSTATE); 1557 + } 1558 + 1538 1559 void fpsimd_thread_switch(struct task_struct *next) 1539 1560 { 1540 1561 bool wrong_task, wrong_cpu; ··· 1573 1552 1574 1553 if (test_tsk_thread_flag(next, TIF_KERNEL_FPSTATE)) { 1575 1554 fpsimd_load_kernel_state(next); 1576 - set_tsk_thread_flag(next, TIF_FOREIGN_FPSTATE); 1555 + fpsimd_flush_cpu_state(); 1577 1556 } else { 1578 1557 /* 1579 1558 * Fix up TIF_FOREIGN_FPSTATE to correctly describe next's ··· 1861 1840 set_tsk_thread_flag(t, TIF_FOREIGN_FPSTATE); 1862 1841 1863 1842 barrier(); 1864 - } 1865 - 1866 - /* 1867 - * Invalidate any task's FPSIMD state that is present on this cpu. 1868 - * The FPSIMD context should be acquired with get_cpu_fpsimd_context() 1869 - * before calling this function. 1870 - */ 1871 - static void fpsimd_flush_cpu_state(void) 1872 - { 1873 - WARN_ON(!system_supports_fpsimd()); 1874 - __this_cpu_write(fpsimd_last_state.st, NULL); 1875 - 1876 - /* 1877 - * Leaving streaming mode enabled will cause issues for any kernel 1878 - * NEON and leaving streaming mode or ZA enabled may increase power 1879 - * consumption. 1880 - */ 1881 - if (system_supports_sme()) 1882 - sme_smstop(); 1883 - 1884 - set_thread_flag(TIF_FOREIGN_FPSTATE); 1885 1843 } 1886 1844 1887 1845 /*
+12
arch/arm64/kernel/proton-pack.c
··· 558 558 559 559 /* SCTLR_EL1.DSSBS was initialised to 0 during boot */ 560 560 set_pstate_ssbs(0); 561 + 562 + /* 563 + * SSBS is self-synchronizing and is intended to affect subsequent 564 + * speculative instructions, but some CPUs can speculate with a stale 565 + * value of SSBS. 566 + * 567 + * Mitigate this with an unconditional speculation barrier, as CPUs 568 + * could mis-speculate branches and bypass a conditional barrier. 569 + */ 570 + if (IS_ENABLED(CONFIG_ARM64_WORKAROUND_SPECULATIVE_SSBS)) 571 + spec_bar(); 572 + 561 573 return SPECTRE_MITIGATED; 562 574 } 563 575
+1
arch/arm64/tools/cpucaps
··· 102 102 WORKAROUND_QCOM_FALKOR_E1003 103 103 WORKAROUND_REPEAT_TLBI 104 104 WORKAROUND_SPECULATIVE_AT 105 + WORKAROUND_SPECULATIVE_SSBS 105 106 WORKAROUND_SPECULATIVE_UNPRIV_LOAD
+6 -3
drivers/perf/arm_dmc620_pmu.c
··· 542 542 if (event->cpu < 0) 543 543 return -EINVAL; 544 544 545 + hwc->idx = -1; 546 + 547 + if (event->group_leader == event) 548 + return 0; 549 + 545 550 /* 546 551 * We can't atomically disable all HW counters so only one event allowed, 547 552 * although software events are acceptable. 548 553 */ 549 - if (event->group_leader != event && 550 - !is_software_event(event->group_leader)) 554 + if (!is_software_event(event->group_leader)) 551 555 return -EINVAL; 552 556 553 557 for_each_sibling_event(sibling, event->group_leader) { ··· 560 556 return -EINVAL; 561 557 } 562 558 563 - hwc->idx = -1; 564 559 return 0; 565 560 } 566 561