[coreboot-gerrit] New patch to review for coreboot: [UNVERIFIED] lb_new_record: Make sure that records are 8-byte aligned

Jonathan Neuschäfer (j.neuschaefer@gmx.net) gerrit at coreboot.org
Fri May 27 09:26:15 CEST 2016


Jonathan Neuschäfer (j.neuschaefer at gmx.net) just uploaded a new patch set to gerrit, which you can find at https://review.coreboot.org/14985

-gerrit

commit d79d0e2abe4ca3e30d14cf2c5579e159c88fee8f
Author: Jonathan Neuschäfer <j.neuschaefer at gmx.net>
Date:   Fri May 27 09:05:03 2016 +0200

    [UNVERIFIED] lb_new_record: Make sure that records are 8-byte aligned
    
    Some records contain uint64_t fields that could trigger an unaligned
    memory access fault on RISC-V.
    
    I have not yet tested whether this patch breaks any other architectures.
    
    Change-Id: I54ff68ca00009a0977249adc839fadc4a1d6881d
    Signed-off-by: Jonathan Neuschäfer <j.neuschaefer at gmx.net>
---
 src/lib/coreboot_table.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/src/lib/coreboot_table.c b/src/lib/coreboot_table.c
index 3af2be6..cf37776 100644
--- a/src/lib/coreboot_table.c
+++ b/src/lib/coreboot_table.c
@@ -87,6 +87,10 @@ struct lb_record *lb_new_record(struct lb_header *header)
 	struct lb_record *rec;
 	rec = lb_last_record(header);
 	if (header->table_entries) {
+		/* Make sure that the next record is sufficiently aligned to
+		 * avoid an unaligned memory access. */
+		rec->size = ALIGN_UP(rec->size, sizeof(uint64_t));
+
 		header->table_bytes += rec->size;
 	}
 	rec = lb_last_record(header);



More information about the coreboot-gerrit mailing list