[PS5] Set address sanitizer shadow offset

This commit is contained in:
Paul Robinson 2022-06-16 11:26:04 -07:00
parent 03cc58ff2a
commit 593fa3ab30
2 changed files with 7 additions and 6 deletions

View File

@ -110,7 +110,7 @@ static const uint64_t kFreeBSDKasan_ShadowOffset64 = 0xdffff7c000000000;
static const uint64_t kNetBSD_ShadowOffset32 = 1ULL << 30; static const uint64_t kNetBSD_ShadowOffset32 = 1ULL << 30;
static const uint64_t kNetBSD_ShadowOffset64 = 1ULL << 46; static const uint64_t kNetBSD_ShadowOffset64 = 1ULL << 46;
static const uint64_t kNetBSDKasan_ShadowOffset64 = 0xdfff900000000000; 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 kWindowsShadowOffset32 = 3ULL << 28;
static const uint64_t kEmscriptenShadowOffset = 0; static const uint64_t kEmscriptenShadowOffset = 0;
@ -469,7 +469,7 @@ static ShadowMapping getShadowMapping(const Triple &TargetTriple, int LongSize,
bool IsMacOS = TargetTriple.isMacOSX(); bool IsMacOS = TargetTriple.isMacOSX();
bool IsFreeBSD = TargetTriple.isOSFreeBSD(); bool IsFreeBSD = TargetTriple.isOSFreeBSD();
bool IsNetBSD = TargetTriple.isOSNetBSD(); bool IsNetBSD = TargetTriple.isOSNetBSD();
bool IsPS4 = TargetTriple.isPS4(); bool IsPS = TargetTriple.isPS();
bool IsLinux = TargetTriple.isOSLinux(); bool IsLinux = TargetTriple.isOSLinux();
bool IsPPC64 = TargetTriple.getArch() == Triple::ppc64 || bool IsPPC64 = TargetTriple.getArch() == Triple::ppc64 ||
TargetTriple.getArch() == Triple::ppc64le; TargetTriple.getArch() == Triple::ppc64le;
@ -528,8 +528,8 @@ static ShadowMapping getShadowMapping(const Triple &TargetTriple, int LongSize,
Mapping.Offset = kNetBSDKasan_ShadowOffset64; Mapping.Offset = kNetBSDKasan_ShadowOffset64;
else else
Mapping.Offset = kNetBSD_ShadowOffset64; Mapping.Offset = kNetBSD_ShadowOffset64;
} else if (IsPS4) } else if (IsPS)
Mapping.Offset = kPS4_ShadowOffset64; Mapping.Offset = kPS_ShadowOffset64;
else if (IsLinux && IsX86_64) { else if (IsLinux && IsX86_64) {
if (IsKasan) if (IsKasan)
Mapping.Offset = kLinuxKasan_ShadowOffset64; 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, // 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 // we could OR the constant in a single instruction, but it's more
// efficient to load it once and use indexed addressing. // efficient to load it once and use indexed addressing.
Mapping.OrShadowOffset = !IsAArch64 && !IsPPC64 && !IsSystemZ && !IsPS4 && Mapping.OrShadowOffset = !IsAArch64 && !IsPPC64 && !IsSystemZ && !IsPS &&
!IsRISCV64 && !IsRISCV64 &&
!(Mapping.Offset & (Mapping.Offset - 1)) && !(Mapping.Offset & (Mapping.Offset - 1)) &&
Mapping.Offset != kDynamicShadowSentinel; Mapping.Offset != kDynamicShadowSentinel;

View File

@ -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-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 { define i32 @read_4_bytes(i32* %a) sanitize_address {
entry: entry:
@ -8,7 +9,7 @@ entry:
; CHECK: @read_4_bytes ; CHECK: @read_4_bytes
; CHECK-NOT: ret ; 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: lshr {{.*}} 3
; CHECK-NEXT: {{1099511627776}} ; CHECK-NEXT: {{1099511627776}}
; CHECK: ret ; CHECK: ret