From a7421fb9cb91b4f6467d6e658f00aa8c34d7ebd8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ky=C3=B6sti=20M=C3=A4lkki?= Date: Tue, 5 Sep 2017 22:43:05 +0300 Subject: arch/x86 postcar: Fix use with stage_cache MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Postcar failed when loading from stage_cache, if romstage did not pass same pcf->stack on normal and resume paths. Change-Id: I853afb1fbdb942fd671d89950911c850c96e3af3 Signed-off-by: Kyösti Mälkki Signed-off-by: Aaron Durbin Reviewed-on: https://review.coreboot.org/21444 Tested-by: build bot (Jenkins) --- src/arch/x86/postcar_loader.c | 26 ++++++++++++++++---------- 1 file changed, 16 insertions(+), 10 deletions(-) (limited to 'src') diff --git a/src/arch/x86/postcar_loader.c b/src/arch/x86/postcar_loader.c index 287a0d807b..0d2f0b59b5 100644 --- a/src/arch/x86/postcar_loader.c +++ b/src/arch/x86/postcar_loader.c @@ -124,6 +124,17 @@ void *postcar_commit_mtrrs(struct postcar_frame *pcf) return (void *) pcf->stack; } +static void finalize_load(uintptr_t *stack_top_ptr, uintptr_t stack_top) +{ + *stack_top_ptr = stack_top; + /* + * Signal to rest of system that another update was made to the + * postcar program prior to running it. + */ + prog_segment_loaded((uintptr_t)stack_top_ptr, sizeof(uintptr_t), + SEG_FINAL); +} + static void load_postcar_cbfs(struct prog *prog, struct postcar_frame *pcf) { struct rmod_stage_load rsl = { @@ -140,14 +151,7 @@ static void load_postcar_cbfs(struct prog *prog, struct postcar_frame *pcf) if (rsl.params == NULL) die("No parameters found in after CAR program.\n"); - *(uintptr_t *)rsl.params = pcf->stack; - - /* - * Signal to rest of system that another update was made to the - * postcar program prior to running it. - */ - prog_segment_loaded((uintptr_t)rsl.params, sizeof(uintptr_t), - SEG_FINAL); + finalize_load(rsl.params, pcf->stack); if (!IS_ENABLED(CONFIG_NO_STAGE_CACHE)) stage_cache_add(STAGE_POSTCAR, prog); @@ -160,9 +164,11 @@ void run_postcar_phase(struct postcar_frame *pcf) postcar_commit_mtrrs(pcf); - if (!IS_ENABLED(CONFIG_NO_STAGE_CACHE) && romstage_handoff_is_resume()) + if (!IS_ENABLED(CONFIG_NO_STAGE_CACHE) && + romstage_handoff_is_resume()) { stage_cache_load_stage(STAGE_POSTCAR, &prog); - else + finalize_load(prog.arg, pcf->stack); + } else load_postcar_cbfs(&prog, pcf); prog_run(&prog); -- cgit v1.2.3