Simon Glass has uploaded this change for review. ( https://review.coreboot.org/c/coreboot/+/40243 )
Change subject: fmap: Avoid unaligned access ......................................................................
fmap: Avoid unaligned access
The fmap header has unaligned fields in it. Some CPUs do not like this, and it is not very friendly to hide this sort of thing in innocuous code.
Fix it by copying the data into an aligned location first.
BUG=b:153203967 TEST=See this output now: Getting SPI ROM info. FMAP: Found "FLASH" version 1.1 at 0xb04000. FMAP: base = 0xff000000 size = 0x1000000 #areas = 29
Signed-off-by: Simon Glass sjg@chromium.org Change-Id: I6ac83766616cb2107b75eba6995cd09b4fc90968 --- M src/lib/fmap.c 1 file changed, 12 insertions(+), 4 deletions(-)
git pull ssh://review.coreboot.org:29418/coreboot refs/changes/43/40243/1
diff --git a/src/lib/fmap.c b/src/lib/fmap.c index ecd23f6..4a67053 100644 --- a/src/lib/fmap.c +++ b/src/lib/fmap.c @@ -35,10 +35,15 @@
static void report(const struct fmap *fmap) { + uint64_t base; + uint32_t size; + print_once(BIOS_DEBUG, "FMAP: Found "%s" version %d.%d at %#x.\n", fmap->name, fmap->ver_major, fmap->ver_minor, FMAP_OFFSET); + memcpy(&base, &fmap->base, sizeof(fmap->base)); + memcpy(&size, &fmap->size, sizeof(fmap->size)); print_once(BIOS_DEBUG, "FMAP: base = %#llx size = %#x #areas = %d\n", - (long long)fmap->base, fmap->size, fmap->nareas); + base, size, fmap->nareas); fmap_print_once = 1; }
@@ -155,6 +160,7 @@
while (1) { struct fmap_area *area; + uint32_t area_offset, area_size;
area = rdev_mmap(&fmrd, offset, sizeof(*area));
@@ -166,12 +172,14 @@ offset += sizeof(struct fmap_area); continue; } + memcpy(&area_offset, &area->offset, sizeof(area->offset)); + memcpy(&area_size, &area->size, sizeof(area->size));
printk(BIOS_DEBUG, "FMAP: area %s found @ %x (%d bytes)\n", - name, area->offset, area->size); + name, area_offset, area_size);
- ar->offset = area->offset; - ar->size = area->size; + ar->offset = area_offset; + ar->size = area_size;
rdev_munmap(&fmrd, area);