Do "Return stack refilling", based on the "Return stack underflow" discussion
authorguenther <guenther@openbsd.org>
Mon, 23 Jul 2018 17:54:04 +0000 (17:54 +0000)
committerguenther <guenther@openbsd.org>
Mon, 23 Jul 2018 17:54:04 +0000 (17:54 +0000)
commita4858df8c5455654ebfa3e96349cf3f1eab81b02
tree762ed868032b5963109bda76f4f2a35d72b8165e
parent4698a0ba0d5547fce37134cb00f204c68f429885
Do "Return stack refilling", based on the "Return stack underflow" discussion
and its associated appendix at https://support.google.com/faqs/answer/7625886
This should address at least some cases of "SpectreRSB" and earlier
Spectre variants; more commits to follow.

The refilling is done in the enter-kernel-from-userspace and
return-to-userspace-from-kernel paths, making sure to do it before
unblocking interrupts so that a successive interrupt can't get the
CPU to C code without doing this refill.  Per the link above, it
also does it immediately after mwait, apparently in case the low-power
CPU states of idle-via-mwait flush the RSB.

ok mlarkin@ deraadt@
sys/arch/amd64/amd64/locore.S
sys/arch/amd64/include/asm.h
sys/arch/amd64/include/cpufunc.h
sys/arch/amd64/include/frameasm.h