Skip to content

Commit 5f06a79

Browse files
committed
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
2 parents 872f8ed + e6f85cb commit 5f06a79

File tree

11 files changed

+54
-30
lines changed

11 files changed

+54
-30
lines changed

arch/arm64/Kconfig

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1605,7 +1605,8 @@ config ARM64_BTI_KERNEL
16051605
depends on CC_HAS_BRANCH_PROT_PAC_RET_BTI
16061606
# https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94697
16071607
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
16091610
depends on (!FUNCTION_GRAPH_TRACER || DYNAMIC_FTRACE_WITH_REGS)
16101611
help
16111612
Build the kernel with Branch Target Identification annotations

arch/arm64/include/asm/cache.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@
4747
* cache before the transfer is done, causing old data to be seen by
4848
* the CPU.
4949
*/
50-
#define ARCH_DMA_MINALIGN L1_CACHE_BYTES
50+
#define ARCH_DMA_MINALIGN (128)
5151

5252
#ifdef CONFIG_KASAN_SW_TAGS
5353
#define ARCH_SLAB_MINALIGN (1ULL << KASAN_SHADOW_SCALE_SHIFT)

arch/arm64/include/asm/smp_plat.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010

1111
#include <linux/cpumask.h>
1212

13+
#include <asm/smp.h>
1314
#include <asm/types.h>
1415

1516
struct mpidr_hash {

arch/arm64/kernel/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ CFLAGS_syscall.o += -fno-stack-protector
1717
# It's not safe to invoke KCOV when portions of the kernel environment aren't
1818
# available or are out-of-sync with HW state. Since `noinstr` doesn't always
1919
# inhibit KCOV instrumentation, disable it for the entire compilation unit.
20-
KCOV_INSTRUMENT_entry.o := n
20+
KCOV_INSTRUMENT_entry-common.o := n
2121
KCOV_INSTRUMENT_idle.o := n
2222

2323
# Object file lists.

arch/arm64/kernel/cpufeature.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@
8181
#include <asm/mmu_context.h>
8282
#include <asm/mte.h>
8383
#include <asm/processor.h>
84+
#include <asm/smp.h>
8485
#include <asm/sysreg.h>
8586
#include <asm/traps.h>
8687
#include <asm/virt.h>

arch/arm64/kernel/entry-common.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -604,7 +604,7 @@ asmlinkage void noinstr el0t_64_fiq_handler(struct pt_regs *regs)
604604
__el0_fiq_handler_common(regs);
605605
}
606606

607-
static void __el0_error_handler_common(struct pt_regs *regs)
607+
static void noinstr __el0_error_handler_common(struct pt_regs *regs)
608608
{
609609
unsigned long esr = read_sysreg(esr_el1);
610610

arch/arm64/kernel/mte.c

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -193,18 +193,6 @@ void mte_check_tfsr_el1(void)
193193
}
194194
#endif
195195

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-
208196
static void set_gcr_el1_excl(u64 excl)
209197
{
210198
current->thread.gcr_user_excl = excl;
@@ -265,7 +253,8 @@ void mte_suspend_exit(void)
265253
if (!system_supports_mte())
266254
return;
267255

268-
update_gcr_el1_excl(gcr_kernel_excl);
256+
sysreg_clear_set_s(SYS_GCR_EL1, SYS_GCR_EL1_EXCL_MASK, gcr_kernel_excl);
257+
isb();
269258
}
270259

271260
long set_mte_ctrl(struct task_struct *task, unsigned long arg)

arch/arm64/lib/copy_from_user.S

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,32 +29,34 @@
2929
.endm
3030

3131
.macro ldrh1 reg, ptr, val
32-
user_ldst 9998f, ldtrh, \reg, \ptr, \val
32+
user_ldst 9997f, ldtrh, \reg, \ptr, \val
3333
.endm
3434

3535
.macro strh1 reg, ptr, val
3636
strh \reg, [\ptr], \val
3737
.endm
3838

3939
.macro ldr1 reg, ptr, val
40-
user_ldst 9998f, ldtr, \reg, \ptr, \val
40+
user_ldst 9997f, ldtr, \reg, \ptr, \val
4141
.endm
4242

4343
.macro str1 reg, ptr, val
4444
str \reg, [\ptr], \val
4545
.endm
4646

4747
.macro ldp1 reg1, reg2, ptr, val
48-
user_ldp 9998f, \reg1, \reg2, \ptr, \val
48+
user_ldp 9997f, \reg1, \reg2, \ptr, \val
4949
.endm
5050

5151
.macro stp1 reg1, reg2, ptr, val
5252
stp \reg1, \reg2, [\ptr], \val
5353
.endm
5454

