From fff19d25ea2e121c80c772c42dabcb04bdec74c5 Mon Sep 17 00:00:00 2001 From: Yong Zhao Date: Tue, 3 Jul 2018 20:36:44 -0400 Subject: [PATCH] Set the write permission according to the flag when allocating host cpu mem Change-Id: I758c2b5b1799e968fa852646e1494fabb68c782d Signed-off-by: Yong Zhao [ROCm/ROCR-Runtime commit: 4839882fc8cca2f037ac9af545d41839b8400767] --- projects/rocr-runtime/src/fmm.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/projects/rocr-runtime/src/fmm.c b/projects/rocr-runtime/src/fmm.c index 9aeca436af..5de949ec82 100644 --- a/projects/rocr-runtime/src/fmm.c +++ b/projects/rocr-runtime/src/fmm.c @@ -1121,11 +1121,14 @@ static void *fmm_allocate_host_cpu(uint64_t MemorySizeInBytes, { void *mem = NULL; vm_object_t *vm_obj; - int mmap_prot = PROT_READ | PROT_WRITE; + int mmap_prot = PROT_READ; if (flags.ui32.ExecuteAccess) mmap_prot |= PROT_EXEC; + if (!flags.ui32.ReadOnly) + mmap_prot |= PROT_WRITE; + /* mmap will return a pointer with alignment equal to * sysconf(_SC_PAGESIZE). */