pmap_ts_referenced() clears PG_A of a page's mappings and invalidates
them, which for an EPT pmap counts up pm_eptgen. The page daemon does
this thousands of times a second. A hypervisor that keeps copies of an
EPT pmap's mappings, as vmm does for the EPT of a nested guest, has to
throw them away when pm_eptgen changes, though a cleared accessed flag
leaves every mapping as it was.
Count these invalidations in pm_eptgen_ad as well, before pm_eptgen, so
that pm_eptgen - pm_eptgen_ad changes only when a mapping has. Removing
a mapping and clearing the dirty flag still change it: a copy that stays
writable would lose the dirty tracking. The field goes at the end of
struct pmap.
AI assistance: as D61708, this change was developed with an AI assistant (Anthropic's Claude) under my direction. The assistant wrote the code and this description. The tests in the test plan were run on real hardware.
Signed-off-by: Wanpeng Qian <wanpengqian@gmail.com>
Sponsored by: keelos.dev