32fbbd370c
shared with the kernel, mapped into kernel address space; kernel is notified of its location. kernel segment size is increased to make it fit. - map in kernel and other processes that don't have their own page table using single 4MB (global) mapping. - new sanity check facility: objects that are allocated with the slab allocator are, when running with sanity checking on, marked readonly until they are explicitly unlocked using the USE() macro. - another sanity check facility: collect all uses of memory and see if they don't overlap with (a) eachother and (b) free memory - own munmap() and munmap_text() functions. - exec() recovers from out-of-memory conditions properly now; this solves some weird exec() behaviour - chew off memory from the same side of the chunk as where we start scanning, solving some memory fragmentation issues - use avl trees for freelist and phys_ranges in regions - implement most useful part of munmap() - remap() stuff is GQ's for shared memory
71 lines
1.7 KiB
C
71 lines
1.7 KiB
C
#ifndef _SANITYCHECK_H
|
|
#define _SANITYCHECK_H 1
|
|
|
|
#include "vm.h"
|
|
#include "glo.h"
|
|
|
|
#if SANITYCHECKS
|
|
|
|
/* This macro is used in the sanity check functions, where file and
|
|
* line are function arguments.
|
|
*/
|
|
#define MYASSERT(c) do { if(!(c)) { \
|
|
printf("VM:%s:%d: %s failed\n", file, line, #c); \
|
|
vm_panic("sanity check failed", NO_NUM); } } while(0)
|
|
|
|
#define SLABSANITYCHECK(l) if((l) <= vm_sanitychecklevel) { \
|
|
slab_sanitycheck(__FILE__, __LINE__); }
|
|
|
|
#define SANITYCHECK(l) if(!nocheck && ((l) <= vm_sanitychecklevel)) { \
|
|
struct vmproc *vmp; \
|
|
vm_assert(incheck == 0); \
|
|
incheck = 1; \
|
|
usedpages_reset(); \
|
|
slab_sanitycheck(__FILE__, __LINE__); \
|
|
for(vmp = vmproc; vmp < &vmproc[VMP_NR]; vmp++) { \
|
|
if((vmp->vm_flags & (VMF_INUSE | VMF_HASPT)) == \
|
|
(VMF_INUSE | VMF_HASPT)) { \
|
|
PT_SANE(&vmp->vm_pt); \
|
|
} \
|
|
} \
|
|
map_sanitycheck(__FILE__, __LINE__); \
|
|
vm_assert(incheck == 1); \
|
|
incheck = 0; \
|
|
}
|
|
|
|
#include "../../kernel/proc.h"
|
|
|
|
#define USE(obj, code) do { \
|
|
slabunlock(obj, sizeof(*obj)); \
|
|
do { \
|
|
code \
|
|
} while(0); \
|
|
slablock(obj, sizeof(*obj)); \
|
|
} while(0)
|
|
|
|
#define SLABSANE(ptr) { \
|
|
if(!slabsane_f(__FILE__, __LINE__, ptr, sizeof(*(ptr)))) { \
|
|
printf("VM:%s:%d: SLABSANE(%s)\n", __FILE__, __LINE__, #ptr); \
|
|
vm_panic("SLABSANE failed", NO_NUM); \
|
|
} \
|
|
}
|
|
|
|
#define NOTRUNNABLE(ep) { \
|
|
struct proc pr; \
|
|
if(sys_getproc(&pr, ep) != OK) { \
|
|
vm_panic("VM: sys_getproc failed", ep); \
|
|
} \
|
|
if(!pr.p_rts_flags) { \
|
|
vm_panic("VM: runnable", ep); \
|
|
} \
|
|
}
|
|
|
|
#else
|
|
#define SANITYCHECK
|
|
#define SLABSANITYCHECK(l)
|
|
#define USE(obj, code) do { code } while(0)
|
|
#define SLABSANE(ptr)
|
|
#define NOTRUNNABLE(ep)
|
|
#endif
|
|
|
|
#endif
|