Page 1 of 1
Memory from 0x0000 to 0x1000, safe not to map ?
Posted: Fri Mar 08, 2019 4:23 am
by LIC
My Kernel is loaded at 0x1000 in memory because I know I should not touch memory between 0x0000 and 0x1000. But I was wandering if it was safe not to map the first memory page (0x0000) when enabling paging?
I would then get a page fault if I try to access / modify memory below 0x1000.
Thanks for your answer, regards.
Re: Memory from 0x0000 to 0x1000, safe not to map ?
Posted: Fri Mar 08, 2019 4:33 am
by Octocontrabass
You don't need to map memory you're not going to use.
Re: Memory from 0x0000 to 0x1000, safe not to map ?
Posted: Fri Mar 08, 2019 4:51 am
by LIC
Thanks for the reply, that means that the kernel will never have to use memory below 0x1000 ?
In this case I agree I don't need to map it
Re: Memory from 0x0000 to 0x1000, safe not to map ?
Posted: Fri Mar 08, 2019 7:12 am
by bellezzasolo
LIC wrote:My Kernel is loaded at 0x1000 in memory because I know I should not touch memory between 0x0000 and 0x1000. But I was wandering if it was safe not to map the first memory page (0x0000) when enabling paging?
I would then get a page fault if I try to access / modify memory below 0x1000.
Thanks for your answer, regards.
My kernel maps low memory at times (despite being 32/64 bit). Obviously, there's the VGA error. But 0x0-0x1000 comes into use too.
The last bit of code I wrote hit 0x40E. That's usually the location of the EBDA (stored in the BDA). That's part of my code searching for the ACPI RSDP.
Heck, I've used the IVT before. If you drop into real mode to change graphics mode, you need the IVT.
So yeah, you may want to touch that memory at some point.
Re: Memory from 0x0000 to 0x1000, safe not to map ?
Posted: Fri Mar 08, 2019 10:12 am
by mallard
Are you talking about physical or virtual addresses?
You may well need to access physical addresses at the bottom end of memory (i.e. for the MMIO in the 640KB-1MB region, maybe the (E)BDA or real-mode IVT), but there's no particular reason why that has to be mapped into the low virtual addresses (well, unless you're using V86 for something).
Personally, my OS identity maps the first 1MB at boot, except for the very first page, to provide easy trapping of NULL pointer dereferences. For access to the IVT (used by my VBE code which runs the BIOS in an x86 emulator), the first physical page is mapped (upon request) to some other unused address.
Re: Memory from 0x0000 to 0x1000, safe not to map ?
Posted: Fri Mar 08, 2019 2:17 pm
by LIC
okay, thanks for your replies.
Are you talking about physical or virtual addresses?
I am talking about physical memory.
I think I am going to do it mallard's way to detect NULL pointer error and I'll map bottom memory to another address I if I need to.