Page 1 of 1
mapping kernel space
Posted: Tue Jan 17, 2006 10:52 am
by yassin
i have read that some devices and cpuid are mapped in the high memory area.
does this means we must map the kernel in the last GB(s) in order to avoid user programs access (even accidently) this addresses?
Re:mapping kernel space
Posted: Tue Jan 17, 2006 10:58 am
by kataklinger
No, you can map kernel where ever you want. It is usually mapped in last GB. It's because device are mapped in physical address space not in virtual address space, so using paging you can map device wherever you want.
<more_info>
Region of virtual memory which is mapped to device should be strongly unchachable. To do that set CD and WT bits in PTE or use MTTRs.
</more_info>
Re:mapping kernel space
Posted: Wed Jan 18, 2006 9:00 am
by JAAman
i have read that some devices and cpuid are mapped in the high memory area.
no cpuid is an instruction and exists entirly inside the CPU, but many devices are located in memory (some as low as the 1GB mark) and the BIOS ROM is located at TOP_OF_MEMORY (4GB-(size_of_ROM))
this is why you should always use the appropriate BIOS calls to discover how much memory you have in your system (only E820 will tell you where these memory-mapped-devices are)
but as kataklinger said, this is only physical memory, not virtual memory (where the devices will be restricted or not present -- depending on your OS design)
most OSs are at TOP_OF_MEM as a tradition held over from the time when the OS was located in ROM chips (which by traddition are always at the top -- growing down while RAM starts at the bottom, growing up -- important because the CPU needs to know what memory addresses are availible on boot (only ROM) and certain addresses are not usefull unless located in RAM (IDT for example)