freebsd-skq/sys
Konstantin Belousov b7dbf1132e Optimize context switch for PTI on PCID pmap.
In pti-enabled pmap, the PCID allocation scheme assigns temporal id
for the kernel page table, and user page table twin PCID is
calculating by setting high bit in the kernel PCID.  So the kernel AS
is mapped with per-vmspace PCID, and we must completely shut down all
mappings in KVA when switching contexts, so that newly switched thread
would see all changes in KVA occured while it was not executing.
After all, KVA is same between all threads.

Currently the pti context switch for the user part of the page table
gets its TLB entries flushed too. It is excessive. The same PCID
flushing algorithm that is used for non-pti pmap, correctly works for
the UVA mappings.  The only shared TLB entries are the pages from KVA
accessed by the kernel entry trampoline.  All of them are static
except per-thread TSS and LDT. For TSS and LDT, the lifetime of newly
allocated entries is the whole thread life, so it is fine as well. If
not fine, then explicit shutdowns for current pmap of the newly
allocated LDT and TSS pages would be enough.

Also restore the constant value for the pm_pcid for the kernel_pmap.
Before, for PTI pmap, pm_pcid was erronously rolled same as user
pmap's pm_pcid, but it was not used.

Reviewed by:	markj (previous version)
Discussed with:	alc
Tested by:	pho
Sponsored by:	The FreeBSD Foundation
MFC after:	1 month
Differential revision:	https://reviews.freebsd.org/D14961
2018-04-12 19:59:36 +00:00
..
amd64 Optimize context switch for PTI on PCID pmap. 2018-04-12 19:59:36 +00:00
arm [pi] Do not attach bcm2835_pwm if DTB node is not enabled 2018-04-10 20:31:25 +00:00
arm64 Enable Qualcomm Debug Subsystem (QDSS) block on MSM8916 SoC. 2018-04-10 12:53:48 +00:00
bsm
cam Do not fail devices just for errors in descriptor format. 2018-04-06 19:47:44 +00:00
cddl allow ZFS pool to have temporary name for duration of current import 2018-04-12 10:37:26 +00:00
compat linuxulator: deduplicate linux_exec_imgact_try 2018-04-09 17:24:01 +00:00
conf Add SMP support for BERI CPU. 2018-04-12 17:43:19 +00:00
contrib Import CK as of commit b19ed4c6a56ec93215ab567ba18ba61bf1cfbac8 2018-04-02 23:40:50 +00:00
crypto opencrypto: Integrate Chacha20 algorithm into OCF 2018-03-29 04:02:50 +00:00
ddb db_script_exec: use a saved script name when reporting commands executed 2018-03-04 13:27:21 +00:00
dev Tune xDMA interface slightly: 2018-04-12 15:36:24 +00:00
dts Remove deprecated DT sources of Armada 38x SoCs 2018-04-10 13:25:42 +00:00
fs Move most of the contents of opt_compat.h to opt_global.h. 2018-04-06 17:35:35 +00:00
gdb amd64: Protect the kernel text, data, and BSS by setting the RW/NX bits 2018-03-06 14:28:37 +00:00
geom Annotate geom modules with MODULE_VERSION 2018-04-10 19:18:16 +00:00
gnu bwn(4): txpid2g/txpid5g[lh] are not defined after sromrev 7; the default 2018-02-13 17:43:54 +00:00
i386 linuxulator: deduplicate linux_exec_imgact_try 2018-04-09 17:24:01 +00:00
isa Revert r330780, it was improperly tested and results in taking a spin 2018-03-11 20:13:15 +00:00
kern locks: extend speculative spin waiting for readers to drain 2018-04-11 01:43:29 +00:00
kgssapi kgssapi: Remove trivial deadcode 2018-02-14 00:12:03 +00:00
libkern iconv uses strlen directly on user supplied memory 2018-02-26 18:23:36 +00:00
mips Add SMP support for BERI CPU. 2018-04-12 17:43:19 +00:00
modules netmap: align codebase to the current upstream (commit id 3fb001303718146) 2018-04-12 07:20:50 +00:00
net Restore r332389 after resolution of locking fixes. 2018-04-12 14:35:37 +00:00
net80211 Use an accessor function to access ifr_data. 2018-03-30 18:50:13 +00:00
netgraph Correct pseudo misspelling in sys/ comments 2018-02-23 18:15:50 +00:00
netinet Remove support for FDDI networks. 2018-04-11 17:28:24 +00:00
netinet6 Remove support for FDDI networks. 2018-04-11 17:28:24 +00:00
netipsec Set the proper vnet in IPsec callback functions. 2018-03-20 17:05:23 +00:00
netpfil pf: limit ioctl to a reasonable and tuneable number of elements 2018-04-11 11:43:12 +00:00
netsmb Unsign some values related to allocation. 2018-01-22 02:08:10 +00:00
nfs Remove support for FDDI networks. 2018-04-11 17:28:24 +00:00
nfsclient style: Remove remaining deprecated MALLOC/FREE macros 2018-01-25 22:25:13 +00:00
nfsserver
nlm Use syscall_helper_register() to register syscalls and initialize though 2018-02-10 01:09:22 +00:00
ofed Improve copy-and-pasted versions of SIOCGIFADDR. 2018-03-27 20:51:49 +00:00
opencrypto Move most of the contents of opt_compat.h to opt_global.h. 2018-04-06 17:35:35 +00:00
powerpc Reenter KDB on fault on powerpc, instead of panicking 2018-04-10 21:14:54 +00:00
riscv Rename assym.s to assym.inc 2018-03-20 17:58:51 +00:00
rpc Do pass removing some write-only variables from the kernel. 2017-12-25 04:48:39 +00:00
security Use an accessor function to access ifr_data. 2018-03-30 18:50:13 +00:00
sparc64 Clean up OF_getprop_alloc API 2018-04-08 22:59:34 +00:00
sys Fix a typo. 2018-04-12 14:57:48 +00:00
teken Pedantic polishing of code to please FlexeLint. 2018-04-08 19:23:50 +00:00
tests
tools Add dtb overlays support 2018-03-24 21:30:24 +00:00
ufs Renumber soft-update types starting at 1 instead of 0 to avoid confusion 2018-04-05 00:32:01 +00:00
vm Handle Skylake-X errata SKZ63. 2018-04-07 17:06:13 +00:00
x86 Move most of the contents of opt_compat.h to opt_global.h. 2018-04-06 17:35:35 +00:00
xdr
xen
Makefile