freebsd-skq/sys/amd64
kib 1a6817d592 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
..
acpica Merge ACPICA 20190329. 2019-03-29 20:21:28 +00:00
amd64 amd64 pmap: microoptimize local shootdowns for PCID PTI configurations 2020-07-18 18:19:57 +00:00
cloudabi32 Use uintptr_t instead of register_t * for the stack base. 2019-12-03 23:17:54 +00:00
cloudabi64 Use uintptr_t instead of register_t * for the stack base. 2019-12-03 23:17:54 +00:00
conf Switch from SCTP to SCTP_SUPPORT in GENERIC configs. 2020-07-16 15:09:04 +00:00
ia32 Make ps_strings in struct image_params into a pointer. 2020-04-15 20:21:30 +00:00
include amd64 pmap: microoptimize local shootdowns for PCID PTI configurations 2020-07-18 18:19:57 +00:00
linux Regen after r363304. 2020-07-18 11:31:31 +00:00
linux32 Regen after r363304. 2020-07-18 11:31:31 +00:00
pci pci_cfgreg.c: Use io port config access for early boot time. 2019-04-09 18:07:17 +00:00
sgx Fix a few places that free a page from an object without busy held. This is 2019-12-02 22:42:05 +00:00
vmm bhyve(8): For prototyping, reattempt decode in userspace 2020-06-25 00:18:42 +00:00
Makefile