Skip to content

Commit 7e6582e

Browse files
committed
Merge tag 'riscv-for-linus-5.6-rc5' of git://git.kernel.org/pub/scm/linux/kernel/git/riscv/linux
Pull RISC-V fixes from Palmer Dabbelt: "This contains a handful of fixes that I would like to target for 5.6: - A pair of fixes to module loading, which we hope solve the last of the issues with module text being loaded too sparsely for our call relocations. - A Kconfig fix that disallows selecting memory models not supported by NOMMU. - A series of Kconfig updates to ease selecting the drivers necessary to run on QEMU's virt platform. - DTS updates for SiFive's HiFive Unleashed. - A fix to our seccomp support that avoids mangling restartable syscalls" * tag 'riscv-for-linus-5.6-rc5' of git://git.kernel.org/pub/scm/linux/kernel/git/riscv/linux: riscv: fix seccomp reject syscall code path riscv: dts: Add GPIO reboot method to HiFive Unleashed DTS file RISC-V: Select Goldfish RTC driver for QEMU virt machine RISC-V: Select SYSCON Reboot and Poweroff for QEMU virt machine RISC-V: Enable QEMU virt machine support in defconfigs RISC-V: Add kconfig option for QEMU virt machine riscv: Fix range looking for kernel image memblock riscv: Force flat memory model with no-mmu riscv: Change code model of module to medany to improve data accessing riscv: avoid the PIC offset of static percpu data in module beyond 2G limits
2 parents 611d61f + af33d24 commit 7e6582e

File tree

11 files changed

+65
-53
lines changed

11 files changed

+65
-53
lines changed

arch/riscv/Kconfig

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,7 @@ config ARCH_FLATMEM_ENABLE
121121

122122
config ARCH_SPARSEMEM_ENABLE
123123
def_bool y
124+
depends on MMU
124125
select SPARSEMEM_VMEMMAP_ENABLE
125126

126127
config ARCH_SELECT_MEMORY_MODEL

arch/riscv/Kconfig.socs

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,28 @@ config SOC_SIFIVE
1010
help
1111
This enables support for SiFive SoC platform hardware.
1212

13+
config SOC_VIRT
14+
bool "QEMU Virt Machine"
15+
select VIRTIO_PCI
16+
select VIRTIO_BALLOON
17+
select VIRTIO_MMIO
18+
select VIRTIO_CONSOLE
19+
select VIRTIO_NET
20+
select NET_9P_VIRTIO
21+
select VIRTIO_BLK
22+
select SCSI_VIRTIO
23+
select DRM_VIRTIO_GPU
24+
select HW_RANDOM_VIRTIO
25+
select RPMSG_CHAR
26+
select RPMSG_VIRTIO
27+
select CRYPTO_DEV_VIRTIO
28+
select VIRTIO_INPUT
29+
select POWER_RESET_SYSCON
30+
select POWER_RESET_SYSCON_POWEROFF
31+
select GOLDFISH
32+
select RTC_DRV_GOLDFISH
33+
select SIFIVE_PLIC
34+
help
35+
This enables support for QEMU Virt Machine.
36+
1337
endmenu

arch/riscv/Makefile

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,10 @@ LDFLAGS_vmlinux :=
1313
ifeq ($(CONFIG_DYNAMIC_FTRACE),y)
1414
LDFLAGS_vmlinux := --no-relax
1515
endif
16-
KBUILD_AFLAGS_MODULE += -fPIC
17-
KBUILD_CFLAGS_MODULE += -fPIC
16+
17+
ifeq ($(CONFIG_64BIT)$(CONFIG_CMODEL_MEDLOW),yy)
18+
KBUILD_CFLAGS_MODULE += -mcmodel=medany
19+
endif
1820

1921
export BITS
2022
ifeq ($(CONFIG_ARCH_RV64I),y)

arch/riscv/boot/dts/sifive/hifive-unleashed-a00.dts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
/* Copyright (c) 2018-2019 SiFive, Inc */
33

44
#include "fu540-c000.dtsi"
5+
#include <dt-bindings/gpio/gpio.h>
56

67
/* Clock frequency (in Hz) of the PCB crystal for rtcclk */
78
#define RTCCLK_FREQ 1000000
@@ -41,6 +42,10 @@
4142
clock-frequency = <RTCCLK_FREQ>;
4243
clock-output-names = "rtcclk";
4344
};
45+
gpio-restart {
46+
compatible = "gpio-restart";
47+
gpios = <&gpio 10 GPIO_ACTIVE_LOW>;
48+
};
4449
};
4550

