Skip to content

Commit

Permalink
memory/patcher: do not hook mmap
Browse files Browse the repository at this point in the history
Signed-off-by: Nathan Hjelm <[email protected]>
  • Loading branch information
hjelmn committed Apr 9, 2016
1 parent ab03460 commit 4b5ffab
Showing 1 changed file with 13 additions and 5 deletions.
18 changes: 13 additions & 5 deletions opal/mca/memory/patcher/memory_patcher_component.c
Original file line number Diff line number Diff line change
Expand Up @@ -83,11 +83,6 @@ opal_memory_patcher_component_t mca_memory_patcher_component = {
it out) */
};

#if OPAL_MEMORY_PATCHER_HAVE___MMAP && !OPAL_MEMORY_PATCHER_HAVE___MMAP_PROTO
/* prototype for Apple's internal mmap function */
void *__mmap (void *start, size_t length, int prot, int flags, int fd, off_t offset);
#endif

#if OPAL_MEMORY_PATCHER_HAVE___SYSCALL_PROTO && OPAL_MEMORY_PATCHER_HAVE___SYSCALL
/* calling __syscall is preferred on some systems when some arguments may be 64-bit. it also
* has the benefit of having an off_t return type */
Expand All @@ -96,6 +91,13 @@ void *__mmap (void *start, size_t length, int prot, int flags, int fd, off_t off
#define memory_patcher_syscall syscall
#endif

#if 0

#if OPAL_MEMORY_PATCHER_HAVE___MMAP && !OPAL_MEMORY_PATCHER_HAVE___MMAP_PROTO
/* prototype for Apple's internal mmap function */
void *__mmap (void *start, size_t length, int prot, int flags, int fd, off_t offset);
#endif

static void *(*original_mmap)(void *, size_t, int, int, int, off_t);

static void *intercept_mmap(void *start, size_t length, int prot, int flags, int fd, off_t offset)
Expand Down Expand Up @@ -127,6 +129,8 @@ static void *intercept_mmap(void *start, size_t length, int prot, int flags, int
return result;
}

#endif

static int (*original_munmap) (void *, size_t);

static int intercept_munmap(void *start, size_t length)
Expand Down Expand Up @@ -372,10 +376,14 @@ static int patcher_open (void)
/* set memory hooks support level */
opal_mem_hooks_set_support (OPAL_MEMORY_FREE_SUPPORT | OPAL_MEMORY_MUNMAP_SUPPORT);

#if 0
/* NTH: the only reason to hook mmap would be to detect memory protection. this does not invalidate
* any cache entries in the region. */
rc = opal_patcher->patch_symbol ("mmap", (uintptr_t) intercept_mmap, (uintptr_t *) &original_mmap);
if (OPAL_SUCCESS != rc) {
return rc;
}
#endif

rc = opal_patcher->patch_symbol ("munmap", (uintptr_t)intercept_munmap, (uintptr_t *) &original_munmap);
if (OPAL_SUCCESS != rc) {
Expand Down

0 comments on commit 4b5ffab

Please sign in to comment.