diff options
author | Arthur Heymans <arthur@aheymans.xyz> | 2022-05-24 08:46:09 +0200 |
---|---|---|
committer | Lean Sheng Tan <sheng.tan@9elements.com> | 2023-04-06 15:19:00 +0000 |
commit | 71bc9f0eba4fce8ffa2b0b90e388f3596ffb6a5d (patch) | |
tree | 55a6762b4b59e78f88a365cc2203a62749293965 /src/cpu/x86 | |
parent | 21ca7753bf619f1de8dca79fd1113a9c22335f11 (diff) |
cpu/x86/mp_init.c: Generate a C header to get start32 offset
In the current design the relocatable parameters are used to know the
offset of the 32bit startpoint. This requires back and forward
interaction between the stub, the loader and the mp init code. This
makes the code hard to read.
This is static information known at buildtime, so a better way to deal
with this is to generate a header that contains this offset.
Change-Id: Ic01badd2af11a6e1dbc27c8e928916fedf104b5b
Signed-off-by: Arthur Heymans <arthur@aheymans.xyz>
Reviewed-on: https://review.coreboot.org/c/coreboot/+/64625
Reviewed-by: Patrick Rudolph <siro@das-labor.org>
Reviewed-by: Maximilian Brune <maximilian.brune@9elements.com>
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Diffstat (limited to 'src/cpu/x86')
-rw-r--r-- | src/cpu/x86/Makefile.inc | 14 | ||||
-rw-r--r-- | src/cpu/x86/mp_init.c | 8 | ||||
-rw-r--r-- | src/cpu/x86/smm/smm_module_loader.c | 2 | ||||
-rw-r--r-- | src/cpu/x86/smm/smm_stub.S | 3 | ||||
-rw-r--r-- | src/cpu/x86/smm_start32_offset.h.template | 9 |
5 files changed, 27 insertions, 9 deletions
diff --git a/src/cpu/x86/Makefile.inc b/src/cpu/x86/Makefile.inc index 3ef3a90313..2381b6fa20 100644 --- a/src/cpu/x86/Makefile.inc +++ b/src/cpu/x86/Makefile.inc @@ -8,6 +8,20 @@ subdirs-$(CONFIG_ARCH_BOOTBLOCK_X86_64) += 64bit subdirs-y += cache subdirs-$(CONFIG_PARALLEL_MP) += name + +ifeq ($(CONFIG_HAVE_SMI_HANDLER),y) +$(obj)/ramstage/cpu/x86/smm_start32_offset.h: $(dir)/smm_start32_offset.h.template $(obj)/smmstub/smmstub.elf + cp $< $@.temp + sed -i 's/##START32_OFFSET##/0x'$$($(NM_smmstub) -an $(obj)/smmstub/smmstub.elf | grep smm_trampolin | cut -d' ' -f1)'/' $@.temp + mv $@.temp $@ +else +$(obj)/ramstage/cpu/x86/smm_start32_offset.h: $(dir)/smm_start32_offset.h.template + cp $< $@.temp + sed -i 's/##START32_OFFSET##/0x0/' $@.temp + mv $@.temp $@ +endif + +$(call src-to-obj,ramstage,$(dir)/mp_init.c): $(obj)/ramstage/cpu/x86/smm_start32_offset.h ramstage-$(CONFIG_PARALLEL_MP) += mp_init.c ramstage-y += backup_default_smm.c diff --git a/src/cpu/x86/mp_init.c b/src/cpu/x86/mp_init.c index 2909022b34..01ca64e87e 100644 --- a/src/cpu/x86/mp_init.c +++ b/src/cpu/x86/mp_init.c @@ -24,6 +24,9 @@ #include <thread.h> #include <types.h> +/* Generated header */ +#include <ramstage/cpu/x86/smm_start32_offset.h> + #include <security/intel/stm/SmmStm.h> struct mp_callback { @@ -672,7 +675,6 @@ struct mp_state { uintptr_t perm_smbase; size_t perm_smsize; size_t smm_save_state_size; - uintptr_t reloc_start32_offset; bool do_smm; } mp_state; @@ -738,7 +740,7 @@ static asmlinkage void smm_do_relocation(void *arg) stm_setup(mseg, p->cpu, perm_smbase, mp_state.perm_smbase, - mp_state.reloc_start32_offset); + SMM_START32_OFFSET); } } @@ -770,8 +772,6 @@ static enum cb_err install_relocation_handler(int num_cpus, size_t save_state_si } adjust_smm_apic_id_map(&smm_params); - mp_state.reloc_start32_offset = smm_params.stub_params->start32_offset; - return CB_SUCCESS; } diff --git a/src/cpu/x86/smm/smm_module_loader.c b/src/cpu/x86/smm/smm_module_loader.c index 6452707f75..6cd9956dd6 100644 --- a/src/cpu/x86/smm/smm_module_loader.c +++ b/src/cpu/x86/smm/smm_module_loader.c @@ -277,8 +277,6 @@ static int smm_module_setup_stub(const uintptr_t smbase, const size_t smm_size, printk(BIOS_DEBUG, "%s: stack_top = 0x%x\n", __func__, stub_params->stack_top); printk(BIOS_DEBUG, "%s: per cpu stack_size = 0x%x\n", __func__, stub_params->stack_size); - printk(BIOS_DEBUG, "%s: runtime.start32_offset = 0x%x\n", __func__, - stub_params->start32_offset); printk(BIOS_DEBUG, "%s: runtime.smm_size = 0x%zx\n", __func__, smm_size); smm_stub_place_staggered_entry_points(params); diff --git a/src/cpu/x86/smm/smm_stub.S b/src/cpu/x86/smm/smm_stub.S index 02532a4d9f..19e9c501ab 100644 --- a/src/cpu/x86/smm/smm_stub.S +++ b/src/cpu/x86/smm/smm_stub.S @@ -31,9 +31,6 @@ fxsave_area_size: * into the table. */ apic_to_cpu_num: .fill CONFIG_MAX_CPUS,2,0xffff -/* allows the STM to bring up SMM in 32-bit mode */ -start32_offset: -.long smm_trampoline32 - _start .data /* Provide fallback stack to use when a valid CPU number cannot be found. */ diff --git a/src/cpu/x86/smm_start32_offset.h.template b/src/cpu/x86/smm_start32_offset.h.template new file mode 100644 index 0000000000..023bca78d7 --- /dev/null +++ b/src/cpu/x86/smm_start32_offset.h.template @@ -0,0 +1,9 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ + +#ifndef _SMM_START32_OFFSET_H +#define _SMM_START32_OFFSET_H + +/* This gets filled in after building the SMM stub */ +#define SMM_START32_OFFSET ##START32_OFFSET## + +#endif |