4651
&uart0 {

arch/riscv/configs/defconfig

Lines changed: 3 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ CONFIG_BLK_DEV_INITRD=y
1515
CONFIG_EXPERT=y
1616
CONFIG_BPF_SYSCALL=y
1717
CONFIG_SOC_SIFIVE=y
18+
CONFIG_SOC_VIRT=y
1819
CONFIG_SMP=y
1920
CONFIG_MODULES=y
2021
CONFIG_MODULE_UNLOAD=y
@@ -30,23 +31,19 @@ CONFIG_IP_PNP_BOOTP=y
3031
CONFIG_IP_PNP_RARP=y
3132
CONFIG_NETLINK_DIAG=y
3233
CONFIG_NET_9P=y
33-
CONFIG_NET_9P_VIRTIO=y
3434
CONFIG_PCI=y
3535
CONFIG_PCIEPORTBUS=y
3636
CONFIG_PCI_HOST_GENERIC=y
3737
CONFIG_PCIE_XILINX=y
3838
CONFIG_DEVTMPFS=y
3939
CONFIG_DEVTMPFS_MOUNT=y
4040
CONFIG_BLK_DEV_LOOP=y
41-
CONFIG_VIRTIO_BLK=y
4241
CONFIG_BLK_DEV_SD=y
4342
CONFIG_BLK_DEV_SR=y
44-
CONFIG_SCSI_VIRTIO=y
4543
CONFIG_ATA=y
4644
CONFIG_SATA_AHCI=y
4745
CONFIG_SATA_AHCI_PLATFORM=y
4846
CONFIG_NETDEVICES=y
49-
CONFIG_VIRTIO_NET=y
5047
CONFIG_MACB=y
5148
CONFIG_E1000E=y
5249
CONFIG_R8169=y
@@ -57,15 +54,13 @@ CONFIG_SERIAL_8250_CONSOLE=y
5754
CONFIG_SERIAL_OF_PLATFORM=y
5855
CONFIG_SERIAL_EARLYCON_RISCV_SBI=y
5956
CONFIG_HVC_RISCV_SBI=y
60-
CONFIG_VIRTIO_CONSOLE=y
6157
CONFIG_HW_RANDOM=y
62-
CONFIG_HW_RANDOM_VIRTIO=y
6358
CONFIG_SPI=y
6459
CONFIG_SPI_SIFIVE=y
6560
# CONFIG_PTP_1588_CLOCK is not set
61+
CONFIG_POWER_RESET=y
6662
CONFIG_DRM=y
6763
CONFIG_DRM_RADEON=y
68-
CONFIG_DRM_VIRTIO_GPU=y
6964
CONFIG_FRAMEBUFFER_CONSOLE=y
7065
CONFIG_USB=y
7166
CONFIG_USB_XHCI_HCD=y
@@ -78,12 +73,7 @@ CONFIG_USB_STORAGE=y
7873
CONFIG_USB_UAS=y
7974
CONFIG_MMC=y
8075
CONFIG_MMC_SPI=y
81-
CONFIG_VIRTIO_PCI=y
82-
CONFIG_VIRTIO_BALLOON=y
83-
CONFIG_VIRTIO_INPUT=y
84-
CONFIG_VIRTIO_MMIO=y
85-
CONFIG_RPMSG_CHAR=y
86-
CONFIG_RPMSG_VIRTIO=y
76+
CONFIG_RTC_CLASS=y
8777
CONFIG_EXT4_FS=y
8878
CONFIG_EXT4_FS_POSIX_ACL=y
8979
CONFIG_AUTOFS4_FS=y
@@ -98,7 +88,6 @@ CONFIG_NFS_V4_2=y
9888
CONFIG_ROOT_NFS=y
9989
CONFIG_9P_FS=y
10090
CONFIG_CRYPTO_USER_API_HASH=y
101-
CONFIG_CRYPTO_DEV_VIRTIO=y
10291
CONFIG_PRINTK_TIME=y
10392
CONFIG_DEBUG_FS=y
10493
CONFIG_DEBUG_PAGEALLOC=y

arch/riscv/configs/rv32_defconfig

Lines changed: 3 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ CONFIG_CHECKPOINT_RESTORE=y
1414
CONFIG_BLK_DEV_INITRD=y
1515
CONFIG_EXPERT=y
1616
CONFIG_BPF_SYSCALL=y
17+
CONFIG_SOC_VIRT=y
1718
CONFIG_ARCH_RV32I=y
1819
CONFIG_SMP=y
1920
CONFIG_MODULES=y
@@ -30,23 +31,19 @@ CONFIG_IP_PNP_BOOTP=y
3031
CONFIG_IP_PNP_RARP=y
3132
CONFIG_NETLINK_DIAG=y
3233
CONFIG_NET_9P=y
33-
CONFIG_NET_9P_VIRTIO=y
3434
CONFIG_PCI=y
3535
CONFIG_PCIEPORTBUS=y
3636
CONFIG_PCI_HOST_GENERIC=y
3737
CONFIG_PCIE_XILINX=y
3838
CONFIG_DEVTMPFS=y
3939
CONFIG_DEVTMPFS_MOUNT=y
4040
CONFIG_BLK_DEV_LOOP=y
41-
CONFIG_VIRTIO_BLK=y
4241
CONFIG_BLK_DEV_SD=y
4342
CONFIG_BLK_DEV_SR=y
44-
CONFIG_SCSI_VIRTIO=y
4543
CONFIG_ATA=y
4644
CONFIG_SATA_AHCI=y
4745
CONFIG_SATA_AHCI_PLATFORM=y
4846
CONFIG_NETDEVICES=y
49-
CONFIG_VIRTIO_NET=y
5047
CONFIG_MACB=y
5148
CONFIG_E1000E=y
5249
CONFIG_R8169=y
@@ -57,13 +54,11 @@ CONFIG_SERIAL_8250_CONSOLE=y
5754
CONFIG_SERIAL_OF_PLATFORM=y
5855
CONFIG_SERIAL_EARLYCON_RISCV_SBI=y
5956
CONFIG_HVC_RISCV_SBI=y
60-
CONFIG_VIRTIO_CONSOLE=y
6157
CONFIG_HW_RANDOM=y
62-
CONFIG_HW_RANDOM_VIRTIO=y
6358
# CONFIG_PTP_1588_CLOCK is not set
59+
CONFIG_POWER_RESET=y
6460
CONFIG_DRM=y
6561
CONFIG_DRM_RADEON=y
66-
CONFIG_DRM_VIRTIO_GPU=y
6762
CONFIG_FRAMEBUFFER_CONSOLE=y
6863
CONFIG_USB=y
6964
CONFIG_USB_XHCI_HCD=y
@@ -74,13 +69,7 @@ CONFIG_USB_OHCI_HCD=y
7469
CONFIG_USB_OHCI_HCD_PLATFORM=y
7570
CONFIG_USB_STORAGE=y
7671
CONFIG_USB_UAS=y
77-
CONFIG_VIRTIO_PCI=y
78-
CONFIG_VIRTIO_BALLOON=y
79-
CONFIG_VIRTIO_INPUT=y
80-
CONFIG_VIRTIO_MMIO=y
81-
CONFIG_RPMSG_CHAR=y
82-
CONFIG_RPMSG_VIRTIO=y
83-
CONFIG_SIFIVE_PLIC=y
72+
CONFIG_RTC_CLASS=y
8473
CONFIG_EXT4_FS=y
8574
CONFIG_EXT4_FS_POSIX_ACL=y
8675
CONFIG_AUTOFS4_FS=y
@@ -95,7 +84,6 @@ CONFIG_NFS_V4_2=y
9584
CONFIG_ROOT_NFS=y
9685
CONFIG_9P_FS=y
9786
CONFIG_CRYPTO_USER_API_HASH=y
98-
CONFIG_CRYPTO_DEV_VIRTIO=y
9987
CONFIG_PRINTK_TIME=y
10088
CONFIG_DEBUG_FS=y
10189
CONFIG_DEBUG_PAGEALLOC=y

arch/riscv/include/asm/syscall.h

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -28,13 +28,6 @@ static inline int syscall_get_nr(struct task_struct *task,
2828
return regs->a7;
2929
}
3030

31-
static inline void syscall_set_nr(struct task_struct *task,
32-
struct pt_regs *regs,
33-
int sysno)
34-
{
35-
regs->a7 = sysno;
36-
}
37-
3831
static inline void syscall_rollback(struct task_struct *task,
3932
struct pt_regs *regs)
4033
{

arch/riscv/kernel/entry.S

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -228,20 +228,13 @@ check_syscall_nr:
228228
/* Check to make sure we don't jump to a bogus syscall number. */
229229
li t0, __NR_syscalls
230230
la s0, sys_ni_syscall
231-
/*
232-
* The tracer can change syscall number to valid/invalid value.
233-
* We use syscall_set_nr helper in syscall_trace_enter thus we
234-
* cannot trust the current value in a7 and have to reload from
235-
* the current task pt_regs.
236-
*/
237-
REG_L a7, PT_A7(sp)
238231
/*
239232
* Syscall number held in a7.
240233
* If syscall number is above allowed value, redirect to ni_syscall.
241234
*/
242235
bge a7, t0, 1f
243236
/*
244-
* Check if syscall is rejected by tracer or seccomp, i.e., a7 == -1.
237+
* Check if syscall is rejected by tracer, i.e., a7 == -1.
245238
* If yes, we pretend it was executed.
246239
*/
247240
li t1, -1
@@ -334,6 +327,7 @@ work_resched:
334327
handle_syscall_trace_enter:
335328
move a0, sp
336329
call do_syscall_trace_enter
330+
move t0, a0
337331
REG_L a0, PT_A0(sp)
338332
REG_L a1, PT_A1(sp)
339333
REG_L a2, PT_A2(sp)
@@ -342,6 +336,7 @@ handle_syscall_trace_enter:
342336
REG_L a5, PT_A5(sp)
343337
REG_L a6, PT_A6(sp)
344338
REG_L a7, PT_A7(sp)
339+
bnez t0, ret_from_syscall_rejected
345340
j check_syscall_nr
346341
handle_syscall_trace_exit:
347342
move a0, sp

arch/riscv/kernel/module.c

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,10 @@
88
#include <linux/err.h>
99
#include <linux/errno.h>
1010
#include <linux/moduleloader.h>
11+
#include <linux/vmalloc.h>
12+
#include <linux/sizes.h>
13+
#include <asm/pgtable.h>
14+
#include <asm/sections.h>
1115

1216
static int apply_r_riscv_32_rela(struct module *me, u32 *location, Elf_Addr v)
1317
{
@@ -386,3 +390,15 @@ int apply_relocate_add(Elf_Shdr *sechdrs, const char *strtab,
386390

387391
return 0;
388392
}
393+
394+
#if defined(CONFIG_MMU) && defined(CONFIG_64BIT)
395+
#define VMALLOC_MODULE_START \
396+
max(PFN_ALIGN((unsigned long)&_end - SZ_2G), VMALLOC_START)
397+
void *module_alloc(unsigned long size)
398+
{
399+
return __vmalloc_node_range(size, 1, VMALLOC_MODULE_START,
400+
VMALLOC_END, GFP_KERNEL,
401+
PAGE_KERNEL_EXEC, 0, NUMA_NO_NODE,
402+
__builtin_return_address(0));
403+
}
404+
#endif

arch/riscv/kernel/ptrace.c

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -148,28 +148,27 @@ long arch_ptrace(struct task_struct *child, long request,
148148
* Allows PTRACE_SYSCALL to work. These are called from entry.S in
149149
* {handle,ret_from}_syscall.
150150
*/
151-
__visible void do_syscall_trace_enter(struct pt_regs *regs)
151+
__visible int do_syscall_trace_enter(struct pt_regs *regs)
152152
{
153153
if (test_thread_flag(TIF_SYSCALL_TRACE))
154154
if (tracehook_report_syscall_entry(regs))
155-
syscall_set_nr(current, regs, -1);
155+
return -1;
156156

157157
/*
158158
* Do the secure computing after ptrace; failures should be fast.
159159
* If this fails we might have return value in a0 from seccomp
160160
* (via SECCOMP_RET_ERRNO/TRACE).
161161
*/
162-
if (secure_computing() == -1) {
163-
syscall_set_nr(current, regs, -1);
164-
return;
165-
}
162+
if (secure_computing() == -1)
163+
return -1;
166164

167165
#ifdef CONFIG_HAVE_SYSCALL_TRACEPOINTS
168166
if (test_thread_flag(TIF_SYSCALL_TRACEPOINT))
169167
trace_sys_enter(regs, syscall_get_nr(current, regs));
170168
#endif
171169

172170
audit_syscall_entry(regs->a7, regs->a0, regs->a1, regs->a2, regs->a3);
171+
return 0;
173172
}
174173

175174
__visible void do_syscall_trace_exit(struct pt_regs *regs)

0 commit comments

Comments
 (0)