From abf7770d46b3a41df911bf58a546f9731bbb8abe Mon Sep 17 00:00:00 2001 From: Xihan Zhang Date: Fri, 10 Apr 2015 22:26:44 +0800 Subject: [PATCH] Add execution property in register memory for gfx801. Signed-off-by: Xihan Zhang [ROCm/ROCR-Runtime commit: 5ed05c99b3cbddbca389127b3656f38493f8339a] --- projects/rocr-runtime/include/hsakmt.h | 3 ++- projects/rocr-runtime/src/memory.c | 14 +++++++++++++- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/projects/rocr-runtime/include/hsakmt.h b/projects/rocr-runtime/include/hsakmt.h index fd2788803d..321df6e6c9 100644 --- a/projects/rocr-runtime/include/hsakmt.h +++ b/projects/rocr-runtime/include/hsakmt.h @@ -364,7 +364,8 @@ HSAKMT_STATUS HSAKMTAPI hsaKmtRegisterMemory( void* MemoryAddress, //IN (page-aligned) - HSAuint64 MemorySizeInBytes //IN (page-aligned) + HSAuint64 MemorySizeInBytes, //IN (page-aligned) + int ExecuteAccess ); diff --git a/projects/rocr-runtime/src/memory.c b/projects/rocr-runtime/src/memory.c index 68d86d5e5e..0be2a0f738 100644 --- a/projects/rocr-runtime/src/memory.c +++ b/projects/rocr-runtime/src/memory.c @@ -170,11 +170,23 @@ HSAKMT_STATUS HSAKMTAPI hsaKmtRegisterMemory( void *MemoryAddress, /* IN (page-aligned) */ - HSAuint64 MemorySizeInBytes /* IN (page-aligned) */ + HSAuint64 MemorySizeInBytes, /* IN (page-aligned) */ + int ExecuteAccess ) { CHECK_KFD_OPEN(); + int err; + /* for CZ ib execution */ + if (ExecuteAccess) { + err = mprotect(MemoryAddress, MemorySizeInBytes, + PROT_READ | PROT_WRITE | PROT_EXEC); + + if (err != 0) { + free(MemoryAddress); + return err; + } + } return HSAKMT_STATUS_SUCCESS; }