This is an archive of the discontinued LLVM Phabricator instance.

[x86/retpoline] Split the LLVM concept of retpolines into separate subtarget features for indirect calls and indirect branches.
ClosedPublic

Authored by chandlerc on Aug 22 2018, 9:00 PM.

Details

Summary

This is in preparation for enabling *only* the call retpolines when
using speculative load hardening.

I've continued to use subtarget features for now as they continue to
seem the best fit given the lack of other retpoline like constructs so
far.

The LLVM side is pretty simple. I'd like to eventually get rid of the
old feature, but not sure what backwards compatibility issues that will
cause.

This does remove the "implies" from requesting an external thunk. This
always seemed somewhat questionable and is now clearly not desirable --
you specify a thunk the same way no matter which set of things are
getting retpolines.

I really want to keep this nicely isolated from end users and just an
LLVM implementation detail, so I've moved the -mretpoline flag in
Clang to no longer rely on a specific subtarget feature by that name and
instead to be directly handled. In some ways this is simpler, but in
order to preserve existing behavior I've had to add some fallback code
so that users who relied on merely passing -mretpoline-external-thunk
continue to get the same behavior. We should eventually remove this
I suspect (we have never tested that it works!) but I've not done that
in this patch.

Diff Detail

Repository
rC Clang

Event Timeline

chandlerc created this revision.Aug 22 2018, 9:00 PM
echristo accepted this revision.Aug 22 2018, 9:04 PM

LGTM. Thanks.

This revision is now accepted and ready to land.Aug 22 2018, 9:04 PM

Thanks!

I'm going to go ahead and land this, but happy to iterate on anything if others have comments.

This revision was automatically updated to reflect the committed changes.