Skip to content

Commit 77d34a4

Browse files
committed
Merge tag 'for-linus' of git://git.armlinux.org.uk/~rmk/linux-arm
Pull ARM development updates from Russell King: - Make it clear __swp_entry_to_pte() uses PTE_TYPE_FAULT - Updates for setting vmalloc size via command line to resolve an issue with the 8MiB hole not properly being accounted for, and clean up the code. - ftrace support for module PLTs - Spelling fixes - kbuild updates for removing generated files and pattern rules for generating files - Clang/llvm updates - Change the way the kernel is mapped, placing it in vmalloc space instead. - Remove arm_pm_restart from arm and aarch64. * tag 'for-linus' of git://git.armlinux.org.uk/~rmk/linux-arm: (29 commits) ARM: 9098/1: ftrace: MODULE_PLT: Fix build problem without DYNAMIC_FTRACE ARM: 9097/1: mmu: Declare section start/end correctly ARM: 9096/1: Remove arm_pm_restart() ARM: 9095/1: ARM64: Remove arm_pm_restart() ARM: 9094/1: Register with kernel restart handler ARM: 9093/1: drivers: firmwapsci: Register with kernel restart handler ARM: 9092/1: xen: Register with kernel restart handler ARM: 9091/1: Revert "mm: qsd8x50: Fix incorrect permission faults" ARM: 9090/1: Map the lowmem and kernel separately ARM: 9089/1: Define kernel physical section start and end ARM: 9088/1: Split KERNEL_OFFSET from PAGE_OFFSET ARM: 9087/1: kprobes: test-thumb: fix for LLVM_IAS=1 ARM: 9086/1: syscalls: use pattern rules to generate syscall headers ARM: 9085/1: remove unneeded abi parameter to syscallnr.sh ARM: 9084/1: simplify the build rule of mach-types.h ARM: 9083/1: uncompress: atags_to_fdt: Spelling s/REturn/Return/ ARM: 9082/1: [v2] mark prepare_page_table as __init ARM: 9079/1: ftrace: Add MODULE_PLTS support ARM: 9078/1: Add warn suppress parameter to arm_gen_branch_link() ARM: 9077/1: PLT: Move struct plt_entries definition to header ...
2 parents 4c55e2a + 6fa630b commit 77d34a4

File tree

26 files changed

+323
-159
lines changed

26 files changed

+323
-159
lines changed

arch/arm/Kconfig.debug

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,8 @@ config UNWINDER_FRAME_POINTER
6666
config UNWINDER_ARM
6767
bool "ARM EABI stack unwinder"
6868
depends on AEABI && !FUNCTION_GRAPH_TRACER
69+
# https://github.com/ClangBuiltLinux/linux/issues/732
70+
depends on !LD_IS_LLD || LLD_VERSION >= 110000
6971
select ARM_UNWIND
7072
help
7173
This option enables stack unwinding support in the kernel

arch/arm/boot/compressed/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ targets := vmlinux vmlinux.lds piggy_data piggy.o \
100100
lib1funcs.o ashldi3.o bswapsdi2.o \
101101
head.o $(OBJS)
102102

103-
clean-files += piggy_data lib1funcs.S ashldi3.S bswapsdi2.S hyp-stub.S
103+
clean-files += lib1funcs.S ashldi3.S bswapsdi2.S hyp-stub.S
104104

105105
KBUILD_CFLAGS += -DDISABLE_BRANCH_PROFILING
106106

