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

Configure Feed

Select the types of activity you want to include in your feed.

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

Pull arm64 fixes from Will Deacon:
"The bulk of the diffstat consists of changes to our uaccess routines
so that they fall back to bytewise copying prior to reporting complete
failure when the initial (multi-byte) access faults.

However, the most disappointing change here is that we've had to bump
ARCH_DMA_MINALIGN back to 128 bytes thanks to Qualcomm's "Kryo" CPU,
which ended up in the MSM8996 mobile SoC. Still, at least we're now
aware of this design and one of the hardware designers confirmed the
L2 cacheline size for us.

Summary:

- Fix instrumentation annotations for entry code

- Ensure kernel MTE state is restored correctly on resume from suspend

- Fix MTE fault from new strlen() routine

- Fallback to byte-wise accesses on initial uaccess fault

- Bump Clang requirement for BTI

- Revert ARCH_DMA_MINALIGN back to 128 bytes (shakes fist at Qualcomm)"

* tag 'arm64-fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/arm64/linux:
arm64: entry: fix KCOV suppression
arm64: entry: add missing noinstr
arm64: mte: fix restoration of GCR_EL1 from suspend
arm64: Avoid premature usercopy failure
arm64: Restrict ARM64_BTI_KERNEL to clang 12.0.0 and newer
Revert "arm64: cache: Lower ARCH_DMA_MINALIGN to 64 (L1_CACHE_BYTES)"
arm64: Add missing header <asm/smp.h> in two files
arm64: fix strlen() with CONFIG_KASAN_HW_TAGS

