Skip to content

Commit f862bbf

Browse files
SiFiveHollandpalmer-dabbelt
authored andcommitted
riscv: Allow NOMMU kernels to run in S-mode
For ease of testing, it is convenient to run NOMMU kernels in supervisor mode. The only required change is to offset the kernel load address, since the beginning of RAM is usually reserved for M-mode firmware. Signed-off-by: Samuel Holland <[email protected]> Reviewed-by: Conor Dooley <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Palmer Dabbelt <[email protected]>
1 parent 9c4319d commit f862bbf

File tree

1 file changed

+10
-5
lines changed

1 file changed

+10
-5
lines changed

arch/riscv/Kconfig

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ config RISCV
6464
select ARCH_WANTS_THP_SWAP if HAVE_ARCH_TRANSPARENT_HUGEPAGE
6565
select BINFMT_FLAT_NO_DATA_START_OFFSET if !MMU
6666
select BUILDTIME_TABLE_SORT if MMU
67-
select CLINT_TIMER if !MMU
67+
select CLINT_TIMER if RISCV_M_MODE
6868
select CLONE_BACKWARDS
6969
select COMMON_CLK
7070
select CPU_PM if CPU_IDLE || HIBERNATION || SUSPEND
@@ -220,8 +220,12 @@ config ARCH_MMAP_RND_COMPAT_BITS_MAX
220220

221221
# set if we run in machine mode, cleared if we run in supervisor mode
222222
config RISCV_M_MODE
223-
bool
224-
default !MMU
223+
bool "Build a kernel that runs in machine mode"
224+
depends on !MMU
225+
default y
226+
help
227+
Select this option if you want to run the kernel in M-mode,
228+
without the assistance of any other firmware.
225229

226230
# set if we are running in S-mode and can use SBI calls
227231
config RISCV_SBI
@@ -238,8 +242,9 @@ config MMU
238242

239243
config PAGE_OFFSET
240244
hex
241-
default 0xC0000000 if 32BIT && MMU
242-
default 0x80000000 if !MMU
245+
default 0x80000000 if !MMU && RISCV_M_MODE
246+
default 0x80200000 if !MMU
247+
default 0xc0000000 if 32BIT
243248
default 0xff60000000000000 if 64BIT
244249

245250
config KASAN_SHADOW_OFFSET

0 commit comments

Comments
 (0)