arch/arm/boot/compressed/atags_to_fdt.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ static void hex_str(char *out, uint32_t value)
121121
/*
122122
* Convert and fold provided ATAGs into the provided FDT.
123123
*
124-
* REturn values:
124+
* Return values:
125125
* = 0 -> pretend success
126126
* = 1 -> bad ATAG (may retry with another possible ATAG pointer)
127127
* < 0 -> error from libfdt

arch/arm/include/asm/ftrace.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,9 @@ extern void __gnu_mcount_nc(void);
1515

1616
#ifdef CONFIG_DYNAMIC_FTRACE
1717
struct dyn_arch_ftrace {
18+
#ifdef CONFIG_ARM_MODULE_PLTS
19+
struct module *mod;
20+
#endif
1821
};
1922

2023
static inline unsigned long ftrace_call_adjust(unsigned long addr)

arch/arm/include/asm/insn.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,18 +13,18 @@ arm_gen_nop(void)
1313
}
1414

1515
unsigned long
16-
__arm_gen_branch(unsigned long pc, unsigned long addr, bool link);
16+
__arm_gen_branch(unsigned long pc, unsigned long addr, bool link, bool warn);
1717

1818
static inline unsigned long
1919
arm_gen_branch(unsigned long pc, unsigned long addr)
2020
{
21-
return __arm_gen_branch(pc, addr, false);
21+
return __arm_gen_branch(pc, addr, false, true);
2222
}
2323

2424
static inline unsigned long
25-
arm_gen_branch_link(unsigned long pc, unsigned long addr)
25+
arm_gen_branch_link(unsigned long pc, unsigned long addr, bool warn)
2626
{
27-
return __arm_gen_branch(pc, addr, true);
27+
return __arm_gen_branch(pc, addr, true, warn);
2828
}
2929

3030
#endif

arch/arm/include/asm/memory.h

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,14 @@
2020
#endif
2121
#include <asm/kasan_def.h>
2222

23-
/* PAGE_OFFSET - the virtual address of the start of the kernel image */
23+
/*
24+
* PAGE_OFFSET: the virtual address of the start of lowmem, memory above
25+
* the virtual address range for userspace.
26+
* KERNEL_OFFSET: the virtual address of the start of the kernel image.
27+
* we may further offset this with TEXT_OFFSET in practice.
28+
*/
2429
#define PAGE_OFFSET UL(CONFIG_PAGE_OFFSET)
30+
#define KERNEL_OFFSET (PAGE_OFFSET)
2531

2632
#ifdef CONFIG_MMU
2733

@@ -152,6 +158,13 @@ extern unsigned long vectors_base;
152158

153159
#ifndef __ASSEMBLY__
154160

