Skip to content

Commit 8e22ba9

Browse files
committed
Merge tag 'riscv-for-linus-5.1-rc4' of git://git.kernel.org/pub/scm/linux/kernel/git/palmer/riscv-linux
Pull RISC-V fixes from Palmer Dabbelt: "I dropped the ball a bit here: these patches should all probably have been part of rc2, but I wanted to get around to properly testing them in the various configurations (qemu32, qeum64, unleashed) first. Unfortunately I've been traveling and didn't have time to actually do that, but since these fix concrete bugs and pass my old set of tests I don't want to delay the fixes any longer. There are four independent fixes here: - A fix for the rv32 port that corrects the 64-bit user accesor's fixup label address. - A fix for a regression introduced during the merge window that broke medlow configurations at run time. This patch also includes a fix that disables ftrace for the same set of functions, which was found by inspection at the same time. - A modification of the memory map to avoid overlapping the FIXMAP and VMALLOC regions on systems with small memory maps. - A fix to the module handling code to use the correct syntax for probing Kconfig entries. These have passed my standard test flow, but I didn't have time to expand that testing like I said I would" * tag 'riscv-for-linus-5.1-rc4' of git://git.kernel.org/pub/scm/linux/kernel/git/palmer/riscv-linux: RISC-V: Use IS_ENABLED(CONFIG_CMODEL_MEDLOW) RISC-V: Fix FIXMAP_TOP to avoid overlap with VMALLOC area RISC-V: Always compile mm/init.c with cmodel=medany and notrace riscv: fix accessing 8-byte variable from RV32
2 parents 20ad549 + da4ed37 commit 8e22ba9

File tree

7 files changed

+37
-14
lines changed

7 files changed

+37
-14
lines changed

arch/riscv/include/asm/fixmap.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ enum fixed_addresses {
2626
};
2727

2828
#define FIXADDR_SIZE (__end_of_fixed_addresses * PAGE_SIZE)
29-
#define FIXADDR_TOP (PAGE_OFFSET)
29+
#define FIXADDR_TOP (VMALLOC_START)
3030
#define FIXADDR_START (FIXADDR_TOP - FIXADDR_SIZE)
3131

3232
#define FIXMAP_PAGE_IO PAGE_KERNEL

arch/riscv/include/asm/uaccess.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -300,7 +300,7 @@ do { \
300300
" .balign 4\n" \
301301
"4:\n" \
302302
" li %0, %6\n" \
303-
" jump 2b, %1\n" \
303+
" jump 3b, %1\n" \
304304
" .previous\n" \
305305
" .section __ex_table,\"a\"\n" \
306306
" .balign " RISCV_SZPTR "\n" \

arch/riscv/kernel/Makefile

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44

55
ifdef CONFIG_FTRACE
66
CFLAGS_REMOVE_ftrace.o = -pg
7-
CFLAGS_REMOVE_setup.o = -pg
87
endif
98

109
extra-y += head.o
@@ -29,8 +28,6 @@ obj-y += vdso.o
2928
obj-y += cacheinfo.o
3029
obj-y += vdso/
3130

32-
CFLAGS_setup.o := -mcmodel=medany
33-
3431
obj-$(CONFIG_FPU) += fpu.o
3532
obj-$(CONFIG_SMP) += smpboot.o
3633
obj-$(CONFIG_SMP) += smp.o

arch/riscv/kernel/module.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ static int apply_r_riscv_hi20_rela(struct module *me, u32 *location,
141141
{
142142
s32 hi20;
143143

144-
if (IS_ENABLED(CMODEL_MEDLOW)) {
144+
if (IS_ENABLED(CONFIG_CMODEL_MEDLOW)) {
145145
pr_err(
146146
"%s: target %016llx can not be addressed by the 32-bit offset from PC = %p\n",
147147
me->name, (long long)v, location);

arch/riscv/kernel/setup.c

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -48,14 +48,6 @@ struct screen_info screen_info = {
4848
};
4949
#endif
5050

51-
unsigned long va_pa_offset;
52-
EXPORT_SYMBOL(va_pa_offset);
53-
unsigned long pfn_base;
54-
EXPORT_SYMBOL(pfn_base);
55-
56-
unsigned long empty_zero_page[PAGE_SIZE / sizeof(unsigned long)] __page_aligned_bss;
57-
EXPORT_SYMBOL(empty_zero_page);
58-
5951
/* The lucky hart to first increment this variable will boot the other cores */
6052
atomic_t hart_lottery;
6153
unsigned long boot_cpu_hartid;

arch/riscv/mm/Makefile

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
2+
CFLAGS_init.o := -mcmodel=medany
3+
ifdef CONFIG_FTRACE
4+
CFLAGS_REMOVE_init.o = -pg
5+
endif
6+
17
obj-y += init.o
28
obj-y += fault.o
39
obj-y += extable.o

arch/riscv/mm/init.c

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,10 @@
2525
#include <asm/pgtable.h>
2626
#include <asm/io.h>
2727

28+
unsigned long empty_zero_page[PAGE_SIZE / sizeof(unsigned long)]
29+
__page_aligned_bss;
30+
EXPORT_SYMBOL(empty_zero_page);
31+
2832
static void __init zone_sizes_init(void)
2933
{
3034
unsigned long max_zone_pfns[MAX_NR_ZONES] = { 0, };
@@ -143,6 +147,11 @@ void __init setup_bootmem(void)
143147
}
144148
}
145149

150+
unsigned long va_pa_offset;
151+
EXPORT_SYMBOL(va_pa_offset);
152+
unsigned long pfn_base;
153+
EXPORT_SYMBOL(pfn_base);
154+
146155
pgd_t swapper_pg_dir[PTRS_PER_PGD] __page_aligned_bss;
147156
pgd_t trampoline_pg_dir[PTRS_PER_PGD] __initdata __aligned(PAGE_SIZE);
148157

@@ -172,6 +181,25 @@ void __set_fixmap(enum fixed_addresses idx, phys_addr_t phys, pgprot_t prot)
172181
}
173182
}
174183

184+
/*
185+
* setup_vm() is called from head.S with MMU-off.
186+
*
187+
* Following requirements should be honoured for setup_vm() to work
188+
* correctly:
189+
* 1) It should use PC-relative addressing for accessing kernel symbols.
190+
* To achieve this we always use GCC cmodel=medany.
191+
* 2) The compiler instrumentation for FTRACE will not work for setup_vm()
192+
* so disable compiler instrumentation when FTRACE is enabled.
193+
*
194+
* Currently, the above requirements are honoured by using custom CFLAGS
195+
* for init.o in mm/Makefile.
196+
*/
197+
198+
#ifndef __riscv_cmodel_medany
199+
#error "setup_vm() is called from head.S before relocate so it should "
200+
"not use absolute addressing."
201+
#endif
202+
175203
asmlinkage void __init setup_vm(void)
176204
{
177205
extern char _start;

0 commit comments

Comments
 (0)