[SeaBIOS] [PATCH] coreboot: Try to auto-detect if the CBFS anchor pointer is a relative pointer

Kevin O'Connor kevin at koconnor.net
Thu Jul 9 01:16:13 CEST 2015

If CONFIG_CBFS_LOCATION is set to a non-zero value then it means the
CBFS flash is not at the very end of memory.  In this case, it's
unclear if the anchor pointer is an absolute pointer or if it is
relative to CONFIG_CBFS_LOCATION.  Some devices have been using
absolute pointers, but it appears some devices are now using relative
pointers there.  Since the anchor pointer almost always points to a
structure in the last 64K of the rom, it should be possible to
auto-detect if the pointer is relative or not.

Signed-off-by: Kevin O'Connor <kevin at koconnor.net>

This parallels a commit in the Google seabios repo (commit a7539dcb).
However, that patch unconditionally changes to relative pointers -
which would defintely not work if the CBFS was setup with absolute

I'm hoping auto-detecting absolute vs relative will work in practice,
and therefore the same code can be used on both new and old devices.

 src/fw/coreboot.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/src/fw/coreboot.c b/src/fw/coreboot.c
index 8fd8449..e0f997d 100644
--- a/src/fw/coreboot.c
+++ b/src/fw/coreboot.c
@@ -421,6 +421,9 @@ coreboot_cbfs_init(void)
     struct cbfs_header *hdr = *(void **)(CONFIG_CBFS_LOCATION - 4);
+        // Looks like the pointer is relative to CONFIG_CBFS_LOCATION
+        hdr = (void*)hdr + CONFIG_CBFS_LOCATION;
     if (hdr->magic != cpu_to_be32(CBFS_HEADER_MAGIC)) {
         dprintf(1, "Unable to find CBFS (ptr=%p; got %x not %x)\n"
                 , hdr, hdr->magic, cpu_to_be32(CBFS_HEADER_MAGIC));

More information about the SeaBIOS mailing list