From 1e1d5d60f72efa006dad18cab9f49f381d79cd9b Mon Sep 17 00:00:00 2001 From: Arthur Heymans Date: Tue, 16 Mar 2021 13:44:05 +0100 Subject: [PATCH] cpu/x86/smm_module_loaderv2.c: Remove noop stack size check The argument provided to the function was always the same as the one computed inside the function so drop the argument. Change-Id: I14abf400dce1bd9b03e401b6619a0500a650fa0e Signed-off-by: Arthur Heymans Reviewed-on: https://review.coreboot.org/c/coreboot/+/51527 Tested-by: build bot (Jenkins) Reviewed-by: Angel Pons --- src/cpu/x86/smm/smm_module_loaderv2.c | 20 +++++--------------- 1 file changed, 5 insertions(+), 15 deletions(-) diff --git a/src/cpu/x86/smm/smm_module_loaderv2.c b/src/cpu/x86/smm/smm_module_loaderv2.c index 8354568b4b..5c45fcc017 100644 --- a/src/cpu/x86/smm/smm_module_loaderv2.c +++ b/src/cpu/x86/smm/smm_module_loaderv2.c @@ -243,8 +243,7 @@ static int smm_place_entry_code(uintptr_t smbase, unsigned int num_cpus, * Place stacks in base -> base + size region, but ensure the stacks don't * overlap the staggered entry points. */ -static void *smm_stub_place_stacks(char *base, size_t size, - struct smm_loader_params *params) +static void *smm_stub_place_stacks(char *base, struct smm_loader_params *params) { size_t total_stack_size; char *stacks_top; @@ -256,17 +255,11 @@ static void *smm_stub_place_stacks(char *base, size_t size, printk(BIOS_DEBUG, "%s: cpus: %zx : stack space: needed -> %zx\n", __func__, params->num_concurrent_stacks, total_stack_size); - printk(BIOS_DEBUG, " available -> %zx : per_cpu_stack_size : %zx\n", - size, params->per_cpu_stack_size); /* There has to be at least one stack user. */ if (params->num_concurrent_stacks < 1) return NULL; - /* Total stack size cannot fit. */ - if (total_stack_size > size) - return NULL; - /* Stacks extend down to SMBASE */ stacks_top = &base[total_stack_size]; printk(BIOS_DEBUG, "%s: exit, stack_top %p\n", __func__, stacks_top); @@ -388,14 +381,9 @@ static int smm_module_setup_stub(void *const smbase, const size_t smm_size, * for default handler, but for relocated handler it lives at the beginning * of SMRAM which is TSEG base */ - const size_t total_stack_size = params->num_concurrent_stacks * - params->per_cpu_stack_size; - stacks_top = smm_stub_place_stacks(smbase, total_stack_size, - params); + stacks_top = smm_stub_place_stacks(smbase, params); if (stacks_top == NULL) { - printk(BIOS_ERR, "%s: not enough space for stacks\n", __func__); - printk(BIOS_ERR, "%s: ....need -> %p : available -> %zx\n", __func__, - base, total_stack_size); + printk(BIOS_ERR, "%s: error assigning stacks\n", __func__); return -1; } params->stack_top = stacks_top; @@ -418,6 +406,8 @@ static int smm_module_setup_stub(void *const smbase, const size_t smm_size, stub_params->fxsave_area = (uintptr_t)fxsave_area; stub_params->fxsave_area_size = FXSAVE_SIZE; + const size_t total_stack_size = + params->num_concurrent_stacks * params->per_cpu_stack_size; printk(BIOS_DEBUG, "%s: stack_end = 0x%lx\n", __func__, stub_params->stack_top - total_stack_size); printk(BIOS_DEBUG,