freebsd-dev/sys
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
..
amd64 amd64 pmap: microoptimize local shootdowns for PCID PTI configurations 2020-07-18 18:19:57 +00:00
arm Switch from SCTP to SCTP_SUPPORT in GENERIC configs. 2020-07-16 15:09:04 +00:00
arm64 Regen after r363304. 2020-07-18 11:31:31 +00:00
bsm bsm: add AUE_CLOSERANGE 2020-04-24 01:27:25 +00:00
cam Hold the mutex when releasing a callout. 2020-07-16 20:43:28 +00:00
cddl Don't overflow the trap frame when accessing lr or xzr. 2020-07-17 14:39:07 +00:00
compat Make linux fallocate(2) return EOPNOTSUPP, not ENOSYS, on unsupported mode, 2020-07-18 12:21:08 +00:00
conf Add a driver for the SafeXcel EIP-97. 2020-07-14 14:09:29 +00:00
contrib MFV: r363292 2020-07-18 07:35:34 +00:00
crypto Add domain policy allocation for amd64 fpu_kern_ctx 2020-07-03 14:54:46 +00:00
ddb [PowerPC] More relocation fixes 2020-06-21 03:39:26 +00:00
dev Add acpi_iort_map_pci_smmuv3(). 2020-07-17 14:51:51 +00:00
dts Remove licenses 2020-06-04 17:20:58 +00:00
fs Fix the pNFS flexible file layout client for servers with small write size. 2020-07-15 01:26:28 +00:00
gdb Mark more nodes as CTLFLAG_MPSAFE or CTLFLAG_NEEDGIANT (17 of many) 2020-02-26 14:26:36 +00:00
geom g_concat_find_device: trim /dev/ if it is present, like other GEOM 2020-07-09 08:00:46 +00:00
gnu dts: patch the am33xx dts for upcoming clock support 2020-06-05 20:14:54 +00:00
i386 Regen after r363304. 2020-07-18 11:31:31 +00:00
isa
kern Short-circuit tdfind when looking for the calling thread. 2020-07-18 00:14:43 +00:00
kgssapi Add support for optional separate output buffers to in-kernel crypto. 2020-05-25 22:12:04 +00:00
libkern libkern: Add arc4random_uniform 2020-05-23 17:51:06 +00:00
mips Revert r240317 to prevent leaking pmap entries 2020-07-16 23:29:26 +00:00
modules build DTS for Orange Pi PC Plus as well 2020-07-15 18:04:01 +00:00
net bridge: Don't sleep during epoch 2020-07-18 12:43:11 +00:00
net80211 [net80211] Commit files missing in the previous commit 2020-07-01 00:24:55 +00:00
netgraph Fix L2CAP ACL packet PB(Packet Boundary) flag for LE PDU. 2020-07-17 15:50:03 +00:00
netinet Remove code which is not needed. 2020-07-18 13:10:02 +00:00
netinet6 Switch inet6 default route subscription to the new rib subscription api. 2020-07-12 11:24:23 +00:00
netipsec Simplify IPsec transform-specific teardown. 2020-06-25 23:59:16 +00:00
netpfil Don't print VNET pointer when initializing dummynet 2020-07-13 13:35:36 +00:00
netsmb Mark more nodes as CTLFLAG_MPSAFE or CTLFLAG_NEEDGIANT (17 of many) 2020-02-26 14:26:36 +00:00
nfs Use epoch(9) for rtentries to simplify control plane operations. 2020-05-23 10:21:02 +00:00
nfsclient
nfsserver
nlm Fix export_args ex_flags field so that is 64bits, the same as mnt_flags. 2020-06-14 00:10:18 +00:00
ofed Infiniband clients must be attached and detached in a specific order in ibcore. 2020-07-06 08:50:11 +00:00
opencrypto Clean up crypto_init(). 2020-07-17 14:45:16 +00:00
powerpc Revert r240317 to prevent leaking pmap entries 2020-07-16 23:29:26 +00:00
riscv Switch from SCTP to SCTP_SUPPORT in GENERIC configs. 2020-07-16 15:09:04 +00:00
rpc Fix up a comment added by r362455. 2020-06-21 02:49:56 +00:00
security vfs: fix vn_poll performance with either MAC or AUDIT 2020-07-16 14:09:18 +00:00
sys o Move iommu_test_boundary() to sys/iommu.h 2020-07-18 13:10:31 +00:00
teken
tests Mark more nodes as CTLFLAG_MPSAFE or CTLFLAG_NEEDGIANT (17 of many) 2020-02-26 14:26:36 +00:00
tools vfs: stop null checking routines in vop wrappers 2020-01-26 00:41:38 +00:00
ufs The binary representation of the superblock (the fs structure) is written 2020-06-19 01:04:25 +00:00
vm Fix vnode_pager handling of read ahead/behind pages when a disk read fails. 2020-07-17 23:10:35 +00:00
x86 o Move iommu_test_boundary() to sys/iommu.h 2020-07-18 13:10:31 +00:00
xdr Split XDR into separate kernel module. Make krpc depend on xdr. 2020-04-17 06:04:20 +00:00
xen Mark more nodes as CTLFLAG_MPSAFE or CTLFLAG_NEEDGIANT (16 of many) 2020-02-25 19:04:39 +00:00
Makefile Remove sparc64 kernel support 2020-02-03 17:35:11 +00:00