Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 1 addition & 26 deletions tcmalloc/internal/percpu.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,27 +33,11 @@
#define TCMALLOC_CACHED_SLABS_BIT 63
#define TCMALLOC_CACHED_SLABS_MASK (1ul << TCMALLOC_CACHED_SLABS_BIT)

// TCMALLOC_INTERNAL_PERCPU_HWASAN is derived from compiler predefined macros
// rather than ABSL_HAVE_HWADDRESS_SANITIZER, since this header must evaluate
// identically in every translation unit (including the RSEQ assembly sources)
// regardless of whether absl/base/config.h has already been included.
#if defined(__has_feature)
#if __has_feature(hwaddress_sanitizer)
#define TCMALLOC_INTERNAL_PERCPU_HWASAN 1
#endif
#endif
#if defined(__SANITIZE_HWADDRESS__)
#define TCMALLOC_INTERNAL_PERCPU_HWASAN 1
#endif
#if !defined(TCMALLOC_INTERNAL_PERCPU_HWASAN)
#define TCMALLOC_INTERNAL_PERCPU_HWASAN 0
#endif

// TCMALLOC_PERCPU_RSEQ_SUPPORTED_PLATFORM defines whether or not we have an
// implementation for the target OS and architecture.
// TODO(b/478927694): re-enable for HWASan
#if defined(__linux__) && (defined(__x86_64__) || defined(__aarch64__)) && \
!TCMALLOC_INTERNAL_PERCPU_HWASAN
!defined(ABSL_HAVE_HWADDRESS_SANITIZER)
#define TCMALLOC_PERCPU_RSEQ_SUPPORTED_PLATFORM 1
#else
#define TCMALLOC_PERCPU_RSEQ_SUPPORTED_PLATFORM 0
Expand Down Expand Up @@ -88,15 +72,6 @@
#include "tcmalloc/internal/linux_syscall_support.h"
#include "tcmalloc/internal/logging.h"

// The RSEQ gate above is evaluated before any absl header is included; verify
// that it agrees with absl's detection now that absl/base/config.h is visible.
#if defined(ABSL_HAVE_HWADDRESS_SANITIZER) && !TCMALLOC_INTERNAL_PERCPU_HWASAN
#error "HWASan detected by absl but not by the TCMalloc per-CPU RSEQ gate"
#endif
#if !defined(ABSL_HAVE_HWADDRESS_SANITIZER) && TCMALLOC_INTERNAL_PERCPU_HWASAN
#error "HWASan detected by the TCMalloc per-CPU RSEQ gate but not by absl"
#endif

// TCMALLOC_INTERNAL_PERCPU_USE_RSEQ defines whether TCMalloc support for RSEQ
// on the target architecture exists. We currently only provide RSEQ for 64-bit
// x86, Arm binaries.
Expand Down
9 changes: 0 additions & 9 deletions tcmalloc/internal/percpu_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -29,15 +29,6 @@
namespace tcmalloc::tcmalloc_internal::subtle::percpu {
namespace {

// percpu.h is the first include of this TU, so the RSEQ gate must be
// evaluated without relying on macros provided by later includes.
#if defined(ABSL_HAVE_HWADDRESS_SANITIZER)
static_assert(TCMALLOC_PERCPU_RSEQ_SUPPORTED_PLATFORM == 0,
"RSEQ must be disabled under HWASan");
static_assert(TCMALLOC_INTERNAL_PERCPU_USE_RSEQ == 0,
"RSEQ must be disabled under HWASan");
#endif

ABSL_CONST_INIT std::atomic<int> alarms{0};

void sa_alrm(int sig) {
Expand Down
Loading