Enable Indirect Branch Tracking for amd64 userland, using XSAVES/XRSTORS
authorguenther <guenther@openbsd.org>
Mon, 10 Jul 2023 03:32:10 +0000 (03:32 +0000)
committerguenther <guenther@openbsd.org>
Mon, 10 Jul 2023 03:32:10 +0000 (03:32 +0000)
commit55fdb5fa9e714dd482ce610b9e56496f18472337
treeaf438398eb7c0bcdadf557dc664194e173135cc9
parenta8701c595f11859a59ce61b3bc5be334963a2e65
Enable Indirect Branch Tracking for amd64 userland, using XSAVES/XRSTORS
to save/restore the state and enabling it at exec-time (and for
signal handling) if the PS_NOBTCFI flag isn't set.

Note: this changes the format of the sc_fpstate data in the signal
context to possibly be in compressed format: starting now we just
guarantee that that state is in a format understood by the XRSTOR
instruction of the system that is being executed on.

At this time, passing sigreturn a corrupt sc_fpstate now results
in the process exiting with no attempt to fix it up or send a
T_PROTFLT trap.  That may change.

prodding by deraadt@
issues with my original signal handling design identified by kettenis@

lots of base and ports preparation for this by deraadt@ and the
libressl and ports teams

ok deraadt@ kettenis@
sys/arch/amd64/amd64/cpu.c
sys/arch/amd64/amd64/locore.S
sys/arch/amd64/amd64/machdep.c
sys/arch/amd64/amd64/vmm_machdep.c
sys/arch/amd64/include/codepatch.h
sys/arch/amd64/include/fpu.h
sys/arch/amd64/include/specialreg.h