Memory from 0x0000 to 0x1000, safe not to map ?

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Post Reply
LIC
Member
Member
Posts: 44
Joined: Mon Jun 04, 2018 8:10 am
Libera.chat IRC: lic

Memory from 0x0000 to 0x1000, safe not to map ?

Post 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.
Octocontrabass
Member
Member
Posts: 5586
Joined: Mon Mar 25, 2013 7:01 pm

Re: Memory from 0x0000 to 0x1000, safe not to map ?

Post by Octocontrabass »

You don't need to map memory you're not going to use.
LIC
Member
Member
Posts: 44
Joined: Mon Jun 04, 2018 8:10 am
Libera.chat IRC: lic

Re: Memory from 0x0000 to 0x1000, safe not to map ?

Post 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 :)
User avatar
bellezzasolo
Member
Member
Posts: 110
Joined: Sun Feb 20, 2011 2:01 pm

Re: Memory from 0x0000 to 0x1000, safe not to map ?

Post 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.
Whoever said you can't do OS development on Windows?
https://github.com/ChaiSoft/ChaiOS
mallard
Member
Member
Posts: 280
Joined: Tue May 13, 2014 3:02 am
Location: Private, UK

Re: Memory from 0x0000 to 0x1000, safe not to map ?

Post 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.
Image
LIC
Member
Member
Posts: 44
Joined: Mon Jun 04, 2018 8:10 am
Libera.chat IRC: lic

Re: Memory from 0x0000 to 0x1000, safe not to map ?

Post 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.
Post Reply