PERFORCE change 116358 for review

Oleksandr Tymoshenko gonzo at FreeBSD.org
Thu Mar 22 20:18:52 UTC 2007


http://perforce.freebsd.org/chv.cgi?CH=116358

Change 116358 by gonzo at gonzo_jeeves on 2007/03/22 20:18:43

	o Save EntryHi (we need ASID part only) before start
	    messing with it and then restore before resume.
	    EntryHi should be set to pm_asid by pmap_activate
	    and should be kept during process's lifecycle 
	    in userland.

Affected files ...

.. //depot/projects/mips2/src/sys/mips/mips/swtch.S#10 edit
.. //depot/projects/mips2/src/sys/mips/mips/tlb.c#12 edit

Differences ...

==== //depot/projects/mips2/src/sys/mips/mips/swtch.S#10 (text+ko) ====

@@ -60,6 +60,7 @@
 	break
 
 entry0:
+	mfc0	t0, MIPS_COP_0_TLB_HI		# Save old ASID
 	mtc0	v0, MIPS_COP_0_TLB_HI		# VPN = va
 	COP0_SYNC
 	nop
@@ -87,6 +88,7 @@
 	nop
 	mtc0	v0, MIPS_COP_0_TLB_HI		# set VPN again
 	COP0_SYNC
+
 entry0set:
 	mtc0	zero, MIPS_COP_0_TLB_INDEX	# TLB entry #0
 	COP0_SYNC
@@ -102,9 +104,9 @@
 	COP0_SYNC
 	nop
 	nop
+	mtc0	t0, MIPS_COP_0_TLB_HI		# Restore old ASID
+
 resume:
-
-
 	.set at
 	lw	t2, pcpup
 	.set noat
@@ -156,7 +158,6 @@
 	li	v0, 0
 	jr	ra
 	nop
-
 END(savectx)
 
 /*
@@ -167,7 +168,6 @@
  */
 
 ENTRY(fork_trampoline)
-
         mtc0    zero, MIPS_COP_0_STATUS         # disable int
         COP0_SYNC
         nop                                     # 3 op delay
@@ -195,5 +195,4 @@
 	jal	exception_restore_registers
 	nop
 	eret
-
 END(fork_trampoline)

==== //depot/projects/mips2/src/sys/mips/mips/tlb.c#12 (text+ko) ====

@@ -181,21 +181,25 @@
 void
 tlb_update(vm_offset_t va, uint32_t asid, pt_entry_t pte0, pt_entry_t pte1)
 {
-	u_long ehi;
+	register_t ehi, old_ehi;
 	int i;
 
 	va &= ~PAGE_MASK;
 	ehi = MIPS_HI_ENTRY(va, asid);
+	old_ehi = mips_rd_entryhi();
 	mips_wr_entryhi(ehi);
 	mips_tlbp();
 	i = mips_rd_index();
 	mips_wr_entrylo0(pte0);
 	mips_wr_entrylo1(pte1);
 	mips_wr_entryhi(ehi);
+
 	if (i < 0)
 		mips_tlbwr();
 	else
 		mips_tlbwi();
+
+	mips_wr_entryhi(old_ehi);
 }
 
 /*
@@ -204,12 +208,9 @@
 void
 tlb_invalidate_all(void)
 {
-	u_long asid;
 	int i;
-	asid = mips_rd_entryhi();
 	for (i = 0; i < mips_num_tlb_entries; i++)
 		tlb_invalidate_one(i);
-	mips_wr_entryhi(asid);
 }
 
 /*
@@ -219,12 +220,9 @@
 void
 tlb_invalidate_nonwired(void)
 {
-	u_long asid;
 	int i;
-	asid = mips_rd_entryhi();
 	for (i = mips_rd_wired(); i < mips_num_tlb_entries; i++)
 		tlb_invalidate_one(i);
-	mips_wr_entryhi(asid);
 }
 
 /*
@@ -246,7 +244,10 @@
 tlb_invalidate_one(int i)
 {
 	u_long ehi;
+	u_long old_ehi;
 
+	old_ehi = mips_rd_entryhi();
+
 	/* Bogus VPN2. */
 	ehi = MIPS_KSEG3_START + 0x0fff0000 + 2 * i * PAGE_SIZE;
 	mips_wr_index(i);
@@ -254,22 +255,30 @@
 	mips_wr_entrylo1(0);
 	mips_wr_entryhi(ehi);
 	mips_tlbwi();
+
+	mips_wr_entryhi(old_ehi);
 }
 
 void
 tlb_invalidate_page(vm_offset_t va, uint32_t asid)
 {
-	u_long ehi;
+	u_long ehi, old_ehi;
 	int i;
 
+	old_ehi = mips_rd_entryhi();
+
 	va &= ~PAGE_MASK;
 	ehi = MIPS_HI_ENTRY(va, asid);
 	mips_wr_entryhi(ehi);
 	mips_tlbp();
 	i = mips_rd_index();
+
 	if (i >= 0)
 		tlb_invalidate_one(i);
+
 	mips_dcache_wbinv_range_index(va, PAGE_SIZE);
+
+	mips_wr_entryhi(old_ehi);
 }
 
 /*


More information about the p4-projects mailing list