mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2025-02-01 05:01:59 +01:00
145c2ec14c
This patch changes hwasan inline instrumentation: Fixes address untagging for shadow address calculation (use 0xFF instead of 0x00 for the top byte). Emits brk instruction instead of hlt for the kernel and user space. Use 0x900 instead of 0x100 for brk immediate (0x100 - 0x800 are unavailable in the kernel). Fixes and adds appropriate tests. Patch by Andrey Konovalov. Differential Revision: https://reviews.llvm.org/D43135 llvm-svn: 325711
30 lines
988 B
LLVM
30 lines
988 B
LLVM
; Test kernel hwasan instrumentation for alloca.
|
|
;
|
|
; RUN: opt < %s -hwasan -hwasan-kernel=1 -S | FileCheck %s
|
|
|
|
target datalayout = "e-m:e-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128"
|
|
target triple = "aarch64--linux-android"
|
|
|
|
declare void @use32(i32*)
|
|
|
|
define void @test_alloca() sanitize_hwaddress {
|
|
; CHECK-LABEL: @test_alloca(
|
|
; CHECK: %[[FP:[^ ]*]] = call i8* @llvm.frameaddress(i32 0)
|
|
; CHECK: %[[A:[^ ]*]] = ptrtoint i8* %[[FP]] to i64
|
|
; CHECK: %[[B:[^ ]*]] = lshr i64 %[[A]], 20
|
|
; CHECK: %[[BASE_TAG:[^ ]*]] = xor i64 %[[A]], %[[B]]
|
|
|
|
; CHECK: %[[X:[^ ]*]] = alloca i32, align 16
|
|
; CHECK: %[[X_TAG:[^ ]*]] = xor i64 %[[BASE_TAG]], 0
|
|
; CHECK: %[[X1:[^ ]*]] = ptrtoint i32* %[[X]] to i64
|
|
; CHECK: %[[C:[^ ]*]] = shl i64 %[[X_TAG]], 56
|
|
; CHECK: %[[D:[^ ]*]] = or i64 %[[C]], 72057594037927935
|
|
; CHECK: %[[E:[^ ]*]] = and i64 %[[X1]], %[[D]]
|
|
; CHECK: %[[X_HWASAN:[^ ]*]] = inttoptr i64 %[[E]] to i32*
|
|
|
|
entry:
|
|
%x = alloca i32, align 4
|
|
call void @use32(i32* nonnull %x)
|
|
ret void
|
|
}
|