diff options
author | Arnie Reynoso <arnier@ti.com> | 2015-01-27 11:13:42 -0800 |
---|---|---|
committer | Robert Tivy <rtivy@ti.com> | 2015-01-28 16:41:20 -0800 |
commit | ff0ca0e3943ab67be47673bfc77f40c53daac078 (patch) | |
tree | 69ddb289191c7a6b4549e5ad1ca3e264edf5e1f9 | |
parent | 4f4f810684555b0aecc3012caf6793304090e9c1 (diff) | |
download | ipc-3.30.tar.gz |
Android: GateMP uses mmap64 calls to map inUse array3.30.03.14ipc-3.30-next3.30
Android's Lollipop filesystem (64-bit) has an issue with mmap() calls.
The offset (off_t type) is incorrectly casted and sign extended.
Using mmap64() and off64_t type explicitly on Android to avoid the issue.
-rw-r--r-- | linux/src/daemon/GateMP_daemon.c | 55 |
1 files changed, 37 insertions, 18 deletions
diff --git a/linux/src/daemon/GateMP_daemon.c b/linux/src/daemon/GateMP_daemon.c index afb1bbd..d2db25d 100644 --- a/linux/src/daemon/GateMP_daemon.c +++ b/linux/src/daemon/GateMP_daemon.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013-2014, Texas Instruments Incorporated + * Copyright (c) 2013-2015, Texas Instruments Incorporated * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -133,6 +133,7 @@ Int GateMP_setup(Void) UInt32 len; UInt32 size; UInt32 alignDiff; + UInt32 offset; Int32 fdMem; NameServer_Params_init(¶ms); @@ -191,59 +192,77 @@ Int GateMP_setup(Void) size = GateMP_module->numRemoteSystem * sizeof (UInt8) + (nsValue[0] & (sysconf(_SC_PAGE_SIZE) - 1)); size = PAGE_ALIGN(size, sysconf(_SC_PAGE_SIZE)); + offset = nsValue[0] & ~(sysconf(_SC_PAGE_SIZE) - 1); +#if defined(IPC_BUILDOS_ANDROID) + GateMP_module->remoteSystemInUse = mmap64(NULL, size, + (PROT_READ|PROT_WRITE), (MAP_SHARED), fdMem, + (off64_t)offset); +#else GateMP_module->remoteSystemInUse = mmap(NULL, size, (PROT_READ|PROT_WRITE), (MAP_SHARED), fdMem, - (off_t)nsValue[0] & ~(sysconf(_SC_PAGE_SIZE) - 1)); + (off_t)offset); +#endif if (GateMP_module->remoteSystemInUse == MAP_FAILED) { - GateMP_module->remoteSystemInUse = NULL; - status = GateMP_E_MEMORY; LOG1("Failed to map remoteSystemInUse=0x%p to host address" \ " space!", GateMP_module->remoteSystemInUse); + GateMP_module->remoteSystemInUse = NULL; + status = GateMP_E_MEMORY; } else { - alignDiff = (off_t)nsValue[0] - - ((off_t)nsValue[0] & ~(sysconf(_SC_PAGE_SIZE) - 1)); + alignDiff = nsValue[0] - offset; GateMP_module->remoteSystemInUse = GateMP_module->remoteSystemInUse + alignDiff; } size = GateMP_module->numRemoteCustom1 * sizeof (UInt8) + - (nsValue[0] & (sysconf(_SC_PAGE_SIZE) - 1)); + (nsValue[1] & (sysconf(_SC_PAGE_SIZE) - 1)); size = PAGE_ALIGN(size, sysconf(_SC_PAGE_SIZE)); + offset = nsValue[1] & ~(sysconf(_SC_PAGE_SIZE) - 1); if (status == GateMP_S_SUCCESS) { +#if defined(IPC_BUILDOS_ANDROID) + GateMP_module->remoteCustom1InUse = mmap64(NULL, size, + (PROT_READ|PROT_WRITE), (MAP_SHARED), fdMem, + (off64_t)offset); +#else GateMP_module->remoteCustom1InUse = mmap(NULL, size, (PROT_READ|PROT_WRITE), (MAP_SHARED), fdMem, - (off_t)nsValue[1] & ~(sysconf(_SC_PAGE_SIZE) - 1)); + (off_t)offset); +#endif if (GateMP_module->remoteCustom1InUse == MAP_FAILED) { - GateMP_module->remoteCustom1InUse = NULL; - status = GateMP_E_MEMORY; LOG1("Failed to map remoteCustom1InUse=%p to host address" \ " space!", GateMP_module->remoteCustom1InUse); + GateMP_module->remoteCustom1InUse = NULL; + status = GateMP_E_MEMORY; } else { - alignDiff = (off_t)nsValue[1] - - ((off_t)nsValue[1] & ~(sysconf(_SC_PAGE_SIZE) - 1)); + alignDiff = nsValue[1] - offset; GateMP_module->remoteCustom1InUse = GateMP_module->remoteCustom1InUse + alignDiff; } } size = GateMP_module->numRemoteCustom2 * sizeof (UInt8) + - (nsValue[0] & (sysconf(_SC_PAGE_SIZE) - 1)); + (nsValue[2] & (sysconf(_SC_PAGE_SIZE) - 1)); size = PAGE_ALIGN(size, sysconf(_SC_PAGE_SIZE)); + offset = nsValue[2] & ~(sysconf(_SC_PAGE_SIZE) - 1); if (status == GateMP_S_SUCCESS) { +#if defined(IPC_BUILDOS_ANDROID) + GateMP_module->remoteCustom2InUse = mmap64(NULL, size, + (PROT_READ|PROT_WRITE), (MAP_SHARED), fdMem, + (off64_t)offset); +#else GateMP_module->remoteCustom2InUse = mmap(NULL, size, (PROT_READ|PROT_WRITE), (MAP_SHARED), fdMem, - (off_t)nsValue[2] & ~(sysconf(_SC_PAGE_SIZE) - 1)); + (off_t)offset); +#endif if (GateMP_module->remoteCustom2InUse == MAP_FAILED) { - GateMP_module->remoteCustom2InUse = NULL; - status = GateMP_E_MEMORY; LOG1("Failed to map remoteCustom2InUse=%p to host address" \ " space!", GateMP_module->remoteCustom2InUse); + GateMP_module->remoteCustom2InUse = NULL; + status = GateMP_E_MEMORY; } else { - alignDiff = (off_t)nsValue[2] - - ((off_t)nsValue[2] & ~(sysconf(_SC_PAGE_SIZE) - 1)); + alignDiff = nsValue[2] - offset; GateMP_module->remoteCustom2InUse = GateMP_module->remoteCustom2InUse + alignDiff; } |