From 593fa3ab30b702c4694401cbbd2cac4f1987a8e0 Mon Sep 17 00:00:00 2001 From: Paul Robinson Date: Thu, 16 Jun 2022 11:26:04 -0700 Subject: [PATCH] [PS5] Set address sanitizer shadow offset --- .../Transforms/Instrumentation/AddressSanitizer.cpp | 10 +++++----- llvm/test/Instrumentation/AddressSanitizer/ps4.ll | 3 ++- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp b/llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp index 0899acf3d656..673738ee931e 100644 --- a/llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp +++ b/llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp @@ -110,7 +110,7 @@ static const uint64_t kFreeBSDKasan_ShadowOffset64 = 0xdffff7c000000000; static const uint64_t kNetBSD_ShadowOffset32 = 1ULL << 30; static const uint64_t kNetBSD_ShadowOffset64 = 1ULL << 46; static const uint64_t kNetBSDKasan_ShadowOffset64 = 0xdfff900000000000; -static const uint64_t kPS4_ShadowOffset64 = 1ULL << 40; +static const uint64_t kPS_ShadowOffset64 = 1ULL << 40; static const uint64_t kWindowsShadowOffset32 = 3ULL << 28; static const uint64_t kEmscriptenShadowOffset = 0; @@ -469,7 +469,7 @@ static ShadowMapping getShadowMapping(const Triple &TargetTriple, int LongSize, bool IsMacOS = TargetTriple.isMacOSX(); bool IsFreeBSD = TargetTriple.isOSFreeBSD(); bool IsNetBSD = TargetTriple.isOSNetBSD(); - bool IsPS4 = TargetTriple.isPS4(); + bool IsPS = TargetTriple.isPS(); bool IsLinux = TargetTriple.isOSLinux(); bool IsPPC64 = TargetTriple.getArch() == Triple::ppc64 || TargetTriple.getArch() == Triple::ppc64le; @@ -528,8 +528,8 @@ static ShadowMapping getShadowMapping(const Triple &TargetTriple, int LongSize, Mapping.Offset = kNetBSDKasan_ShadowOffset64; else Mapping.Offset = kNetBSD_ShadowOffset64; - } else if (IsPS4) - Mapping.Offset = kPS4_ShadowOffset64; + } else if (IsPS) + Mapping.Offset = kPS_ShadowOffset64; else if (IsLinux && IsX86_64) { if (IsKasan) Mapping.Offset = kLinuxKasan_ShadowOffset64; @@ -568,7 +568,7 @@ static ShadowMapping getShadowMapping(const Triple &TargetTriple, int LongSize, // offset is not necessary 1/8-th of the address space. On SystemZ, // we could OR the constant in a single instruction, but it's more // efficient to load it once and use indexed addressing. - Mapping.OrShadowOffset = !IsAArch64 && !IsPPC64 && !IsSystemZ && !IsPS4 && + Mapping.OrShadowOffset = !IsAArch64 && !IsPPC64 && !IsSystemZ && !IsPS && !IsRISCV64 && !(Mapping.Offset & (Mapping.Offset - 1)) && Mapping.Offset != kDynamicShadowSentinel; diff --git a/llvm/test/Instrumentation/AddressSanitizer/ps4.ll b/llvm/test/Instrumentation/AddressSanitizer/ps4.ll index 29faecc766a3..da09fd3e3880 100644 --- a/llvm/test/Instrumentation/AddressSanitizer/ps4.ll +++ b/llvm/test/Instrumentation/AddressSanitizer/ps4.ll @@ -1,4 +1,5 @@ ; RUN: opt < %s -passes='asan-pipeline' -S -mtriple=x86_64-scei-ps4 | FileCheck %s +; RUN: opt < %s -passes='asan-pipeline' -S -mtriple=x86_64-sie-ps5 | FileCheck %s define i32 @read_4_bytes(i32* %a) sanitize_address { entry: @@ -8,7 +9,7 @@ entry: ; CHECK: @read_4_bytes ; CHECK-NOT: ret -; Check for ASAN's Offset on the PS4 (2^40 or 0x10000000000) +; Check for ASAN's Offset on the PS4/PS5 (2^40 or 0x10000000000) ; CHECK: lshr {{.*}} 3 ; CHECK-NEXT: {{1099511627776}} ; CHECK: ret