[PATCH] D36742: [LLD][ELF][AArch64] Implement scanner for Cortex-A53 Erratum 843419

Peter Smith via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Aug 15 08:15:25 PDT 2017


peter.smith created this revision.
Herald added subscribers: kristof.beyls, javed.absar, mgorny, emaste, rengolin, aemerson.

Add a new file SectionPatcher.cpp that implements the logic to scan for the Cortex-A53 Erratum 843419. This involves finding all the executable code, disassembling the instructions that might trigger the erratum and reporting a message if the sequence is detected.

      

This is patch 1 of 3 to fix pr33463 https://bugs.llvm.org/show_bug.cgi?id=33463 . This patch adds two new options -fix-cortex-a53-843419 (taken from gold and ld.bfd) and -print-fixes (lld specific). contains logic to find all the executable code in an AArch64 link and scan it for the erratum sequence. If we find it we can print out a message if -print-fixes is selected. The tests just check that the recognizer can detect the patch sequence, and also avoid detecting sequences that are very similar, or embedded in literal data. The code to actually fix the erratum will follow shortly in a later patch. Regardless of the method of fixing the erratum this should be independent of the code to detect it.

Details of the erratum: http://infocenter.arm.com/help/topic/com.arm.doc.epm048406/Cortex_A53_MPCore_Software_Developers_Errata_Notice.pdf
Arm Architecture Reference Manual: https://developer.arm.com/products/architecture/a-profile/docs/ddi0487/latest/arm-architecture-reference-manual-armv8-for-armv8-a-architecture-profile

There are a number of design decisions that I've made that are somewhat arbitrary and could easily be changed:

- I've not tried to make the implementation target independent, as we only support one patch this would make the initial patch harder to understand. I'm quite happy to extract the target independent and target specific parts if people prefer.
- Mapping symbols are to the best of my knowledge specific to ARM and AArch64, I've followed gold and ld.bfd by only disassembling code that is marked as code by the $x mapping symbol. This avoids fake matches of bit-patterns in inline literal data.
- There is a lot of logic to decode the AArch64 instructions that are part of the erratum sequence, I've followed how these are written in the Arm Architecture Reference Manual, but this is still quite difficult to follow. I'm not sure how this can be avoided.
- I've made a new file SectionPatcher.cpp as much of the code is not reusable elsewhere. There is a lot of target specific AArch64 code in there, I thought it better to leave it there rather than try to somehow hide it behind the Target interface.

This patch is dependent on https://reviews.llvm.org/D36739 to get the correct addresses in the report message.


https://reviews.llvm.org/D36742

Files:
  ELF/CMakeLists.txt
  ELF/Config.h
  ELF/Driver.cpp
  ELF/Options.td
  ELF/SectionPatcher.cpp
  ELF/SectionPatcher.h
  ELF/Writer.cpp
  test/ELF/aarch64-cortex-a53-843419-address.s
  test/ELF/aarch64-cortex-a53-843419-nopatch.s
  test/ELF/aarch64-cortex-a53-843419-recognize.s

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D36742.111165.patch
Type: text/x-patch
Size: 48634 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170815/ac11650b/attachment.bin>


More information about the llvm-commits mailing list