From fa74015cb0349960e8c5a09b93c9f9288000f9d9 Mon Sep 17 00:00:00 2001 From: John Tsiombikas Date: Thu, 2 May 2019 02:25:57 +0300 Subject: [PATCH] fixed bug in physical page allocator init: would mark way much more memory as used by the allocation bitmap, than necessary. --- src/mem.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/src/mem.c b/src/mem.c index 95562b3..4125fe4 100644 --- a/src/mem.c +++ b/src/mem.c @@ -120,14 +120,17 @@ void init_mem(void) } printf("Total usable RAM: %u.%u %s\n", total, 100 * rem / 1024, suffix[i]); - bmsize = max_pg / 8; /* size of the useful bitmap in bytes */ + /* size of the useful part of the bitmap in bytes padded to 4-byte + * boundaries to allow 32bit at a time operations. + */ + bmsize = (max_pg / 32 + 1) * 4; - /* mark all pages occupied by the bitmap as usef */ + /* mark all pages occupied by the bitmap as used */ used_end = (uint32_t)bitmap + bmsize - 1; - printf("marking pages up to %x (page: %d) as used\n", used_end, ADDR_TO_PAGE(used_end)); - - for(i=0; i<=used_end; i++) { + max_pg = ADDR_TO_PAGE(used_end); + printf("marking pages up to %x (page: %d) as used\n", used_end, max_pg); + for(i=0; i<=max_pg; i++) { mark_page(i, USED); } } -- 1.7.10.4