panic() cleanup.

this change
   - makes panic() variadic, doing full printf() formatting -
     no more NO_NUM, and no more separate printf() statements
     needed to print extra info (or something in hex) before panicing
   - unifies panic() - same panic() name and usage for everyone -
     vm, kernel and rest have different names/syntax currently
     in order to implement their own luxuries, but no longer
   - throws out the 1st argument, to make source less noisy.
     the panic() in syslib retrieves the server name from the kernel
     so it should be clear enough who is panicing; e.g.
         panic("sigaction failed: %d", errno);
     looks like:
         at_wini(73130): panic: sigaction failed: 0
         syslib:panic.c: stacktrace: 0x74dc 0x2025 0x100a
   - throws out report() - printf() is more convenient and powerful
   - harmonizes/fixes the use of panic() - there were a few places
     that used printf-style formatting (didn't work) and newlines
     (messes up the formatting) in panic()
   - throws out a few per-server panic() functions
   - cleans up a tie-in of tty with panic()

merging printf() and panic() statements to be done incrementally.
This commit is contained in:
Ben Gras
2010-03-05 15:05:11 +00:00
parent 851dc95566
commit 35a108b911
171 changed files with 1381 additions and 1649 deletions

View File

@@ -127,7 +127,7 @@ int line;
if(!(c)) { \
printf("holes_sanity_f:%s:%d: %s failed\n", file, line, #c); \
util_stacktrace(); \
vm_panic("assert failed.", NO_NUM); } \
panic("assert failed"); } \
}
int h, c = 0, n = 0;
@@ -227,7 +227,7 @@ CHECKHOLES;
if(memflags & PAF_CLEAR) {
if ((s= sys_memset(0, CLICK_SIZE*old_base,
CLICK_SIZE*clicks)) != OK) {
vm_panic("alloc_mem: sys_memset failed", s);
panic("alloc_mem: sys_memset failed: %d", s);
}
}
@@ -284,7 +284,7 @@ CHECKHOLES;
}
if ( (new_ptr = free_slots) == NIL_HOLE)
vm_panic("hole table full", NO_NUM);
panic("hole table full");
new_ptr->h_base = base;
new_ptr->h_len = clicks;
free_slots = new_ptr->h_next;
@@ -520,7 +520,7 @@ PRIVATE PUBLIC phys_bytes alloc_pages(int pages, int memflags)
printmemstats();
#if SANITYCHECKS
if(largest >= pages) {
vm_panic("no memory but largest was enough", NO_NUM);
panic("no memory but largest was enough");
}
#endif
return NO_MEM;
@@ -549,7 +549,7 @@ PRIVATE PUBLIC phys_bytes alloc_pages(int pages, int memflags)
int s;
if ((s= sys_memset(0, CLICK_SIZE*mem,
VM_PAGE_SIZE*pages)) != OK)
vm_panic("alloc_mem: sys_memset failed", s);
panic("alloc_mem: sys_memset failed: %d", s);
}
#if SANITYCHECKS
@@ -589,7 +589,7 @@ PRIVATE void free_pages(phys_bytes pageno, int npages)
pr->size += npages;);
} else {
if(!SLABALLOC(pr))
vm_panic("alloc_pages: can't alloc", NO_NUM);
panic("alloc_pages: can't alloc");
#if SANITYCHECKS
memstats(&firstnodes, &firstpages, &largest);
@@ -683,7 +683,7 @@ PUBLIC int do_adddma(message *msg)
dmatab[i].dt_base,
dmatab[i].dt_size);
}
vm_panic("adddma: table full", NO_NUM);
panic("adddma: table full");
return ENOSPC;
}
@@ -805,7 +805,7 @@ PUBLIC void release_dma(struct vmproc *vmp)
{
int i, found_one;
vm_panic("release_dma not done", NO_NUM);
panic("release_dma not done");
#if 0
found_one= FALSE;

View File

@@ -173,7 +173,7 @@ vir_bytes v;
}
new_clicks -= vmp->vm_arch.vm_seg[D].mem_vir;
if ((r=get_stack_ptr(vmp->vm_endpoint, &new_sp)) != OK)
vm_panic("couldn't get stack pointer", r);
panic("couldn't get stack pointer: %d", r);
r = adjust(vmp, new_clicks, new_sp);
return r;
}

View File

