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>
This commit is contained in:
parent
21ca7753bf
commit
71bc9f0eba
|
@ -8,6 +8,20 @@ subdirs-$(CONFIG_ARCH_BOOTBLOCK_X86_64) += 64bit
|
||||||
subdirs-y += cache
|
subdirs-y += cache
|
||||||
|
|
||||||
subdirs-$(CONFIG_PARALLEL_MP) += name
|
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-$(CONFIG_PARALLEL_MP) += mp_init.c
|
||||||
|
|
||||||
ramstage-y += backup_default_smm.c
|
ramstage-y += backup_default_smm.c
|
||||||
|
|
|
@ -24,6 +24,9 @@
|
||||||
#include <thread.h>
|
#include <thread.h>
|
||||||
#include <types.h>
|
#include <types.h>
|
||||||
|
|
||||||
|
/* Generated header */
|
||||||
|
#include <ramstage/cpu/x86/smm_start32_offset.h>
|
||||||
|
|
||||||
#include <security/intel/stm/SmmStm.h>
|
#include <security/intel/stm/SmmStm.h>
|
||||||
|
|
||||||
struct mp_callback {
|
struct mp_callback {
|
||||||
|
@ -672,7 +675,6 @@ struct mp_state {
|
||||||
uintptr_t perm_smbase;
|
uintptr_t perm_smbase;
|
||||||
size_t perm_smsize;
|
size_t perm_smsize;
|
||||||
size_t smm_save_state_size;
|
size_t smm_save_state_size;
|
||||||
uintptr_t reloc_start32_offset;
|
|
||||||
bool do_smm;
|
bool do_smm;
|
||||||
} mp_state;
|
} mp_state;
|
||||||
|
|
||||||
|
@ -738,7 +740,7 @@ static asmlinkage void smm_do_relocation(void *arg)
|
||||||
stm_setup(mseg, p->cpu,
|
stm_setup(mseg, p->cpu,
|
||||||
perm_smbase,
|
perm_smbase,
|
||||||
mp_state.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);
|
adjust_smm_apic_id_map(&smm_params);
|
||||||
|
|
||||||
mp_state.reloc_start32_offset = smm_params.stub_params->start32_offset;
|
|
||||||
|
|
||||||
return CB_SUCCESS;
|
return CB_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -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: stack_top = 0x%x\n", __func__, stub_params->stack_top);
|
||||||
printk(BIOS_DEBUG, "%s: per cpu stack_size = 0x%x\n", __func__,
|
printk(BIOS_DEBUG, "%s: per cpu stack_size = 0x%x\n", __func__,
|
||||||
stub_params->stack_size);
|
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);
|
printk(BIOS_DEBUG, "%s: runtime.smm_size = 0x%zx\n", __func__, smm_size);
|
||||||
|
|
||||||
smm_stub_place_staggered_entry_points(params);
|
smm_stub_place_staggered_entry_points(params);
|
||||||
|
|
|
@ -31,9 +31,6 @@ fxsave_area_size:
|
||||||
* into the table. */
|
* into the table. */
|
||||||
apic_to_cpu_num:
|
apic_to_cpu_num:
|
||||||
.fill CONFIG_MAX_CPUS,2,0xffff
|
.fill CONFIG_MAX_CPUS,2,0xffff
|
||||||
/* allows the STM to bring up SMM in 32-bit mode */
|
|
||||||
start32_offset:
|
|
||||||
.long smm_trampoline32 - _start
|
|
||||||
|
|
||||||
.data
|
.data
|
||||||
/* Provide fallback stack to use when a valid CPU number cannot be found. */
|
/* Provide fallback stack to use when a valid CPU number cannot be found. */
|
||||||
|
|
|
@ -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
|
|
@ -107,8 +107,6 @@ struct smm_stub_params {
|
||||||
* contiguous like the 1:1 mapping it is up to the caller of the stub
|
* contiguous like the 1:1 mapping it is up to the caller of the stub
|
||||||
* loader to adjust this mapping. */
|
* loader to adjust this mapping. */
|
||||||
u16 apic_id_to_cpu[CONFIG_MAX_CPUS];
|
u16 apic_id_to_cpu[CONFIG_MAX_CPUS];
|
||||||
/* STM's 32bit entry into SMI handler */
|
|
||||||
u32 start32_offset;
|
|
||||||
} __packed;
|
} __packed;
|
||||||
|
|
||||||
/* smm_handler_t is called with arg of smm_module_params pointer. */
|
/* smm_handler_t is called with arg of smm_module_params pointer. */
|
||||||
|
|
Loading…
Reference in New Issue