I am reading through Linux Kernel code. I have some doubt regarding GDT(Global Descriptor Table) in Linux.
My Questions are:
Where Linux Kernel Setup Large GDT?
I know that in pm.c [http://lxr.free-electrons.com/source/arch/x86/boot/pm.c#L123]
kernel call function setup_gdt() and it set up a small GDT with only three entries.
Then jumps to protected mode code.
Then where is the code to setup large GDT with 32 entries
( One specified in Understanding Linux Kernel https://books.google.co.in/books?id=h0lltXyJ8aIC&pg=PT59&lpg=PT59&dq=linux+kernel+file+gdt&source=bl&ots=gO0lH05fHX&sig=h4X1I6TP_P7JlEwzoCkQk3uztjw&hl=en&sa=X&ei=XFwPVM-WBbOBsQTtiIDIDw&redir_esc=y#v=onepage&q=linux%20kernel%20file%20gdt&f=false )
Kernel also defined constants for Large GDT set up in segment.h http://lxr.free-electrons.com/source/arch/x86/include/asm/segment.h#L46.
Why kernel use two steps to set up GDT?
If we are using GRUB as boot loader then, GRUB also set up one GDT in grub-core/kern/i386/realmode.S. Why Linux reset this GDT?
The layout of the main GDT seems to be defined in arch/x86/include/asm/segment.h in line 91.
The initialization seems to be in arch/x86/kernel/cpu/common.c in line 123.
But I may be wrong. And Don't know why kernel use two steps to setup GDT.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With