From 29ed4f56b5c41231081d2fccdf500dd307a3a8d3 Mon Sep 17 00:00:00 2001 From: Patrick Rudolph Date: Sun, 5 Jul 2020 08:46:55 +0200 Subject: arch/x86/gdt: Work around assembler bug The GDT loading did work fine on x86_64 a few months ago, but today it only works in QEMU, but not on real hardware or KVM-enabled QEMU. This might be related to toolchain changes. Use 64bit GDT loading on x86_64 and force the assembler to generate a 64bit address load on the GDT. This will make sure no 32bit (signed) displacement op is being generated, which points to the wrong address in longmode. Verified using readelf and made sure no R_X86_64_32S relocation symbol is emitted. Disassembled the romstage ELF and made sure the GDT address is 64bit in size. Tested on QEMU and KVM-enabled QEMU: Doesn't crash any more on KVM. Signed-off-by: Patrick Rudolph Change-Id: Ia824f90d9611e6e8db09bd62a05e6f990581f09a Reviewed-on: https://review.coreboot.org/c/coreboot/+/43136 Tested-by: build bot (Jenkins) Reviewed-by: Angel Pons --- src/arch/x86/assembly_entry.S | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'src/arch/x86/assembly_entry.S') diff --git a/src/arch/x86/assembly_entry.S b/src/arch/x86/assembly_entry.S index 0d8307bb1f..31670c29b6 100644 --- a/src/arch/x86/assembly_entry.S +++ b/src/arch/x86/assembly_entry.S @@ -15,12 +15,22 @@ #define _STACK_TOP _ecar_stack #endif +#ifdef __x86_64__ +.code64 +#else +.code32 +#endif + .section ".text._start", "ax", @progbits .global _start _start: /* Migrate GDT to this text segment */ +#ifdef __x86_64__ + call gdt_init64 +#else call gdt_init +#endif /* reset stack pointer to CAR/EARLYRAM stack */ mov $_STACK_TOP, %esp -- cgit v1.2.3