OSDN Git Service

riscv: add nommu support
authorChristoph Hellwig <hch@lst.de>
Mon, 28 Oct 2019 12:10:41 +0000 (13:10 +0100)
committerPaul Walmsley <paul.walmsley@sifive.com>
Sun, 17 Nov 2019 23:17:39 +0000 (15:17 -0800)
commit6bd33e1ece528f67646db33bf97406b747dafda0
treef78c5001071a475fa5bed9781c07a609118684f7
parent9e80635619b51ddc56bdeca4da4056eb7a2a77e0
riscv: add nommu support

The kernel runs in M-mode without using page tables, and thus can't run
bare metal without help from additional firmware.

Most of the patch is just stubbing out code not needed without page
tables, but there is an interesting detail in the signals implementation:

 - The normal RISC-V syscall ABI only implements rt_sigreturn as VDSO
   entry point, but the ELF VDSO is not supported for nommu Linux.
   We instead copy the code to call the syscall onto the stack.

In addition to enabling the nommu code a new defconfig for a small
kernel image that can run in nommu mode on qemu is also provided, to run
a kernel in qemu you can use the following command line:

qemu-system-riscv64 -smp 2 -m 64 -machine virt -nographic \
-kernel arch/riscv/boot/loader \
-drive file=rootfs.ext2,format=raw,id=hd0 \
-device virtio-blk-device,drive=hd0

Contains contributions from Damien Le Moal <Damien.LeMoal@wdc.com>.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Anup Patel <anup@brainfault.org>
[paul.walmsley@sifive.com: updated to apply; add CONFIG_MMU guards
 around PCI_IOBASE definition to fix build issues; fixed checkpatch
 issues; move the PCI_IO_* and VMEMMAP address space macros along
 with the others; resolve sparse warning]
Signed-off-by: Paul Walmsley <paul.walmsley@sifive.com>
23 files changed:
arch/riscv/Kconfig
arch/riscv/configs/nommu_virt_defconfig [new file with mode: 0644]
arch/riscv/include/asm/cache.h
arch/riscv/include/asm/elf.h
arch/riscv/include/asm/fixmap.h
arch/riscv/include/asm/futex.h
arch/riscv/include/asm/io.h
arch/riscv/include/asm/mmio.h
arch/riscv/include/asm/mmu.h
arch/riscv/include/asm/page.h
arch/riscv/include/asm/pgalloc.h
arch/riscv/include/asm/pgtable.h
arch/riscv/include/asm/tlbflush.h
arch/riscv/include/asm/uaccess.h
arch/riscv/kernel/Makefile
arch/riscv/kernel/entry.S
arch/riscv/kernel/head.S
arch/riscv/kernel/signal.c
arch/riscv/lib/Makefile
arch/riscv/mm/Makefile
arch/riscv/mm/cacheflush.c
arch/riscv/mm/context.c
arch/riscv/mm/init.c