freebsd-nq/sys/amd64/vmm
Mark Johnston 6f5a960678 vmm: Make pmap_invalidate_ept() wait synchronously for guest exits
Currently EPT TLB invalidation is done by incrementing a generation
counter and issuing an IPI to all CPUs currently running vCPU threads.
The VMM inner loop caches the most recently observed generation on each
host CPU and invalidates TLB entries before executing the VM if the
cached generation number is not the most recent value.
pmap_invalidate_ept() issues IPIs to force each vCPU to stop executing
guest instructions and reload the generation number.  However, it does
not actually wait for vCPUs to exit, potentially creating a window where
guests may continue to reference stale TLB entries.

Fix the problem by bracketing guest execution with an SMR read section
which is entered before loading the invalidation generation.  Then,
pmap_invalidate_ept() increments the current write sequence before
loading pm_active and sending IPIs, and polls readers to ensure that all
vCPUs potentially operating with stale TLB entries have exited before
pmap_invalidate_ept() returns.

Also ensure that unsynchronized loads of the generation counter are
wrapped with atomic(9), and stop (inconsistently) updating the
invalidation counter and pm_active bitmask with acquire semantics.

Reviewed by:	grehan, kib
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D26910
2020-11-11 15:01:17 +00:00
..
amd vmm: Make pmap_invalidate_ept() wait synchronously for guest exits 2020-11-11 15:01:17 +00:00
intel vmm: Make pmap_invalidate_ept() wait synchronously for guest exits 2020-11-11 15:01:17 +00:00
io amd64: clean up empty lines in .c and .h files 2020-09-01 21:16:54 +00:00
vmm_dev.c vmm(4): Add 12 user ABI compat after r349948 2020-05-20 17:27:54 +00:00
vmm_host.c
vmm_host.h amd64: move GDT into PCPU area. 2019-11-12 15:51:47 +00:00
vmm_instruction_emul.c Add bhyve support for LA57 guest mode. 2020-08-23 20:37:21 +00:00
vmm_ioport.c
vmm_ioport.h
vmm_ktr.h
vmm_lapic.c vmx: use C99 bool, not boolean_t 2019-08-01 02:16:48 +00:00
vmm_lapic.h vmx: use C99 bool, not boolean_t 2019-08-01 02:16:48 +00:00
vmm_mem.c
vmm_mem.h
vmm_snapshot.c Initial support for bhyve save and restore. 2020-05-05 00:02:04 +00:00
vmm_stat.c vmm: Add Hygon Dhyana support. 2020-02-13 19:03:12 +00:00
vmm_stat.h amd64: clean up empty lines in .c and .h files 2020-09-01 21:16:54 +00:00
vmm_util.c vmm: Add Hygon Dhyana support. 2020-02-13 19:03:12 +00:00
vmm_util.h vmm: Add Hygon Dhyana support. 2020-02-13 19:03:12 +00:00
vmm.c amd64: clean up empty lines in .c and .h files 2020-09-01 21:16:54 +00:00
x86.c Clear the upper 32-bits of registers in x86_emulate_cpuid(). 2020-10-01 16:45:11 +00:00
x86.h Clear the upper 32-bits of registers in x86_emulate_cpuid(). 2020-10-01 16:45:11 +00:00