[all-commits] [llvm/llvm-project] a3e56a: [KMSAN] Enable on SystemZ

Ilya Leoshkevich via All-commits all-commits at lists.llvm.org
Thu Apr 27 05:22:02 PDT 2023


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: a3e56a8792ffaf3a3d3538736e1042b8db45ab89
      https://github.com/llvm/llvm-project/commit/a3e56a8792ffaf3a3d3538736e1042b8db45ab89
  Author: Ilya Leoshkevich <iii at linux.ibm.com>
  Date:   2023-04-27 (Thu, 27 Apr 2023)

  Changed paths:
    M clang/lib/Driver/ToolChains/Linux.cpp
    M llvm/lib/Transforms/Instrumentation/MemorySanitizer.cpp
    A llvm/test/Instrumentation/MemorySanitizer/SystemZ/basic-kernel.ll
    M llvm/test/Instrumentation/MemorySanitizer/SystemZ/vararg-kernel.ll

  Log Message:
  -----------
  [KMSAN] Enable on SystemZ

Enable -fsanitize=kernel-memory support in Clang.

The x86_64 ABI requires that shadow_origin_ptr_t must be returned via a
register pair, and the s390x ABI requires that it must be returned via
memory pointed to by a hidden parameter. Normally Clang takes care of
the ABI, but the sanitizers run long after it, so unfortunately they
have to duplicate the ABI logic.

Therefore add a special case for SystemZ and manually emit the
s390x-ABI-compliant calling sequences. Since it's only 2 architectures,
do not create a VarArgHelper-like abstraction layer.

The kernel functions are compiled with the "packed-stack" and
"use-soft-float" attributes. For the "packed-stack" functions, it's not
correct for copyRegSaveArea() to copy 160 bytes of shadow and origins,
since the save area is dynamically sized. Things are greatly simplified
by the fact that the vararg "use-soft-float" functions use precisely
56 bytes in order to save the argument registers to where va_arg() can
find them.

Make copyRegSaveArea() copy only 56 bytes in the "use-soft-float" case.
The "packed-stack" && !"use-soft-float" case has no practical uses at
the moment, so leave it for the future.

Add tests.

Reviewed By: eugenis

Differential Revision: https://reviews.llvm.org/D148596




More information about the All-commits mailing list