In older kernels, GDT is set in arch/i386/kernel/head.S. Now, in newer kernels everything moved to arch/x86, bud in arch/x86/kernel/head_32.S i can't find where is GDT set. I mean something like
.quad 0x0000000000000000 /* NULL descriptor */
.quad 0x0000000000000000 /* not used */
.quad 0x00cf9a000000ffff /* 0x10 kernel 4GB code at 0x00000000 */
.quad 0x00cf92000000ffff /* 0x18 kernel 4GB data at 0x00000000 */
.quad 0x00cffa000000ffff /* 0x23 user 4GB code at 0x00000000 */
So, where is this code or something similar in newer kernels? grep was unsuccessful :(
multiple places
apparently there are multiple gdts used in booting, initialized in setup_gdt() in arch/x86/boot/pm.c, in boot_gdt at the end of arch/x86/kernel/head_32.S, and then via definitions and code in include/asm-x86/segment.h, include/asm-x86/desc.h, arch/x86/kernel/smpcommon.c and the architecture and virtualization code in arch/x86. where did you grep? "grep -i gdt" worked.