Skip to content

Commit 5ba9aa5

Browse files
Merge branch 'next/nommu' into for-next
Conflicts: arch/riscv/boot/Makefile arch/riscv/include/asm/sbi.h
2 parents 4a97986 + 405fe7a commit 5ba9aa5

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

54 files changed

+947
-375
lines changed

arch/riscv/Kconfig

Lines changed: 27 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -26,15 +26,15 @@ config RISCV
2626
select GENERIC_IRQ_SHOW
2727
select GENERIC_PCI_IOMAP
2828
select GENERIC_SCHED_CLOCK
29-
select GENERIC_STRNCPY_FROM_USER
30-
select GENERIC_STRNLEN_USER
29+
select GENERIC_STRNCPY_FROM_USER if MMU
30+
select GENERIC_STRNLEN_USER if MMU
3131
select GENERIC_SMP_IDLE_THREAD
3232
select GENERIC_ATOMIC64 if !64BIT
3333
select HAVE_ARCH_AUDITSYSCALL
3434
select HAVE_ARCH_SECCOMP_FILTER
3535
select HAVE_ASM_MODVERSIONS
3636
select HAVE_MEMBLOCK_NODE_MAP
37-
select HAVE_DMA_CONTIGUOUS
37+
select HAVE_DMA_CONTIGUOUS if MMU
3838
select HAVE_FUTEX_CMPXCHG if FUTEX
3939
select HAVE_PERF_EVENTS
4040
select HAVE_PERF_REGS
@@ -51,6 +51,7 @@ config RISCV
5151
select PCI_DOMAINS_GENERIC if PCI
5252
select PCI_MSI if PCI
5353
select RISCV_TIMER
54+
select UACCESS_MEMCPY if !MMU
5455
select GENERIC_IRQ_MULTI_HANDLER
5556
select GENERIC_ARCH_TOPOLOGY if SMP
5657
select ARCH_HAS_PTE_SPECIAL
@@ -61,7 +62,7 @@ config RISCV
6162
select ARCH_WANT_HUGE_PMD_SHARE if 64BIT
6263
select SPARSEMEM_STATIC if 32BIT
6364
select ARCH_WANT_DEFAULT_TOPDOWN_MMAP_LAYOUT if MMU
64-
select HAVE_ARCH_MMAP_RND_BITS
65+
select HAVE_ARCH_MMAP_RND_BITS if MMU
6566

6667
config ARCH_MMAP_RND_BITS_MIN
6768
default 18 if 64BIT
@@ -73,8 +74,23 @@ config ARCH_MMAP_RND_BITS_MAX
7374
default 24 if 64BIT # SV39 based
7475
default 17
7576

77+
# set if we run in machine mode, cleared if we run in supervisor mode
78+
config RISCV_M_MODE
79+
bool
80+
default !MMU
81+
82+
# set if we are running in S-mode and can use SBI calls
83+
config RISCV_SBI
84+
bool
85+
depends on !RISCV_M_MODE
86+
default y
87+
7688
config MMU
77-
def_bool y
89+
bool "MMU-based Paged Memory Management Support"
90+
default y
91+
help
92+
Select if you want MMU-based virtualised addressing space
93+
support by paged memory management. If unsure, say 'Y'.
7894

7995
config ZONE_DMA32
8096
bool
@@ -93,6 +109,7 @@ config PA_BITS
93109
config PAGE_OFFSET
94110
hex
95111
default 0xC0000000 if 32BIT && MAXPHYSMEM_2GB
112+
default 0x80000000 if 64BIT && !MMU
96113
default 0xffffffff80000000 if 64BIT && MAXPHYSMEM_2GB
97114
default 0xffffffe000000000 if 64BIT && MAXPHYSMEM_128GB
98115

@@ -136,7 +153,7 @@ config GENERIC_HWEIGHT
136153
def_bool y
137154

138155
config FIX_EARLYCON_MEM
139-
def_bool y
156+
def_bool CONFIG_MMU
140157

141158
config PGTABLE_LEVELS
142159
int
@@ -161,6 +178,7 @@ config ARCH_RV32I
161178
select GENERIC_LIB_ASHRDI3
162179
select GENERIC_LIB_LSHRDI3
163180
select GENERIC_LIB_UCMPDI2
181+
select MMU
164182

165183
config ARCH_RV64I
166184
bool "RV64I"
@@ -169,9 +187,9 @@ config ARCH_RV64I
169187
select HAVE_FUNCTION_TRACER
170188
select HAVE_FUNCTION_GRAPH_TRACER
171189
select HAVE_FTRACE_MCOUNT_RECORD
172-
select HAVE_DYNAMIC_FTRACE
173-
select HAVE_DYNAMIC_FTRACE_WITH_REGS
174-
select SWIOTLB
190+
select HAVE_DYNAMIC_FTRACE if MMU
191+
select HAVE_DYNAMIC_FTRACE_WITH_REGS if HAVE_DYNAMIC_FTRACE
192+
select SWIOTLB if MMU
175193

