From 816d956dfd18c0d59f092d880e3513b1e3e3c677 Mon Sep 17 00:00:00 2001 From: Patrick Rudolph Date: Thu, 10 Apr 2025 08:26:40 +0200 Subject: [PATCH] arch/x86: Use defines for GDT segments Stop using magic values and use defines for Global Descriptor Table (GDT) offsets. Use the existing defines from the corresponding headers. Change-Id: I40c15f6341bdef9cd457619ec81e7ac624ec2d63 Signed-off-by: Patrick Rudolph Reviewed-on: https://review.coreboot.org/c/coreboot/+/87254 Reviewed-by: Felix Held Tested-by: build bot (Jenkins) --- src/arch/x86/wakeup.S | 8 +++++--- src/cpu/x86/smm/smm_stub.S | 5 +++-- src/device/oprom/realmode/x86_asm.S | 2 +- 3 files changed, 9 insertions(+), 6 deletions(-) diff --git a/src/arch/x86/wakeup.S b/src/arch/x86/wakeup.S index 7462dadbe8..7bff006d14 100644 --- a/src/arch/x86/wakeup.S +++ b/src/arch/x86/wakeup.S @@ -1,5 +1,7 @@ /* SPDX-License-Identifier: GPL-2.0-only */ +#include + #define WAKEUP_BASE 0x600 #define RELOCATED(x) (x - __wakeup + WAKEUP_BASE) @@ -29,7 +31,7 @@ __wakeup: add $8, %rax push %rax pushfq - push $0x10 + push $RAM_CODE_SEG lea 3(%rip), %rax push %rax iretq @@ -58,7 +60,7 @@ __wakeup: movw %ax, (__wakeup_segment) /* Activate the right segment descriptor real mode. */ - ljmp $0x28, $RELOCATED(1f) + ljmp $RAM_CODE16_SEG, $RELOCATED(1f) 1: .code16 /* 16 bit code from here on... */ @@ -68,7 +70,7 @@ __wakeup: * configurations (limits, writability, etc.) once * protected mode is turned off. */ - mov $0x30, %ax + mov $RAM_DATA16_SEG, %ax mov %ax, %ds mov %ax, %es mov %ax, %fs diff --git a/src/cpu/x86/smm/smm_stub.S b/src/cpu/x86/smm/smm_stub.S index 9b4b966f7c..ae8e047f4e 100644 --- a/src/cpu/x86/smm/smm_stub.S +++ b/src/cpu/x86/smm/smm_stub.S @@ -9,6 +9,7 @@ * found in smm.h. */ +#include #include #include #include @@ -93,7 +94,7 @@ untampered_lapic: movl %eax, %cr0 /* Enable protected mode */ - ljmpl $0x8, $smm_trampoline32 + ljmpl $ROM_CODE_SEG, $smm_trampoline32 .align 4 smm_relocate_gdt: @@ -124,7 +125,7 @@ smm_relocate_gdt_end: .global smm_trampoline32 smm_trampoline32: /* Use flat data segment */ - movw $0x10, %ax + movw $ROM_DATA_SEG, %ax movw %ax, %ds movw %ax, %es movw %ax, %ss diff --git a/src/device/oprom/realmode/x86_asm.S b/src/device/oprom/realmode/x86_asm.S index a2c4aa56b9..ff33c0f4ba 100644 --- a/src/device/oprom/realmode/x86_asm.S +++ b/src/device/oprom/realmode/x86_asm.S @@ -150,7 +150,7 @@ __realmode_call: mov %ax, %es mov %ax, %fs mov %ax, %gs - mov $0x40, %ax + mov $RAM_DATA_ACPI_SEG, %ax mov %ax, %ds pop %ax