1
votes

I'm compiling the kernel with a custom kernel module that prints out the kernel's code start and end (physical) addresses. It starts at 0x8000 and ends at 0xefe6d8. Looking through the generated System.map, I see that almost all functions in the kernel sit at 0x10000 (1Mb) in physical memory and onwards. But the code starts at 0x8000. I cannot figure out what lives in between those two addresses. Can anyone shed some light on this?

Snippet from System.map (virtual mapping starts on 0xc0000000):

c0008000 T _text
c0008000 T stext
c000804c t __create_page_tables
c000814c t __turn_mmu_on_loc
c0008158 t __vet_atags
c0100000 T __exception_text_start

The __create_page_tables function is indicative that the page tables live after the __vet_atags code. But why would they be part of executable memory?

1
Your question is hardware/platform specific. Are we supposed to assume that you are using x86? You should specify the HW for clarity. - sawdust

1 Answers

2
votes

From the kernel boot procotol, the kernel memory layout is as follows:

        ~                        ~
        |  Protected-mode kernel |
100000  +------------------------+
        |  I/O memory hole       |
0A0000  +------------------------+
        |  Reserved for BIOS     |  Leave as much as possible unused
        ~                        ~
        |  Command line          |  (Can also be below the X+10000 mark)
X+10000 +------------------------+
        |  Stack/heap            |  For use by the kernel real-mode code.
X+08000 +------------------------+  
        |  Kernel setup          |  The kernel real-mode code.
        |  Kernel boot sector    |  The kernel legacy boot sector.
X       +------------------------+
        |  Boot loader           |  <- Boot sector entry point 0000:7C00
001000  +------------------------+
        |  Reserved for MBR/BIOS |
000800  +------------------------+
        |  Typically used by MBR |
000600  +------------------------+ 
        |  BIOS use only         |
000000  +------------------------+