From 5ed05c99b3cbddbca389127b3656f38493f8339a 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 --- include/hsakmt.h | 3 ++- src/memory.c | 14 +++++++++++++- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/include/hsakmt.h b/include/hsakmt.h index fd2788803d..321df6e6c9 100644 --- a/include/hsakmt.h +++ b/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/src/memory.c b/src/memory.c index 68d86d5e5e..0be2a0f738 100644 --- a/src/memory.c +++ b/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; }