You can boot a RISC-V kernel down to 32MiB of RAM without any tricks specific
to low-memory systems:
$ git diff
diff --git a/Makefile b/Makefile
index 408a4247fe64..4913e768f410 100644
--- a/Makefile
+++ b/Makefile
@@ -213,4 +213,5 @@ sim: $(spike) $(bbl)
qemu: $(qemu) $(bbl) $(rootfs)
$(qemu) -nographic -machine virt -kernel $(bbl) \
-drive file=$(rootfs),format=raw,id=hd0 -device virtio-blk-device,drive=hd0 \
- -netdev user,id=net0 -device virtio-net-device,netdev=net0
+ -netdev user,id=net0 -device virtio-net-device,netdev=net0 \
+ -m 32
$ cat work/linux/.config | grep -i CONFIG_MAXPHYSMEM
# CONFIG_MAXPHYSMEM_2GB is not set
CONFIG_MAXPHYSMEM_128GB=y
$ make qemu
...
Starting logging: OK
Starting mdev...
sort: /sys/devices/platform/Fixed: No such file or directory
modprobe: can't change directory to '/lib/modules': No such file or directory
Initializing random number generator... done.
Starting network...
udhcpc (v1.24.2) started
Sending discover...
Sending select for 10.0.2.15...
Lease of 10.0.2.15 obtained, lease time 86400
deleting routers
adding dns 10.0.2.3
Starting dropbear sshd: OK
Welcome to Buildroot
buildroot login: root
Password:
# free -m
total used free shared buffers cached
Mem: 24 19 4 8 0 8
-/+ buffers/cache: 11 12
Swap: 0 0 0
You don't need to map every virtual address in order to have a valid userspace,
just the ones that are actually used. Thus there's no reason to bother
restricting the user's virtual address space to a particular bit width -- just
let the user allocate whatever it wants.
CONFIG_MAXPHYSMEM is a small-scale optimization: if the kernel knows it can
only access 2GiB of physical memory then it can be compiled to use LUI-based
addressing for all symbols, which allows the compiler to generate better code
in some cases. I'd be very surpried if you could find any workload where this
was a 1% performance benefit.
>> email to
sw-dev+un...@groups.riscv.org.
>> <
https://groups.google.com/a/groups.riscv.org/d/msgid/sw-dev/38a4725e-cff5-4598-8c2d-a4ae9e65ca60%40groups.riscv.org?utm_medium=email&utm_source=footer>
>> .
>>