rv32emu icon indicating copy to clipboard operation
rv32emu copied to clipboard

Fix insufficient memory on some platforms

Open tony2037 opened this issue 1 year ago • 3 comments

[Problem] The MEM_SIZE is hard-corded, but on some platforms, memory is insufficient. Perhaps we should allow user to config accordingly

[Solution] Expose an environment variable, CONFIG_MEM_SIZE, to allow user config the memory size with it

[Test]

  • before $> make $> ./build/rv32emu ./build/hello.elf rv32emu: src/riscv.c:199: rv_create: Assertion `attr->mem' failed. Aborted (core dumped)

  • after $> CONFIG_MEM_SIZE=0x40000000 make $> ./build/rv32emu ./build/hello.elf Hello World! Hello World! Hello World! Hello World! Hello World! inferior exit code 0

[Reference] #488

tony2037 avatar May 27 '24 07:05 tony2037

I don't think the proposed change resolves the insufficient memory issue because it just relies on compile-time configurations instead of an adaptive approach to acquire the necessary system resources based on the requirements of RISC-V programs during instruction simulation.

@qwe661234, can you comment this?

jserv avatar May 27 '24 08:05 jserv

This issue arises when the memory size is insufficient, especially when running rv32emu on a VM. However, arbitrarily setting a MEM_SIZE to pass specific tests can cause segmentation faults in other tests. A better solution is to revert to the original virtual memory implementation when memory size is insufficient, allocating memory only as needed for read or write operations.

qwe661234 avatar May 28 '24 06:05 qwe661234

After investigation, you can set MEM_SIZE to 0x80000 to run the benchmarks in directory tests. However, if you want to run some video games like doom or quake, the 4G memory is required.

qwe661234 avatar Jun 03 '24 12:06 qwe661234

Reworked in commit feca1dea732e110a8b08926f3266d2db732147b0

jserv avatar Sep 01 '24 07:09 jserv