Skip to content

Commit

Permalink
mem_check(): Correct alignment assumptions
Browse files Browse the repository at this point in the history
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@linux.ibm.com>
  • Loading branch information
stewartsmith committed Jul 17, 2018
1 parent 4757519 commit 2c30ddb
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions core/mem_region.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 2c30ddb

Please sign in to comment.