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

0 commit comments

Comments
 (0)