There are four new PowerPC instructions that are introduced in
Power 10. They are hashst, hashchk, hashstp, hashchkp.
These instructions will be used for ROP Protection.
This patch adds the four instructions.
Paths
| Differential D99375
[PowerPC] Add ROP Protection Instructions for PowerPC ClosedPublic Authored by stefanp on Mar 25 2021, 1:32 PM.
Details
Summary There are four new PowerPC instructions that are introduced in These instructions will be used for ROP Protection.
Diff Detail
Event TimelineHerald added subscribers: steven.zhang, shchenz, kbarton, hiraditya. · View Herald TranscriptMar 25 2021, 1:32 PM stefanp added a child revision: D99377: [PowerPC] Add ROP Protection to prologue and epilogue.Mar 25 2021, 1:46 PM Comment Actions Overall this LGTM.
This revision is now accepted and ready to land.Apr 5 2021, 2:58 PM Closed by commit rG16fe741c6942: [PowerPC] Add ROP Protection Instructions for PowerPC (authored by stefanp). · Explain WhyApr 9 2021, 10:09 AM This revision was automatically updated to reflect the committed changes. Comment Actions Looks like this patch broke the UBSan buildbot (https://lab.llvm.org/buildbot/#/builders/5/builds/6546), PTAL. Repro instructions here, copied the UBSan report below for your reference: FAIL: LLVM :: MC/Disassembler/PowerPC/ppc64-encoding-ISA31.txt (54419 of 75431) ******************** TEST 'LLVM :: MC/Disassembler/PowerPC/ppc64-encoding-ISA31.txt' FAILED ******************** Script: -- : 'RUN: at line 1'; /b/sanitizer-x86_64-linux-fast/build/llvm_build_ubsan/bin/llvm-mc --disassemble /b/sanitizer-x86_64-linux-fast/build/llvm-project/llvm/test/MC/Disassembler/PowerPC/ppc64-encoding-ISA31.txt -triple powerpc64-unknown-linux-gnu -mcpu=pwr10 | /b/sanitizer-x86_64-linux-fast/build/llvm_build_ubsan/bin/FileCheck /b/sanitizer-x86_64-linux-fast/build/llvm-project/llvm/test/MC/Disassembler/PowerPC/ppc64-encoding-ISA31.txt -- Exit Code: 1 Command Output (stderr): -- /b/sanitizer-x86_64-linux-fast/build/llvm-project/llvm/lib/Target/PowerPC/Disassembler/PPCDisassembler.cpp:290:60: runtime error: left shift of negative value -1 #0 0x133a4a8 in decodeMemRIHashOperands /b/sanitizer-x86_64-linux-fast/build/llvm-project/llvm/lib/Target/PowerPC/Disassembler/PPCDisassembler.cpp:290:60 #1 0x133a4a8 in llvm::MCDisassembler::DecodeStatus llvm::decodeToMCInst<unsigned long>(llvm::MCDisassembler::DecodeStatus, unsigned int, unsigned long, llvm::MCInst&, unsigned long, void const*, bool&) /b/sanitizer-x86_64-linux-fast/build/llvm_build_ubsan/lib/Target/PowerPC/PPCGenDisassemblerTables.inc:6657:9 #2 0x1337b3e in llvm::MCDisassembler::DecodeStatus llvm::decodeInstruction<unsigned long>(unsigned char const*, llvm::MCInst&, unsigned long, unsigned long, void const*, llvm::MCSubtargetInfo const&) /b/sanitizer-x86_64-linux-fast/build/llvm_build_ubsan/lib/Target/PowerPC/PPCGenDisassemblerTables.inc:8119:11 #3 0xfc69a9 in PrintInsts /b/sanitizer-x86_64-linux-fast/build/llvm-project/llvm/tools/llvm-mc/Disassembler.cpp:49:16 #4 0xfc69a9 in llvm::Disassembler::disassemble(llvm::Target const&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, llvm::MCSubtargetInfo&, llvm::MCStreamer&, llvm::MemoryBuffer&, llvm::SourceMgr&, llvm::MCContext&, llvm::raw_ostream&, llvm::MCTargetOptions const&) /b/sanitizer-x86_64-linux-fast/build/llvm-project/llvm/tools/llvm-mc/Disassembler.cpp:196:24 #5 0xfb7b68 in main /b/sanitizer-x86_64-linux-fast/build/llvm-project/llvm/tools/llvm-mc/llvm-mc.cpp:559:11 #6 0x7ff4a60a409a in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x2409a) #7 0xf9c949 in _start (/b/sanitizer-x86_64-linux-fast/build/llvm_build_ubsan/bin/llvm-mc+0xf9c949) SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior /b/sanitizer-x86_64-linux-fast/build/llvm-project/llvm/lib/Target/PowerPC/Disassembler/PPCDisassembler.cpp:290:60 in hctim added a reverting change: rG1a2756b777b6: Revert "[PowerPC] Add ROP Protection Instructions for PowerPC".Apr 9 2021, 1:37 PM This revision is now accepted and ready to land.Apr 12 2021, 3:31 AM Comment Actions Was able to reproduce the issue that caused the left shift of -1. Closed by commit rGf28cb01be071: [PowerPC] Add ROP Protection Instructions for PowerPC (authored by stefanp). · Explain WhyApr 15 2021, 9:38 AM This revision was automatically updated to reflect the committed changes.
Revision Contents
Diff 337796 llvm/lib/Target/PowerPC/AsmParser/PPCAsmParser.cpp
llvm/lib/Target/PowerPC/Disassembler/PPCDisassembler.cpp
llvm/lib/Target/PowerPC/MCTargetDesc/PPCInstPrinter.h
llvm/lib/Target/PowerPC/MCTargetDesc/PPCInstPrinter.cpp
llvm/lib/Target/PowerPC/MCTargetDesc/PPCMCCodeEmitter.h
llvm/lib/Target/PowerPC/MCTargetDesc/PPCMCCodeEmitter.cpp
llvm/lib/Target/PowerPC/P9InstrResources.td
llvm/lib/Target/PowerPC/PPCInstr64Bit.td
llvm/lib/Target/PowerPC/PPCInstrFormats.td
llvm/lib/Target/PowerPC/PPCInstrInfo.td
llvm/test/MC/Disassembler/PowerPC/ppc64-encoding-ISA31.txt
llvm/test/MC/PowerPC/ppc64-encoding-ISA31.s
|
I believe the hasSideEffects is needed because the instruction may TRAP if the hash does not match the hash stored at the specified address. This is a super minor nit, but maybe it might be better to explicitly say that the flag is needed because of this reason.
I think this is minor though, so if you think it's not needed, you can feel free to disregard this comment.