From e3c2391fca4464ac4d2862e480ddc93a1434152d Mon Sep 17 00:00:00 2001 From: Julius Werner Date: Mon, 26 Nov 2018 15:57:59 -0800 Subject: [PATCH] cbmem: Fix remaining mapped memory accesses to use aligned_memcpy() aligned_memcpy() was introduced to fix issues with platforms that don't allow unaligned accesses to areas mapped with /dev/mem, but we missed a few spots. Fix them. Change-Id: I97ea953455b41a50023ceaca7eb148d60e6b8097 Signed-off-by: Julius Werner Reviewed-on: https://review.coreboot.org/c/29848 Tested-by: build bot (Jenkins) Reviewed-by: Aaron Durbin --- util/cbmem/cbmem.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/util/cbmem/cbmem.c b/util/cbmem/cbmem.c index 8ab80b0a59..90ad55e070 100644 --- a/util/cbmem/cbmem.c +++ b/util/cbmem/cbmem.c @@ -279,7 +279,7 @@ static struct lb_cbmem_ref parse_cbmem_ref(const struct lb_cbmem_ref *cbmem_ref) { struct lb_cbmem_ref ret; - ret = *cbmem_ref; + aligned_memcpy(&ret, cbmem_ref, sizeof(ret)); if (cbmem_ref->size < sizeof(*cbmem_ref)) ret.cbmem_addr = (uint32_t)ret.cbmem_addr; @@ -651,7 +651,7 @@ static void dump_timestamps(int mach_readable) sorted_tst_p = malloc(size); if (!sorted_tst_p) die("Failed to allocate memory"); - memcpy(sorted_tst_p, tst_p, size); + aligned_memcpy(sorted_tst_p, tst_p, size); qsort(&sorted_tst_p->entries[0], sorted_tst_p->num_entries, sizeof(struct timestamp_entry), compare_timestamp_entries);