mapping kernel space

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
yassin

mapping kernel space

Post 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?
User avatar
kataklinger
Member
Member
Posts: 381
Joined: Fri Nov 04, 2005 12:00 am
Location: Serbia

Re:mapping kernel space

Post 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>
JAAman

Re:mapping kernel space

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