From 2b69310adf67a9518e7ef6c974177de844ce8357 Mon Sep 17 00:00:00 2001 From: Alexander Boettcher Date: Tue, 10 Feb 2015 21:11:59 +0100 Subject: [PATCH] nova: detect overlapping module regions Detect overlapping regions which should not overlap and print some meaningful message instead of dying with some mysterious page fault. Issue #1402 --- repos/base-nova/src/core/platform.cc | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/repos/base-nova/src/core/platform.cc b/repos/base-nova/src/core/platform.cc index 22efb5c717..353b227161 100644 --- a/repos/base-nova/src/core/platform.cc +++ b/repos/base-nova/src/core/platform.cc @@ -405,6 +405,30 @@ Platform::Platform() : prev_cmd_line_page = curr_cmd_line_page; } + /* sanity checks that regions don't overlap - could be bootloader issue */ + mem_desc = (Hip::Mem_desc *)mem_desc_base; + for (unsigned i = 0; i < num_mem_desc; i++, mem_desc++) { + + if (mem_desc->type == Hip::Mem_desc::AVAILABLE_MEMORY) continue; + + Hip::Mem_desc * mem_d = (Hip::Mem_desc *)mem_desc_base; + for (unsigned j = 0; j < num_mem_desc; j++, mem_d++) { + if (mem_d->type == Hip::Mem_desc::AVAILABLE_MEMORY) continue; + if (mem_d == mem_desc) continue; + + /* if regions are disjunct all is fine */ + if ((mem_d->addr + mem_d->size <= mem_desc->addr) || + (mem_d->addr >= mem_desc->addr + mem_desc->size)) + continue; + + PERR("region overlap [0x%8llx+0x%8llx] (%d) with " + "[0x%8llx+0x%8llx] (%d)", + mem_desc->addr, mem_desc->size, mem_desc->type, + mem_d->addr, mem_d->size, mem_d->type); + nova_die(); + } + } + /* * From now on, it is save to use the core allocators... */