Page MenuHomeFreeBSD

D61939.1795510510.diff
No OneTemporary

Authored By
Unknown
Size
1 KB
Referenced Files
None
Subscribers
None

D61939.1795510510.diff

diff --git a/sys/amd64/amd64/pmap.c b/sys/amd64/amd64/pmap.c
--- a/sys/amd64/amd64/pmap.c
+++ b/sys/amd64/amd64/pmap.c
@@ -3359,6 +3359,21 @@
}
}
+/*
+ * Invalidate a mapping of which only the accessed flag has been cleared. For
+ * an EPT pmap this is counted in pm_eptgen_ad as well as in pm_eptgen, so that
+ * a hypervisor that keeps copies of the pmap's mappings, such as the EPT of a
+ * nested guest, knows that they are still right.
+ */
+static void
+pmap_invalidate_page_accessed(pmap_t pmap, vm_offset_t va)
+{
+
+ if (pmap->pm_type == PT_EPT)
+ atomic_add_long(&pmap->pm_eptgen_ad, 1);
+ pmap_invalidate_page(pmap, va);
+}
+
void
pmap_invalidate_range(pmap_t pmap, vm_offset_t sva, vm_offset_t eva)
{
@@ -9026,7 +9041,8 @@
(oldpde & PG_W) == 0) {
if (safe_to_clear_referenced(pmap, oldpde)) {
atomic_clear_long(pde, PG_A);
- pmap_invalidate_page(pmap, pv->pv_va);
+ pmap_invalidate_page_accessed(pmap,
+ pv->pv_va);
demoted = false;
} else if (pmap_demote_pde_locked(pmap, pde,
pv->pv_va, &lock)) {
@@ -9107,7 +9123,7 @@
if ((*pte & PG_A) != 0) {
if (safe_to_clear_referenced(pmap, *pte)) {
atomic_clear_long(pte, PG_A);
- pmap_invalidate_page(pmap, pv->pv_va);
+ pmap_invalidate_page_accessed(pmap, pv->pv_va);
cleared++;
} else if ((*pte & PG_W) == 0) {
/*
diff --git a/sys/amd64/include/pmap.h b/sys/amd64/include/pmap.h
--- a/sys/amd64/include/pmap.h
+++ b/sys/amd64/include/pmap.h
@@ -335,6 +335,7 @@
int pm_flags;
struct pmap_pcid *pm_pcidp;
struct rangeset pm_pkru;
+ long pm_eptgen_ad; /* of pm_eptgen: only PG_A cleared */
};
/* flags */

File Metadata

Mime Type
text/plain
Expires
Tue, Nov 24, 8:55 AM (22 h, 54 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
41951100
Default Alt Text
D61939.1795510510.diff (1 KB)

Event Timeline