161+
/*
162+
* Physical start and end address of the kernel sections. These addresses are
163+
* 2MB-aligned to match the section mappings placed over the kernel.
164+
*/
165+
extern u32 kernel_sec_start;
166+
extern u32 kernel_sec_end;
167+
155168
/*
156169
* Physical vs virtual RAM address space conversion. These are
157170
* private definitions which should NOT be used outside memory.h

arch/arm/include/asm/module.h

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,18 @@ enum {
1919
};
2020
#endif
2121

22+
#define PLT_ENT_STRIDE L1_CACHE_BYTES
23+
#define PLT_ENT_COUNT (PLT_ENT_STRIDE / sizeof(u32))
24+
#define PLT_ENT_SIZE (sizeof(struct plt_entries) / PLT_ENT_COUNT)
25+
26+
struct plt_entries {
27+
u32 ldr[PLT_ENT_COUNT];
28+
u32 lit[PLT_ENT_COUNT];
29+
};
30+
2231
struct mod_plt_sec {
2332
struct elf32_shdr *plt;
33+
struct plt_entries *plt_ent;
2434
int plt_count;
2535
};
2636

arch/arm/include/asm/pgtable.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -306,7 +306,7 @@ static inline pte_t pte_modify(pte_t pte, pgprot_t newprot)
306306
#define __swp_entry(type,offset) ((swp_entry_t) { ((type) << __SWP_TYPE_SHIFT) | ((offset) << __SWP_OFFSET_SHIFT) })
307307

308308
#define __pte_to_swp_entry(pte) ((swp_entry_t) { pte_val(pte) })
309-
#define __swp_entry_to_pte(swp) ((pte_t) { (swp).val })
309+
#define __swp_entry_to_pte(swp) __pte((swp).val | PTE_TYPE_FAULT)
310310

311311
/*
312312
* It is an error for the kernel to have more swap files than we can

arch/arm/include/asm/system_misc.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
extern void cpu_init(void);
1414

1515
void soft_restart(unsigned long);
16-
extern void (*arm_pm_restart)(enum reboot_mode reboot_mode, const char *cmd);
1716
extern void (*arm_pm_idle)(void);
1817

1918
#ifdef CONFIG_HARDEN_BRANCH_PREDICTOR

arch/arm/kernel/ftrace.c

Lines changed: 38 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -68,9 +68,10 @@ int ftrace_arch_code_modify_post_process(void)
6868
return 0;
6969
}
7070

71-
static unsigned long ftrace_call_replace(unsigned long pc, unsigned long addr)
71+
static unsigned long ftrace_call_replace(unsigned long pc, unsigned long addr,
72+
bool warn)
7273
{
73-
return arm_gen_branch_link(pc, addr);
74+
return arm_gen_branch_link(pc, addr, warn);
7475
}
7576

7677
static int ftrace_modify_code(unsigned long pc, unsigned long old,
@@ -104,14 +105,14 @@ int ftrace_update_ftrace_func(ftrace_func_t func)
104105
int ret;
105106

106107
pc = (unsigned long)&ftrace_call;
107-
new = ftrace_call_replace(pc, (unsigned long)func);
108+
new = ftrace_call_replace(pc, (unsigned long)func, true);
108109

109110
ret = ftrace_modify_code(pc, 0, new, false);
110111

111112
#ifdef CONFIG_DYNAMIC_FTRACE_WITH_REGS
112113
if (!ret) {
113114
pc = (unsigned long)&ftrace_regs_call;
114-
new = ftrace_call_replace(pc, (unsigned long)func);
115+
new = ftrace_call_replace(pc, (unsigned long)func, true);
115116

116117
ret = ftrace_modify_code(pc, 0, new, false);
117118
}
@@ -124,10 +125,22 @@ int ftrace_make_call(struct dyn_ftrace *rec, unsigned long addr)
124125
{
125126
unsigned long new, old;
126127
unsigned long ip = rec->ip;
128+
unsigned long aaddr = adjust_address(rec, addr);
129+
struct module *mod = NULL;
130+
131+
#ifdef CONFIG_ARM_MODULE_PLTS
132+
mod = rec->arch.mod;
133+
#endif
127134

128135
old = ftrace_nop_replace(rec);
129136

130-
new = ftrace_call_replace(ip, adjust_address(rec, addr));
137+
new = ftrace_call_replace(ip, aaddr, !mod);
138+
#ifdef CONFIG_ARM_MODULE_PLTS
139+
if (!new && mod) {
140+
aaddr = get_module_plt(mod, ip, aaddr);
141+
new = ftrace_call_replace(ip, aaddr, true);
142+
}
143+
#endif
131144

132145
return ftrace_modify_code(rec->ip, old, new, true);
133146
}
@@ -140,9 +153,9 @@ int ftrace_modify_call(struct dyn_ftrace *rec, unsigned long old_addr,
140153
unsigned long new, old;
141154
unsigned long ip = rec->ip;
142155

143-
old = ftrace_call_replace(ip, adjust_address(rec, old_addr));
156+
old = ftrace_call_replace(ip, adjust_address(rec, old_addr), true);
144157

145-
new = ftrace_call_replace(ip, adjust_address(rec, addr));
158+
new = ftrace_call_replace(ip, adjust_address(rec, addr), true);
146159

147160
return ftrace_modify_code(rec->ip, old, new, true);
148161
}
@@ -152,12 +165,29 @@ int ftrace_modify_call(struct dyn_ftrace *rec, unsigned long old_addr,
152165
int ftrace_make_nop(struct module *mod,
153166
struct dyn_ftrace *rec, unsigned long addr)
154167
{
168+
unsigned long aaddr = adjust_address(rec, addr);
155169
unsigned long ip = rec->ip;
156170
unsigned long old;
157171
unsigned long new;
158172
int ret;
159173

160-
old = ftrace_call_replace(ip, adjust_address(rec, addr));
174+
#ifdef CONFIG_ARM_MODULE_PLTS
175+
/* mod is only supplied during module loading */
176+
if (!mod)
177+
mod = rec->arch.mod;
178+
else
179+
rec->arch.mod = mod;
180+
#endif
181+
182+
old = ftrace_call_replace(ip, aaddr,
183+
!IS_ENABLED(CONFIG_ARM_MODULE_PLTS) || !mod);
184+
#ifdef CONFIG_ARM_MODULE_PLTS
185+
if (!old && mod) {
186+
aaddr = get_module_plt(mod, ip, aaddr);
187+
old = ftrace_call_replace(ip, aaddr, true);
188+
}
189+
#endif
190+
161191
new = ftrace_nop_replace(rec);
162192
ret = ftrace_modify_code(ip, old, new, true);
163193

arch/arm/kernel/head.S

Lines changed: 25 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,15 +23,14 @@
2323
#if defined(CONFIG_DEBUG_LL) && !defined(CONFIG_DEBUG_SEMIHOSTING)
2424
#include CONFIG_DEBUG_LL_INCLUDE
2525
#endif
26-
2726
/*
2827
* swapper_pg_dir is the virtual address of the initial page table.
2928
* We place the page tables 16K below KERNEL_RAM_VADDR. Therefore, we must
3029
* make sure that KERNEL_RAM_VADDR is correctly set. Currently, we expect
3130
* the least significant 16 bits to be 0x8000, but we could probably
3231
* relax this restriction to KERNEL_RAM_VADDR >= PAGE_OFFSET + 0x4000.
3332
*/
34-
#define KERNEL_RAM_VADDR (PAGE_OFFSET + TEXT_OFFSET)
33+
#define KERNEL_RAM_VADDR (KERNEL_OFFSET + TEXT_OFFSET)
3534
#if (KERNEL_RAM_VADDR & 0xffff) != 0x8000
3635
#error KERNEL_RAM_VADDR must start at 0xXXXX8000
3736
#endif
@@ -48,6 +47,20 @@
4847
.globl swapper_pg_dir
4948
.equ swapper_pg_dir, KERNEL_RAM_VADDR - PG_DIR_SIZE
5049