@@ -100,7 +100,7 @@ SANITYCHECK(SCL_DETAIL);
r= sys_datacopy(msg->m_source, (vir_bytes)ptr,
SELF, (vir_bytes)&args, sizeof(args));
if (r != OK)
vm_panic("exec_newmem: sys_datacopy failed", r);
panic("exec_newmem: sys_datacopy failed: %d", r);
/* Minimum stack region (not preallocated)
* Stopgap for better rlimit-based stack size system
@@ -281,7 +281,7 @@ SANITYCHECK(SCL_DETAIL);
/* We secretly know that making a new pagetable
* in the same slot if one was there will never fail.
*/
vm_panic("new_mem: pt_new failed", ENOMEM);
panic("new_mem: pt_new failed: %d", ENOMEM);
}
rmp->vm_flags |= VMF_HASPT;
SANITYCHECK(SCL_DETAIL);
@@ -325,7 +325,7 @@ SANITYCHECK(SCL_DETAIL);
*/
base = (phys_bytes)(new_base+text_clicks-1) << CLICK_SHIFT;
if ((s= sys_memset(0, base, CLICK_SIZE)) != OK)
vm_panic("new_mem: sys_memset failed", s);
panic("new_mem: sys_memset failed: %d", s);
}
}
@@ -351,7 +351,7 @@ SANITYCHECK(SCL_DETAIL);
if((r2=sys_newmap(rmp->vm_endpoint, rmp->vm_arch.vm_seg)) != OK) {
/* report new map to the kernel */
vm_panic("sys_newmap failed", r2);
panic("sys_newmap failed: %d", r2);
}
/* Zero the bss, gap, and stack segment. */
@@ -362,12 +362,12 @@ SANITYCHECK(SCL_DETAIL);
bytes -= bss_offset;
if ((s=sys_memset(0, base, bytes)) != OK) {
vm_panic("new_mem can't zero", s);
panic("new_mem can't zero: %d", s);
}
/* Tell kernel this thing has no page table. */
if((s=pt_bind(NULL, rmp)) != OK)
vm_panic("exec_newmem: pt_bind failed", s);
panic("exec_newmem: pt_bind failed: %d", s);
*stack_top= ((vir_bytes)rmp->vm_arch.vm_seg[S].mem_vir << CLICK_SHIFT) +
((vir_bytes)rmp->vm_arch.vm_seg[S].mem_len << CLICK_SHIFT);
}
@@ -474,7 +474,7 @@ PUBLIC int proc_new(struct vmproc *vmp,
if(!map_page_region(vmp, vstart + text_bytes + data_bytes + hole_bytes,
0, stack_bytes + gap_bytes, MAP_NONE,
VR_ANON | VR_WRITABLE, 0) != OK) {
vm_panic("map_page_region failed for stack", NO_NUM);
panic("map_page_region failed for stack");
}
vmp->vm_arch.vm_seg[D].mem_phys = ABS2CLICK(vstart + text_bytes);
@@ -506,10 +506,10 @@ PUBLIC int proc_new(struct vmproc *vmp,
vmp->vm_flags |= VMF_HASPT;
if((s=sys_newmap(vmp->vm_endpoint, vmp->vm_arch.vm_seg)) != OK)
vm_panic("sys_newmap (vm) failed", s);
panic("sys_newmap (vm) failed: %d", s);
if((s=pt_bind(&vmp->vm_pt, vmp)) != OK)
vm_panic("exec_newmem: pt_bind failed", s);
panic("exec_newmem: pt_bind failed: %d", s);
return OK;
}

View File

@@ -123,7 +123,7 @@ PUBLIC int do_fork(message *msg)
child_abs = (phys_bytes) child_base << CLICK_SHIFT;
parent_abs = (phys_bytes) vmp->vm_arch.vm_seg[D].mem_phys << CLICK_SHIFT;
s = sys_abscopy(parent_abs, child_abs, prog_bytes);
if (s < 0) vm_panic("do_fork can't copy", s);
if (s < 0) panic("do_fork can't copy: %d", s);
/* A separate I&D child keeps the parents text segment. The data and stack
* segments must refer to the new copy.
@@ -150,7 +150,7 @@ PUBLIC int do_fork(message *msg)
if((r=sys_fork(vmp->vm_endpoint, childproc,
&vmc->vm_endpoint, vmc->vm_arch.vm_seg,
PFF_VMINHIBIT, &msgaddr)) != OK) {
vm_panic("do_fork can't sys_fork", r);
panic("do_fork can't sys_fork: %d", r);
}
NOTRUNNABLE(vmp->vm_endpoint);
@@ -168,7 +168,7 @@ PUBLIC int do_fork(message *msg)
}
if((r=pt_bind(&vmc->vm_pt, vmc)) != OK)
vm_panic("fork can't pt_bind", r);
panic("fork can't pt_bind: %d", r);
/* Inform caller of new child endpoint. */
msg->VMF_CHILD_ENDPOINT = vmc->vm_endpoint;

View File

@@ -107,7 +107,7 @@ PUBLIC void pt_sanitycheck(pt_t *pt, char *file, int line)
}
if(slot >= ELEMENTS(vmproc)) {
vm_panic("pt_sanitycheck: passed pt not in any proc", NO_NUM);
panic("pt_sanitycheck: passed pt not in any proc");
}
MYASSERT(usedpages_add(pt->pt_dir_phys, I386_PAGE_SIZE) == OK);
@@ -137,7 +137,7 @@ PRIVATE void *aalloc(size_t bytes)
u32_t b;
b = (u32_t) malloc(I386_PAGE_SIZE + bytes);
if(!b) vm_panic("aalloc: out of memory", bytes);
if(!b) panic("aalloc: out of memory: %d", bytes);
b += I386_PAGE_SIZE - (b % I386_PAGE_SIZE);
return (void *) b;
@@ -214,8 +214,7 @@ PRIVATE void vm_freepages(vir_bytes vir, vir_bytes phys, int pages, int reason)
FREE_MEM(ABS2CLICK(phys), pages);
if(pt_writemap(&vmp->vm_pt, arch_vir2map(vmp, vir),
MAP_NONE, pages*I386_PAGE_SIZE, 0, WMF_OVERWRITE) != OK)
vm_panic("vm_freepages: pt_writemap failed",
NO_NUM);
panic("vm_freepages: pt_writemap failed");
} else {
printf("VM: vm_freepages not freeing VM heap pages (%d)\n",
pages);
@@ -334,7 +333,7 @@ PUBLIC void *vm_allocpage(phys_bytes *phys, int reason)
}
if((r=sys_vmctl(SELF, VMCTL_FLUSHTLB, 0)) != OK) {
vm_panic("VMCTL_FLUSHTLB failed", r);
panic("VMCTL_FLUSHTLB failed: %d", r);
}
level--;
@@ -367,11 +366,11 @@ PUBLIC void vm_pagelock(void *vir, int lockflag)
/* Update flags. */
if((r=pt_writemap(pt, m, 0, I386_PAGE_SIZE,
flags, WMF_OVERWRITE | WMF_WRITEFLAGSONLY)) != OK) {
vm_panic("vm_lockpage: pt_writemap failed\n", NO_NUM);
panic("vm_lockpage: pt_writemap failed");
}
if((r=sys_vmctl(SELF, VMCTL_FLUSHTLB, 0)) != OK) {
vm_panic("VMCTL_FLUSHTLB failed", r);
panic("VMCTL_FLUSHTLB failed: %d", r);
}
return;
@@ -439,10 +438,10 @@ PUBLIC int pt_writemap(pt_t *pt, vir_bytes v, phys_bytes physaddr,
*/
#if SANITYCHECKS
if(physaddr != MAP_NONE && !(flags & I386_VM_PRESENT)) {
vm_panic("pt_writemap: writing dir with !P\n", NO_NUM);
panic("pt_writemap: writing dir with !P");
}
if(physaddr == MAP_NONE && flags) {
vm_panic("pt_writemap: writing 0 with flags\n", NO_NUM);
panic("pt_writemap: writing 0 with flags");
}
#endif
@@ -458,7 +457,7 @@ PUBLIC int pt_writemap(pt_t *pt, vir_bytes v, phys_bytes physaddr,
if(pt->pt_dir[pdecheck] & I386_VM_BIGPAGE) {
printf("pt_writemap: trying to write 0x%lx into 0x%lx\n",
physaddr, v);
vm_panic("pt_writemap: BIGPAGE found", NO_NUM);
panic("pt_writemap: BIGPAGE found");
}
if(!(pt->pt_dir[pdecheck] & I386_VM_PRESENT)) {
int r;
@@ -615,7 +614,7 @@ PUBLIC int pt_new(pt_t *pt)
/* Map in kernel. */
if(pt_mapkernel(pt) != OK)
vm_panic("pt_new: pt_mapkernel failed", NO_NUM);
panic("pt_new: pt_mapkernel failed");
return OK;
}
@@ -680,10 +679,10 @@ PUBLIC void pt_init(phys_bytes usedlimit)
/* Get ourselves spare pages. */
if(!(sparepages_mem = (vir_bytes) aalloc(I386_PAGE_SIZE*SPAREPAGES)))
vm_panic("pt_init: aalloc for spare failed", NO_NUM);
panic("pt_init: aalloc for spare failed");
if((r=sys_umap(SELF, VM_D, (vir_bytes) sparepages_mem,
I386_PAGE_SIZE*SPAREPAGES, &sparepages_ph)) != OK)
vm_panic("pt_init: sys_umap failed", r);
panic("pt_init: sys_umap failed: %d", r);
for(s = 0; s < SPAREPAGES; s++) {
sparepages[s].page = (void *) (sparepages_mem + s*I386_PAGE_SIZE);
@@ -728,7 +727,7 @@ PUBLIC void pt_init(phys_bytes usedlimit)
* from the current one.
*/
if(pt_new(newpt) != OK)
vm_panic("pt_init: pt_new failed", NO_NUM);
panic("pt_init: pt_new failed");
/* Set up mappings for VM process. */
for(v = lo; v < hi; v += I386_PAGE_SIZE) {
@@ -740,7 +739,7 @@ PUBLIC void pt_init(phys_bytes usedlimit)
*/
if(pt_writemap(newpt, v+moveup, v, I386_PAGE_SIZE,
I386_VM_PRESENT|I386_VM_WRITE|I386_VM_USER, 0) != OK)
vm_panic("pt_init: pt_writemap failed", NO_NUM);
panic("pt_init: pt_writemap failed");
}
/* Move segments up too. */
@@ -753,7 +752,7 @@ PUBLIC void pt_init(phys_bytes usedlimit)
*/
if(!(page_directories = vm_allocpage(&page_directories_phys,
VMP_PAGETABLE)))
vm_panic("no virt addr for vm mappings", NO_NUM);
panic("no virt addr for vm mappings");
memset(page_directories, 0, I386_PAGE_SIZE);
@@ -793,7 +792,7 @@ PUBLIC void pt_init(phys_bytes usedlimit)
&flags) == OK) {
vir_bytes vir;
if(index >= MAX_KERNMAPPINGS)
vm_panic("VM: too many kernel mappings", index);
panic("VM: too many kernel mappings: %d", index);
kern_mappings[index].phys_addr = addr;
kern_mappings[index].len = len;
kern_mappings[index].flags = flags;
@@ -805,12 +804,12 @@ PUBLIC void pt_init(phys_bytes usedlimit)
kern_mappings[index].flags |=
I386_VM_PWT | I386_VM_PCD;
if(addr % I386_PAGE_SIZE)
vm_panic("VM: addr unaligned", addr);
panic("VM: addr unaligned: %d", addr);
if(len % I386_PAGE_SIZE)
vm_panic("VM: len unaligned", len);
panic("VM: len unaligned: %d", len);
vir = arch_map2vir(&vmproc[VMP_SYSTEM], offset);
if(sys_vmctl_reply_mapping(index, vir) != OK)
vm_panic("VM: reply failed", NO_NUM);
panic("VM: reply failed");
offset += len;
index++;
kernmappings++;
@@ -827,7 +826,7 @@ PUBLIC void pt_init(phys_bytes usedlimit)
/* Tell kernel about free pde's. */
while(free_pde*I386_BIG_PAGE_SIZE < VM_PROCSTART) {
if((r=sys_vmctl(SELF, VMCTL_I386_FREEPDE, free_pde++)) != OK) {
vm_panic("VMCTL_I386_FREEPDE failed", r);
panic("VMCTL_I386_FREEPDE failed: %d", r);
}
}
@@ -838,7 +837,7 @@ PUBLIC void pt_init(phys_bytes usedlimit)
/* Increase kernel segment to address this memory. */
if((r=sys_vmctl(SELF, VMCTL_I386_KERNELLIMIT, kernlimit)) != OK) {
vm_panic("VMCTL_I386_KERNELLIMIT failed", r);
panic("VMCTL_I386_KERNELLIMIT failed: %d", r);
}
kpagedir = arch_map2vir(&vmproc[VMP_SYSTEM],
@@ -846,7 +845,7 @@ PUBLIC void pt_init(phys_bytes usedlimit)
/* Tell kernel how to get at the page directories. */
if((r=sys_vmctl(SELF, VMCTL_I386_PAGEDIRS, kpagedir)) != OK) {
vm_panic("VMCTL_I386_PAGEDIRS failed", r);
panic("VMCTL_I386_PAGEDIRS failed: %d", r);
}
/* Give our process the new, copied, private page table. */
@@ -855,7 +854,7 @@ PUBLIC void pt_init(phys_bytes usedlimit)
/* Now actually enable paging. */
if(sys_vmctl_enable_paging(vmp->vm_arch.vm_seg) != OK)
vm_panic("pt_init: enable paging failed", NO_NUM);
panic("pt_init: enable paging failed");
/* Back to reality - this is where the stack actually is. */
vmp->vm_arch.vm_seg[S].mem_len -= extra_clicks;
@@ -934,7 +933,7 @@ PUBLIC int pt_mapkernel(pt_t *pt)
I386_VM_WRITE | global_bit;
}
} else {
vm_panic("VM: pt_mapkernel: no bigpage", NO_NUM);
panic("VM: pt_mapkernel: no bigpage");
}
if(pagedir_pde >= 0) {
@@ -948,7 +947,7 @@ PUBLIC int pt_mapkernel(pt_t *pt)
kern_mappings[i].phys_addr,
kern_mappings[i].len,
kern_mappings[i].flags, 0) != OK) {
vm_panic("pt_mapkernel: pt_writemap failed", NO_NUM);
panic("pt_mapkernel: pt_writemap failed");
}
}

View File

@@ -84,7 +84,7 @@ PUBLIC int main(void)
SANITYCHECK(SCL_DETAIL);
if ((r=sef_receive(ANY, &msg)) != OK)
vm_panic("sef_receive() error", r);
panic("sef_receive() error: %d", r);
SANITYCHECK(SCL_DETAIL);
@@ -136,7 +136,7 @@ PUBLIC int main(void)
if((r=send(who_e, &msg)) != OK) {
printf("VM: couldn't send %d to %d (err %d)\n",
msg.m_type, who_e, r);
vm_panic("send() error", NO_NUM);
panic("send() error");
}
SANITYCHECK(SCL_DETAIL);
}
@@ -193,7 +193,7 @@ PRIVATE int sef_cb_init_fresh(int type, sef_init_info_t *info)
* slots to fill in.
*/
if (OK != (s=sys_getimage(image)))
vm_panic("couldn't get image table: %d\n", s);
panic("couldn't get image table: %d", s);
/* Set table to 0. This invalidates all slots (clear VMF_INUSE). */
memset(vmproc, 0, sizeof(vmproc));
@@ -209,7 +209,7 @@ PRIVATE int sef_cb_init_fresh(int type, sef_init_info_t *info)
phys_bytes proclimit;
struct vmproc *vmp;
if(ip->proc_nr >= _NR_PROCS) { vm_panic("proc", ip->proc_nr); }
if(ip->proc_nr >= _NR_PROCS) { panic("proc: %d", ip->proc_nr); }
if(ip->proc_nr < 0 && ip->proc_nr != SYSTEM) continue;
#define GETVMP(v, nr) \
@@ -218,7 +218,7 @@ PRIVATE int sef_cb_init_fresh(int type, sef_init_info_t *info)
} else if(nr == SYSTEM) { \
vmp = &vmproc[VMP_SYSTEM]; \
} else { \
vm_panic("init: crazy proc_nr", nr); \
panic("init: crazy proc_nr: %d", nr); \
}
/* Initialize normal process table slot or special SYSTEM
@@ -231,7 +231,7 @@ PRIVATE int sef_cb_init_fresh(int type, sef_init_info_t *info)
/* Get memory map for this process from the kernel. */
if ((s=get_mem_map(ip->proc_nr, vmp->vm_arch.vm_seg)) != OK)
vm_panic("couldn't get process mem_map",s);
panic("couldn't get process mem_map: %d", s);
/* Remove this memory from the free list. */
reserve_proc_mem(mem_chunks, vmp->vm_arch.vm_seg);
@@ -279,13 +279,13 @@ PRIVATE int sef_cb_init_fresh(int type, sef_init_info_t *info)
vmp->vm_arch.vm_seg[D].mem_len;
if(pt_new(&vmp->vm_pt) != OK)
vm_panic("VM: no new pagetable", NO_NUM);
panic("VM: no new pagetable");
#define BASICSTACK VM_PAGE_SIZE
old_stacktop = CLICK2ABS(vmp->vm_arch.vm_seg[S].mem_vir +
vmp->vm_arch.vm_seg[S].mem_len);
if(sys_vmctl(vmp->vm_endpoint, VMCTL_INCSP,
VM_STACKTOP - old_stacktop) != OK) {
vm_panic("VM: vmctl for new stack failed", NO_NUM);
panic("VM: vmctl for new stack failed");
}
FREE_MEM(vmp->vm_arch.vm_seg[D].mem_phys +
@@ -303,14 +303,14 @@ PRIVATE int sef_cb_init_fresh(int type, sef_init_info_t *info)
CLICK2ABS(vmp->vm_arch.vm_seg[T].mem_phys),
CLICK2ABS(vmp->vm_arch.vm_seg[D].mem_phys),
VM_STACKTOP) != OK) {
vm_panic("failed proc_new for boot process", NO_NUM);
panic("failed proc_new for boot process");
}
}
/* Set up table of calls. */
#define CALLMAP(code, func) { int i; \
if((i=CALLNUMBER(code)) < 0) { vm_panic(#code " invalid", (code)); } \
if(i >= NR_VM_CALLS) { vm_panic(#code " invalid", (code)); } \
if((i=CALLNUMBER(code)) < 0) { panic(#code " invalid: %d", (code)); } \
if(i >= NR_VM_CALLS) { panic(#code " invalid: %d", (code)); } \
vm_calls[i].vmc_func = (func); \
vm_calls[i].vmc_name = #code; \
}
@@ -352,7 +352,7 @@ PRIVATE int sef_cb_init_fresh(int type, sef_init_info_t *info)
/* Sanity checks */
if(find_kernel_top() >= VM_PROCSTART)
vm_panic("kernel loaded too high", NO_NUM);
panic("kernel loaded too high");
/* Initialize the structures for queryexit */
init_query_exit();
@@ -364,12 +364,12 @@ PRIVATE int sef_cb_init_fresh(int type, sef_init_info_t *info)
/* Map all the services in the boot image. */
if((s = sys_safecopyfrom(RS_PROC_NR, info->rproctab_gid, 0,
(vir_bytes) rprocpub, sizeof(rprocpub), S)) != OK) {
panic("VM", "sys_safecopyfrom failed", s);
panic("sys_safecopyfrom failed: %d", s);
}
for(i=0;i < NR_BOOT_PROCS;i++) {
if(rprocpub[i].in_use) {
if((s = map_service(&rprocpub[i])) != OK) {
vm_panic("unable to map service", s);
panic("unable to map service: %d", s);
}
}
}
@@ -405,7 +405,7 @@ PRIVATE int vm_acl_ok(endpoint_t caller, int call)
int n, r;
if ((r = vm_isokendpt(caller, &n)) != OK)
vm_panic("VM: from strange source.", caller);
panic("VM: from strange source: %d", caller);
/* See if the call is allowed. */
if (!GET_BIT(vmproc[n].vm_call_mask, call)) {

View File

@@ -145,7 +145,7 @@ PRIVATE int do_map_memory(struct vmproc *vms, struct vmproc *vmd,
physr_start_iter(vrs->phys, &iter, offset_s, AVL_EQUAL);
prs = physr_get_iter(&iter);
if(!prs)
vm_panic("map_memory: no aligned phys region.", 0);
panic("map_memory: no aligned phys region: %d", 0);
/* flag: 0 -> read-only
* 1 -> writable
@@ -230,10 +230,10 @@ PUBLIC int map_memory(endpoint_t sour, endpoint_t dest,
int r;
if(vm_isokendpt(sour, &p) != OK)
vm_panic("handle_memory: endpoint wrong", sour);
panic("handle_memory: endpoint wrong: %d", sour);
vms = &vmproc[p];
if(vm_isokendpt(dest, &p) != OK)
vm_panic("handle_memory: endpoint wrong", dest);
panic("handle_memory: endpoint wrong: %d", dest);
vmd = &vmproc[p];
vrs = map_lookup(vms, virt_s);
@@ -295,7 +295,7 @@ PUBLIC int unmap_memory(endpoint_t sour, endpoint_t dest,
/* Use information on the destination process to unmap. */
if(vm_isokendpt(dest, &p) != OK)
vm_panic("handle_memory: endpoint wrong", dest);
panic("handle_memory: endpoint wrong: %d", dest);
vmd = &vmproc[p];
vrd = map_lookup(vmd, virt_d);
@@ -306,7 +306,7 @@ PUBLIC int unmap_memory(endpoint_t sour, endpoint_t dest,
physr_start_iter(vrd->phys, &iter, off, AVL_EQUAL);
pr = physr_get_iter(&iter);
if(!pr)
vm_panic("map_memory: no aligned phys region.", 0);
panic("map_memory: no aligned phys region: %d", 0);
/* Copy the phys block now rather than doing COW. */
end = off + length;

View File

@@ -41,7 +41,7 @@ PUBLIC int do_mmap(message *m)
struct vir_region *vr = NULL;
if((r=vm_isokendpt(m->m_source, &n)) != OK) {
vm_panic("do_mmap: message from strange source", m->m_source);
panic("do_mmap: message from strange source: %d", m->m_source);
}
vmp = &vmproc[n];
@@ -281,7 +281,7 @@ PUBLIC int do_shared_unmap(message *m)
}
if(map_unmap_region(vmp, vr, vr->length) != OK)
vm_panic("do_shared_unmap: map_unmap_region failed", NO_NUM);
panic("do_shared_unmap: map_unmap_region failed");
return OK;
}
@@ -349,7 +349,7 @@ PUBLIC int do_munmap(message *m)
struct vir_region *vr;
if((r=vm_isokendpt(m->m_source, &n)) != OK) {
vm_panic("do_mmap: message from strange source", m->m_source);
panic("do_mmap: message from strange source: %d", m->m_source);
}
vmp = &vmproc[n];
@@ -362,7 +362,7 @@ PUBLIC int do_munmap(message *m)
} else if(m->m_type == VM_MUNMAP_TEXT) {
addr = (vir_bytes) arch_vir2map_text(vmp, (vir_bytes) m->VMUM_ADDR);
} else {
vm_panic("do_munmap: strange type", NO_NUM);
panic("do_munmap: strange type");
}
if(!(vr = map_lookup(vmp, addr))) {
@@ -380,7 +380,7 @@ PUBLIC int do_munmap(message *m)
}
if(map_unmap_region(vmp, vr, len) != OK)
vm_panic("do_munmap: map_unmap_region failed", NO_NUM);
panic("do_munmap: map_unmap_region failed");
return OK;
}

View File

@@ -63,7 +63,7 @@ PUBLIC void do_pagefaults(void)
int p, wr = PFERR_WRITE(err);
if(vm_isokendpt(ep, &p) != OK)
vm_panic("do_pagefaults: endpoint wrong", ep);
panic("do_pagefaults: endpoint wrong: %d", ep);
vmp = &vmproc[p];
vm_assert(vmp->vm_flags & VMF_INUSE);
@@ -75,9 +75,9 @@ PUBLIC void do_pagefaults(void)
ep, arch_map2vir(vmp, addr), pf_errstr(err));
sys_sysctl_stacktrace(vmp->vm_endpoint);
if((s=sys_kill(vmp->vm_endpoint, SIGSEGV)) != OK)
vm_panic("sys_kill failed", s);
panic("sys_kill failed: %d", s);
if((s=sys_vmctl(ep, VMCTL_CLEAR_PAGEFAULT, r)) != OK)
vm_panic("do_pagefaults: sys_vmctl failed", ep);
panic("do_pagefaults: sys_vmctl failed: %d", ep);
continue;
}
@@ -97,9 +97,9 @@ PUBLIC void do_pagefaults(void)
ep, arch_map2vir(vmp, addr), pf_errstr(err));
sys_sysctl_stacktrace(vmp->vm_endpoint);
if((s=sys_kill(vmp->vm_endpoint, SIGSEGV)) != OK)
vm_panic("sys_kill failed", s);
panic("sys_kill failed: %d", s);
if((s=sys_vmctl(ep, VMCTL_CLEAR_PAGEFAULT, r)) != OK)
vm_panic("do_pagefaults: sys_vmctl failed", ep);
panic("do_pagefaults: sys_vmctl failed: %d", ep);
continue;
}
@@ -111,15 +111,15 @@ PUBLIC void do_pagefaults(void)
printf("VM: pagefault: SIGSEGV %d pagefault not handled\n", ep);
sys_sysctl_stacktrace(vmp->vm_endpoint);
if((s=sys_kill(vmp->vm_endpoint, SIGSEGV)) != OK)
vm_panic("sys_kill failed", s);
panic("sys_kill failed: %d", s);
if((s=sys_vmctl(ep, VMCTL_CLEAR_PAGEFAULT, r)) != OK)
vm_panic("do_pagefaults: sys_vmctl failed", ep);
panic("do_pagefaults: sys_vmctl failed: %d", ep);
continue;
}
/* Pagefault is handled, so now reactivate the process. */
if((s=sys_vmctl(ep, VMCTL_CLEAR_PAGEFAULT, r)) != OK)
vm_panic("do_pagefaults: sys_vmctl failed", ep);
panic("do_pagefaults: sys_vmctl failed: %d", ep);
}
@@ -146,7 +146,7 @@ PUBLIC void do_memory(void)
switch(r) {
case VMPTYPE_CHECK:
if(vm_isokendpt(who, &p) != OK)
vm_panic("do_memory: bad endpoint", who);
panic("do_memory: bad endpoint: %d", who);
vmp = &vmproc[p];
r = handle_memory(vmp, mem, len, wrflag);
@@ -165,7 +165,7 @@ PUBLIC void do_memory(void)
}
if(sys_vmctl(requestor, VMCTL_MEMREQ_REPLY, r) != OK)
vm_panic("do_memory: sys_vmctl failed", r);
panic("do_memory: sys_vmctl failed: %d", r);
}
}

View File

@@ -51,7 +51,7 @@ PRIVATE char *map_name(struct vir_region *vr)
case VR_DIRECT:
return "direct";
default:
vm_panic("unknown mapping type", type);
panic("unknown mapping type: %d", type);
}
return "NOTREACHED";
@@ -455,7 +455,7 @@ PUBLIC void pb_unreferenced(struct vir_region *region, struct phys_region *pr)
} else if(region->flags & VR_DIRECT) {
; /* No action required. */
} else {
vm_panic("strange phys flags", NO_NUM);
panic("strange phys flags");
}
SLABFREE(pb);
}
@@ -588,7 +588,7 @@ vir_bytes offset;
SANITYCHECK(SCL_FUNCTIONS);
if(!vmp->vm_regions)
vm_panic("process has no regions", vmp->vm_endpoint);
panic("process has no regions: %d", vmp->vm_endpoint);
for(r = vmp->vm_regions; r; r = r->next) {
if(offset >= r->vaddr && offset < r->vaddr + r->length)
@@ -758,7 +758,7 @@ USE(newpb,
*/
r = map_ph_writept(vmp, region, ph);
if(r != OK)
vm_panic("map_copy_ph_block: map_ph_writept failed", r);
panic("map_copy_ph_block: map_ph_writept failed: %d", r);
return OK;
}
@@ -825,7 +825,7 @@ int write;
#if SANITYCHECKS
if(OK != pt_checkrange(&vmp->vm_pt, region->vaddr+offset, VM_PAGE_SIZE, write)) {
vm_panic("map_pf: pt_checkrange failed", r);
panic("map_pf: pt_checkrange failed: %d", r);
}
#endif
@@ -885,8 +885,8 @@ int write;
#define RESET_ITER(it, where, what) { \
physr_start_iter(region->phys, &it, where, AVL_EQUAL); \
what = physr_get_iter(&it); \
if(!what) vm_panic("thing missing", NO_NUM); \
if(what->offset != where) vm_panic("thing wrong", NO_NUM); \
if(!what) panic("thing missing"); \
if(what->offset != where) panic("thing wrong"); \
}
FREE_RANGE_HERE(NULL, physr);
@@ -960,7 +960,7 @@ int write;
printf("handle mem %s-", arch_map2str(vmp, region->vaddr+offset));
printf("%s failed\n", arch_map2str(vmp, region->vaddr+offset+length));
map_printregion(vmp, region);
vm_panic("checkrange failed", NO_NUM);
panic("checkrange failed");
}
#endif
@@ -1269,7 +1269,7 @@ PUBLIC int map_unmap_region(struct vmproc *vmp, struct vir_region *region,
SANITYCHECK(SCL_DETAIL);
if(r == NULL)
vm_panic("map_unmap_region: region not found\n", NO_NUM);
panic("map_unmap_region: region not found");
if(len > r->length || (len % VM_PAGE_SIZE)) {
printf("VM: bogus length 0x%lx\n", len);
@@ -1388,7 +1388,7 @@ PUBLIC int map_remap(struct vmproc *dvmp, vir_bytes da, size_t size,
struct phys_block *pb = ph->ph;
USE(pb, pb->refcount++;);
if(map_ph_writept(dvmp, vr, ph) != OK) {
vm_panic("map_remap: map_ph_writept failed", NO_NUM);
panic("map_remap: map_ph_writept failed");
}
physr_incr_iter(&iter);

View File

@@ -11,7 +11,7 @@
*/
#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)
panic("sanity check failed"); } } while(0)
#define SLABSANITYCHECK(l) if((l) <= vm_sanitychecklevel) { \
slab_sanitycheck(__FILE__, __LINE__); }
@@ -46,17 +46,17 @@
#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); \
panic("SLABSANE failed"); \
} \
}
#define NOTRUNNABLE(ep) { \
struct proc pr; \
if(sys_getproc(&pr, ep) != OK) { \
vm_panic("VM: sys_getproc failed", ep); \
panic("VM: sys_getproc failed: %d", ep); \
} \
if(!pr.p_rts_flags) { \
vm_panic("VM: runnable", ep); \
panic("VM: runnable: %d", ep); \
} \
}

View File

@@ -46,7 +46,7 @@ PUBLIC int do_push_sig(message *msg)
vmp = &vmproc[n];
if ((r=get_stack_ptr(ep, &sp)) != OK)
vm_panic("couldn't get new stack pointer (for sig)",r);
panic("couldn't get new stack pointer (for sig): %d", r);
/* Save old SP for caller */
msg->VMPS_OLD_SP = (char *) sp;

View File

@@ -354,7 +354,7 @@ PUBLIC void *slaballoc(int bytes)
printf("slaballoc: odd, bytes %d?\n", bytes);
}
if(!slabsane_f(__FILE__, __LINE__, ret, bytes))
vm_panic("slaballoc: slabsane failed", NO_NUM);
panic("slaballoc: slabsane failed");
#endif
return ret;
@@ -365,7 +365,7 @@ PUBLIC void *slaballoc(int bytes)
}
SLABSANITYCHECK(SCL_FUNCTIONS);
vm_panic("slaballoc: no space in 'used' slabdata", NO_NUM);
panic("slaballoc: no space in 'used' slabdata");
/* Not reached. */
return NULL;
@@ -442,7 +442,7 @@ PUBLIC void slabfree(void *mem, int bytes)
SLABSANITYCHECK(SCL_FUNCTIONS);
if(objstats(mem, bytes, &s, &f, &i) != OK) {
vm_panic("slabfree objstats failed", NO_NUM);
panic("slabfree objstats failed");
}
#if SANITYCHECKS
@@ -498,7 +498,7 @@ PUBLIC void slablock(void *mem, int bytes)
struct slabdata *f;
if(objstats(mem, bytes, &s, &f, &i) != OK)
vm_panic("slablock objstats failed", NO_NUM);
panic("slablock objstats failed");
SLABDATAUNWRITABLE(f);
@@ -517,7 +517,7 @@ PUBLIC void slabunlock(void *mem, int bytes)
struct slabdata *f;
if(objstats(mem, bytes, &s, &f, &i) != OK)
vm_panic("slablock objstats failed", NO_NUM);
panic("slablock objstats failed");
SLABDATAWRITABLE(f, i);

