Skip to content

Commit 444fc5c

Browse files
committed
Merge tag 'for-linus' of git://git.armlinux.org.uk/~rmk/linux-arm
Pull ARM fixes from Russell King: - correct value of decompressor tag size in header - fix DACR value when we have nested exceptions - fix a missing newline on a kernel message - fix mask for ptrace thumb breakpoint hook * tag 'for-linus' of git://git.armlinux.org.uk/~rmk/linux-arm: ARM: 8977/1: ptrace: Fix mask for thumb breakpoint hook ARM: 8973/1: Add missing newline terminator to kernel message ARM: uaccess: fix DACR mismatch with nested exceptions ARM: uaccess: integrate uaccess_save and uaccess_restore ARM: uaccess: consolidate uaccess asm to asm/uaccess-asm.h ARM: 8970/1: decompressor: increase tag size
2 parents 9cb1fd0 + 3866f21 commit 444fc5c

File tree

7 files changed

+127
-93
lines changed

7 files changed

+127
-93
lines changed

arch/arm/boot/compressed/vmlinux.lds.S

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ SECTIONS
4242
}
4343
.table : ALIGN(4) {
4444
_table_start = .;
45-
LONG(ZIMAGE_MAGIC(2))
45+
LONG(ZIMAGE_MAGIC(4))
4646
LONG(ZIMAGE_MAGIC(0x5a534c4b))
4747
LONG(ZIMAGE_MAGIC(__piggy_size_addr - _start))
4848
LONG(ZIMAGE_MAGIC(_kernel_bss_size))

arch/arm/include/asm/assembler.h

Lines changed: 1 addition & 74 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,11 @@
1818
#endif
1919

2020
#include <asm/ptrace.h>
21-
#include <asm/domain.h>
2221
#include <asm/opcodes-virt.h>
2322
#include <asm/asm-offsets.h>
2423
#include <asm/page.h>
2524
#include <asm/thread_info.h>
25+
#include <asm/uaccess-asm.h>
2626

2727
#define IOMEM(x) (x)
2828

@@ -446,79 +446,6 @@ THUMB( orr \reg , \reg , #PSR_T_BIT )
446446
.size \name , . - \name
447447
.endm
448448

449-
.macro csdb
450-
#ifdef CONFIG_THUMB2_KERNEL
451-
.inst.w 0xf3af8014
452-
#else
453-
.inst 0xe320f014
454-
#endif
455-
.endm
456-
457-
.macro check_uaccess, addr:req, size:req, limit:req, tmp:req, bad:req
458-
#ifndef CONFIG_CPU_USE_DOMAINS
459-
adds \tmp, \addr, #\size - 1
460-
sbcscc \tmp, \tmp, \limit
461-
bcs \bad
462-
#ifdef CONFIG_CPU_SPECTRE
463-
movcs \addr, #0
464-
csdb
465-
#endif
466-
#endif
467-
.endm
468-
469-
.macro uaccess_mask_range_ptr, addr:req, size:req, limit:req, tmp:req
470-
#ifdef CONFIG_CPU_SPECTRE
471-
sub \tmp, \limit, #1
472-
subs \tmp, \tmp, \addr @ tmp = limit - 1 - addr
473-
addhs \tmp, \tmp, #1 @ if (tmp >= 0) {
474-
subshs \tmp, \tmp, \size @ tmp = limit - (addr + size) }
475-
movlo \addr, #0 @ if (tmp < 0) addr = NULL
476-
csdb
477-
#endif
478-
.endm
479-
480-
.macro uaccess_disable, tmp, isb=1
481-
#ifdef CONFIG_CPU_SW_DOMAIN_PAN
482-
/*
483-
* Whenever we re-enter userspace, the domains should always be
484-
* set appropriately.
485-
*/
486-
mov \tmp, #DACR_UACCESS_DISABLE
487-
mcr p15, 0, \tmp, c3, c0, 0 @ Set domain register
488-
.if \isb
489-
instr_sync
490-
.endif
491-
#endif
492-
.endm
493-
494-
.macro uaccess_enable, tmp, isb=1
495-
#ifdef CONFIG_CPU_SW_DOMAIN_PAN
496-
/*
497-
* Whenever we re-enter userspace, the domains should always be
498-
* set appropriately.
499-
*/
500-
mov \tmp, #DACR_UACCESS_ENABLE
501-
mcr p15, 0, \tmp, c3, c0, 0
502-
.if \isb
503-
instr_sync
504-
.endif
505-
#endif
506-
.endm
507-
508-
.macro uaccess_save, tmp
509-
#ifdef CONFIG_CPU_SW_DOMAIN_PAN
510-
mrc p15, 0, \tmp, c3, c0, 0
511-
str \tmp, [sp, #SVC_DACR]
512-
#endif
513-
.endm
514-
515-
.macro uaccess_restore
516-
#ifdef CONFIG_CPU_SW_DOMAIN_PAN
517-
ldr r0, [sp, #SVC_DACR]
518-
mcr p15, 0, r0, c3, c0, 0
519-
#endif
520-
.endm
521-
522449
.irp c,,eq,ne,cs,cc,mi,pl,vs,vc,hi,ls,ge,lt,gt,le,hs,lo
523450
.macro ret\c, reg
524451
#if __LINUX_ARM_ARCH__ < 6

arch/arm/include/asm/uaccess-asm.h

Lines changed: 117 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,117 @@
1+
/* SPDX-License-Identifier: GPL-2.0-only */
2+
3+
#ifndef __ASM_UACCESS_ASM_H__
4+
#define __ASM_UACCESS_ASM_H__
5+
6+
#include <asm/asm-offsets.h>
7+
#include <asm/domain.h>
8+
#include <asm/memory.h>
9+
#include <asm/thread_info.h>
10+
11+
.macro csdb
12+
#ifdef CONFIG_THUMB2_KERNEL
13+
.inst.w 0xf3af8014
14+
#else
15+
.inst 0xe320f014
16+
#endif
17+
.endm
18+
19+
.macro check_uaccess, addr:req, size:req, limit:req, tmp:req, bad:req
20+
#ifndef CONFIG_CPU_USE_DOMAINS
21+
adds \tmp, \addr, #\size - 1
22+
sbcscc \tmp, \tmp, \limit
23+
bcs \bad
24+
#ifdef CONFIG_CPU_SPECTRE
25+
movcs \addr, #0
26+
csdb
27+
#endif
28+
#endif
29+
.endm
30+
31+
.macro uaccess_mask_range_ptr, addr:req, size:req, limit:req, tmp:req
32+
#ifdef CONFIG_CPU_SPECTRE
33+
sub \tmp, \limit, #1
34+
subs \tmp, \tmp, \addr @ tmp = limit - 1 - addr
35+
addhs \tmp, \tmp, #1 @ if (tmp >= 0) {
36+
subshs \tmp, \tmp, \size @ tmp = limit - (addr + size) }
37+
movlo \addr, #0 @ if (tmp < 0) addr = NULL
38+
csdb
39+
#endif
40+
.endm
41+
42+
.macro uaccess_disable, tmp, isb=1
43+
#ifdef CONFIG_CPU_SW_DOMAIN_PAN
44+
/*
45+
* Whenever we re-enter userspace, the domains should always be
46+
* set appropriately.
47+
*/
48+
mov \tmp, #DACR_UACCESS_DISABLE
49+
mcr p15, 0, \tmp, c3, c0, 0 @ Set domain register
50+
.if \isb
51+
instr_sync
52+
.endif
53+
#endif
54+
.endm
55+
56+
.macro uaccess_enable, tmp, isb=1
57+
#ifdef CONFIG_CPU_SW_DOMAIN_PAN
58+
/*
59+
* Whenever we re-enter userspace, the domains should always be
60+
* set appropriately.
61+
*/
62+
mov \tmp, #DACR_UACCESS_ENABLE
63+
mcr p15, 0, \tmp, c3, c0, 0
64+
.if \isb
65+
instr_sync
66+
.endif
67+
#endif
68+
.endm
69+
70+
#if defined(CONFIG_CPU_SW_DOMAIN_PAN) || defined(CONFIG_CPU_USE_DOMAINS)
71+
#define DACR(x...) x
72+
#else
73+
#define DACR(x...)
74+
#endif
75+
76+
/*
77+
* Save the address limit on entry to a privileged exception.
78+
*
79+
* If we are using the DACR for kernel access by the user accessors
80+
* (CONFIG_CPU_USE_DOMAINS=y), always reset the DACR kernel domain
81+
* back to client mode, whether or not \disable is set.
82+
*
83+
* If we are using SW PAN, set the DACR user domain to no access
84+
* if \disable is set.
85+
*/
86+
.macro uaccess_entry, tsk, tmp0, tmp1, tmp2, disable
87+
ldr \tmp1, [\tsk, #TI_ADDR_LIMIT]
88+
mov \tmp2, #TASK_SIZE
89+
str \tmp2, [\tsk, #TI_ADDR_LIMIT]
90+
DACR( mrc p15, 0, \tmp0, c3, c0, 0)
91+
DACR( str \tmp0, [sp, #SVC_DACR])
92+
str \tmp1, [sp, #SVC_ADDR_LIMIT]
93+
.if \disable && IS_ENABLED(CONFIG_CPU_SW_DOMAIN_PAN)
94+
/* kernel=client, user=no access */
95+
mov \tmp2, #DACR_UACCESS_DISABLE
96+
mcr p15, 0, \tmp2, c3, c0, 0
97+
instr_sync
98+
.elseif IS_ENABLED(CONFIG_CPU_USE_DOMAINS)
99+
/* kernel=client */
100+
bic \tmp2, \tmp0, #domain_mask(DOMAIN_KERNEL)
101+
orr \tmp2, \tmp2, #domain_val(DOMAIN_KERNEL, DOMAIN_CLIENT)
102+
mcr p15, 0, \tmp2, c3, c0, 0
103+
instr_sync
104+
.endif
105+
.endm
106+
107+
/* Restore the user access state previously saved by uaccess_entry */
108+
.macro uaccess_exit, tsk, tmp0, tmp1
109+
ldr \tmp1, [sp, #SVC_ADDR_LIMIT]
110+
DACR( ldr \tmp0, [sp, #SVC_DACR])
111+
str \tmp1, [\tsk, #TI_ADDR_LIMIT]
112+
DACR( mcr p15, 0, \tmp0, c3, c0, 0)
113+
.endm
114+
115+
#undef DACR
116+
117+
#endif /* __ASM_UACCESS_ASM_H__ */

arch/arm/kernel/atags_proc.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ static int __init init_atags_procfs(void)
4242
size_t size;
4343

4444
if (tag->hdr.tag != ATAG_CORE) {
45-
pr_info("No ATAGs?");
45+
pr_info("No ATAGs?\n");
4646
return -EINVAL;
4747
}
4848

arch/arm/kernel/entry-armv.S

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
#include <asm/unistd.h>
2828
#include <asm/tls.h>
2929
#include <asm/system_info.h>
30+
#include <asm/uaccess-asm.h>
3031

3132
#include "entry-header.S"
3233
#include <asm/entry-macro-multi.S>
@@ -179,15 +180,7 @@ ENDPROC(__und_invalid)
179180
stmia r7, {r2 - r6}
180181

181182
get_thread_info tsk
182-
ldr r0, [tsk, #TI_ADDR_LIMIT]
183-
mov r1, #TASK_SIZE
184-
str r1, [tsk, #TI_ADDR_LIMIT]
185-
str r0, [sp, #SVC_ADDR_LIMIT]
186-
187-
uaccess_save r0
188-
.if \uaccess
189-
uaccess_disable r0
190-
.endif
183+
uaccess_entry tsk, r0, r1, r2, \uaccess
191184

192185
.if \trace
193186
#ifdef CONFIG_TRACE_IRQFLAGS

arch/arm/kernel/entry-header.S

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
#include <asm/asm-offsets.h>
77
#include <asm/errno.h>
88
#include <asm/thread_info.h>
9+
#include <asm/uaccess-asm.h>
910
#include <asm/v7m.h>
1011

1112
@ Bad Abort numbers
@@ -217,9 +218,7 @@
217218
blne trace_hardirqs_off
218219
#endif
219220
.endif
220-
ldr r1, [sp, #SVC_ADDR_LIMIT]
221-
uaccess_restore
222-
str r1, [tsk, #TI_ADDR_LIMIT]
221+
uaccess_exit tsk, r0, r1
223222

224223
#ifndef CONFIG_THUMB2_KERNEL
225224
@ ARM mode SVC restore
@@ -263,9 +262,7 @@
263262
@ on the stack remains correct).
264263
@
265264
.macro svc_exit_via_fiq
266-
ldr r1, [sp, #SVC_ADDR_LIMIT]
267-
uaccess_restore
268-
str r1, [tsk, #TI_ADDR_LIMIT]
265+
uaccess_exit tsk, r0, r1
269266
#ifndef CONFIG_THUMB2_KERNEL
270267
@ ARM mode restore
271268
mov r0, sp

arch/arm/kernel/ptrace.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -219,8 +219,8 @@ static struct undef_hook arm_break_hook = {
219219
};
220220

221221
static struct undef_hook thumb_break_hook = {
222-
.instr_mask = 0xffff,
223-
.instr_val = 0xde01,
222+
.instr_mask = 0xffffffff,
223+
.instr_val = 0x0000de01,
224224
.cpsr_mask = PSR_T_BIT,
225225
.cpsr_val = PSR_T_BIT,
226226
.fn = break_trap,

0 commit comments

Comments
 (0)