shithub: riscv

Download patch

ref: 13785bbbef60f5c13aa973c1e7d4277aa55f6a2d
parent: 28836f3ff593f729a9dc92b67a6f99382bc84c28
author: cinap_lenrek <cinap_lenrek@felloff.net>
date: Fri Dec 6 21:19:14 EST 2019

pc: replace duplicated and broken mmu flush code in vunmap()

comparing m with MACHP() is wrong as m is a constant on 386.

add procflushothers(), which flushes all processes except up
using common procflushmmu() routine.

--- a/sys/src/9/pc/mmu.c
+++ b/sys/src/9/pc/mmu.c
@@ -643,10 +643,7 @@
 void
 vunmap(void *v, int size)
 {
-	int i;
 	ulong va, o;
-	Mach *nm;
-	Proc *p;
 	
 	/*
 	 * might not be aligned
@@ -675,25 +672,8 @@
 		putcr3(PADDR(MACHP(0)->pdb));
 		return;
 	}
-	for(i=0; i<conf.nproc; i++){
-		p = proctab(i);
-		if(p->state == Dead)
-			continue;
-		if(p != up)
-			p->newtlb = 1;
-	}
-	for(i=0; i<conf.nmach; i++){
-		nm = MACHP(i);
-		if(nm != m)
-			nm->flushmmu = 1;
-	}
+	procflushothers();
 	flushmmu();
-	for(i=0; i<conf.nmach; i++){
-		nm = MACHP(i);
-		if(nm != m)
-			while(active.machs[nm->machno] && nm->flushmmu)
-				;
-	}
 }
 
 /*
--- a/sys/src/9/port/portfns.h
+++ b/sys/src/9/port/portfns.h
@@ -229,6 +229,7 @@
 int		procfdprint(Chan*, int, char*, int);
 void		procflushseg(Segment*);
 void		procflushpseg(Physseg*);
+void		procflushothers(void);
 int		procindex(ulong);
 void		procinit0(void);
 ulong		procpagecount(Proc*);
--- a/sys/src/9/port/proc.c
+++ b/sys/src/9/port/proc.c
@@ -1412,6 +1412,17 @@
 	procflushmmu(matchpseg, ps);
 }
 
+static int
+matchother(Proc *p, void *a)
+{
+	return p != a;
+}
+void
+procflushothers(void)
+{
+	procflushmmu(matchother, up);
+}
+
 void
 scheddump(void)
 {