On a 64-bit kernel, the next function to execute after efi_main returns is startup_64, which sets up its own GDT, so setting one up in efi_main is unnecessary. Signed-off-by: Arvind Sankar <nivedita@xxxxxxxxxxxx> --- arch/x86/boot/compressed/eboot.c | 60 ++++++-------------------------- 1 file changed, 10 insertions(+), 50 deletions(-) diff --git a/arch/x86/boot/compressed/eboot.c b/arch/x86/boot/compressed/eboot.c index 066125a18391..a72cfda91d7e 100644 --- a/arch/x86/boot/compressed/eboot.c +++ b/arch/x86/boot/compressed/eboot.c @@ -346,6 +346,7 @@ void setup_graphics(struct boot_params *boot_params) static efi_status_t setup_gdt(struct desc_ptr *gdt) { +#ifdef CONFIG_X86_32 efi_status_t status; struct desc_struct *desc; @@ -361,30 +362,10 @@ static efi_status_t setup_gdt(struct desc_ptr *gdt) /* The first GDT is a dummy. */ desc++; + /* Second entry is unused on 32-bit */ + desc++; - if (IS_ENABLED(CONFIG_X86_64)) { - /* __KERNEL32_CS */ - desc->limit0 = 0xffff; - desc->base0 = 0x0000; - desc->base1 = 0x0000; - desc->type = SEG_TYPE_CODE | SEG_TYPE_EXEC_READ; - desc->s = DESC_TYPE_CODE_DATA; - desc->dpl = 0; - desc->p = 1; - desc->limit1 = 0xf; - desc->avl = 0; - desc->l = 0; - desc->d = SEG_OP_SIZE_32BIT; - desc->g = SEG_GRANULARITY_4KB; - desc->base2 = 0x00; - - desc++; - } else { - /* Second entry is unused on 32-bit */ - desc++; - } - - /* __KERNEL_CS */ + /* __BOOT_CS */ desc->limit0 = 0xffff; desc->base0 = 0x0000; desc->base1 = 0x0000; @@ -394,19 +375,13 @@ static efi_status_t setup_gdt(struct desc_ptr *gdt) desc->p = 1; desc->limit1 = 0xf; desc->avl = 0; - - if (IS_ENABLED(CONFIG_X86_64)) { - desc->l = 1; - desc->d = 0; - } else { - desc->l = 0; - desc->d = SEG_OP_SIZE_32BIT; - } + desc->l = 0; + desc->d = SEG_OP_SIZE_32BIT; desc->g = SEG_GRANULARITY_4KB; desc->base2 = 0x00; desc++; - /* __KERNEL_DS */ + /* __BOOT_DS */ desc->limit0 = 0xffff; desc->base0 = 0x0000; desc->base1 = 0x0000; @@ -422,23 +397,7 @@ static efi_status_t setup_gdt(struct desc_ptr *gdt) desc->base2 = 0x00; desc++; - if (IS_ENABLED(CONFIG_X86_64)) { - /* Task segment value */ - desc->limit0 = 0x0000; - desc->base0 = 0x0000; - desc->base1 = 0x0000; - desc->type = SEG_TYPE_TSS; - desc->s = 0; - desc->dpl = 0; - desc->p = 1; - desc->limit1 = 0x0; - desc->avl = 0; - desc->l = 0; - desc->d = 0; - desc->g = SEG_GRANULARITY_4KB; - desc->base2 = 0x00; - desc++; - } +#endif /* CONFIG_X86_32 */ return EFI_SUCCESS; } @@ -883,7 +842,8 @@ struct boot_params *efi_main(efi_handle_t handle, } raw_local_irq_disable(); - native_load_gdt(&gdt); + if (IS_ENABLED(CONFIG_X86_32)) + native_load_gdt(&gdt); return boot_params; fail: -- 2.24.1