[Skiboot] [RFC v2 PATCH 5/6] mem_check(): Correct alignment assumptions

Stewart Smith stewart at linux.ibm.com
Thu Jun 28 12:55:00 AEST 2018


Back in the dim dark past, mem_check() was written to take the
assumption that mem regions need to be sizeof(alloc_hdr) aligned.

I can't see any real reason for this, so change it to sizeof(long)
aligned as we count space by number of longs, so at least that kind of
makes sense.

We hit this assert in a future patch when preserving BOOTKERNEL across
fast reboots.

Signed-off-by: Stewart Smith <stewart at linux.ibm.com>
---
 core/mem_region.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/core/mem_region.c b/core/mem_region.c
index 571ee52c929c..ce1280b64073 100644
--- a/core/mem_region.c
+++ b/core/mem_region.c
@@ -548,12 +548,12 @@ bool mem_check(const struct mem_region *region)
 	struct free_hdr *f;
 
 	/* Check it's sanely aligned. */
-	if (region->start % sizeof(struct alloc_hdr)) {
+	if (region->start % sizeof(long)) {
 		prerror("Region '%s' not sanely aligned (%llx)\n",
 			region->name, (unsigned long long)region->start);
 		return false;
 	}
-	if ((long)region->len % sizeof(struct alloc_hdr)) {
+	if ((long)region->len % sizeof(long)) {
 		prerror("Region '%s' not sane length (%llu)\n",
 			region->name, (unsigned long long)region->len);
 		return false;
-- 
2.17.1



More information about the Skiboot mailing list