PERFORCE change 105330 for review
tkuik
tkuik at FreeBSD.org
Wed Aug 30 15:58:16 UTC 2006
http://perforce.freebsd.org/chv.cgi?CH=105330
Change 105330 by tkuik at tkuik_freebsd on 2006/08/30 15:28:02
Clear PMAP1 & PMAP2 entries after use to prevent grant transfer
failures in case the page being mapped is later transferred to another
domain.
Affected files ...
.. //depot/projects/xen3/src/sys/i386-xen/i386-xen/pmap.c#7 edit
Differences ...
==== //depot/projects/xen3/src/sys/i386-xen/i386-xen/pmap.c#7 (text+ko) ====
@@ -249,6 +249,9 @@
#endif
static pt_entry_t *PMAP1 = 0, *PMAP2;
static pt_entry_t *PADDR1 = 0, *PADDR2;
+#ifdef XEN
+static int PMAP1_inuse = 0, PMAP2_inuse = 0;
+#endif
#ifdef SMP
static int PMAP1cpu;
static int PMAP1changedcpu;
@@ -765,6 +768,7 @@
if (tmppf != newpf) {
PT_SET_VA(PMAP2, newpf | PG_V | PG_A, FALSE);
pmap_invalidate_page(kernel_pmap, (vm_offset_t)PADDR2);
+ PMAP2_inuse = 1;
}
#else
@@ -827,13 +831,14 @@
return (vtopte(va));
mtx_assert(&vm_page_queue_mtx, MA_OWNED);
KASSERT(curthread->td_pinned > 0, ("curthread not pinned"));
- newpf = *pde & PG_FRAME;
#ifdef XEN
newpf = PT_GET(pde) & PG_FRAME;
tmppf = PT_GET(PMAP1) & PG_FRAME;
if (tmppf != newpf) {
PT_SET_VA(PMAP1, newpf | PG_V | PG_A, TRUE);
+ PMAP1_inuse = 1;
#else
+ newpf = *pde & PG_FRAME;
if ((*PMAP1 & PG_FRAME) != newpf) {
*PMAP1 = newpf | PG_RW | PG_V | PG_A | PG_M;
#endif
@@ -889,6 +894,12 @@
rtval = (*pte & PG_FRAME) | (va & PAGE_MASK);
#endif
pmap_pte_release(pte);
+#ifdef XEN
+ if (PMAP2_inuse) {
+ PT_CLEAR_VA(PMAP2, TRUE);
+ PMAP2_inuse = 0;
+ }
+#endif
}
PMAP_UNLOCK(pmap);
return (rtval);
@@ -918,6 +929,12 @@
pte = pmap_pte(pmap, va);
rtval = (*pte & PG_FRAME) | (va & PAGE_MASK);
pmap_pte_release(pte);
+#ifdef XEN
+ if (PMAP2_inuse) {
+ PT_CLEAR_VA(PMAP2, TRUE);
+ PMAP2_inuse = 0;
+ }
+#endif
}
PMAP_UNLOCK(pmap);
return (rtval);
@@ -957,6 +974,10 @@
sched_pin();
#ifdef XEN
pte = PT_GET(pmap_pte_quick(pmap, va));
+ if (PMAP1_inuse) {
+ PT_CLEAR_VA(PMAP1, TRUE);
+ PMAP1_inuse = 0;
+ }
#else
pte = *pmap_pte_quick(pmap, va);
#endif
@@ -1739,6 +1760,12 @@
free_pv_entry(pv);
}
}
+#ifdef XEN
+ if (PMAP1_inuse) {
+ PT_CLEAR_VA(PMAP1, TRUE);
+ PMAP1_inuse = 0;
+ }
+#endif
sched_unpin();
if (allocated_pv == NULL) {
if (vpq == &vm_page_queues[PQ_INACTIVE]) {
@@ -1845,10 +1872,16 @@
mtx_assert(&vm_page_queue_mtx, MA_OWNED);
KASSERT(curthread->td_pinned > 0, ("curthread not pinned"));
PMAP_LOCK_ASSERT(pmap, MA_OWNED);
- if ((pte = pmap_pte_quick(pmap, va)) == NULL || *pte == 0)
- return;
- pmap_remove_pte(pmap, pte, va);
- pmap_invalidate_page(pmap, va);
+ if ((pte = pmap_pte_quick(pmap, va)) && *pte) {
+ pmap_remove_pte(pmap, pte, va);
+ pmap_invalidate_page(pmap, va);
+ }
+#ifdef XEN
+ if (PMAP1_inuse) {
+ PT_CLEAR_VA(PMAP1, TRUE);
+ PMAP1_inuse = 0;
+ }
+#endif
}
/*
@@ -1939,6 +1972,12 @@
break;
}
}
+#ifdef XEN
+ if (PMAP1_inuse) {
+ PT_CLEAR_VA(PMAP1, TRUE);
+ PMAP1_inuse = 0;
+ }
+#endif
out:
sched_unpin();
vm_page_unlock_queues();
@@ -2006,6 +2045,12 @@
free_pv_entry(pv);
}
vm_page_flag_clear(m, PG_WRITEABLE);
+#ifdef XEN
+ if (PMAP1_inuse) {
+ PT_CLEAR_VA(PMAP1, TRUE);
+ PMAP1_inuse = 0;
+ }
+#endif
sched_unpin();
}
@@ -2106,6 +2151,12 @@
}
}
}
+#ifdef XEN
+ if (PMAP1_inuse) {
+ PT_CLEAR_VA(PMAP1, TRUE);
+ PMAP1_inuse = 0;
+ }
+#endif
sched_unpin();
vm_page_unlock_queues();
if (anychanged)
@@ -2302,6 +2353,12 @@
} else
pte_store(pte, newpte | PG_A);
}
+#ifdef XEN
+ if (PMAP1_inuse) {
+ PT_CLEAR_VA(PMAP1, TRUE);
+ PMAP1_inuse = 0;
+ }
+#endif
sched_unpin();
vm_page_unlock_queues();
PMAP_UNLOCK(pmap);
@@ -2542,6 +2599,12 @@
*/
pmap_pte_set_w(pte, wired);
pmap_pte_release(pte);
+#ifdef XEN
+ if (PMAP2_inuse) {
+ PT_CLEAR_VA(PMAP2, TRUE);
+ PMAP2_inuse = 0;
+ }
+#endif
PMAP_UNLOCK(pmap);
}
@@ -2666,6 +2729,12 @@
}
}
PT_UPDATES_FLUSH();
+#ifdef XEN
+ if (PMAP1_inuse) {
+ PT_CLEAR_VA(PMAP1, TRUE);
+ PMAP1_inuse = 0;
+ }
+#endif
sched_unpin();
vm_page_unlock_queues();
PMAP_UNLOCK(src_pmap);
@@ -2956,6 +3025,12 @@
pmap_unuse_pt(pmap, pv->pv_va);
free_pv_entry(pv);
}
+#ifdef XEN
+ if (PMAP1_inuse) {
+ PT_CLEAR_VA(PMAP1, TRUE);
+ PMAP1_inuse = 0;
+ }
+#endif
sched_unpin();
pmap_invalidate_all(pmap);
PMAP_UNLOCK(pmap);
@@ -2996,6 +3071,12 @@
if (rv)
break;
}
+#ifdef XEN
+ if (PMAP1_inuse) {
+ PT_CLEAR_VA(PMAP1, TRUE);
+ PMAP1_inuse = 0;
+ }
+#endif
sched_unpin();
return (rv);
}
@@ -3094,6 +3175,12 @@
}
if (bit == PG_RW)
vm_page_flag_clear(m, PG_WRITEABLE);
+#ifdef XEN
+ if (PMAP1_inuse) {
+ PT_CLEAR_VA(PMAP1, TRUE);
+ PMAP1_inuse = 0;
+ }
+#endif
sched_unpin();
}
@@ -3172,6 +3259,12 @@
}
PMAP_UNLOCK(pv->pv_pmap);
} while ((pv = pvn) != NULL && pv != pvf);
+#ifdef XEN
+ if (PMAP1_inuse) {
+ PT_CLEAR_VA(PMAP1, TRUE);
+ PMAP1_inuse = 0;
+ }
+#endif
}
sched_unpin();
@@ -3270,6 +3363,12 @@
ptep = pmap_pte(pmap, addr);
pte = (ptep != NULL) ? PT_GET(ptep) : 0;
pmap_pte_release(ptep);
+#ifdef XEN
+ if (PMAP2_inuse) {
+ PT_CLEAR_VA(PMAP2, TRUE);
+ PMAP2_inuse = 0;
+ }
+#endif
PMAP_UNLOCK(pmap);
if (pte != 0) {
@@ -3401,8 +3500,7 @@
index = 0;
printf("\n");
}
- sx_sunlock(&allproc_lock);
- return npte;
+ goto done;
}
pte = pmap_pte(pmap, va);
if (pte && pmap_pte_v(pte)) {
@@ -3426,6 +3524,13 @@
}
}
}
+ done:
+#ifdef XEN
+ if (PMAP2_inuse) {
+ PT_CLEAR_VA(PMAP2, TRUE);
+ PMAP2_inuse = 0;
+ }
+#endif
sx_sunlock(&allproc_lock);
return npte;
}
@@ -3460,6 +3565,12 @@
printf("%x:%x ", va, *ptep);
};
+#ifdef XEN
+ if (PMAP2_inuse) {
+ PT_CLEAR_VA(PMAP2, TRUE);
+ PMAP2_inuse = 0;
+ }
+#endif
}
void
@@ -3492,6 +3603,10 @@
pmap_pte_release(pte);
}
PT_UPDATES_FLUSH();
+ if (PMAP2_inuse) {
+ PT_CLEAR_VA(PMAP2, TRUE);
+ PMAP2_inuse = 0;
+ }
}
void
@@ -3506,6 +3621,10 @@
pmap_pte_release(pte);
}
PT_UPDATES_FLUSH();
+ if (PMAP2_inuse) {
+ PT_CLEAR_VA(PMAP2, TRUE);
+ PMAP2_inuse = 0;
+ }
}
More information about the p4-projects
mailing list