Arthur Heymans has uploaded this change for review. ( https://review.coreboot.org/c/coreboot/+/63710 )
Change subject: lib/coreboot_table.c: Make sure entries are aligned ......................................................................
lib/coreboot_table.c: Make sure entries are aligned
Unaligned pointer access may be invalid code on some architectures.
By padding each entry size to 64bit it is possible to ensure each table entry is aligned to the size of pointers of the payload. This for instance the case when coreboot runs as 32bit code but the payload is 64bit.
Change-Id: I278245894ef2f23c4f058abb8467e7af41cadcbd Signed-off-by: Arthur Heymans arthur@aheymans.xyz --- M src/lib/coreboot_table.c 1 file changed, 6 insertions(+), 0 deletions(-)
git pull ssh://review.coreboot.org:29418/coreboot refs/changes/10/63710/1
diff --git a/src/lib/coreboot_table.c b/src/lib/coreboot_table.c index 3ceab37..fdea98d 100644 --- a/src/lib/coreboot_table.c +++ b/src/lib/coreboot_table.c @@ -73,6 +73,12 @@ { struct lb_record *rec; rec = lb_last_record(header); + /* + * Pad all record sizes to make sure each record is aligned to the size of pointers. + * Because the environment decoding the coreboot tables can have a different pointer + * size than coreboot, simply use 64bit all the time. + */ + rec->size = ALIGN_UP(rec->size, 8); if (header->table_entries) header->table_bytes += rec->size; rec = lb_last_record(header);