Skip to content

Commit 919a02d

Browse files
kirylIngo Molnar
authored andcommitted
x86/boot/efi: Define __KERNEL32_CS GDT on 64-bit configurations
We would need to switch temporarily to compatibility mode during booting with 5-level paging enabled. It would require 32-bit code segment descriptor. Signed-off-by: Kirill A. Shutemov <[email protected]> Reviewed-by: Matt Fleming <[email protected]> Cc: Andrew Morton <[email protected]> Cc: Andy Lutomirski <[email protected]> Cc: Andy Lutomirski <[email protected]> Cc: Borislav Petkov <[email protected]> Cc: Brian Gerst <[email protected]> Cc: Dave Hansen <[email protected]> Cc: Denys Vlasenko <[email protected]> Cc: H. Peter Anvin <[email protected]> Cc: Josh Poimboeuf <[email protected]> Cc: Linus Torvalds <[email protected]> Cc: Peter Zijlstra <[email protected]> Cc: Thomas Gleixner <[email protected]> Cc: [email protected] Cc: [email protected] Link: http://lkml.kernel.org/r/[email protected] Signed-off-by: Ingo Molnar <[email protected]>
1 parent 4c94117 commit 919a02d

File tree

1 file changed

+23
-2
lines changed

1 file changed

+23
-2
lines changed

arch/x86/boot/compressed/eboot.c

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1046,8 +1046,29 @@ struct boot_params *efi_main(struct efi_config *c,
10461046
memset((char *)gdt->address, 0x0, gdt->size);
10471047
desc = (struct desc_struct *)gdt->address;
10481048

1049-
/* The first GDT is a dummy and the second is unused. */
1050-
desc += 2;
1049+
/* The first GDT is a dummy. */
1050+
desc++;
1051+
1052+
if (IS_ENABLED(CONFIG_X86_64)) {
1053+
/* __KERNEL32_CS */
1054+
desc->limit0 = 0xffff;
1055+
desc->base0 = 0x0000;
1056+
desc->base1 = 0x0000;
1057+
desc->type = SEG_TYPE_CODE | SEG_TYPE_EXEC_READ;
1058+
desc->s = DESC_TYPE_CODE_DATA;
1059+
desc->dpl = 0;
1060+
desc->p = 1;
1061+
desc->limit = 0xf;
1062+
desc->avl = 0;
1063+
desc->l = 0;
1064+
desc->d = SEG_OP_SIZE_32BIT;
1065+
desc->g = SEG_GRANULARITY_4KB;
1066+
desc->base2 = 0x00;
1067+
desc++;
1068+
} else {
1069+
/* Second entry is unused on 32-bit */
1070+
desc++;
1071+
}
10511072

10521073
/* __KERNEL_CS */
10531074
desc->limit0 = 0xffff;

0 commit comments

Comments
 (0)