Skip to content

Commit 1177984

Browse files
author
Russell King (Oracle)
committed
Merge branches 'devel-stable' and 'misc' into for-linus
3 parents 8bb7eca + c1e42ef + 0e52fc2 commit 1177984

39 files changed

+372
-235
lines changed

arch/arm/Kconfig

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ config ARM
9191
select HAVE_FAST_GUP if ARM_LPAE
9292
select HAVE_FTRACE_MCOUNT_RECORD if !XIP_KERNEL
9393
select HAVE_FUNCTION_GRAPH_TRACER if !THUMB2_KERNEL && !CC_IS_CLANG
94-
select HAVE_FUNCTION_TRACER if !XIP_KERNEL
94+
select HAVE_FUNCTION_TRACER if !XIP_KERNEL && !(THUMB2_KERNEL && CC_IS_CLANG)
9595
select HAVE_FUTEX_CMPXCHG if FUTEX
9696
select HAVE_GCC_PLUGINS
9797
select HAVE_HW_BREAKPOINT if PERF_EVENTS && (CPU_V6 || CPU_V6K || CPU_V7)
@@ -126,6 +126,7 @@ config ARM
126126
select PERF_USE_VMALLOC
127127
select RTC_LIB
128128
select SYS_SUPPORTS_APM_EMULATION
129+
select THREAD_INFO_IN_TASK if CURRENT_POINTER_IN_TPIDRURO
129130
select TRACE_IRQFLAGS_SUPPORT if !CPU_V7M
130131
# Above selects are sorted alphabetically; please add new ones
131132
# according to that. Thanks.
@@ -265,10 +266,12 @@ config PHYS_OFFSET
265266
hex "Physical address of main memory" if MMU
266267
depends on !ARM_PATCH_PHYS_VIRT
267268
default DRAM_BASE if !MMU
268-
default 0x00000000 if ARCH_FOOTBRIDGE
269+
default 0x00000000 if ARCH_FOOTBRIDGE || ARCH_IXP4XX
269270
default 0x10000000 if ARCH_OMAP1 || ARCH_RPC
270-
default 0x20000000 if ARCH_S5PV210
271-
default 0xc0000000 if ARCH_SA1100
271+
default 0x30000000 if ARCH_S3C24XX
272+
default 0xa0000000 if ARCH_IOP32X || ARCH_PXA
273+
default 0xc0000000 if ARCH_EP93XX || ARCH_SA1100
274+
default 0
272275
help
273276
Please provide the physical address corresponding to the
274277
location of main memory in your system.
@@ -433,6 +436,7 @@ config ARCH_PXA
433436
config ARCH_RPC
434437
bool "RiscPC"
435438
depends on MMU
439+
depends on !CC_IS_CLANG && GCC_VERSION < 90100 && GCC_VERSION >= 60000
436440
select ARCH_ACORN
437441
select ARCH_MAY_HAVE_PC_FDC
438442
select ARCH_SPARSEMEM_ENABLE
@@ -1158,6 +1162,11 @@ config SMP_ON_UP
11581162

11591163
If you don't know what to do here, say Y.
11601164

1165+
1166+
config CURRENT_POINTER_IN_TPIDRURO
1167+
def_bool y
1168+
depends on SMP && CPU_32v6K && !CPU_V6
1169+
11611170
config ARM_CPU_TOPOLOGY
11621171
bool "Support cpu topology definition"
11631172
depends on SMP && CPU_V7
@@ -1601,7 +1610,7 @@ config XEN
16011610

16021611
config STACKPROTECTOR_PER_TASK
16031612
bool "Use a unique stack canary value for each task"
1604-
depends on GCC_PLUGINS && STACKPROTECTOR && SMP && !XIP_DEFLATED_DATA
1613+
depends on GCC_PLUGINS && STACKPROTECTOR && THREAD_INFO_IN_TASK && !XIP_DEFLATED_DATA
16051614
select GCC_PLUGIN_ARM_SSP_PER_TASK
16061615
default y
16071616
help

arch/arm/Makefile

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,10 @@ ifeq ($(CONFIG_CC_IS_CLANG),y)
113113
CFLAGS_ABI += -meabi gnu
114114
endif
115115

