Skip to content

Commit

Permalink
linux-user: use libc wrapper instead of direct mremap syscall
Browse files Browse the repository at this point in the history
This commit essentially reverts commit
3af72a4, which has replaced
five-argument calls to mremap() by direct mremap syscalls for
compatibility with glibc older than version 2.4.

The direct syscall was buggy for 64bit targets on 32bit hosts
because of the default integer type promotions. Since glibc-2.4
is now a decade old, we can remove this workaround.

Signed-off-by: Felix Janda <felix.janda@posteo.de>
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Riku Voipio <riku.voipio@linaro.org>
  • Loading branch information
doughdemon authored and Riku Voipio committed Oct 21, 2016
1 parent 04c95f4 commit 52956a9
Showing 1 changed file with 4 additions and 10 deletions.
14 changes: 4 additions & 10 deletions linux-user/mmap.c
Expand Up @@ -17,8 +17,6 @@
* along with this program; if not, see <http://www.gnu.org/licenses/>.
*/
#include "qemu/osdep.h"
#include <linux/mman.h>
#include <linux/unistd.h>

#include "qemu.h"
#include "qemu-common.h"
Expand Down Expand Up @@ -681,10 +679,8 @@ abi_long target_mremap(abi_ulong old_addr, abi_ulong old_size,
mmap_lock();

if (flags & MREMAP_FIXED) {
host_addr = (void *) syscall(__NR_mremap, g2h(old_addr),
old_size, new_size,
flags,
g2h(new_addr));
host_addr = mremap(g2h(old_addr), old_size, new_size,
flags, g2h(new_addr));

if (reserved_va && host_addr != MAP_FAILED) {
/* If new and old addresses overlap then the above mremap will
Expand All @@ -700,10 +696,8 @@ abi_long target_mremap(abi_ulong old_addr, abi_ulong old_size,
errno = ENOMEM;
host_addr = MAP_FAILED;
} else {
host_addr = (void *) syscall(__NR_mremap, g2h(old_addr),
old_size, new_size,
flags | MREMAP_FIXED,
g2h(mmap_start));
host_addr = mremap(g2h(old_addr), old_size, new_size,
flags | MREMAP_FIXED, g2h(mmap_start));
if (reserved_va) {
mmap_reserve(old_addr, old_size);
}
Expand Down

0 comments on commit 52956a9

Please sign in to comment.