176194
endchoice
177195

arch/riscv/Makefile

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -83,13 +83,18 @@ PHONY += vdso_install
8383
vdso_install:
8484
$(Q)$(MAKE) $(build)=arch/riscv/kernel/vdso $@
8585

86-
all: Image.gz
86+
ifeq ($(CONFIG_RISCV_M_MODE),y)
87+
KBUILD_IMAGE := $(boot)/loader
88+
else
89+
KBUILD_IMAGE := $(boot)/Image.gz
90+
endif
91+
BOOT_TARGETS := Image Image.gz loader
8792

88-
Image: vmlinux
89-
$(Q)$(MAKE) $(build)=$(boot) $(boot)/$@
93+
all: $(notdir $(KBUILD_IMAGE))
9094

91-
Image.%: Image
95+
$(BOOT_TARGETS): vmlinux
9296
$(Q)$(MAKE) $(build)=$(boot) $(boot)/$@
97+
@$(kecho) ' Kernel: $(boot)/$@ is ready'
9398

9499
zinstall install:
95100
$(Q)$(MAKE) $(build)=$(boot) $@

arch/riscv/boot/Makefile

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,19 @@
1616

1717
OBJCOPYFLAGS_Image :=-O binary -R .note -R .note.gnu.build-id -R .comment -S
1818

19-
targets := Image
19+
targets := Image loader
2020

2121
$(obj)/Image: vmlinux FORCE
2222
$(call if_changed,objcopy)
2323

2424
$(obj)/Image.gz: $(obj)/Image FORCE
2525
$(call if_changed,gzip)
2626

27+
loader.o: $(src)/loader.S $(obj)/Image
28+
29+
$(obj)/loader: $(obj)/loader.o $(obj)/Image $(obj)/loader.lds FORCE
30+
$(Q)$(LD) -T $(obj)/loader.lds -o $@ $(obj)/loader.o
31+
2732
$(obj)/Image.bz2: $(obj)/Image FORCE
2833
$(call if_changed,bzip2)
2934

arch/riscv/boot/loader.S

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
/* SPDX-License-Identifier: GPL-2.0 */
2+
3+
.align 4
4+
.section .payload, "ax", %progbits
5+
.globl _start
6+
_start:
7+
.incbin "arch/riscv/boot/Image"
8+

