From 25817b0854097a6a93e8cf066c83f30d65ed6656 Mon Sep 17 00:00:00 2001 From: Ben Gras Date: Wed, 19 Sep 2012 15:29:53 +0200 Subject: [PATCH] vm: change NO_MEM to a more impossible value fixes an assert() firing when starting X. thanks to the report by pikpik. . NO_MEM was 0, which is actually an existing piece of physical memory. it can't be allocated because it's reserved for bios data (by the kernel), but it can be mapped in (e.g. by X), causing sanity check disaster. . NONCONTIGUOUS is also obsolete as all allocations are single-page now, i.e. NONCONTIGUOUS is really the default and only mode. --- servers/vm/alloc.c | 21 +++++++-------------- servers/vm/vm.h | 4 +--- 2 files changed, 8 insertions(+), 17 deletions(-) diff --git a/servers/vm/alloc.c b/servers/vm/alloc.c index 5d9e6e497..5dbcbaa27 100644 --- a/servers/vm/alloc.c +++ b/servers/vm/alloc.c @@ -376,8 +376,14 @@ struct memlist *alloc_mem_in_list(phys_bytes bytes, u32_t flags, phys_bytes know assert(!(flags & PAF_CONTIG)); - if(known != MAP_NONE) + if(known != MAP_NONE) { + if(known == NO_MEM) { + printf("VM: odd mem for alloc_mem_in_list: 0x%lx\n", + known); + return NULL; + } phys_count = known; + } do { struct memlist *ml; @@ -426,19 +432,6 @@ struct memlist *alloc_mem_in_list(phys_bytes bytes, u32_t flags, phys_bytes know rempages--; } while(rempages > 0); - { - struct memlist *ml; - for(ml = head; ml; ml = ml->next) { - assert(ml->phys); -#if NONCONTIGUOUS - if(!(flags & PAF_CONTIG)) { - if(ml->next) - assert(ml->phys + ml->length != ml->next->phys); - } -#endif - } - } - return head; } diff --git a/servers/vm/vm.h b/servers/vm/vm.h index 66287dc37..edf205c41 100644 --- a/servers/vm/vm.h +++ b/servers/vm/vm.h @@ -1,6 +1,4 @@ -#define NO_MEM ((phys_clicks) 0) /* returned by alloc_mem() with mem is up */ - /* Memory flags to pt_allocmap() and alloc_mem(). */ #define PAF_CLEAR 0x01 /* Clear physical memory. */ #define PAF_CONTIG 0x02 /* Physically contiguous. */ @@ -21,7 +19,6 @@ /* VM behaviour */ #define MEMPROTECT 0 /* Slab objects not mapped. Access with USE() */ #define JUNKFREE 0 /* Fill freed pages with junk */ -#define NONCONTIGUOUS 0 /* Make phys pages max. noncontiguous */ /* How noisy are we supposed to be? */ #define VERBOSE 0 @@ -51,4 +48,5 @@ #define WMF_VERIFY 0x08 /* Check pagetable contents. */ #define MAP_NONE 0xFFFFFFFE +#define NO_MEM ((phys_clicks) MAP_NONE) /* returned by alloc_mem() with mem is up */ -- 2.44.0