How does Linux not pagefault when jumping to the decompressed bzImage in x86_64?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hello!

For the past few weeks I have been trying to figure out how Linux
boots in its entirety as I found it rather interesting. However, I
have now come to a point where I am nothing short of confused.

As we can see in the linking script (vmlinux.lds.S), it is offset to a
certain address, namely __START_KERNEL. This define resolves to
__START_KERNEL_map + __PHYSICAL_START. So the entire 'kernel image' is
(from as far as my understanding goes) shifted by __START_KERNEL_map,
which holds a value of 0xffffffff80000000.

Now, when decompression has finished, it dereferences the first few
bytes of bzImage to get the address of `startup_64`, and it jumps to
the defined address and resumes execution while still in physical
address space. But how can they execute code that is compiled to be
run at a completely different address space, without causing page
faults? When I attempt to do the same, writing to the descriptor of
the temporary GDT causes it to have an access violation at address
0xffffffff8141d0a0
(https://github.com/torvalds/linux/blob/56e337f2cf1326323844927a04e9dbce9a244835/arch/x86/kernel/head64.c#L616)

Any help or resources on this would be greatly appreciated.

-- 
Kind regards,
Harm Smits



[Index of Archives]     [Audio]     [Hams]     [Kernel Newbies]     [Security]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Samba]     [Video 4 Linux]     [Fedora Users]

  Powered by Linux