On CPUs with eIBRS ("enhanced Indirect Branch Restricted Speculation")
authorguenther <guenther@openbsd.org>
Mon, 31 Jul 2023 04:01:07 +0000 (04:01 +0000)
committerguenther <guenther@openbsd.org>
Mon, 31 Jul 2023 04:01:07 +0000 (04:01 +0000)
commit1538f8cb209f93ed99ddae606a02707e3bdd9dfc
tree52408cde4645d69fc4e0400d59f53ecbbbf1db26
parent183b7dd1109a83aabbd0498cbaf8d93d385757f7
On CPUs with eIBRS ("enhanced Indirect Branch Restricted Speculation")
or IBT enabled the kernel, the hardware should the attacks which
retpolines were created to prevent.  In those cases, retpolines
should be a net negative for security as they are an indirect branch
gadget.  They're also slower.
 * use -mretpoline-external-thunk to give us control of the code
   used for indirect branches
 * default to using a retpoline as before, but marks it and the
   other ASM kernel retpolines for code patching
 * if the CPU has eIBRS, then enable it
 * if the CPU has eIBRS *or* IBT, then codepatch the three different
   retpolines to just indirect jumps

make clean && make config required after this

ok kettenis@
sys/arch/amd64/amd64/cpu.c
sys/arch/amd64/amd64/locore.S
sys/arch/amd64/amd64/vector.S
sys/arch/amd64/conf/Makefile.amd64
sys/arch/amd64/include/codepatch.h