This is an archive of the discontinued LLVM Phabricator instance.

[X86][CET] Add Diags for targets pre to i686 for `-fcf-protection`
ClosedPublic

Authored by pengfei on Nov 3 2022, 12:55 AM.

Details

Summary

Intel Control-flow Enforcement Technology (CET) provides new instructions endbr32/64 for the indirect branch control. They are NOPs on i686 and new targets. We need to check for that in case it crashes on older targets.

Fixes #58737

Diff Detail

Event Timeline

pengfei created this revision.Nov 3 2022, 12:55 AM
Herald added a project: Restricted Project. · View Herald TranscriptNov 3 2022, 12:55 AM
pengfei requested review of this revision.Nov 3 2022, 12:55 AM
Herald added a project: Restricted Project. · View Herald TranscriptNov 3 2022, 12:55 AM
Herald added a subscriber: cfe-commits. · View Herald Transcript
pengfei planned changes to this revision.Nov 3 2022, 1:18 AM
pengfei updated this revision to Diff 472916.Nov 3 2022, 6:15 AM

Fix lit fail.

nickdesaulniers accepted this revision.Nov 3 2022, 9:44 AM

Seems fine, though looking at llvm::X86::CPUKind, why do you choose llvm::X86::CK_PentiumPro as the lower bounds? Surely llvm::X86::CK_Pentium2 doesn't support CET?

Does the backend already have an equivalent CPU target check that could be reused by clang?

This revision is now accepted and ready to land.Nov 3 2022, 9:44 AM

Seems fine, though looking at llvm::X86::CPUKind, why do you choose llvm::X86::CK_PentiumPro as the lower bounds? Surely llvm::X86::CK_Pentium2 doesn't support CET?

Does the backend already have an equivalent CPU target check that could be reused by clang?

My understanding was that the CET encodings reuse some encodings that have been equivalent to multibyte NOPs since PentiumPro. I think the intent was that a CET mitigated binary would still run on a CPU that didn't support CET.

Seems fine, though looking at llvm::X86::CPUKind, why do you choose llvm::X86::CK_PentiumPro as the lower bounds? Surely llvm::X86::CK_Pentium2 doesn't support CET?

Does the backend already have an equivalent CPU target check that could be reused by clang?

My understanding was that the CET encodings reuse some encodings that have been equivalent to multibyte NOPs since PentiumPro. I think the intent was that a CET mitigated binary would still run on a CPU that didn't support CET.

Makes sense; consider adding that additional information as context to the commit message @pengfei .

pengfei retitled this revision from [X86][CET] Add Diags for targets pre to i686 to [X86][CET] Add Diags for targets pre to i686 for `-fcf-protection`.Nov 3 2022, 8:18 PM
pengfei edited the summary of this revision. (Show Details)