freebsd-dev/sys/amd64/include
Konstantin Belousov 3ec7e1695c amd64 pmap: microoptimize local shootdowns for PCID PTI configurations
When pmap operates in PTI mode, we must reload %cr3 on return to
userspace.  In non-PCID mode the reload always flushes all non-global
TLB entries and we take advantage of it by only invalidating the KPT
TLB entries (there is no cached UPT entries at all).

In PCID mode, we flush both KPT and UPT TLB explicitly, but we can
take advantage of the fact that PCID mode command to reload %cr3
includes a flag to flush/not flush target TLB.  In particular, we can
avoid the flush for UPT, instead record that load of pc_ucr3 into %cr3
on return to usermode should be flushing.  This is done by providing
either all-1s or ~CR3_PCID_MASK in pc_ucr3_load_mask.  The mask is
automatically reset to all-1s on return to usermode.

Similarly, we can avoid flushing UPT TLB on context switch, replacing
it by setting pc_ucr3_load_mask.  This unifies INVPCID and non-INVPCID
PTI ifunc, leaving only 4 cases instead of 6.  This trick is also
applicable both to the TLB shootdown IPI handlers, since handlers
interrupt the target thread.

But then we need to check pc_curpmap in handlers, and this would
reopen the same race for INVPCID machines as was fixed in r306350 for
non-INVPCID.  To not introduce the same bug, unconditionally do
spinlock_enter() in pmap_activate().

Reviewed by:	alc, markj
Tested by:	pho
Sponsored by:	The FreeBSD Foundation
MFC after:	3 weeks
Differential revision:	https://reviews.freebsd.org/D25483
2020-07-18 18:19:57 +00:00
..
pc
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
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
fdt.h
float.h
floatingpoint.h
fpu.h Add domain policy allocation for amd64 fpu_kern_ctx 2020-07-03 14:54:46 +00:00
frame.h
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
intr_machdep.h Drop "All rights reserved" from my copyright statements. 2019-03-06 22:11:45 +00:00
iodev.h
kdb.h
limits.h
md_var.h amd64: move pcb out of kstack to struct thread. 2019-10-25 20:09:42 +00:00
memdev.h
metadata.h
minidump.h
mp_watchdog.h
nexusvar.h
npx.h
ofw_machdep.h
param.h Define MAXCPU consistently between the kernel and KLDs. 2020-02-05 19:08:21 +00:00
pcb.h Provide dummy definition of the amd64 struct pcb for -m32 compilation. 2019-10-26 18:22:52 +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 amd64 pmap: microoptimize local shootdowns for PCID PTI configurations 2020-07-18 18:19:57 +00:00
pmc_mdep.h hwpmc: ABI fixes 2018-06-04 02:05:48 +00:00
ppireg.h
proc.h amd64: move pcb out of kstack to struct thread. 2019-10-25 20:09:42 +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
resource.h
runq.h
segments.h amd64: move GDT into PCPU area. 2019-11-12 15:51:47 +00:00
setjmp.h
sf_buf.h
sgx.h
sgxreg.h
sigframe.h
signal.h
smp.h amd64: allow parallel shootdown IPIs 2020-07-14 20:37:50 +00:00
specialreg.h
stack.h
stdarg.h
sysarch.h
timerreg.h
trap.h
tss.h amd64: move common_tss into pcpu. 2019-11-10 09:28:18 +00:00
ucontext.h
vdso.h
vm.h
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 Initial support for bhyve save and restore. 2020-05-05 00:02:04 +00:00
vmm.h bhyve(8): For prototyping, reattempt decode in userspace 2020-06-25 00:18:42 +00:00
vmparam.h Fix some nits in pmap_page_array_startup(). 2019-09-03 22:26:01 +00:00