+54 -30
+2 -1
arch/arm64/Kconfig
··· 1605 1605 depends on CC_HAS_BRANCH_PROT_PAC_RET_BTI 1606 1606 # https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94697 1607 1607 depends on !CC_IS_GCC || GCC_VERSION >= 100100 1608 - depends on !(CC_IS_CLANG && GCOV_KERNEL) 1608 + # https://github.com/llvm/llvm-project/commit/a88c722e687e6780dcd6a58718350dc76fcc4cc9 1609 + depends on !CC_IS_CLANG || CLANG_VERSION >= 120000 1609 1610 depends on (!FUNCTION_GRAPH_TRACER || DYNAMIC_FTRACE_WITH_REGS) 1610 1611 help 1611 1612 Build the kernel with Branch Target Identification annotations
+1 -1
arch/arm64/include/asm/cache.h
··· 47 47 * cache before the transfer is done, causing old data to be seen by 48 48 * the CPU. 49 49 */ 50 - #define ARCH_DMA_MINALIGN L1_CACHE_BYTES 50 + #define ARCH_DMA_MINALIGN (128) 51 51 52 52 #ifdef CONFIG_KASAN_SW_TAGS 53 53 #define ARCH_SLAB_MINALIGN (1ULL << KASAN_SHADOW_SCALE_SHIFT)
+1
arch/arm64/include/asm/smp_plat.h
··· 10 10 11 11 #include <linux/cpumask.h> 12 12 13 + #include <asm/smp.h> 13 14 #include <asm/types.h> 14 15 15 16 struct mpidr_hash {
+1 -1
arch/arm64/kernel/Makefile
··· 17 17 # It's not safe to invoke KCOV when portions of the kernel environment aren't 18 18 # available or are out-of-sync with HW state. Since `noinstr` doesn't always 19 19 # inhibit KCOV instrumentation, disable it for the entire compilation unit. 20 - KCOV_INSTRUMENT_entry.o := n 20 + KCOV_INSTRUMENT_entry-common.o := n 21 21 KCOV_INSTRUMENT_idle.o := n 22 22 23 23 # Object file lists.
+1
arch/arm64/kernel/cpufeature.c
··· 81 81 #include <asm/mmu_context.h> 82 82 #include <asm/mte.h> 83 83 #include <asm/processor.h> 84 + #include <asm/smp.h> 84 85 #include <asm/sysreg.h> 85 86 #include <asm/traps.h> 86 87 #include <asm/virt.h>
+1 -1
arch/arm64/kernel/entry-common.c
··· 604 604 __el0_fiq_handler_common(regs); 605 605 } 606 606 607 - static void __el0_error_handler_common(struct pt_regs *regs) 607 + static void noinstr __el0_error_handler_common(struct pt_regs *regs) 608 608 { 609 609 unsigned long esr = read_sysreg(esr_el1); 610 610
+2 -13
arch/arm64/kernel/mte.c
··· 193 193 } 194 194 #endif 195 195 196 - static void update_gcr_el1_excl(u64 excl) 197 - { 198 - 199 - /* 200 - * Note that the mask controlled by the user via prctl() is an 201 - * include while GCR_EL1 accepts an exclude mask. 202 - * No need for ISB since this only affects EL0 currently, implicit 203 - * with ERET. 204 - */ 205 - sysreg_clear_set_s(SYS_GCR_EL1, SYS_GCR_EL1_EXCL_MASK, excl); 206 - } 207 - 208 196 static void set_gcr_el1_excl(u64 excl) 209 197 { 210 198 current->thread.gcr_user_excl = excl; ··· 253 265 if (!system_supports_mte()) 254 266 return; 255 267 256 - update_gcr_el1_excl(gcr_kernel_excl); 268 + sysreg_clear_set_s(SYS_GCR_EL1, SYS_GCR_EL1_EXCL_MASK, gcr_kernel_excl); 269 + isb(); 257 270 } 258 271 259 272 long set_mte_ctrl(struct task_struct *task, unsigned long arg)
+10 -3
arch/arm64/lib/copy_from_user.S
··· 29 29 .endm 30 30 31 31 .macro ldrh1 reg, ptr, val 32 - user_ldst 9998f, ldtrh, \reg, \ptr, \val 32 + user_ldst 9997f, ldtrh, \reg, \ptr, \val 33 33 .endm 34 34 35 35 .macro strh1 reg, ptr, val ··· 37 37 .endm 38 38 39 39 .macro ldr1 reg, ptr, val 40 - user_ldst 9998f, ldtr, \reg, \ptr, \val 40 + user_ldst 9997f, ldtr, \reg, \ptr, \val 41 41 .endm 42 42 43 43 .macro str1 reg, ptr, val ··· 45 45 .endm 46 46 47 47 .macro ldp1 reg1, reg2, ptr, val 48 - user_ldp 9998f, \reg1, \reg2, \ptr, \val 48 + user_ldp 9997f, \reg1, \reg2, \ptr, \val 49 49 .endm 50 50 51 51 .macro stp1 reg1, reg2, ptr, val ··· 53 53 .endm 54 54 55 55 end .req x5 56 + srcin .req x15 56 57 SYM_FUNC_START(__arch_copy_from_user) 57 58 add end, x0, x2 59 + mov srcin, x1 58 60 #include "copy_template.S" 59 61 mov x0, #0 // Nothing to copy 60 62 ret ··· 65 63 66 64 .section .fixup,"ax" 67 65 .align 2 66 + 9997: cmp dst, dstin 67 + b.ne 9998f 68 + // Before being absolutely sure we couldn't copy anything, try harder 69 + USER(9998f, ldtrb tmp1w, [srcin]) 70 + strb tmp1w, [dst], #1 68 71 9998: sub x0, end, dst // bytes not copied 69 72 ret 70 73 .previous
+14 -7
arch/arm64/lib/copy_in_user.S
··· 30 30 .endm 31 31 32 32 .macro ldrh1 reg, ptr, val 33 - user_ldst 9998f, ldtrh, \reg, \ptr, \val 33 + user_ldst 9997f, ldtrh, \reg, \ptr, \val 34 34 .endm 35 35 36 36 .macro strh1 reg, ptr, val 37 - user_ldst 9998f, sttrh, \reg, \ptr, \val 37 + user_ldst 9997f, sttrh, \reg, \ptr, \val 38 38 .endm 39 39 40 40 .macro ldr1 reg, ptr, val 41 - user_ldst 9998f, ldtr, \reg, \ptr, \val 41 + user_ldst 9997f, ldtr, \reg, \ptr, \val 42 42 .endm 43 43 44 44 .macro str1 reg, ptr, val 45 - user_ldst 9998f, sttr, \reg, \ptr, \val 45 + user_ldst 9997f, sttr, \reg, \ptr, \val 46 46 .endm 47 47 48 48 .macro ldp1 reg1, reg2, ptr, val 49 - user_ldp 9998f, \reg1, \reg2, \ptr, \val 49 + user_ldp 9997f, \reg1, \reg2, \ptr, \val 50 50 .endm 51 51 52 52 .macro stp1 reg1, reg2, ptr, val 53 - user_stp 9998f, \reg1, \reg2, \ptr, \val 53 + user_stp 9997f, \reg1, \reg2, \ptr, \val 54 54 .endm 55 55 56 56 end .req x5 57 - 57 + srcin .req x15 58 58 SYM_FUNC_START(__arch_copy_in_user) 59 59 add end, x0, x2 60 + mov srcin, x1 60 61 #include "copy_template.S" 61 62 mov x0, #0 62 63 ret ··· 66 65 67 66 .section .fixup,"ax" 68 67 .align 2 68 + 9997: cmp dst, dstin 69 + b.ne 9998f 70 + // Before being absolutely sure we couldn't copy anything, try harder 71 + USER(9998f, ldtrb tmp1w, [srcin]) 72 + USER(9998f, sttrb tmp1w, [dst]) 73 + add dst, dst, #1 69 74 9998: sub x0, end, dst // bytes not copied 70 75 ret 71 76 .previous
+11 -3
arch/arm64/lib/copy_to_user.S
··· 32 32 .endm 33 33 34 34 .macro strh1 reg, ptr, val 35 - user_ldst 9998f, sttrh, \reg, \ptr, \val 35 + user_ldst 9997f, sttrh, \reg, \ptr, \val 36 36 .endm 37 37 38 38 .macro ldr1 reg, ptr, val ··· 40 40 .endm 41 41 42 42 .macro str1 reg, ptr, val 43 - user_ldst 9998f, sttr, \reg, \ptr, \val 43 + user_ldst 9997f, sttr, \reg, \ptr, \val 44 44 .endm 45 45 46 46 .macro ldp1 reg1, reg2, ptr, val ··· 48 48 .endm 49 49 50 50 .macro stp1 reg1, reg2, ptr, val 51 - user_stp 9998f, \reg1, \reg2, \ptr, \val 51 + user_stp 9997f, \reg1, \reg2, \ptr, \val 52 52 .endm 53 53 54 54 end .req x5 55 + srcin .req x15 55 56 SYM_FUNC_START(__arch_copy_to_user) 56 57 add end, x0, x2 58 + mov srcin, x1 57 59 #include "copy_template.S" 58 60 mov x0, #0 59 61 ret ··· 64 62 65 63 .section .fixup,"ax" 66 64 .align 2 65 + 9997: cmp dst, dstin 66 + b.ne 9998f 67 + // Before being absolutely sure we couldn't copy anything, try harder 68 + ldrb tmp1w, [srcin] 69 + USER(9998f, sttrb tmp1w, [dst]) 70 + add dst, dst, #1 67 71 9998: sub x0, end, dst // bytes not copied 68 72 ret 69 73 .previous
+10
arch/arm64/lib/strlen.S
··· 8 8 9 9 #include <linux/linkage.h> 10 10 #include <asm/assembler.h> 11 + #include <asm/mte-def.h> 11 12 12 13 /* Assumptions: 13 14 * ··· 43 42 #define REP8_7f 0x7f7f7f7f7f7f7f7f 44 43 #define REP8_80 0x8080808080808080 45 44 45 + /* 46 + * When KASAN_HW_TAGS is in use, memory is checked at MTE_GRANULE_SIZE 47 + * (16-byte) granularity, and we must ensure that no access straddles this 48 + * alignment boundary. 49 + */ 50 + #ifdef CONFIG_KASAN_HW_TAGS 51 + #define MIN_PAGE_SIZE MTE_GRANULE_SIZE 52 + #else 46 53 #define MIN_PAGE_SIZE 4096 54 + #endif 47 55 48 56 /* Since strings are short on average, we check the first 16 bytes 49 57 of the string for a NUL character. In order to do an unaligned ldp