Skip to content

Commit d4b500c

Browse files
Merge patch series "riscv: 64-bit NOMMU fixes and enhancements"
Samuel Holland <[email protected]> says: This series aims to improve support for NOMMU, specifically by making it easier to test NOMMU kernels in QEMU and on various widely-available hardware (errata permitting). After all, everything supports Svbare... After applying this series, a NOMMU kernel based on defconfig (changing only the three options below*) boots to userspace on QEMU when passed as -kernel. # CONFIG_RISCV_M_MODE is not set # CONFIG_MMU is not set CONFIG_NONPORTABLE=y *if you are using LLD, you must also disable BPF_SYSCALL and KALLSYMS, because LLD bails on out-of-range references to undefined weak symbols. * b4-shazam-merge: riscv: Allow NOMMU kernels to run in S-mode riscv: Remove MMU dependency from Zbb and Zicboz riscv: Fix loading 64-bit NOMMU kernels past the start of RAM riscv: Fix TASK_SIZE on 64-bit NOMMU Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Palmer Dabbelt <[email protected]>
2 parents 70a57b2 + f862bbf commit d4b500c

File tree

4 files changed

+13
-10
lines changed

4 files changed

+13
-10
lines changed

arch/riscv/Kconfig

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ config RISCV
7171
select ARCH_WANTS_THP_SWAP if HAVE_ARCH_TRANSPARENT_HUGEPAGE
7272
select BINFMT_FLAT_NO_DATA_START_OFFSET if !MMU
7373
select BUILDTIME_TABLE_SORT if MMU
74-
select CLINT_TIMER if !MMU
74+
select CLINT_TIMER if RISCV_M_MODE
7575
select CLONE_BACKWARDS
7676
select COMMON_CLK
7777
select CPU_PM if CPU_IDLE || HIBERNATION || SUSPEND
@@ -230,8 +230,12 @@ config ARCH_MMAP_RND_COMPAT_BITS_MAX
230230

231231
# set if we run in machine mode, cleared if we run in supervisor mode
232232
config RISCV_M_MODE
233-
bool
234-
default !MMU
233+
bool "Build a kernel that runs in machine mode"
234+
depends on !MMU
235+
default y
236+
help
237+
Select this option if you want to run the kernel in M-mode,
238+
without the assistance of any other firmware.
235239

236240
# set if we are running in S-mode and can use SBI calls
237241
config RISCV_SBI
@@ -248,8 +252,9 @@ config MMU
248252

249253
config PAGE_OFFSET
250254
hex
251-
default 0xC0000000 if 32BIT && MMU
252-
default 0x80000000 if !MMU
255+
default 0x80000000 if !MMU && RISCV_M_MODE
256+
default 0x80200000 if !MMU
257+
default 0xc0000000 if 32BIT
253258
default 0xff60000000000000 if 64BIT
254259

255260
config KASAN_SHADOW_OFFSET
@@ -597,7 +602,6 @@ config TOOLCHAIN_HAS_VECTOR_CRYPTO
597602
config RISCV_ISA_ZBB
598603
bool "Zbb extension support for bit manipulation instructions"
599604
depends on TOOLCHAIN_HAS_ZBB
600-
depends on MMU
601605
depends on RISCV_ALTERNATIVE
602606
default y
603607
help
@@ -629,7 +633,6 @@ config RISCV_ISA_ZICBOM
629633

630634
config RISCV_ISA_ZICBOZ
631635
bool "Zicboz extension support for faster zeroing of memory"
632-
depends on MMU
633636
depends on RISCV_ALTERNATIVE
634637
default y
635638
help

arch/riscv/include/asm/page.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ typedef struct page *pgtable_t;
8989
#define PTE_FMT "%08lx"
9090
#endif
9191

92-
#ifdef CONFIG_64BIT
92+
#if defined(CONFIG_64BIT) && defined(CONFIG_MMU)
9393
/*
9494
* We override this value as its generic definition uses __pa too early in
9595
* the boot process (before kernel_map.va_pa_offset is set).

arch/riscv/include/asm/pgtable.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -890,7 +890,7 @@ static inline pte_t pte_swp_clear_exclusive(pte_t pte)
890890
#define PAGE_SHARED __pgprot(0)
891891
#define PAGE_KERNEL __pgprot(0)
892892
#define swapper_pg_dir NULL
893-
#define TASK_SIZE 0xffffffffUL
893+
#define TASK_SIZE _AC(-1, UL)
894894
#define VMALLOC_START _AC(0, UL)
895895
#define VMALLOC_END TASK_SIZE
896896

arch/riscv/mm/init.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -231,7 +231,7 @@ static void __init setup_bootmem(void)
231231
* In 64-bit, any use of __va/__pa before this point is wrong as we
232232
* did not know the start of DRAM before.
233233
*/
234-
if (IS_ENABLED(CONFIG_64BIT))
234+
if (IS_ENABLED(CONFIG_64BIT) && IS_ENABLED(CONFIG_MMU))
235235
kernel_map.va_pa_offset = PAGE_OFFSET - phys_ram_base;
236236

237237
/*

0 commit comments

Comments
 (0)