shithub: riscv

Download patch

ref: e7e6f4fc9061190720b7a67adfff49f2546843aa
parent: 77ddc8c654824962149160af822f849b78cc6cc0
author: cinap_lenrek <cinap_lenrek@felloff.net>
date: Wed Jul 15 23:11:27 EDT 2020

pc64: disable interrupts in mmuwalk() for checkmmu()

we have to disable interrupts during mmuwalk() of user pages
as we can get preempted during mmu walk and the original
m->pml4 might become one of a different process.

--- a/sys/src/9/pc64/mmu.c
+++ b/sys/src/9/pc64/mmu.c
@@ -517,12 +517,17 @@
 void
 checkmmu(uintptr va, uintptr pa)
 {
-	uintptr *pte;
+	uintptr *pte, old;
+	int x;
 
+	x = splhi();
 	pte = mmuwalk(m->pml4, va, 0, 0);
-	if(pte != 0 && (*pte & PTEVALID) != 0 && PPN(*pte) != pa)
-		print("%ld %s: va=%#p pa=%#p pte=%#p\n",
-			up->pid, up->text, va, pa, *pte);
+	if(pte == 0 || ((old = *pte) & PTEVALID) == 0 || PPN(old) == pa){
+		splx(x);
+		return;
+	}
+	splx(x);
+	print("%ld %s: va=%#p pa=%#p pte=%#p\n", up->pid, up->text, va, pa, old);
 }
 
 uintptr