From 50ece62d3c3c874108bfe089c8f5061423152a39 Mon Sep 17 00:00:00 2001 From: Arthur Heymans Date: Tue, 4 May 2021 08:46:58 +0200 Subject: [PATCH] arch/x86/walkcbfs.S: Use FMAP instead of "cbfs master header" Tested on qemu/i440fx on X86_64: - Page tables are found in cbfs (finding a file works) - returns 0 when a file is not found - works when there is no cbfs file at the start of the FMAP, e.g. with the cbfs master header removed. Change-Id: Ibab657cc40cd5c09c3a73c54950b98ac45a98dbf Signed-off-by: Arthur Heymans Reviewed-on: https://review.coreboot.org/c/coreboot/+/52879 Reviewed-by: Patrick Georgi Tested-by: build bot (Jenkins) --- src/arch/x86/Makefile.inc | 1 + src/arch/x86/walkcbfs.S | 30 +++++------------------------- 2 files changed, 6 insertions(+), 25 deletions(-) diff --git a/src/arch/x86/Makefile.inc b/src/arch/x86/Makefile.inc index 07378920d8..a7d91a4753 100644 --- a/src/arch/x86/Makefile.inc +++ b/src/arch/x86/Makefile.inc @@ -91,6 +91,7 @@ else $(eval $(call early_x86_stage,bootblock,elf64-x86-64)) endif +$(call src-to-obj,bootblock,$(dir)/walkcbfs.S): $(obj)/fmap_config.h bootblock-y += walkcbfs.S endif # CONFIG_ARCH_BOOTBLOCK_X86_32 / CONFIG_ARCH_BOOTBLOCK_X86_64 diff --git a/src/arch/x86/walkcbfs.S b/src/arch/x86/walkcbfs.S index 393bcf54ed..4608e2c12a 100644 --- a/src/arch/x86/walkcbfs.S +++ b/src/arch/x86/walkcbfs.S @@ -1,13 +1,6 @@ /* SPDX-License-Identifier: GPL-2.0-only */ -#define CBFS_HEADER_PTR 0xfffffffc - -#define CBFS_HEADER_MAGIC 0 -#define CBFS_HEADER_VERSION (CBFS_HEADER_MAGIC + 4) -#define CBFS_HEADER_ROMSIZE (CBFS_HEADER_VERSION + 4) -#define CBFS_HEADER_BOOTBLOCKSIZE (CBFS_HEADER_ROMSIZE + 4) -#define CBFS_HEADER_ALIGN (CBFS_HEADER_BOOTBLOCKSIZE + 4) -#define CBFS_HEADER_OFFSET (CBFS_HEADER_ALIGN + 4) +#include /* we use this instead of CBFS_HEADER_ALIGN because the latter is retired. */ #define CBFS_ALIGNMENT 64 @@ -33,14 +26,7 @@ walkcbfs_asm: cld - mov CBFS_HEADER_PTR, %eax - mov CBFS_HEADER_ROMSIZE(%eax), %ecx - bswap %ecx - mov $0, %ebx - sub %ecx, %ebx /* ROM base address in ebx */ - mov CBFS_HEADER_OFFSET(%eax), %ecx - bswap %ecx - add %ecx, %ebx /* address where we start looking for LARCHIVEs */ + movl $FMAP_SECTION_COREBOOT_START, %ebx /* determine filename length */ mov $0, %eax @@ -96,17 +82,11 @@ tryharder: mov %ecx, %ebx check_for_exit: - /* look if we should exit: did we pass into the bootblock already? */ - mov CBFS_HEADER_PTR, %ecx - mov CBFS_HEADER_BOOTBLOCKSIZE(%ecx), %ecx - bswap %ecx - not %ecx - add $1, %ecx + /* if addr <= COREBOOT_END - 1, continue */ +#define FMAP_SECTION_COREBOOT_END (FMAP_SECTION_COREBOOT_START - 1 + FMAP_SECTION_COREBOOT_SIZE) + movl $FMAP_SECTION_COREBOOT_END, %ecx cmp %ecx, %ebx - /* if bootblockstart >= addr (==we're still in the data area), - * jump back - */ jbe walker out: