From: Peter H. Froehlich Date: Sun, 18 Oct 2015 05:16:17 +0000 (-0400) Subject: Two sanity checks that were missing. X-Git-Url: https://hydra-www.ietfng.org/gitweb/?a=commitdiff_plain;h=691080c73bb4028e3cedca488340bb82417b528d;p=xv6-public Two sanity checks that were missing. --- diff --git a/main.c b/main.c index c958e51..88a3867 100644 --- a/main.c +++ b/main.c @@ -84,7 +84,8 @@ startothers(void) // Tell entryother.S what stack to use, where to enter, and what // pgdir to use. We cannot use kpgdir yet, because the AP processor // is running in low memory, so we use entrypgdir for the APs too. - stack = kalloc(); + if((stack = kalloc()) == 0) + panic("startothers: failed to allocate stack"); *(void**)(code-4) = stack + KSTACKSIZE; *(void**)(code-8) = mpenter; *(int**)(code-12) = (void *) V2P(entrypgdir); diff --git a/vm.c b/vm.c index 8f34f58..b340696 100644 --- a/vm.c +++ b/vm.c @@ -133,8 +133,8 @@ setupkvm(void) if((pgdir = (pde_t*)kalloc()) == 0) return 0; memset(pgdir, 0, PGSIZE); - if (P2V(PHYSTOP) > (void*)DEVSPACE) - panic("PHYSTOP too high"); + if(P2V(PHYSTOP) > (void*)DEVSPACE) + panic("setupkvm: PHYSTOP too high"); for(k = kmap; k < &kmap[NELEM(kmap)]; k++) if(mappages(pgdir, k->virt, k->phys_end - k->phys_start, (uint)k->phys_start, k->perm) < 0) @@ -148,6 +148,8 @@ void kvmalloc(void) { kpgdir = setupkvm(); + if(kpgdir == 0) + panic("kvmalloc: could not create kernel page table"); switchkvm(); }