On Tue, Apr 12, 2022, Varad Gautam wrote: > diff --git a/lib/x86/setup.c b/lib/x86/setup.c > index 94e9f86..7dd6677 100644 > --- a/lib/x86/setup.c > +++ b/lib/x86/setup.c > @@ -170,7 +170,7 @@ void setup_multiboot(struct mbi_bootinfo *bi) > #ifdef CONFIG_EFI > > /* From x86/efi/efistart64.S */ > -extern void load_gdt_tss(size_t tss_offset); > +extern void setup_segments64(void); > > static efi_status_t setup_memory_allocator(efi_bootinfo_t *efi_bootinfo) > { > @@ -275,6 +275,8 @@ static void setup_gdt_tss(void) > /* 64-bit setup_tss does not use the stacktop argument. */ > tss_offset = setup_tss(NULL); > load_gdt_tss(tss_offset); > + > + setup_segments64(); Rather than call back into asm, how about doing this in inline asm? It's a bit gross no matter what, but this has the advantage of getting to use KERNEL_CS/DS without extra magic. And then the future patch that manipulates MSR_GS_BASE can use the wrmsr() helper. asm volatile("mov %0, %%ds\n\t" "mov %0, %%es\n\t" "mov %0, %%fs\n\t" "mov %0, %%gs\n\t" "mov %0, %%ss\n\t" "pushq %1\n\t" "lea 1f(%%rip), %0\n\t" "pushq %0\n\t" "lretq\n\t" "1:" :: "r" ((u64)KERNEL_DS), "i" (KERNEL_CS) ); > efi_status_t setup_efi(efi_bootinfo_t *efi_bootinfo) > diff --git a/x86/efi/efistart64.S b/x86/efi/efistart64.S > index ea3d1c0..8eadca5 100644 > --- a/x86/efi/efistart64.S > +++ b/x86/efi/efistart64.S > @@ -26,15 +26,8 @@ ptl4: > .code64 > .text > > -.globl load_gdt_tss > -load_gdt_tss: > - /* Load GDT */ > - lgdt gdt_descr(%rip) > - > - /* Load TSS */ > - mov %rdi, %rax > - ltr %ax > - > +.globl setup_segments64 > +setup_segments64: > /* Update data segments */ > mov $0x10, %ax /* 3rd entry in gdt64: 32/64-bit data segment */ > mov %ax, %ds > -- > 2.32.0 >