A hypervisor that has no accessed and dirty flags for EPT has to make
them up: it maps a page without access first and takes an EPT violation
to note the access. The pmap of FreeBSD does this, and it invalidates
the EPT every time, which is an INVEPT that empties the tables L2 runs
on. A FreeBSD guest with bhyve in it is very slow that way. L1 is now
offered the flags.
- When L1's EPTP has them on, a translation that is used for L2 sets the accessed flag in all of L1's entries, and the dirty flag in the last one when L2 writes. A page whose dirty flag is not set is given to L2 without write access, so that the first write comes back.
- An access of the CPU to one of L2's page tables counts as a write, as the SDM says (29.3.5).
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