This is an archive of the discontinued LLVM Phabricator instance.

[PowerPC] Don't crash when disassembling invalid immediate
ClosedPublic

Authored by nemanjai on Dec 16 2022, 1:49 PM.

Details

Reviewers
rzurob
Group Reviewers
Restricted Project
Summary

There is an assert in the disassembler functions to ensure that the immediate is the appropriate width. However, sometimes what is being disassembled is not instructions but data that happens to have the bit pattern of an existing instruction but invalid operands. It is valid for such things to exist in the text section so we don't want to crash when disassembling such a thing.

This patch removes the asserts and produces a disassembler failure for such cases.

Diff Detail

Event Timeline

nemanjai created this revision.Dec 16 2022, 1:49 PM
Herald added a project: Restricted Project. · View Herald TranscriptDec 16 2022, 1:49 PM
nemanjai requested review of this revision.Dec 16 2022, 1:49 PM
Herald added a project: Restricted Project. · View Herald TranscriptDec 16 2022, 1:49 PM

AFAIK values >12 are all invalid, not only those that are >15. This instruction and the one which inserts elements need custom decoder for their operands. Other changes are unnecessary.
But let's see what PPC guys say.

AFAIK values >12 are all invalid, not only those that are >15. This instruction and the one which inserts elements need custom decoder for their operands. Other changes are unnecessary.
But let's see what PPC guys say.

Thank you for your comment. However, I must clarify. Values larger than 12 produce undefined results, but they are not invalid. The instruction xxinsertw vs1, vs2, 14 is not an illegal instruction - although it does produce undefined results.

rzurob accepted this revision.Feb 2 2023, 9:06 AM

LGTM

This revision is now accepted and ready to land.Feb 2 2023, 9:06 AM