aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2018-07-05 12:47:18 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2018-07-05 12:47:18 -0400
commitb19b9282093588e73401f9d4981310a8de975f7d (patch)
treedb4f060586a49cf578c7b437bbfa1a913641b646
parent760885f282b1531f89c4ed8aa198ae0ca1acc172 (diff)
parent9a6a51154f8be90a76f6a8ea8809115c11cec9dd (diff)
Merge tag 'riscv-for-linus-4.18-rc4' of git://git.kernel.org/pub/scm/linux/kernel/git/palmer/riscv-linux
Pull RISC-V fixes from Palmer Dabbelt: "This contains a handful of fixes for the RISC-V port: - A fix to R_RISCV_ADD32/R_RISCV_SUB32 relocations that allows modules that use these to load correctly. - The removal of of_platform_populate(), which is obselete. - The removal of irq-riscv-intc.h, which is obselete. - A fix to PTRACE_SETREGSET. - Fixes that allow the RV32I kernel to build (at least for Zong, I've got another patch on the mailing list that's necessary on my setup :)). I've just given these a defconfig build test" * tag 'riscv-for-linus-4.18-rc4' of git://git.kernel.org/pub/scm/linux/kernel/git/palmer/riscv-linux: RISC-V: Fix PTRACE_SETREGSET bug. RISC-V: Don't include irq-riscv-intc.h riscv: remove unnecessary of_platform_populate call RISC-V: fix R_RISCV_ADD32/R_RISCV_SUB32 relocations RISC-V: Change variable type for 32-bit compatible RISC-V: Add definiion of extract symbol's index and type for 32-bit RISC-V: Select GENERIC_UCMPDI2 on RV32I RISC-V: Add conditional macro for zone of DMA32
-rw-r--r--arch/riscv/Kconfig1
-rw-r--r--arch/riscv/include/uapi/asm/elf.h9
-rw-r--r--arch/riscv/kernel/irq.c4
-rw-r--r--arch/riscv/kernel/module.c26
-rw-r--r--arch/riscv/kernel/ptrace.c2
-rw-r--r--arch/riscv/kernel/setup.c5
-rw-r--r--arch/riscv/mm/init.c2
7 files changed, 24 insertions, 25 deletions
diff --git a/arch/riscv/Kconfig b/arch/riscv/Kconfig
index f12680c9b947..4764fdeb4f1f 100644
--- a/arch/riscv/Kconfig
+++ b/arch/riscv/Kconfig
@@ -107,6 +107,7 @@ config ARCH_RV32I
107 select GENERIC_LIB_ASHLDI3 107 select GENERIC_LIB_ASHLDI3
108 select GENERIC_LIB_ASHRDI3 108 select GENERIC_LIB_ASHRDI3
109 select GENERIC_LIB_LSHRDI3 109 select GENERIC_LIB_LSHRDI3
110 select GENERIC_LIB_UCMPDI2
110 111
111config ARCH_RV64I 112config ARCH_RV64I
112 bool "RV64I" 113 bool "RV64I"
diff --git a/arch/riscv/include/uapi/asm/elf.h b/arch/riscv/include/uapi/asm/elf.h
index 5cae4c30cd8e..1e0dfc36aab9 100644
--- a/arch/riscv/include/uapi/asm/elf.h
+++ b/arch/riscv/include/uapi/asm/elf.h
@@ -21,8 +21,13 @@ typedef struct user_regs_struct elf_gregset_t;
21 21
22typedef union __riscv_fp_state elf_fpregset_t; 22typedef union __riscv_fp_state elf_fpregset_t;
23 23
24#define ELF_RISCV_R_SYM(r_info) ((r_info) >> 32) 24#if __riscv_xlen == 64
25#define ELF_RISCV_R_TYPE(r_info) ((r_info) & 0xffffffff) 25#define ELF_RISCV_R_SYM(r_info) ELF64_R_SYM(r_info)
26#define ELF_RISCV_R_TYPE(r_info) ELF64_R_TYPE(r_info)
27#else
28#define ELF_RISCV_R_SYM(r_info) ELF32_R_SYM(r_info)
29#define ELF_RISCV_R_TYPE(r_info) ELF32_R_TYPE(r_info)
30#endif
26 31
27/* 32/*
28 * RISC-V relocation types 33 * RISC-V relocation types
diff --git a/arch/riscv/kernel/irq.c b/arch/riscv/kernel/irq.c
index b74cbfbce2d0..7bcdaed15703 100644
--- a/arch/riscv/kernel/irq.c
+++ b/arch/riscv/kernel/irq.c
@@ -16,10 +16,6 @@
16#include <linux/irqchip.h> 16#include <linux/irqchip.h>
17#include <linux/irqdomain.h> 17#include <linux/irqdomain.h>
18 18
19#ifdef CONFIG_RISCV_INTC
20#include <linux/irqchip/irq-riscv-intc.h>
21#endif
22
23void __init init_IRQ(void) 19void __init init_IRQ(void)
24{ 20{
25 irqchip_init(); 21 irqchip_init();
diff --git a/arch/riscv/kernel/module.c b/arch/riscv/kernel/module.c
index 1d5e9b934b8c..3303ed2cd419 100644
--- a/arch/riscv/kernel/module.c
+++ b/arch/riscv/kernel/module.c
@@ -37,7 +37,7 @@ static int apply_r_riscv_64_rela(struct module *me, u32 *location, Elf_Addr v)
37static int apply_r_riscv_branch_rela(struct module *me, u32 *location, 37static int apply_r_riscv_branch_rela(struct module *me, u32 *location,
38 Elf_Addr v) 38 Elf_Addr v)
39{ 39{
40 s64 offset = (void *)v - (void *)location; 40 ptrdiff_t offset = (void *)v - (void *)location;
41 u32 imm12 = (offset & 0x1000) << (31 - 12); 41 u32 imm12 = (offset & 0x1000) << (31 - 12);
42 u32 imm11 = (offset & 0x800) >> (11 - 7); 42 u32 imm11 = (offset & 0x800) >> (11 - 7);
43 u32 imm10_5 = (offset & 0x7e0) << (30 - 10); 43 u32 imm10_5 = (offset & 0x7e0) << (30 - 10);
@@ -50,7 +50,7 @@ static int apply_r_riscv_branch_rela(struct module *me, u32 *location,
50static int apply_r_riscv_jal_rela(struct module *me, u32 *location, 50static int apply_r_riscv_jal_rela(struct module *me, u32 *location,
51 Elf_Addr v) 51 Elf_Addr v)
52{ 52{
53 s64 offset = (void *)v - (void *)location; 53 ptrdiff_t offset = (void *)v - (void *)location;
54 u32 imm20 = (offset & 0x100000) << (31 - 20); 54 u32 imm20 = (offset & 0x100000) << (31 - 20);
55 u32 imm19_12 = (offset & 0xff000); 55 u32 imm19_12 = (offset & 0xff000);
56 u32 imm11 = (offset & 0x800) << (20 - 11); 56 u32 imm11 = (offset & 0x800) << (20 - 11);
@@ -63,7 +63,7 @@ static int apply_r_riscv_jal_rela(struct module *me, u32 *location,
63static int apply_r_riscv_rcv_branch_rela(struct module *me, u32 *location, 63static int apply_r_riscv_rcv_branch_rela(struct module *me, u32 *location,
64 Elf_Addr v) 64 Elf_Addr v)
65{ 65{
66 s64 offset = (void *)v - (void *)location; 66 ptrdiff_t offset = (void *)v - (void *)location;
67 u16 imm8 = (offset & 0x100) << (12 - 8); 67 u16 imm8 = (offset & 0x100) << (12 - 8);
68 u16 imm7_6 = (offset & 0xc0) >> (6 - 5); 68 u16 imm7_6 = (offset & 0xc0) >> (6 - 5);
69 u16 imm5 = (offset & 0x20) >> (5 - 2); 69 u16 imm5 = (offset & 0x20) >> (5 - 2);
@@ -78,7 +78,7 @@ static int apply_r_riscv_rcv_branch_rela(struct module *me, u32 *location,
78static int apply_r_riscv_rvc_jump_rela(struct module *me, u32 *location, 78static int apply_r_riscv_rvc_jump_rela(struct module *me, u32 *location,
79 Elf_Addr v) 79 Elf_Addr v)
80{ 80{
81 s64 offset = (void *)v - (void *)location; 81 ptrdiff_t offset = (void *)v - (void *)location;
82 u16 imm11 = (offset & 0x800) << (12 - 11); 82 u16 imm11 = (offset & 0x800) << (12 - 11);
83 u16 imm10 = (offset & 0x400) >> (10 - 8); 83 u16 imm10 = (offset & 0x400) >> (10 - 8);
84 u16 imm9_8 = (offset & 0x300) << (12 - 11); 84 u16 imm9_8 = (offset & 0x300) << (12 - 11);
@@ -96,7 +96,7 @@ static int apply_r_riscv_rvc_jump_rela(struct module *me, u32 *location,
96static int apply_r_riscv_pcrel_hi20_rela(struct module *me, u32 *location, 96static int apply_r_riscv_pcrel_hi20_rela(struct module *me, u32 *location,
97 Elf_Addr v) 97 Elf_Addr v)
98{ 98{
99 s64 offset = (void *)v - (void *)location; 99 ptrdiff_t offset = (void *)v - (void *)location;
100 s32 hi20; 100 s32 hi20;
101 101
102 if (offset != (s32)offset) { 102 if (offset != (s32)offset) {
@@ -178,7 +178,7 @@ static int apply_r_riscv_lo12_s_rela(struct module *me, u32 *location,
178static int apply_r_riscv_got_hi20_rela(struct module *me, u32 *location, 178static int apply_r_riscv_got_hi20_rela(struct module *me, u32 *location,
179 Elf_Addr v) 179 Elf_Addr v)
180{ 180{
181 s64 offset = (void *)v - (void *)location; 181 ptrdiff_t offset = (void *)v - (void *)location;
182 s32 hi20; 182 s32 hi20;
183 183
184 /* Always emit the got entry */ 184 /* Always emit the got entry */
@@ -200,7 +200,7 @@ static int apply_r_riscv_got_hi20_rela(struct module *me, u32 *location,
200static int apply_r_riscv_call_plt_rela(struct module *me, u32 *location, 200static int apply_r_riscv_call_plt_rela(struct module *me, u32 *location,
201 Elf_Addr v) 201 Elf_Addr v)
202{ 202{
203 s64 offset = (void *)v - (void *)location; 203 ptrdiff_t offset = (void *)v - (void *)location;
204 s32 fill_v = offset; 204 s32 fill_v = offset;
205 u32 hi20, lo12; 205 u32 hi20, lo12;
206 206
@@ -227,7 +227,7 @@ static int apply_r_riscv_call_plt_rela(struct module *me, u32 *location,
227static int apply_r_riscv_call_rela(struct module *me, u32 *location, 227static int apply_r_riscv_call_rela(struct module *me, u32 *location,
228 Elf_Addr v) 228 Elf_Addr v)
229{ 229{
230 s64 offset = (void *)v - (void *)location; 230 ptrdiff_t offset = (void *)v - (void *)location;
231 s32 fill_v = offset; 231 s32 fill_v = offset;
232 u32 hi20, lo12; 232 u32 hi20, lo12;
233 233
@@ -263,14 +263,14 @@ static int apply_r_riscv_align_rela(struct module *me, u32 *location,
263static int apply_r_riscv_add32_rela(struct module *me, u32 *location, 263static int apply_r_riscv_add32_rela(struct module *me, u32 *location,
264 Elf_Addr v) 264 Elf_Addr v)
265{ 265{
266 *(u32 *)location += (*(u32 *)v); 266 *(u32 *)location += (u32)v;
267 return 0; 267 return 0;
268} 268}
269 269
270static int apply_r_riscv_sub32_rela(struct module *me, u32 *location, 270static int apply_r_riscv_sub32_rela(struct module *me, u32 *location,
271 Elf_Addr v) 271 Elf_Addr v)
272{ 272{
273 *(u32 *)location -= (*(u32 *)v); 273 *(u32 *)location -= (u32)v;
274 return 0; 274 return 0;
275} 275}
276 276
@@ -347,7 +347,7 @@ int apply_relocate_add(Elf_Shdr *sechdrs, const char *strtab,
347 unsigned int j; 347 unsigned int j;
348 348
349 for (j = 0; j < sechdrs[relsec].sh_size / sizeof(*rel); j++) { 349 for (j = 0; j < sechdrs[relsec].sh_size / sizeof(*rel); j++) {
350 u64 hi20_loc = 350 unsigned long hi20_loc =
351 sechdrs[sechdrs[relsec].sh_info].sh_addr 351 sechdrs[sechdrs[relsec].sh_info].sh_addr
352 + rel[j].r_offset; 352 + rel[j].r_offset;
353 u32 hi20_type = ELF_RISCV_R_TYPE(rel[j].r_info); 353 u32 hi20_type = ELF_RISCV_R_TYPE(rel[j].r_info);
@@ -360,12 +360,12 @@ int apply_relocate_add(Elf_Shdr *sechdrs, const char *strtab,
360 Elf_Sym *hi20_sym = 360 Elf_Sym *hi20_sym =
361 (Elf_Sym *)sechdrs[symindex].sh_addr 361 (Elf_Sym *)sechdrs[symindex].sh_addr
362 + ELF_RISCV_R_SYM(rel[j].r_info); 362 + ELF_RISCV_R_SYM(rel[j].r_info);
363 u64 hi20_sym_val = 363 unsigned long hi20_sym_val =
364 hi20_sym->st_value 364 hi20_sym->st_value
365 + rel[j].r_addend; 365 + rel[j].r_addend;
366 366
367 /* Calculate lo12 */ 367 /* Calculate lo12 */
368 u64 offset = hi20_sym_val - hi20_loc; 368 size_t offset = hi20_sym_val - hi20_loc;
369 if (IS_ENABLED(CONFIG_MODULE_SECTIONS) 369 if (IS_ENABLED(CONFIG_MODULE_SECTIONS)
370 && hi20_type == R_RISCV_GOT_HI20) { 370 && hi20_type == R_RISCV_GOT_HI20) {
371 offset = module_emit_got_entry( 371 offset = module_emit_got_entry(
diff --git a/arch/riscv/kernel/ptrace.c b/arch/riscv/kernel/ptrace.c
index ba3e80712797..9f82a7e34c64 100644
--- a/arch/riscv/kernel/ptrace.c
+++ b/arch/riscv/kernel/ptrace.c
@@ -50,7 +50,7 @@ static int riscv_gpr_set(struct task_struct *target,
50 struct pt_regs *regs; 50 struct pt_regs *regs;
51 51
52 regs = task_pt_regs(target); 52 regs = task_pt_regs(target);
53 ret = user_regset_copyin(&pos, &count, &kbuf, &ubuf, &regs, 0, -1); 53 ret = user_regset_copyin(&pos, &count, &kbuf, &ubuf, regs, 0, -1);
54 return ret; 54 return ret;
55} 55}
56 56
diff --git a/arch/riscv/kernel/setup.c b/arch/riscv/kernel/setup.c
index ee44a48faf79..f0d2070866d4 100644
--- a/arch/riscv/kernel/setup.c
+++ b/arch/riscv/kernel/setup.c
@@ -220,8 +220,3 @@ void __init setup_arch(char **cmdline_p)
220 riscv_fill_hwcap(); 220 riscv_fill_hwcap();
221} 221}
222 222
223static int __init riscv_device_init(void)
224{
225 return of_platform_populate(NULL, of_default_bus_match_table, NULL, NULL);
226}
227subsys_initcall_sync(riscv_device_init);
diff --git a/arch/riscv/mm/init.c b/arch/riscv/mm/init.c
index c77df8142be2..58a522f9bcc3 100644
--- a/arch/riscv/mm/init.c
+++ b/arch/riscv/mm/init.c
@@ -28,7 +28,9 @@ static void __init zone_sizes_init(void)
28{ 28{
29 unsigned long max_zone_pfns[MAX_NR_ZONES] = { 0, }; 29 unsigned long max_zone_pfns[MAX_NR_ZONES] = { 0, };
30 30
31#ifdef CONFIG_ZONE_DMA32
31 max_zone_pfns[ZONE_DMA32] = PFN_DOWN(min(4UL * SZ_1G, max_low_pfn)); 32 max_zone_pfns[ZONE_DMA32] = PFN_DOWN(min(4UL * SZ_1G, max_low_pfn));
33#endif
32 max_zone_pfns[ZONE_NORMAL] = max_low_pfn; 34 max_zone_pfns[ZONE_NORMAL] = max_low_pfn;
33 35
34 free_area_init_nodes(max_zone_pfns); 36 free_area_init_nodes(max_zone_pfns);