arch/riscv/boot/loader.lds.S

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
/* SPDX-License-Identifier: GPL-2.0 */
2+
3+
#include <asm/page.h>
4+
5+
OUTPUT_ARCH(riscv)
6+
ENTRY(_start)
7+
8+
SECTIONS
9+
{
10+
. = PAGE_OFFSET;
11+
12+
.payload : {
13+
*(.payload)
14+
. = ALIGN(8);
15+
}
16+
}
Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
# CONFIG_CPU_ISOLATION is not set
2+
CONFIG_LOG_BUF_SHIFT=16
3+
CONFIG_PRINTK_SAFE_LOG_BUF_SHIFT=12
4+
CONFIG_BLK_DEV_INITRD=y
5+
# CONFIG_RD_BZIP2 is not set
6+
# CONFIG_RD_LZMA is not set
7+
# CONFIG_RD_XZ is not set
8+
# CONFIG_RD_LZO is not set
9+
# CONFIG_RD_LZ4 is not set
10+
CONFIG_CC_OPTIMIZE_FOR_SIZE=y
11+
CONFIG_EXPERT=y
12+
# CONFIG_SYSFS_SYSCALL is not set
13+
# CONFIG_FHANDLE is not set
14+
# CONFIG_BASE_FULL is not set
15+
# CONFIG_EPOLL is not set
16+
# CONFIG_SIGNALFD is not set
17+
# CONFIG_TIMERFD is not set
18+
# CONFIG_EVENTFD is not set
19+
# CONFIG_AIO is not set
20+
# CONFIG_IO_URING is not set
21+
# CONFIG_ADVISE_SYSCALLS is not set
22+
# CONFIG_MEMBARRIER is not set
23+
# CONFIG_KALLSYMS is not set
24+
# CONFIG_VM_EVENT_COUNTERS is not set
25+
# CONFIG_COMPAT_BRK is not set
26+
CONFIG_SLOB=y
27+
# CONFIG_SLAB_MERGE_DEFAULT is not set
28+
# CONFIG_MMU is not set
29+
CONFIG_MAXPHYSMEM_2GB=y
30+
CONFIG_SMP=y
31+
CONFIG_CMDLINE="root=/dev/vda rw earlycon=uart8250,mmio,0x10000000,115200n8 console=ttyS0"
32+
CONFIG_CMDLINE_FORCE=y
33+
# CONFIG_BLK_DEV_BSG is not set
34+
CONFIG_PARTITION_ADVANCED=y
35+
# CONFIG_MSDOS_PARTITION is not set
36+
# CONFIG_EFI_PARTITION is not set
37+
# CONFIG_MQ_IOSCHED_DEADLINE is not set
38+
# CONFIG_MQ_IOSCHED_KYBER is not set
39+
CONFIG_BINFMT_FLAT=y
40+
# CONFIG_COREDUMP is not set
41+
CONFIG_DEVTMPFS=y
42+
CONFIG_DEVTMPFS_MOUNT=y
43+
# CONFIG_FW_LOADER is not set
44+
# CONFIG_ALLOW_DEV_COREDUMP is not set
45+
CONFIG_VIRTIO_BLK=y
46+
# CONFIG_INPUT_KEYBOARD is not set
47+
# CONFIG_INPUT_MOUSE is not set
48+
# CONFIG_SERIO is not set
49+
# CONFIG_LEGACY_PTYS is not set
50+
# CONFIG_LDISC_AUTOLOAD is not set
51+
# CONFIG_DEVMEM is not set
52+
CONFIG_SERIAL_8250=y
53+
# CONFIG_SERIAL_8250_DEPRECATED_OPTIONS is not set
54+
CONFIG_SERIAL_8250_CONSOLE=y
55+
CONFIG_SERIAL_8250_NR_UARTS=1
56+
CONFIG_SERIAL_8250_RUNTIME_UARTS=1
57+
CONFIG_SERIAL_OF_PLATFORM=y
58+
# CONFIG_HW_RANDOM is not set
59+
# CONFIG_HWMON is not set
60+
# CONFIG_LCD_CLASS_DEVICE is not set
61+
# CONFIG_BACKLIGHT_CLASS_DEVICE is not set
62+
# CONFIG_VGA_CONSOLE is not set
63+
# CONFIG_HID is not set
64+
# CONFIG_USB_SUPPORT is not set
65+
CONFIG_VIRTIO_MMIO=y
66+
CONFIG_VIRTIO_MMIO_CMDLINE_DEVICES=y
67+
CONFIG_SIFIVE_PLIC=y
68+
# CONFIG_VALIDATE_FS_PARSER is not set
69+
CONFIG_EXT2_FS=y
70+
# CONFIG_DNOTIFY is not set
71+
# CONFIG_INOTIFY_USER is not set
72+
# CONFIG_MISC_FILESYSTEMS is not set
73+
CONFIG_LSM="[]"
74+
CONFIG_PRINTK_TIME=y
75+
# CONFIG_SCHED_DEBUG is not set
76+
# CONFIG_RCU_TRACE is not set
77+
# CONFIG_FTRACE is not set
78+
# CONFIG_RUNTIME_TESTING_MENU is not set

arch/riscv/include/asm/cache.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,12 @@
1111

1212
#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
1313

14+
/*
15+
* RISC-V requires the stack pointer to be 16-byte aligned, so ensure that
16+
* the flat loader aligns it accordingly.
17+
*/
18+
#ifndef CONFIG_MMU
19+
#define ARCH_SLAB_MINALIGN 16
20+
#endif
21+
1422
#endif /* _ASM_RISCV_CACHE_H */

arch/riscv/include/asm/clint.h

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
/* SPDX-License-Identifier: GPL-2.0 */
2+
#ifndef _ASM_RISCV_CLINT_H
3+
#define _ASM_RISCV_CLINT_H 1
4+
5+
#include <linux/io.h>
6+
#include <linux/smp.h>
7+
8+
#ifdef CONFIG_RISCV_M_MODE
9+
extern u32 __iomem *clint_ipi_base;
10+
11+
void clint_init_boot_cpu(void);
12+
13+
static inline void clint_send_ipi_single(unsigned long hartid)
14+
{
15+
writel(1, clint_ipi_base + hartid);
16+
}
17+
18+
static inline void clint_send_ipi_mask(const struct cpumask *hartid_mask)
19+
{
20+
int hartid;
21+
22+
for_each_cpu(hartid, hartid_mask)
23+
clint_send_ipi_single(hartid);
24+
}
25+
26+
static inline void clint_clear_ipi(unsigned long hartid)
27+
{
28+
writel(0, clint_ipi_base + hartid);
29+
}
30+
#else /* CONFIG_RISCV_M_MODE */
31+
#define clint_init_boot_cpu() do { } while (0)
32+
33+
/* stubs to for code is only reachable under IS_ENABLED(CONFIG_RISCV_M_MODE): */
34+
void clint_send_ipi_single(unsigned long hartid);
35+
void clint_send_ipi_mask(const struct cpumask *hartid_mask);
36+
void clint_clear_ipi(unsigned long hartid);
37+
#endif /* CONFIG_RISCV_M_MODE */
38+
39+
#endif /* _ASM_RISCV_CLINT_H */

0 commit comments

Comments
 (0)