Re: [RFC][PATCH] x86: Add straight-line-speculation mitigation

Peter Zijlstra
2021-10-28T21:31:23Z

On Thu, Oct 28, 2021 at 09:06:30PM +0100, Andrew Cooper wrote:
> It would be remiss of me not to say...  In Xen, I've currently gone with:
>
> #ifdef CONFIG_SPECULATIVE_HARDEN_STRAIGHT_LINE
> # define ret ret; int3
> # define retq retq; int3

#define retq ret

Surely :-)

> #endif
>
>
> which avoids needing to patch any asm files, and therefore is a far less
> invasive patch.

All the asm stuff was more or less:

find arch/x86/ -name \*.s | while read file;
do
sed -i $file -e 's/\<retq?\>/RET/'
done

or thereabout. The pesky bits were the inline asm and realizing that
RETPOLINE_SAFE also means we really don't care about SLS.

> I know those defines probably deserve a WTF, and will confuse anyone who
> doesn't understand the phrase "painting blue", but they have the
> advantage that casual contributions don't need to remember to avoid
> naked `ret` instructions to maintain safety, making it a rather more
> robust option.

objtool while whinge if someone forgets