From c7de73d96ffdeed7d6a5ee64cfc5a92ec29a95e7 Mon Sep 17 00:00:00 2001 From: C4Phone Date: Sun, 15 Nov 2015 22:14:24 -0600 Subject: [PATCH] try fixing #38 --- mp3/student-distrib/inc/klibs/palloc.h | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/mp3/student-distrib/inc/klibs/palloc.h b/mp3/student-distrib/inc/klibs/palloc.h index 27fee95f..68001641 100644 --- a/mp3/student-distrib/inc/klibs/palloc.h +++ b/mp3/student-distrib/inc/klibs/palloc.h @@ -250,13 +250,23 @@ PhysPageManager::PhysPageManager(multiboot_info_t* mbi) end_high++; end_low = start_low + mmap->length_low; + // Avoid addition overflow. if(((1 - (1<<10)) << 22) & start_high) continue; + + // Avoid memory larger than 4GB + if(start_high > 0) + continue; start_idx = (start_low >> 22) | (start_high << 10); + // Avoid addition overflow. if(((1 - (1<<10)) << 22) & end_high) continue; - end_idx = (end_low >> 22) | (end_high << 10); + + // Avoid memory larger than 4GB + if(end_high == 0) + end_idx = (end_low >> 22) | (end_high << 10); + else end_idx = 0xffc; // This is an available memory. if(mmap->type == 1)