freebsd-skq/sys/amd64/vmm/intel
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
..
ept.c Mark more nodes as CTLFLAG_MPSAFE or CTLFLAG_NEEDGIANT (4 of many) 2020-02-15 18:57:49 +00:00
ept.h
vmcs.c amd64: clean up empty lines in .c and .h files 2020-09-01 21:16:54 +00:00
vmcs.h Initial support for bhyve save and restore. 2020-05-05 00:02:04 +00:00
vmx_controls.h
vmx_cpufunc.h
vmx_genassym.c vmx: Implement pmap (de)activation in C 2020-10-19 15:24:35 +00:00
vmx_msr.c amd64: clean up empty lines in .c and .h files 2020-09-01 21:16:54 +00:00
vmx_msr.h Support guest rdtscp and rdpid instructions on Intel VT-x 2020-08-18 07:23:47 +00:00
vmx_support.S vmx: Implement pmap (de)activation in C 2020-10-19 15:24:35 +00:00
vmx.c vmm: Make pmap_invalidate_ept() wait synchronously for guest exits 2020-11-11 15:01:17 +00:00
vmx.h vmx: Implement pmap (de)activation in C 2020-10-19 15:24:35 +00:00
vtd.c amd64: clean up empty lines in .c and .h files 2020-09-01 21:16:54 +00:00