Ver código fonte

there were a few cases of getppages getting called directly, which caused issues after vm_init is true, as that sets first and last to 0 in ram.c, which is used by stealmem. so those would fail after init. hence the issue. i simply changed those to use alloc_kpages, so now there should be no exceptions. ran one set of tests, but those pass now

tarfeef101 6 anos atrás
pai
commit
a4fb607edb

+ 16 - 16
kern/arch/mips/vm/dumbvm.c

@@ -90,10 +90,18 @@ void vm_bootstrap(void)
   init = true;
 }
 
-// get virtual or physical pages
-static paddr_t getpages(int n)
+// get physical pages
+static paddr_t getppages(int n)
+{
+	paddr_t addr;
+	spinlock_acquire(&stealmem_lock);
+	addr = ram_stealmem(n);
+	spinlock_release(&stealmem_lock);
+	return addr;
+}
+
+static paddr_t getvpages(int n)
 {
-  if (!init) goto skip2;
   bool first = true;
 	spinlock_acquire(&stealmem_lock);
 
@@ -174,22 +182,14 @@ static paddr_t getpages(int n)
 	
 	spinlock_release(&stealmem_lock);
 	return 0;
-	
-	skip2:
-	// why won't this work
-	if (false) panic("bullshit\n");
-	paddr_t addr;
-	spinlock_acquire(&stealmem_lock);
-	addr = ram_stealmem(n);
-	spinlock_release(&stealmem_lock);
-	return addr;
 }
 
 /* Allocate/free some kernel-space virtual pages */
 vaddr_t alloc_kpages(int npages)
 {
 	paddr_t pa;
-	pa = getpages(npages);
+	if (init) pa = getvpages(npages);
+	else pa = getppages(npages);
 	if (!(pa)) return 0;
 	return PADDR_TO_KVADDR(pa);
 }
@@ -454,17 +454,17 @@ as_prepare_load(struct addrspace *as)
 	KASSERT(as->as_pbase2 == 0);
 	KASSERT(as->as_stackpbase == 0);
 
-	as->as_pbase1 = getpages(as->as_npages1);
+	as->as_pbase1 = alloc_kpages(as->as_npages1) - MIPS_KSEG0;
 	if (as->as_pbase1 == 0) {
 		return ENOMEM;
 	}
 
-	as->as_pbase2 = getpages(as->as_npages2);
+	as->as_pbase2 = alloc_kpages(as->as_npages2) - MIPS_KSEG0;
 	if (as->as_pbase2 == 0) {
 		return ENOMEM;
 	}
 
-	as->as_stackpbase = getpages(DUMBVM_STACKPAGES);
+	as->as_stackpbase = alloc_kpages(DUMBVM_STACKPAGES) - MIPS_KSEG0;
 	if (as->as_stackpbase == 0) {
 		return ENOMEM;
 	}

BIN
kern/compile/ASST3/kernel


+ 1 - 1
kern/compile/ASST3/vers.c

@@ -1,3 +1,3 @@
 /* This file is automatically generated. Edits will be lost.*/
-const int buildversion = 25;
+const int buildversion = 28;
 const char buildconfig[] = "ASST3";

+ 1 - 1
kern/compile/ASST3/version

@@ -1 +1 @@
-25
+28