50+
/*
51+
* This needs to be assigned at runtime when the linker symbols are
52+
* resolved.
53+
*/
54+
.pushsection .data
55+
.align 2
56+
.globl kernel_sec_start
57+
.globl kernel_sec_end
58+
kernel_sec_start:
59+
.long 0
60+
kernel_sec_end:
61+
.long 0
62+
.popsection
63+
5164
.macro pgtbl, rd, phys
5265
add \rd, \phys, #TEXT_OFFSET
5366
sub \rd, \rd, #PG_DIR_SIZE
@@ -230,16 +243,23 @@ __create_page_tables:
230243
blo 1b
231244

232245
/*
233-
* Map our RAM from the start to the end of the kernel .bss section.
246+
* The main matter: map in the kernel using section mappings, and
247+
* set two variables to indicate the physical start and end of the
248+
* kernel.
234249
*/
235-
add r0, r4, #PAGE_OFFSET >> (SECTION_SHIFT - PMD_ORDER)
250+
add r0, r4, #KERNEL_OFFSET >> (SECTION_SHIFT - PMD_ORDER)
236251
ldr r6, =(_end - 1)
237-
orr r3, r8, r7
252+
adr_l r5, kernel_sec_start @ _pa(kernel_sec_start)
253+
str r8, [r5] @ Save physical start of kernel
254+
orr r3, r8, r7 @ Add the MMU flags
238255
add r6, r4, r6, lsr #(SECTION_SHIFT - PMD_ORDER)
239256
1: str r3, [r0], #1 << PMD_ORDER
240257
add r3, r3, #1 << SECTION_SHIFT
241258
cmp r0, r6
242259
bls 1b
260+
eor r3, r3, r7 @ Remove the MMU flags
261+
adr_l r5, kernel_sec_end @ _pa(kernel_sec_end)
262+
str r3, [r5] @ Save physical end of kernel
243263

244264
#ifdef CONFIG_XIP_KERNEL
245265
/*

arch/arm/kernel/insn.c

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,17 @@
33
#include <linux/kernel.h>
44
#include <asm/opcodes.h>
55

6-
static unsigned long
7-
__arm_gen_branch_thumb2(unsigned long pc, unsigned long addr, bool link)
6+
static unsigned long __arm_gen_branch_thumb2(unsigned long pc,
7+
unsigned long addr, bool link,
8+
bool warn)
89
{
910
unsigned long s, j1, j2, i1, i2, imm10, imm11;
1011
unsigned long first, second;
1112
long offset;
1213

1314
offset = (long)addr - (long)(pc + 4);
1415
if (offset < -16777216 || offset > 16777214) {
15-
WARN_ON_ONCE(1);
16+
WARN_ON_ONCE(warn);
1617
return 0;
1718
}
1819

@@ -33,8 +34,8 @@ __arm_gen_branch_thumb2(unsigned long pc, unsigned long addr, bool link)
3334
return __opcode_thumb32_compose(first, second);
3435
}
3536

36-
static unsigned long
37-
__arm_gen_branch_arm(unsigned long pc, unsigned long addr, bool link)
37+
static unsigned long __arm_gen_branch_arm(unsigned long pc, unsigned long addr,
38+
bool link, bool warn)
3839
{
3940
unsigned long opcode = 0xea000000;
4041
long offset;
@@ -44,7 +45,7 @@ __arm_gen_branch_arm(unsigned long pc, unsigned long addr, bool link)
4445

4546
offset = (long)addr - (long)(pc + 8);
4647
if (unlikely(offset < -33554432 || offset > 33554428)) {
47-
WARN_ON_ONCE(1);
48+
WARN_ON_ONCE(warn);
4849
return 0;
4950
}
5051

@@ -54,10 +55,10 @@ __arm_gen_branch_arm(unsigned long pc, unsigned long addr, bool link)
5455
}
5556

5657
unsigned long
57-
__arm_gen_branch(unsigned long pc, unsigned long addr, bool link)
58+
__arm_gen_branch(unsigned long pc, unsigned long addr, bool link, bool warn)
5859
{
5960
if (IS_ENABLED(CONFIG_THUMB2_KERNEL))
60-
return __arm_gen_branch_thumb2(pc, addr, link);
61+
return __arm_gen_branch_thumb2(pc, addr, link, warn);
6162
else
62-
return __arm_gen_branch_arm(pc, addr, link);
63+
return __arm_gen_branch_arm(pc, addr, link, warn);
6364
}

0 commit comments

Comments
 (0)