116+
ifeq ($(CONFIG_CURRENT_POINTER_IN_TPIDRURO),y)
117+
CFLAGS_ABI += -mtp=cp15
118+
endif
119+
116120
# Accept old syntax despite ".syntax unified"
117121
AFLAGS_NOWARN :=$(call as-option,-Wa$(comma)-mno-warn-deprecated,-Wa$(comma)-W)
118122

@@ -273,11 +277,8 @@ ifeq ($(CONFIG_STACKPROTECTOR_PER_TASK),y)
273277
prepare: stack_protector_prepare
274278
stack_protector_prepare: prepare0
275279
$(eval SSP_PLUGIN_CFLAGS := \
276-
-fplugin-arg-arm_ssp_per_task_plugin-tso=$(shell \
277-
awk '{if ($$2 == "THREAD_SZ_ORDER") print $$3;}'\
278-
include/generated/asm-offsets.h) \
279280
-fplugin-arg-arm_ssp_per_task_plugin-offset=$(shell \
280-
awk '{if ($$2 == "TI_STACK_CANARY") print $$3;}'\
281+
awk '{if ($$2 == "TSK_STACK_CANARY") print $$3;}'\
281282
include/generated/asm-offsets.h))
282283
$(eval KBUILD_CFLAGS += $(SSP_PLUGIN_CFLAGS))
283284
$(eval GCC_PLUGINS_CFLAGS += $(SSP_PLUGIN_CFLAGS))

arch/arm/boot/compressed/fdt_check_mem_start.c

