Index: arch/mips32/src/mm/tlb.c
===================================================================
--- arch/mips32/src/mm/tlb.c	(revision 20d50a15ee7f195ac1e5a2da974bef0722bb9d60)
+++ arch/mips32/src/mm/tlb.c	(revision f94250069a06e988996338d826128cadeacca6fb)
@@ -400,6 +400,8 @@
 	page_mask_t mask;
 	entry_lo_t lo0, lo1;
-	entry_hi_t hi;
+	entry_hi_t hi, hi_save;
 	int i;
+
+	hi_save.value = cp0_entry_hi_read();
 
 	printf("TLB:\n");
@@ -418,4 +420,6 @@
 		       lo1.g, lo1.v, lo1.d, lo1.c, lo1.pfn);
 	}
+	
+	cp0_entry_hi_write(hi_save.value);
 }
 
@@ -425,6 +429,8 @@
 	ipl_t ipl;
 	entry_lo_t lo0, lo1;
+	entry_hi_t hi_save;
 	int i;
 
+	hi_save.value = cp0_entry_hi_read();
 	ipl = interrupts_disable();
 
@@ -446,4 +452,5 @@
 	
 	interrupts_restore(ipl);
+	cp0_entry_hi_write(hi_save.value);
 }
 
@@ -456,9 +463,10 @@
 	ipl_t ipl;
 	entry_lo_t lo0, lo1;
-	entry_hi_t hi;
+	entry_hi_t hi, hi_save;
 	int i;
 
 	ASSERT(asid != ASID_INVALID);
 
+	hi_save.value = cp0_entry_hi_read();
 	ipl = interrupts_disable();
 	
@@ -484,4 +492,5 @@
 	
 	interrupts_restore(ipl);
+	cp0_entry_hi_write(hi_save.value);
 }
 
@@ -495,9 +504,10 @@
 	ipl_t ipl;
 	entry_lo_t lo0, lo1;
-	entry_hi_t hi;
+	entry_hi_t hi, hi_save;
 	tlb_index_t index;
 
 	ASSERT(asid != ASID_INVALID);
 
+	hi_save.value = cp0_entry_hi_read();
 	ipl = interrupts_disable();
 
@@ -526,3 +536,4 @@
 	
 	interrupts_restore(ipl);
-}
+	cp0_entry_hi_write(hi_save.value);
+}
Index: generic/src/mm/as.c
===================================================================
--- generic/src/mm/as.c	(revision 20d50a15ee7f195ac1e5a2da974bef0722bb9d60)
+++ generic/src/mm/as.c	(revision f94250069a06e988996338d826128cadeacca6fb)
@@ -59,8 +59,8 @@
 
 /*
- * Here we assume that PFN (Physical Frame Numbers) space
+ * Here we assume that PFN (Physical Frame Number) space
  * is smaller than the width of index_t. UNALLOCATED_PFN
  * can be then used to mark mappings wich were not
- * allocated a physical frame.
+ * yet allocated a physical frame.
  */
 #define UNALLOCATED_PFN		((index_t) -1)
@@ -142,5 +142,6 @@
 			/*
 			 * Frames will be allocated on-demand by
-			 * as_page_fault().
+			 * as_page_fault() or preloaded by
+			 * as_area_load_mapping().
 			 */
 			a->mapping[i] = UNALLOCATED_PFN;
@@ -160,5 +161,5 @@
 	spinlock_unlock(&as->lock);
 	interrupts_restore(ipl);
-	
+
 	return a;
 }
@@ -181,4 +182,5 @@
 	for (i = 0; i < a->size; i++) {
 		ASSERT(a->mapping[i] == UNALLOCATED_PFN);
+		ASSERT(pfn[i] != UNALLOCATED_PFN);
 		a->mapping[i] = pfn[i];
 	}
@@ -195,5 +197,5 @@
  * @param page Faulting page.
  *
- * @return 0 on page fault, 1 if address space operation
+ * @return 0 on page fault, 1 on success.
  */
 int as_page_fault(__address page)
@@ -251,4 +253,5 @@
 		memsetb(frame, FRAME_SIZE, 0);
 		area->mapping[vpn] = frame / FRAME_SIZE;
+		ASSERT(area->mapping[vpn] != UNALLOCATED_PFN);
 	} else {
 		frame = area->mapping[vpn] * FRAME_SIZE;
