summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVyacheslav Cherkashin <v.cherkashin@samsung.com>2019-07-30 15:44:01 (GMT)
committerVyacheslav Cherkashin <v.cherkashin@samsung.com>2019-07-30 15:44:01 (GMT)
commitfbb6bd2376d32c404762b47bb231e436ed2af2cb (patch)
tree1f4f1bb10a87968c597b18063a0dab07202651d5
parentb38f0d1f3274e420f01454fc9769e4678b271694 (diff)
downloadcoreclr-fbb6bd2376d32c404762b47bb231e436ed2af2cb.zip
coreclr-fbb6bd2376d32c404762b47bb231e436ed2af2cb.tar.gz
coreclr-fbb6bd2376d32c404762b47bb231e436ed2af2cb.tar.bz2
fixup! ASan: add AMD64 support
Change-Id: I57dc575b1fcfba3e7c354169b4e9e7773a42ca1e
-rw-r--r--src/vm/amd64/cgenamd64.cpp10
-rw-r--r--src/vm/amd64/tizenasanenv.S164
-rw-r--r--src/vm/tizenasanenv.cpp10
3 files changed, 96 insertions, 88 deletions
diff --git a/src/vm/amd64/cgenamd64.cpp b/src/vm/amd64/cgenamd64.cpp
index 814f04d..7d09871 100644
--- a/src/vm/amd64/cgenamd64.cpp
+++ b/src/vm/amd64/cgenamd64.cpp
@@ -26,6 +26,10 @@
#include "clrtocomcall.h"
#endif // FEATURE_COMINTEROP
+#ifdef TIZEN_ASAN_ENVIRONMENT
+#include <tizenasanenv.h>
+#endif // TIZEN_ASAN_ENVIRONMENT
+
void UpdateRegDisplayFromCalleeSavedRegisters(REGDISPLAY * pRD, CalleeSavedRegisters * pRegs)
{
LIMITED_METHOD_CONTRACT;
@@ -563,6 +567,12 @@ void UMEntryThunkCode::Encode(BYTE* pTargetCode, void* pvSecretParam)
}
CONTRACTL_END;
+#ifdef TIZEN_ASAN_ENVIRONMENT
+ pTargetCode = (BYTE *)TizenASanEnv::CreateWrapperJmp((LPVOID)pTargetCode,
+ TizenASanEnv::PushAndDisableASan,
+ TizenASanEnv::PopAndEnableASan);
+#endif // TIZEN_ASAN_ENVIRONMENT
+
// padding // CC CC CC CC
// mov r10, pUMEntryThunk // 49 ba xx xx xx xx xx xx xx xx // METHODDESC_REGISTER
// mov rax, pJmpDest // 48 b8 xx xx xx xx xx xx xx xx // need to ensure this imm64 is qword aligned
diff --git a/src/vm/amd64/tizenasanenv.S b/src/vm/amd64/tizenasanenv.S
index dc4e7e7..939b75a 100644
--- a/src/vm/amd64/tizenasanenv.S
+++ b/src/vm/amd64/tizenasanenv.S
@@ -1,53 +1,44 @@
RETADDR_OFFSET=8*15
.macro PUSH_REGS
- push %rdi # 0, arg0
- push %rsi # 1, arg1
- push %rdx # 2, arg2
- push %rcx # 3, arg3
- push %r8 # 4, arg4
- push %r9 # 5, arg5
- push %r10 # 6, ...
- push %r11 # 7, temprory reg
- push %rax # 8
-
- push %rbp
- push %rbx
- push %r15
- push %r14
- push %r13
- push %r12
+ push %rdi # 0, arg0
+ push %rsi # 1, arg1
+ push %rdx # 2, arg2
+ push %rcx # 3, arg3
+ push %r8 # 4, arg4
+ push %r9 # 5, arg5
+ push %r10 # 6, ...
+ push %r11 # 7, temprory reg
+ push %rax # 8
+
+ push %rbp
+ push %rbx
+ push %r15
+ push %r14
+ push %r13
+ push %r12
.endm
.macro POP_REGS
- pop %r12
- pop %r13
- pop %r14
- pop %r15
- pop %rbx
- pop %rbp
-
-
- pop %rax
- pop %r11
- pop %r10
- pop %r9
- pop %r8
- pop %rcx
- pop %rdx
- pop %rsi
- pop %rdi
+ pop %r12
+ pop %r13
+ pop %r14
+ pop %r15
+ pop %rbx
+ pop %rbp
+
+
+ pop %rax
+ pop %r11
+ pop %r10
+ pop %r9
+ pop %r8
+ pop %rcx
+ pop %rdx
+ pop %rsi
+ pop %rdi
.endm
- .global hex_wrapper
- .global hex_wrapper_size
- .global hex_wrapper_entry_offset
-
- # Extern functions
- .global asan_enable_addr_offset
- .global asan_disable_addr_offset
- .global target_addr_offset
- .global get_return_addr_offset
// Export symbols
.global tizenASanWrapper
@@ -71,40 +62,45 @@ entryPointer:
PUSH_REGS
// Save the return address and call 'pre handler'
- mov RETADDR_OFFSET(%rsp), %rdi // rdi: get return address
- call *pushAddr(%rsp) // save the return address
+ mov RETADDR_OFFSET(%rsp), %rdi // rdi: get return address
+ call *pushAddr(%rip) // save the return address
// Change the return address
- call next
-next: pop %rax // rax: get current rip
- add $(postLabel - next), %rax // rax: add offset to 'postLabel'
- mov %rax, RETADDR_OFFSET(%rsp) // change the return address
+ call next
+next:
+ pop %rax // rax: get current rip
+ add $(postLabel - next), %rax // rax: add offset to 'postLabel'
+ mov %rax, RETADDR_OFFSET(%rsp) // change the return address
- // Restore context
- POP_REGS
+ // Restore context
+ POP_REGS
- // Call original function
- jmp *target(%rip)
+ // Call original function
+ jmp *target(%rip)
postLabel:
- // Save context
- PUSH_REGS
+ // Save context
+ PUSH_REGS
// Get the return address and call 'post handler'
- add $8, %rsp // align stack
- call *popAddr(%rip) // rdi: get the return address
- sub $8, %rsp // restore stack
- mov %rdi, RETADDR_OFFSET(%rsp) // restore the return address
+ add $8, %rsp // align stack
+ call *popAddr(%rip) // rax: get the return address
+ sub $8, %rsp // restore stack
+ mov %rax, RETADDR_OFFSET(%rsp) // restore the return address
- // Restore context
- POP_REGS
+ // Restore context
+ POP_REGS
- // Return
- ret
+ // Return
+ ret
-tizenASanWrapperSize: .word . - tizenASanWrapper
-tizenASanWrapperEntryOffset: .word entryPointer - tizenASanWrapper
+tizenASanWrapperSize: .long . - tizenASanWrapper
+tizenASanWrapperEntryOffset: .long entryPointer - tizenASanWrapper
+// Export symbols
+.global tizenASanWrapperJmp
+.global tizenASanWrapperJmpSize
+.global tizenASanWrapperJmpEntryOffset
tizenASanWrapperJmp:
// !!! ATTENTION !!!
@@ -120,36 +116,36 @@ entryPointerJmp:
PUSH_REGS
// Save the return address and call 'pre handler'
- mov RETADDR_OFFSET(%rsp), %rdi // rdi: get return address
- call *pushAddrJmp(%rsp) // save the return address
+ mov RETADDR_OFFSET(%rsp), %rdi // rdi: get return address
+ call *pushAddrJmp(%rip) // save the return address
// Change the return address
- call nextJmp
+ call nextJmp
nextJmp:
- pop %rax // rax: get current rip
- add $(postLabelJmp - nextJmp), %rax // rax: add offset to 'postLabel'
- mov %rax, RETADDR_OFFSET(%rsp) // change the return address
+ pop %rax // rax: get current rip
+ add $(postLabelJmp - nextJmp), %rax // rax: add offset to 'postLabelJmp'
+ mov %rax, RETADDR_OFFSET(%rsp) // change the return address
- // Restore context
- POP_REGS
+ // Restore context
+ POP_REGS
- // Call original function
- jmp *targetJmp(%rip)
+ // Call original function
+ jmp *targetJmp(%rip)
postLabelJmp:
sub $8, %rsp // add space for the return addr
- // Save context
- PUSH_REGS
+ // Save context
+ PUSH_REGS
// Get the return address and call 'post handler'
- call *popAddr(%rip) // rdi: get the return address
- mov %rdi, RETADDR_OFFSET(%rsp) // restore the return address
+ call *popAddrJmp(%rip) // rax: get the return address
+ mov %rax, RETADDR_OFFSET(%rsp) // restore the return address
- // Restore context
- POP_REGS
+ // Restore context
+ POP_REGS
- // Return
- ret
+ // Return
+ ret
-tizenASanWrapperSizeJmp: .word . - tizenASanWrapperJmp
-tizenASanWrapperEntryOffsetJmp: .word entryPointerJmp - tizenASanWrapperJmp
+tizenASanWrapperJmpSize: .long . - tizenASanWrapperJmp
+tizenASanWrapperJmpEntryOffset: .long entryPointerJmp - tizenASanWrapperJmp
diff --git a/src/vm/tizenasanenv.cpp b/src/vm/tizenasanenv.cpp
index 34fffea..9c34c67 100644
--- a/src/vm/tizenasanenv.cpp
+++ b/src/vm/tizenasanenv.cpp
@@ -54,6 +54,12 @@ extern LPVOID tizenASanWrapper;
extern UINT32 tizenASanWrapperSize;
extern UINT32 tizenASanWrapperEntryOffset;
+#ifdef _AMD64_
+extern LPVOID tizenASanWrapperJmp;
+extern UINT32 tizenASanWrapperJmpSize;
+extern UINT32 tizenASanWrapperJmpEntryOffset;
+#endif // _AMD64_
+
static __thread StaticStack<LPVOID, 128> s_retaddrStack;
static __thread int s_enableCounter;
@@ -172,10 +178,6 @@ LPVOID CreateWrapper(LPVOID target, void (*pushAddr)(LPVOID addr), LPVOID (*popA
}
#ifdef _AMD64_
-extern LPVOID ::tizenASanWrapperJmp;
-extern UINT32 ::tizenASanWrapperJmpSize;
-extern UINT32 ::tizenASanWrapperJmpEntryOffset;
-
LPVOID CreateWrapperJmp(LPVOID target, void (*pushAddr)(LPVOID addr), LPVOID (*popAddr)())
{
_ASSERTE(tizenASanWrapperJmpEntryOffset == sizeof(AuxiliaryCalls));