View File

@@ -12,17 +12,12 @@
if(vm_sanitychecklevel > 0 && !(cond)) { \
printf("VM:%s:%d: assert failed: %s\n", \
__FILE__, __LINE__, #cond); \
panic("VM", "assert failed", NO_NUM); \
panic("assert failed"); \
} \
}
#else
#define vm_assert(cond) ;
#endif
#define vm_panic(str, n) { char _pline[100]; \
sprintf(_pline, "%s:%d: %s", __FILE__, __LINE__, (str)); \
panic("VM", _pline, (n)); \
}
#endif

View File

@@ -68,7 +68,7 @@ struct memory *mem_chunks; /* store mem chunks here */
/* Obtain and parse memory from system environment. */
if(env_memory_parse(mem_chunks, NR_MEMS) != OK)
vm_panic("couldn't obtain memory chunks", NO_NUM);
panic("couldn't obtain memory chunks");
/* Round physical memory to clicks. Round start up, round end down. */
for (i = 0; i < NR_MEMS; i++) {
@@ -110,8 +110,8 @@ struct mem_map *map_ptr; /* memory to remove */
}
if (memp >= &mem_chunks[NR_MEMS])
{
vm_panic("reserve_proc_mem: can't find map in mem_chunks ",
map_ptr[T].mem_phys);
panic("reserve_proc_mem: can't find map in mem_chunks: 0x%lx",
map_ptr[T].mem_phys);
}
}
@@ -160,7 +160,7 @@ char *brk_addr;
/* VM wants to call brk() itself. */
if((r=real_brk(vmm, (vir_bytes) brk_addr)) != OK)
vm_panic("VM: brk() on myself failed\n", NO_NUM);
panic("VM: brk() on myself failed");
_brksize = brk_addr;
return 0;
}