Lines changed: 42 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -55,16 +55,17 @@ static uint64_t get_val(const fdt32_t *cells, uint32_t ncells)
5555
* DTB, and, if out-of-range, replace it by the real start address.
5656
* To preserve backwards compatibility (systems reserving a block of memory
5757
* at the start of physical memory, kdump, ...), the traditional method is
58-
* always used if it yields a valid address.
58+
* used if it yields a valid address, unless the "linux,usable-memory-range"
59+
* property is present.
5960
*
6061
* Return value: start address of physical memory to use
6162
*/
6263
uint32_t fdt_check_mem_start(uint32_t mem_start, const void *fdt)
6364
{
64-
uint32_t addr_cells, size_cells, base;
65+
uint32_t addr_cells, size_cells, usable_base, base;
6566
uint32_t fdt_mem_start = 0xffffffff;
66-
const fdt32_t *reg, *endp;
67-
uint64_t size, end;
67+
const fdt32_t *usable, *reg, *endp;
68+
uint64_t size, usable_end, end;
6869
const char *type;
6970
int offset, len;
7071

@@ -80,6 +81,27 @@ uint32_t fdt_check_mem_start(uint32_t mem_start, const void *fdt)
8081
if (addr_cells > 2 || size_cells > 2)
8182
return mem_start;
8283

84+
/*
85+
* Usable memory in case of a crash dump kernel
86+
* This property describes a limitation: memory within this range is
87+
* only valid when also described through another mechanism
88+
*/
89+
usable = get_prop(fdt, "/chosen", "linux,usable-memory-range",
90+
(addr_cells + size_cells) * sizeof(fdt32_t));
91+
if (usable) {
92+
size = get_val(usable + addr_cells, size_cells);
93+
if (!size)
94+
return mem_start;
95+
96+
if (addr_cells > 1 && fdt32_ld(usable)) {
97+
/* Outside 32-bit address space */
98+
return mem_start;
99+
}
100+
101+
usable_base = fdt32_ld(usable + addr_cells - 1);
102+
usable_end = usable_base + size;
103+
}
104+
83105
/* Walk all memory nodes and regions */
84106
for (offset = fdt_next_node(fdt, -1, NULL); offset >= 0;
85107
offset = fdt_next_node(fdt, offset, NULL)) {
@@ -107,7 +129,20 @@ uint32_t fdt_check_mem_start(uint32_t mem_start, const void *fdt)
107129

108130
base = fdt32_ld(reg + addr_cells - 1);
109131
end = base + size;
110-
if (mem_start >= base && mem_start < end) {
132+
if (usable) {
133+
/*
134+
* Clip to usable range, which takes precedence
135+
* over mem_start
136+
*/
137+
if (base < usable_base)
138+
base = usable_base;
139+
140+
if (end > usable_end)
141+
end = usable_end;
142+
143+
if (end <= base)
144+
continue;
145+
} else if (mem_start >= base && mem_start < end) {
111146
/* Calculated address is valid, use it */
112147
return mem_start;
113148
}
@@ -123,7 +158,8 @@ uint32_t fdt_check_mem_start(uint32_t mem_start, const void *fdt)
123158
}
124159

125160
/*
126-
* The calculated address is not usable.
161+
* The calculated address is not usable, or was overridden by the
162+
* "linux,usable-memory-range" property.
127163
* Use the lowest usable physical memory address from the DTB instead,
128164
* and make sure this is a multiple of 2 MiB for phys/virt patching.
129165
*/

arch/arm/common/scoop.c

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -240,9 +240,6 @@ static int scoop_remove(struct platform_device *pdev)
240240
{
241241
struct scoop_dev *sdev = platform_get_drvdata(pdev);
242242

243-
if (!sdev)
244-
return -EINVAL;
245-
246243
if (sdev->gpio.base != -1)
247244
gpiochip_remove(&sdev->gpio);
248245

arch/arm/include/asm/assembler.h

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -199,14 +199,43 @@
199199
.endm
200200
.endr
201201

202+
.macro get_current, rd
203+
#ifdef CONFIG_CURRENT_POINTER_IN_TPIDRURO
204+
mrc p15, 0, \rd, c13, c0, 3 @ get TPIDRURO register
205+
#else
206+
get_thread_info \rd
207+
ldr \rd, [\rd, #TI_TASK]
208+
#endif
209+
.endm
210+
211+
.macro set_current, rn
212+
#ifdef CONFIG_CURRENT_POINTER_IN_TPIDRURO
213+
mcr p15, 0, \rn, c13, c0, 3 @ set TPIDRURO register
214+
#endif
215+
.endm
216+
217+
.macro reload_current, t1:req, t2:req
218+
#ifdef CONFIG_CURRENT_POINTER_IN_TPIDRURO
219+
adr_l \t1, __entry_task @ get __entry_task base address
220+
mrc p15, 0, \t2, c13, c0, 4 @ get per-CPU offset
221+
ldr \t1, [\t1, \t2] @ load variable
222+
mcr p15, 0, \t1, c13, c0, 3 @ store in TPIDRURO
223+
#endif
224+
.endm
225+
202226
/*
203227
* Get current thread_info.
204228
*/
205229
.macro get_thread_info, rd
230+
#ifdef CONFIG_THREAD_INFO_IN_TASK
231+
/* thread_info is the first member of struct task_struct */
232+
get_current \rd
233+
#else
206234
ARM( mov \rd, sp, lsr #THREAD_SIZE_ORDER + PAGE_SHIFT )
207235
THUMB( mov \rd, sp )
208236
THUMB( lsr \rd, \rd, #THREAD_SIZE_ORDER + PAGE_SHIFT )
209237
mov \rd, \rd, lsl #THREAD_SIZE_ORDER + PAGE_SHIFT
238+
#endif
210239
.endm
211240

212241
/*

arch/arm/include/asm/current.h

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
/* SPDX-License-Identifier: GPL-2.0-only */
2+
/*
3+
* Copyright (c) 2021 Keith Packard <[email protected]>
4+
* Copyright (c) 2021 Google, LLC <[email protected]>
5+
*/
6+
7+
#ifndef _ASM_ARM_CURRENT_H
8+
#define _ASM_ARM_CURRENT_H
9+
10+
#ifndef __ASSEMBLY__
11+
12+
struct task_struct;
13+
14+
static inline void set_current(struct task_struct *cur)
15+
{
16+
if (!IS_ENABLED(CONFIG_CURRENT_POINTER_IN_TPIDRURO))
17+
return;
18+
19+
/* Set TPIDRURO */
20+
asm("mcr p15, 0, %0, c13, c0, 3" :: "r"(cur) : "memory");
21+
}
22+
23+
#ifdef CONFIG_CURRENT_POINTER_IN_TPIDRURO
24+
25+
static inline struct task_struct *get_current(void)
26+
{
27+
struct task_struct *cur;
28+
29+
#if __has_builtin(__builtin_thread_pointer) && \
30+
!(defined(CONFIG_THUMB2_KERNEL) && \
31+
defined(CONFIG_CC_IS_CLANG) && CONFIG_CLANG_VERSION < 130001)
32+
/*
33+
* Use the __builtin helper when available - this results in better
34+
* code, especially when using GCC in combination with the per-task
35+
* stack protector, as the compiler will recognize that it needs to
36+
* load the TLS register only once in every function.
37+
*
38+
* Clang < 13.0.1 gets this wrong for Thumb2 builds:
39+
* https://github.com/ClangBuiltLinux/linux/issues/1485
40+
*/
41+
cur = __builtin_thread_pointer();
42+
#else
43+
asm("mrc p15, 0, %0, c13, c0, 3" : "=r"(cur));
44+
#endif
45+
return cur;
46+
}
47+
48+
#define current get_current()
49+
#else
50+
#include <asm-generic/current.h>
51+
#endif /* CONFIG_CURRENT_POINTER_IN_TPIDRURO */
52+
53+
#endif /* __ASSEMBLY__ */
54+
55+
#endif /* _ASM_ARM_CURRENT_H */

arch/arm/include/asm/io.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,7 @@ extern void __iomem *__arm_ioremap_caller(phys_addr_t, size_t, unsigned int,
138138
void *);
139139
extern void __iomem *__arm_ioremap_pfn(unsigned long, unsigned long, size_t, unsigned int);
140140
extern void __iomem *__arm_ioremap_exec(phys_addr_t, size_t, bool cached);
141+
void __arm_iomem_set_ro(void __iomem *ptr, size_t size);
141142
extern void __iounmap(volatile void __iomem *addr);
142143

143144
extern void __iomem * (*arch_ioremap_caller)(phys_addr_t, size_t,

arch/arm/include/asm/opcodes.h

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -110,12 +110,17 @@ extern asmlinkage unsigned int arm_check_condition(u32 opcode, u32 psr);
110110
#define __opcode_to_mem_thumb16(x) ___opcode_identity16(x)
111111
#define ___asm_opcode_to_mem_arm(x) ___asm_opcode_identity32(x)
112112
#define ___asm_opcode_to_mem_thumb16(x) ___asm_opcode_identity16(x)
113-
#ifndef CONFIG_CPU_ENDIAN_BE32
113+
#ifdef CONFIG_CPU_ENDIAN_BE32
114+
#ifndef __ASSEMBLY__
114115
/*
115116
* On BE32 systems, using 32-bit accesses to store Thumb instructions will not
116117
* work in all cases, due to alignment constraints. For now, a correct
117-
* version is not provided for BE32.
118+
* version is not provided for BE32, but the prototype needs to be there
119+
* to compile patch.c.
118120
*/
121+
extern __u32 __opcode_to_mem_thumb32(__u32);
122+
#endif
123+
#else
119124
#define __opcode_to_mem_thumb32(x) ___opcode_swahw32(x)
120125
#define ___asm_opcode_to_mem_thumb32(x) ___asm_opcode_swahw32(x)
121126
#endif

arch/arm/include/asm/setup.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
static const struct tagtable __tagtable_##fn __tag = { tag, fn }
2020

2121
extern int arm_add_memory(u64 start, u64 size);
22-
extern void early_print(const char *str, ...);
22+
extern __printf(1, 2) void early_print(const char *str, ...);
2323
extern void dump_machine_table(void);
2424

2525
#ifdef CONFIG_ATAGS_PROC

arch/arm/include/asm/smp.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ extern void set_smp_ipi_range(int ipi_base, int nr_ipi);
4848
* Called from platform specific assembly code, this is the
4949
* secondary CPU entry point.
5050
*/
51-
asmlinkage void secondary_start_kernel(void);
51+
asmlinkage void secondary_start_kernel(struct task_struct *task);
5252

5353

5454
/*
@@ -61,6 +61,7 @@ struct secondary_data {
6161
};
6262
unsigned long swapper_pg_dir;
6363
void *stack;
64+
struct task_struct *task;
6465
};
6566
extern struct secondary_data secondary_data;
6667
extern void secondary_startup(void);

0 commit comments

Comments
 (0)