5555
end .req x5
56+
srcin .req x15
5657
SYM_FUNC_START(__arch_copy_from_user)
5758
add end, x0, x2
59+
mov srcin, x1
5860
#include "copy_template.S"
5961
mov x0, #0 // Nothing to copy
6062
ret
@@ -63,6 +65,11 @@ EXPORT_SYMBOL(__arch_copy_from_user)
6365

6466
.section .fixup,"ax"
6567
.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+
strb tmp1w, [dst], #1
6673
9998: sub x0, end, dst // bytes not copied
6774
ret
6875
.previous

arch/arm64/lib/copy_in_user.S

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -30,33 +30,34 @@
3030
.endm
3131

3232
.macro ldrh1 reg, ptr, val
33-
user_ldst 9998f, ldtrh, \reg, \ptr, \val
33+
user_ldst 9997f, ldtrh, \reg, \ptr, \val
3434
.endm
3535

3636
.macro strh1 reg, ptr, val
37-
user_ldst 9998f, sttrh, \reg, \ptr, \val
37+
user_ldst 9997f, sttrh, \reg, \ptr, \val
3838
.endm
3939

4040
.macro ldr1 reg, ptr, val
41-
user_ldst 9998f, ldtr, \reg, \ptr, \val
41+
user_ldst 9997f, ldtr, \reg, \ptr, \val
4242
.endm
4343

4444
.macro str1 reg, ptr, val
45-
user_ldst 9998f, sttr, \reg, \ptr, \val
45+
user_ldst 9997f, sttr, \reg, \ptr, \val
4646
.endm
4747

4848
.macro ldp1 reg1, reg2, ptr, val
49-
user_ldp 9998f, \reg1, \reg2, \ptr, \val
49+
user_ldp 9997f, \reg1, \reg2, \ptr, \val
5050
.endm
5151

5252
.macro stp1 reg1, reg2, ptr, val
53-
user_stp 9998f, \reg1, \reg2, \ptr, \val
53+
user_stp 9997f, \reg1, \reg2, \ptr, \val
5454
.endm
5555

5656
end .req x5
57-
57+
srcin .req x15
5858
SYM_FUNC_START(__arch_copy_in_user)
5959
add end, x0, x2
60+
mov srcin, x1
6061
#include "copy_template.S"
6162
mov x0, #0
6263
ret
@@ -65,6 +66,12 @@ EXPORT_SYMBOL(__arch_copy_in_user)
6566

6667
.section .fixup,"ax"
6768
.align 2
69+
9997: cmp dst, dstin
70+
b.ne 9998f
71+
// Before being absolutely sure we couldn't copy anything, try harder
72+
USER(9998f, ldtrb tmp1w, [srcin])
73+
USER(9998f, sttrb tmp1w, [dst])
74+
add dst, dst, #1
6875
9998: sub x0, end, dst // bytes not copied
6976
ret
7077
.previous

arch/arm64/lib/copy_to_user.S

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,28 +32,30 @@
3232
.endm
3333

3434
.macro strh1 reg, ptr, val
35-
user_ldst 9998f, sttrh, \reg, \ptr, \val
35+
user_ldst 9997f, sttrh, \reg, \ptr, \val
3636
.endm
3737

3838
.macro ldr1 reg, ptr, val
3939
ldr \reg, [\ptr], \val
4040
.endm
4141

4242
.macro str1 reg, ptr, val
43-
user_ldst 9998f, sttr, \reg, \ptr, \val
43+
user_ldst 9997f, sttr, \reg, \ptr, \val
4444
.endm
4545

4646
.macro ldp1 reg1, reg2, ptr, val
4747
ldp \reg1, \reg2, [\ptr], \val
4848
.endm
4949

5050
.macro stp1 reg1, reg2, ptr, val
51-
user_stp 9998f, \reg1, \reg2, \ptr, \val
51+
user_stp 9997f, \reg1, \reg2, \ptr, \val
5252
.endm
5353

5454
end .req x5
55+
srcin .req x15
5556
SYM_FUNC_START(__arch_copy_to_user)
5657
add end, x0, x2
58+
mov srcin, x1
5759
#include "copy_template.S"
5860
mov x0, #0
5961
ret
@@ -62,6 +64,12 @@ EXPORT_SYMBOL(__arch_copy_to_user)
6264

6365
.section .fixup,"ax"
6466
.align 2
67+
9997: cmp dst, dstin
68+
b.ne 9998f
69+
// Before being absolutely sure we couldn't copy anything, try harder
70+
ldrb tmp1w, [srcin]
71+
USER(9998f, sttrb tmp1w, [dst])
72+
add dst, dst, #1
6573
9998: sub x0, end, dst // bytes not copied
6674
ret
6775
.previous

0 commit comments

Comments
 (0)