This is an archive of the discontinued LLVM Phabricator instance.

Document potential implementation of CFI in hardware.
ClosedPublic

Authored by kcc on Oct 10 2016, 3:20 PM.

Event Timeline

kcc updated this revision to Diff 74180.Oct 10 2016, 3:20 PM
kcc retitled this revision from to Document potential implementation of CFI in hardware..
kcc updated this object.
kcc added reviewers: pcc, eugenis.
kcc added a subscriber: llvm-commits.
eugenis accepted this revision.Oct 10 2016, 4:43 PM
eugenis edited edge metadata.
eugenis added inline comments.
docs/ControlFlowIntegrityDesign.rst
510

We usually refer to it as "cross-DSO scheme".

This revision is now accepted and ready to land.Oct 10 2016, 4:43 PM
pcc edited edge metadata.Oct 10 2016, 4:46 PM

I think this would benefit from an assembly code listing for a couple of cases (e.g. all-ones, bit vector).

One concern I have is that in the case where we have a bit vector lookup, the code would end up computing the byte offset redundantly with the instruction, which would somewhat diminish the code size benefits here.

kcc updated this revision to Diff 74186.Oct 10 2016, 4:47 PM
kcc edited edge metadata.

Use "cross-DSO scheme"

kcc added a comment.Oct 10 2016, 4:50 PM
In D25455#566834, @pcc wrote:

I think this would benefit from an assembly code listing for a couple of cases (e.g. all-ones, bit vector).

One concern I have is that in the case where we have a bit vector lookup, the code would end up computing the byte offset redundantly with the instruction, which would somewhat diminish the code size benefits here.

Right now I don't see a good way to have the bit vector lookup in the HW scheme. (written: "The bit vector lookup is probably too complex for a hardware implementation.")
Even w/o the bit vector the check will nearly precise (and fully precise in > 50% cases).

pcc added a comment.Oct 10 2016, 5:58 PM

My point was that this would make it more verbose to implement the bit vector check in software. But I think on balance this is fine because as you point out bit vector tests are relatively rare, I don't think we've removed as many as we can and even in the case where we want to be 100% we can always fall back to our existing code.

docs/ControlFlowIntegrityDesign.rst
507

An estimate of the # of bytes would be useful here.

509

aligned

523–526

Please put these in the same order as the "arguments" below.

kcc updated this revision to Diff 74287.Oct 11 2016, 1:18 PM

address pcc's comments

kcc marked 4 inline comments as done.Oct 11 2016, 1:19 PM

addressed comments

pcc added a comment.Oct 11 2016, 1:50 PM

An estimate of less than 10 bytes doesn't seem realistic if the operands take up 10 bytes by themselves.

kcc updated this revision to Diff 74290.Oct 11 2016, 1:56 PM

Changed the instruction size estimate to 12.
We may still be able to make the constants smaller.
May also have two instructions: 1 for monolythic case, one for cross-DSO.
The first one will be smaller.

pcc accepted this revision.Oct 11 2016, 2:09 PM
pcc edited edge metadata.

LGTM

kcc closed this revision.Oct 12 2016, 11:42 AM