freebsd-dev/sys/amd64/include
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
..
pc amd64: clean up empty lines in .c and .h files 2020-09-01 21:16:54 +00:00
xen
_align.h
_bus.h Regularize my copyright notice 2019-12-04 16:56:11 +00:00
_inttypes.h
_limits.h
_stdint.h
_types.h
acpica_machdep.h
apm_bios.h
asm.h amd64: Add CFI directives for libc syscall stubs 2019-10-23 19:03:03 +00:00
asmacros.h amd64: prevents speculations over swapgs reload of %gs base. 2019-08-06 16:53:25 +00:00
atomic.h Expand generic subword atomic primitives 2020-03-25 23:12:43 +00:00
bus_dma.h sys/amd64: further adoption of SPDX licensing ID tags. 2017-11-27 15:03:07 +00:00
bus.h
clock.h re-synchronize TSC-s on SMP systems after resume, if necessary 2018-05-25 07:33:20 +00:00
counter.h amd64: provide custom zpcpu set/add/sub routines 2020-02-12 11:15:33 +00:00
cpu.h Add a custom implementation of cpu_lock_delay() for x86. 2018-11-05 22:54:03 +00:00
cpufunc.h amd64: patch ffsl to use the compiler builtin 2020-07-16 11:28:24 +00:00
cputypes.h
csan.h Add kcsan_md_unsupported from NetBSD. 2019-11-21 13:22:23 +00:00
db_machdep.h Cleanups related to debug exceptions on x86. 2018-05-22 00:45:00 +00:00
dump.h
efi.h amd64 ef_rt_arch_call: Preserve %rflags around call into EFI RT service. 2019-06-03 15:32:42 +00:00
elf.h
endian.h
exec.h sys: further adoption of SPDX licensing ID tags. 2017-11-20 19:43:44 +00:00
fdt.h
float.h
floatingpoint.h spdx: initial adoption of licensing ID tags. 2017-11-18 14:26:50 +00:00
fpu.h Add domain policy allocation for amd64 fpu_kern_ctx 2020-07-03 14:54:46 +00:00
frame.h PTI for amd64. 2018-01-17 11:44:21 +00:00
gdb_machdep.h gdb(4):amd64: Bump MI GDB_BUFSZ for more efficient transfers 2019-08-22 00:35:17 +00:00
ieeefp.h Resolve conflicts between macros in fenv.h and ieeefp.h 2018-05-31 20:22:47 +00:00
in_cksum.h sys: further adoption of SPDX licensing ID tags. 2017-11-20 19:43:44 +00:00
intr_machdep.h amd64: Make it easier to configure exception stack sizes 2020-11-04 16:42:20 +00:00
iodev.h sys/amd64: further adoption of SPDX licensing ID tags. 2017-11-27 15:03:07 +00:00
iommu.h o Add machine/iommu.h and include MD iommu headers from it, 2020-08-05 19:11:31 +00:00
kdb.h sys/amd64: further adoption of SPDX licensing ID tags. 2017-11-27 15:03:07 +00:00
limits.h sys: further adoption of SPDX licensing ID tags. 2017-11-20 19:43:44 +00:00
md_var.h amd64: Store full 64bit of FIP/FDP for 64bit processes when using XSAVE. 2020-10-03 23:17:29 +00:00
memdev.h Add the MEM_EXTRACT_PADDR ioctl to /dev/mem. 2020-09-02 18:12:47 +00:00
metadata.h
minidump.h Sparsify the vm_page_dump bitmap 2020-09-21 22:21:59 +00:00
mp_watchdog.h sys/amd64: further adoption of SPDX licensing ID tags. 2017-11-27 15:03:07 +00:00
nexusvar.h
npx.h
ofw_machdep.h
param.h amd64: clean up empty lines in .c and .h files 2020-09-01 21:16:54 +00:00
pcb.h Fix for mis-interpretation of PCB_KERNFPU. 2020-10-14 23:01:41 +00:00
pci_cfgreg.h
pcpu_aux.h amd64: move pcb out of kstack to struct thread. 2019-10-25 20:09:42 +00:00
pcpu.h amd64 pmap: microoptimize local shootdowns for PCID PTI configurations 2020-07-18 18:19:57 +00:00
pmap.h vmm: Make pmap_invalidate_ept() wait synchronously for guest exits 2020-11-11 15:01:17 +00:00
pmc_mdep.h hwpmc: ABI fixes 2018-06-04 02:05:48 +00:00
ppireg.h sys/amd64: further adoption of SPDX licensing ID tags. 2017-11-27 15:03:07 +00:00
proc.h Get rid of sa->narg. It serves no purpose; use sa->callp->sy_narg instead. 2020-09-27 18:47:06 +00:00
procctl.h amd64 KPTI: add control from procctl(2). 2019-03-16 11:44:33 +00:00
profile.h Fix high resolution kernel profiling just enough to not crash at boot 2018-06-02 05:48:44 +00:00
psl.h
ptrace.h
pvclock.h
reg.h
reloc.h sys: further adoption of SPDX licensing ID tags. 2017-11-20 19:43:44 +00:00
resource.h
runq.h sys/amd64: further adoption of SPDX licensing ID tags. 2017-11-27 15:03:07 +00:00
segments.h amd64: move GDT into PCPU area. 2019-11-12 15:51:47 +00:00
setjmp.h
sf_buf.h sys/amd64: further adoption of SPDX licensing ID tags. 2017-11-27 15:03:07 +00:00
sgx.h
sgxreg.h
sigframe.h
signal.h
smp.h Allow swi_sched() to be called from NMI context. 2020-07-25 15:19:38 +00:00
specialreg.h
stack.h
stdarg.h
sysarch.h
timerreg.h sys/amd64: further adoption of SPDX licensing ID tags. 2017-11-27 15:03:07 +00:00
trap.h
tss.h amd64: move common_tss into pcpu. 2019-11-10 09:28:18 +00:00
ucontext.h
vdso.h
vm.h sys/amd64: further adoption of SPDX licensing ID tags. 2017-11-27 15:03:07 +00:00
vmm_dev.h vmm(4): Add 12 user ABI compat after r349948 2020-05-20 17:27:54 +00:00
vmm_instruction_emul.h bhyve(8): For prototyping, reattempt decode in userspace 2020-06-25 00:18:42 +00:00
vmm_snapshot.h amd64: clean up empty lines in .c and .h files 2020-09-01 21:16:54 +00:00
vmm.h amd64: clean up empty lines in .c and .h files 2020-09-01 21:16:54 +00:00
vmparam.h Add a vmparam.h constant indicating pmap support for large pages. 2020-09-23 19:34:21 +00:00