From 298636079d912d0936f8156a609fe74b839c547b Mon Sep 17 00:00:00 2001 From: Kimplul Date: Tue, 9 Jul 2024 17:35:56 +0300 Subject: allow mapping null page + User has to 'free' the 0 page before it becomes accessible to mapping. Probably worth noting that this is likely VERY niche and mainly concerns stuff like certain kinds of emulators that I'm still eons from implementing, but still. Unbacked pages can also be useful for some kinds of notifications, like 'if someone writes to this page, please report it to me with this ID' or whatever, I remember seeing some discussion about it somewhere but that's also not really relevant for the moment. Most significantly, at least with the current design, after the null page is freed it becomes available for use to regular req_mem() calls, so users should probably using locks around memory requests. That's probably a good idea anyway as internally the kernal has to lock the virtual memory, and without a scheduler it might cause threads to spin for a while in the kernel which is rather bad. --- arch/riscv64/conf/init.c | 2 +- arch/riscv64/config.h | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) (limited to 'arch/riscv64') diff --git a/arch/riscv64/conf/init.c b/arch/riscv64/conf/init.c index c4e8064..03fdc64 100644 --- a/arch/riscv64/conf/init.c +++ b/arch/riscv64/conf/init.c @@ -273,7 +273,7 @@ static void sys_sleep() #define CSR_TIME "0xc01" #define csr_read(csr, \ - res) __asm__ volatile ("csrr %0, " csr : "=r" (res) :: "memory") + res) __asm__ volatile ("csrr %0, " csr : "=r" (res) :: "memory") #define CSR_CYCLE "0xc00" diff --git a/arch/riscv64/config.h b/arch/riscv64/config.h index 952c0ca..d686ed9 100644 --- a/arch/riscv64/config.h +++ b/arch/riscv64/config.h @@ -51,8 +51,9 @@ */ #define CSTACK_PAGE 248UL -/** User virtual memory space start. */ -#define UVMEM_START (SZ_4K) +/** User virtual memory space start. Should essentially always be the start of + * the NULL page, which is marked reserved in the address space by \ref init_uvmem().*/ +#define UVMEM_START (0) /** User virtual memory space end. */ #define UVMEM_END (SZ_256G - SZ_8G) -- cgit v1.3