]> hydra-www.ietfng.org Git - xv6-public/commitdiff
Two sanity checks that were missing.
authorPeter H. Froehlich <peter.hans.froehlich@gmail.com>
Sun, 18 Oct 2015 05:16:17 +0000 (01:16 -0400)
committerPeter H. Froehlich <peter.hans.froehlich@gmail.com>
Sun, 18 Oct 2015 05:16:17 +0000 (01:16 -0400)
main.c
vm.c

diff --git a/main.c b/main.c
index c958e5170a6b5502161c44c4c77722699b064140..88a386792d8dae7fb72a7a90c7668cc2e5bf1459 100644 (file)
--- 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 8f34f58e0886d926b4990aa082a0fb07bc0ea52e..b340696b44ccc1cb8ffcae93a98ac2dd6f1f67fb 100644 (file)
--- 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();
 }