Index: arch/ia64/src/mm/tlb.c
===================================================================
--- arch/ia64/src/mm/tlb.c	(revision d764ddcbe18be0470e47c313dfb3b7325aad5b11)
+++ arch/ia64/src/mm/tlb.c	(revision 2299914109fe20b32a7226821981f5eb11a8394a)
@@ -424,4 +424,5 @@
 	
 	va = istate->cr_ifa;	/* faulting address */
+	page_table_lock(AS, true);
 	t = page_mapping_find(AS, va);
 	if (t) {
@@ -431,9 +432,12 @@
 		 */
 		itc_pte_copy(t);
+		page_table_unlock(AS, true);
 	} else {
 		/*
 		 * Forward the page fault to address space page fault handler.
 		 */
+		page_table_unlock(AS, true);
 		if (!as_page_fault(va)) {
+			page_table_unlock(AS, true);
 			panic("%s: va=%P, rid=%d\n", __FUNCTION__, istate->cr_ifa, rr.map.rid);
 		}
@@ -467,4 +471,5 @@
 	}
 
+	page_table_lock(AS, true);
 	t = page_mapping_find(AS, va);
 	if (t) {
@@ -474,8 +479,10 @@
 		 */
 		dtc_pte_copy(t);
+		page_table_unlock(AS, true);
 	} else {
 		/*
 		 * Forward the page fault to address space page fault handler.
 		 */
+		page_table_unlock(AS, true);
 		if (!as_page_fault(va)) {
 			panic("%s: va=%P, rid=%d, iip=%P\n", __FUNCTION__, va, rid, istate->cr_iip);
@@ -505,4 +512,5 @@
 	pte_t *t;
 
+	page_table_lock(AS, true);
 	t = page_mapping_find(AS, istate->cr_ifa);
 	ASSERT(t && t->p);
@@ -515,4 +523,5 @@
 		dtc_pte_copy(t);
 	}
+	page_table_unlock(AS, true);
 }
 
@@ -526,4 +535,5 @@
 	pte_t *t;
 
+	page_table_lock(AS, true);
 	t = page_mapping_find(AS, istate->cr_ifa);
 	ASSERT(t && t->p);
@@ -536,4 +546,5 @@
 		itc_pte_copy(t);
 	}
+	page_table_unlock(AS, true);
 }
 
@@ -547,4 +558,5 @@
 	pte_t *t;
 
+	page_table_lock(AS, true);
 	t = page_mapping_find(AS, istate->cr_ifa);
 	ASSERT(t && t->p);
@@ -557,4 +569,5 @@
 		dtc_pte_copy(t);
 	}
+	page_table_unlock(AS, true);
 }
 
@@ -571,4 +584,5 @@
 	
 	va = istate->cr_ifa;	/* faulting address */
+	page_table_lock(AS, true);
 	t = page_mapping_find(AS, va);
 	ASSERT(t);
@@ -583,5 +597,7 @@
 		else
 			dtc_pte_copy(t);
+		page_table_unlock(AS, true);
 	} else {
+		page_table_unlock(AS, true);
 		if (!as_page_fault(va)) {
 			panic("%s: va=%P, rid=%d\n", __FUNCTION__, va, rr.map.rid);
Index: arch/mips32/src/mm/tlb.c
===================================================================
--- arch/mips32/src/mm/tlb.c	(revision d764ddcbe18be0470e47c313dfb3b7325aad5b11)
+++ arch/mips32/src/mm/tlb.c	(revision 2299914109fe20b32a7226821981f5eb11a8394a)
@@ -88,5 +88,6 @@
 {
 	entry_lo_t lo;
-	entry_hi_t hi;	
+	entry_hi_t hi;
+	asid_t asid;
 	__address badvaddr;
 	pte_t *pte;
@@ -94,5 +95,9 @@
 	badvaddr = cp0_badvaddr_read();
 
-	spinlock_lock(&AS->lock);		
+	spinlock_lock(&AS->lock);
+	asid = AS->asid;
+	spinlock_unlock(&AS->lock);
+
+	page_table_lock(AS, true);
 
 	pte = find_mapping_and_check(badvaddr);
@@ -105,5 +110,5 @@
 	pte->a = 1;
 
-	prepare_entry_hi(&hi, AS->asid, badvaddr);
+	prepare_entry_hi(&hi, asid, badvaddr);
 	prepare_entry_lo(&lo, pte->g, pte->p, pte->d, pte->cacheable, pte->pfn);
 
@@ -123,9 +128,9 @@
 	tlbwr();
 
-	spinlock_unlock(&AS->lock);
+	page_table_unlock(AS, true);
 	return;
 	
 fail:
-	spinlock_unlock(&AS->lock);
+	page_table_unlock(AS, true);
 	tlb_refill_fail(istate);
 }
@@ -155,6 +160,6 @@
 	tlbp();
 	index.value = cp0_index_read();
-	
-	spinlock_lock(&AS->lock);	
+
+	page_table_lock(AS, true);	
 	
 	/*
@@ -192,9 +197,9 @@
 	tlbwi();
 
-	spinlock_unlock(&AS->lock);	
+	page_table_unlock(AS, true);
 	return;
 	
 fail:
-	spinlock_unlock(&AS->lock);
+	page_table_unlock(AS, true);
 	tlb_invalid_fail(istate);
 }
@@ -224,6 +229,6 @@
 	tlbp();
 	index.value = cp0_index_read();
-	
-	spinlock_lock(&AS->lock);	
+
+	page_table_lock(AS, true);	
 	
 	/*
@@ -268,9 +273,9 @@
 	tlbwi();
 
-	spinlock_unlock(&AS->lock);	
+	page_table_unlock(AS, true);
 	return;
 	
 fail:
-	spinlock_unlock(&AS->lock);
+	page_table_unlock(AS, true);
 	tlb_modified_fail(istate);
 }
@@ -350,4 +355,5 @@
 		 * Resort to higher-level page fault handler.
 		 */
+		page_table_unlock(AS, true);
 		if (as_page_fault(badvaddr)) {
 			/*
@@ -355,27 +361,15 @@
 			 * The mapping ought to be in place.
 			 */
+			page_table_lock(AS, true);
 			pte = page_mapping_find(AS, badvaddr);
 			ASSERT(pte && pte->p);
 			return pte;
+		} else {
+			page_table_lock(AS, true);
+			printf("Page fault.\n");
+			return NULL;
 		}
-	}
-
-	/*
-	 * Handler cannot succeed if badvaddr has no mapping.
-	 */
-	if (!pte) {
-		printf("No such mapping.\n");
-		return NULL;
-	}
-
-	/*
-	 * Handler cannot succeed if the mapping is marked as invalid.
-	 */
-	if (!pte->p) {
-		printf("Invalid mapping.\n");
-		return NULL;
-	}
-
-	return pte;
+		
+	}
 }
 
