opnsense-src/sys/amd64
Konstantin Belousov 3e902b3d76 Make WRFSBASE and WRGSBASE instructions functional.
Right now, we enable the CR4.FSGSBASE bit on CPUs which support the
facility (Ivy and later), to allow usermode to read fs and gs bases
without syscalls. This bit also controls the write access to bases
from userspace, but WRFSBASE and WRGSBASE instructions currently
cannot be used, because return path from both exceptions or interrupts
overrides bases with the values from pcb.

Supporting the instructions is useful because this means that usermode
can implement green-threads completely in userspace without issuing
syscalls to change all of the machine context.

Support is implemented by saving the fs base and user gs base when
PCB_FULL_IRET flag is set. The flag is set on the context switch,
which potentially causes clobber of the bases due to activation of
another context, and when explicit modification of the user context by
a syscall or exception handler is performed. In particular, the patch
moves setting of the flag before syscalls change context.

The changes to doreti_exit and PUSH_FRAME to clear PCB_FULL_IRET on
entry from userspace can be considered a bug fixes on its own.

Reviewed by:	jhb (previous version)
Tested by:	pho (previous version)
Sponsored by:	The FreeBSD Foundation
MFC after:	3 weeks
Differential revision:	https://reviews.freebsd.org/D12023
2017-08-21 17:38:02 +00:00
..
acpica Ensure that resume path on amd64 only accesses page tables for normal 2017-05-15 20:52:43 +00:00
amd64 Make WRFSBASE and WRGSBASE instructions functional. 2017-08-21 17:38:02 +00:00
cloudabi32 Move struct syscall_args syscall arguments parameters container into 2017-06-12 21:03:23 +00:00
cloudabi64 Keep top page on CloudABI to work around AMD Ryzen stability issues. 2017-08-02 13:08:10 +00:00
conf An MMC/SD/SDIO stack using CAM 2017-07-09 16:57:24 +00:00
ia32 Translate between abridged and full x87 tags for compat32 2017-06-24 11:38:31 +00:00
include Make WRFSBASE and WRGSBASE instructions functional. 2017-08-21 17:38:02 +00:00
linux Lower the amd64 shared page, which contains the signal trampoline, 2017-08-02 01:43:35 +00:00
linux32 Avoid using [LINUX_]SHAREDPAGE constant directly in the vdso code. 2017-07-30 21:24:20 +00:00
pci pcicfg: Fix direct calls of pci_cfg{read,write} on systems w/o PCI host bridge. 2017-05-04 05:28:46 +00:00
sgx Fix module unload when SGX support is not present in CPU. 2017-08-18 14:47:06 +00:00
vmm amd-vi: gcc build errors 2017-07-07 06:37:19 +00:00
Makefile Bring the tags and links entries for amd64 up to date. 2015-10-27 22:59:24 +00:00