So in risc-v, for a virtual memory system, I imagine it's up to the kernel to decide if 0 is a valid memory address or not? But for machine mode, or supervisor mode, is memory address 0 valid to access?
By extent, should I check if the pointer to the device tree provided to the kernel is NULL?
So in risc-v, for a virtual memory system, I imagine it's up to the kernel to decide if 0 is a valid memory address or not? But for machine mode, or supervisor mode, is memory address 0 valid to access?
By extent, should I check if the pointer to the device tree provided to the kernel is NULL?
Share Improve this question asked Mar 15 at 17:05 CocytusDEDICocytusDEDI 3001 silver badge10 bronze badges 6 | Show 1 more comment1 Answer
Reset to default 1By extent, should I check if the pointer to the device tree provided to the kernel is NULL?
I don't think the RISC-V specification per se specifies which addresses might be valid to access when the kernel boots. This information must be hardcoded into the kernel, or detected by probing the hardware or BIOS somehow, or provided by the device tree itself. In that last case it is impossible to sanitize the device tree address, so don't. In the other cases I don't think it's worth the effort; I would simply allow whatever happens when you access invalid memory to happen.
read
andstat
). But I could easily imagine it being optional on RISC-V. – Peter Cordes Commented Mar 17 at 17:11