<div dir="ltr"><div dir="ltr">Awaiting results, but should be fixed in <a href="https://reviews.llvm.org/rL355840">rL355840</a>.</div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Mon, Mar 11, 2019 at 6:44 AM Adhemerval Zanella <<a href="mailto:adhemerval.zanella@linaro.org">adhemerval.zanella@linaro.org</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><br>
<br>
On 08/03/2019 18:22, Mitch Phillips via llvm-commits wrote:<br>
> Author: hctim<br>
> Date: Fri Mar  8 13:22:35 2019<br>
> New Revision: 355738<br>
> <br>
> URL: <a href="http://llvm.org/viewvc/llvm-project?rev=355738&view=rev" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project?rev=355738&view=rev</a><br>
> Log:<br>
> [HWASan] Save + print registers when tag mismatch occurs in AArch64.<br>
> <br>
<br>
[...]<br>
<br>
> Added: compiler-rt/trunk/lib/hwasan/hwasan_tag_mismatch_aarch64.S<br>
> URL: <a href="http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/hwasan/hwasan_tag_mismatch_aarch64.S?rev=355738&view=auto" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/hwasan/hwasan_tag_mismatch_aarch64.S?rev=355738&view=auto</a><br>
> ==============================================================================<br>
> --- compiler-rt/trunk/lib/hwasan/hwasan_tag_mismatch_aarch64.S (added)<br>
> +++ compiler-rt/trunk/lib/hwasan/hwasan_tag_mismatch_aarch64.S Fri Mar  8 13:22:35 2019<br>
> @@ -0,0 +1,108 @@<br>
> +#include "sanitizer_common/sanitizer_asm.h"<br>
> +<br>
> +// The content of this file is AArch64-only:<br>
> +#if defined(__aarch64__)<br>
> +<br>
> +// The responsibility of the HWASan entry point in compiler-rt is to primarily<br>
> +// readjust the stack from the callee and save the current register values to<br>
> +// the stack.<br>
> +// This entry point function should be called from a __hwasan_check_* symbol.<br>
> +// These are generated during a lowering pass in the backend, and are found in<br>
> +// AArch64AsmPrinter::EmitHwasanMemaccessSymbols(). Please look there for<br>
> +// further information.<br>
> +// The __hwasan_check_* caller of this function should have expanded the stack<br>
> +// and saved the previous values of x0, x1, x29, and x30. This function will<br>
> +// "consume" these saved values and treats it as part of its own stack frame.<br>
> +// In this sense, the __hwasan_check_* callee and this function "share" a stack<br>
> +// frame. This allows us to omit having unwinding information (.cfi_*) present<br>
> +// in every __hwasan_check_* function, therefore reducing binary size. This is<br>
> +// particularly important as hwasan_check_* instances are duplicated in every<br>
> +// translation unit where HWASan is enabled.<br>
> +// This function calls HwasanTagMismatch to step back into the C++ code that<br>
> +// completes the stack unwinding and error printing. This function is is not<br>
> +// permitted to return.<br>
> +<br>
> +<br>
> +// Frame from __hwasan_check_:<br>
> +// |              ...                |<br>
> +// |              ...                |<br>
> +// | Previous stack frames...        |<br>
> +// +=================================+<br>
> +// | Unused 8-bytes for maintaining  |<br>
> +// | 16-byte SP alignment.           |<br>
> +// +---------------------------------+<br>
> +// | Return address (x30) for caller |<br>
> +// | of __hwasan_check_*.            |<br>
> +// +---------------------------------+<br>
> +// | Frame address (x29) for caller  |<br>
> +// | of __hwasan_check_*             |<br>
> +// +---------------------------------+ <-- [SP + 232]<br>
> +// |              ...                |<br>
> +// |                                 |<br>
> +// | Stack frame space for x2 - x28. |<br>
> +// |                                 |<br>
> +// |              ...                |<br>
> +// +---------------------------------+ <-- [SP + 16]<br>
> +// |                                 |<br>
> +// | Saved x1, as __hwasan_check_*   |<br>
> +// | clobbers it.                    |<br>
> +// +---------------------------------+<br>
> +// | Saved x0, likewise above.       |<br>
> +// +---------------------------------+ <-- [x30 / SP]<br>
> +<br>
> +// This function takes two arguments:<br>
> +//   * x0: The address of read/write instruction that caused HWASan check fail.<br>
> +//   * x1: The tag size.<br>
> +<br>
> +.section .text<br>
> +.file "hwasan_tag_mismatch_aarch64.S"<br>
> +.global __hwasan_tag_mismatch<br>
> +.type __hwasan_tag_mismatch, %function<br>
> +__hwasan_tag_mismatch:<br>
> +  CFI_STARTPROC<br>
> +<br>
> +  // Set the CFA to be the return address for caller of __hwasan_check_*. Note<br>
> +  // that we do not emit CFI predicates to describe the contents of this stack<br>
> +  // frame, as this proxy entry point should never be debugged. The contents<br>
> +  // are static and are handled by the unwinder after calling<br>
> +  // __hwasan_tag_mismatch. The frame pointer is already correctly setup<br>
> +  // by __hwasan_check_*.<br>
> +  add x29, sp, #232<br>
> +  CFI_DEF_CFA(w29, 16)<br>
> +  CFI_OFFSET(w30, -8)<br>
> +  CFI_OFFSET(w29, -16)<br>
> +<br>
> +  // Save the rest of the registers into the preallocated space left by<br>
> +  // __hwasan_check.<br>
> +  str     x28,      [sp, #224]<br>
> +  stp     x26, x27, [sp, #208]<br>
> +  stp     x24, x25, [sp, #192]<br>
> +  stp     x22, x23, [sp, #176]<br>
> +  stp     x20, x21, [sp, #160]<br>
> +  stp     x18, x19, [sp, #144]<br>
> +  stp     x16, x17, [sp, #128]<br>
> +  stp     x14, x15, [sp, #112]<br>
> +  stp     x12, x13, [sp, #96]<br>
> +  stp     x10, x11, [sp, #80]<br>
> +  stp     x8,  x9,  [sp, #64]<br>
> +  stp     x6,  x7,  [sp, #48]<br>
> +  stp     x4,  x5,  [sp, #32]<br>
> +  stp     x2,  x3,  [sp, #16]<br>
> +<br>
> +  // Pass the address of the frame to __hwasan_tag_mismatch_stub, so that it can<br>
> +  // extract the saved registers from this frame without having to worry about<br>
> +  // finding this frame.<br>
> +  mov x2, sp<br>
> +<br>
> +  bl __hwasan_tag_mismatch_stub<br>
> +  CFI_ENDPROC<br>
> +<br>
> +.Lfunc_end0:<br>
> +  .size __hwasan_tag_mismatch, .Lfunc_end0-__hwasan_tag_mismatch<br>
> +<br>
> +.addrsig<br>
<br>
This is causing a regression on llvm aarch bots [1] on the case of using system<br>
compiler (in this case gcc/binutils) to build compiler-rt.<br>
<br>
My understanding it should be ok to just remove the the assembly directive.<br>
<br>
<br>
[1] <a href="http://lab.llvm.org:8011/builders/clang-cmake-aarch64-lld/builds/6162" rel="noreferrer" target="_blank">http://lab.llvm.org:8011/builders/clang-cmake-aarch64-lld/builds/6162</a><br>
</blockquote></div>