75 lines
3.0 KiB
Diff
75 lines
3.0 KiB
Diff
From: Alexander Graf <agraf@suse.de>
|
|
|
|
When executing 32-bit guest binaries on 64-bit hosts, mmap() can return
|
|
a 64-bit pointer. Tell mmap() to always map in 32-bit address space, so
|
|
we make 32-bit guest applications happy.
|
|
|
|
This is a hack and should not go upstream in its current form!
|
|
|
|
Signed-off-by: Alexander Graf <agraf@suse.de>
|
|
---
|
|
linux-user/mmap.c | 12 ++++++------
|
|
1 files changed, 6 insertions(+), 6 deletions(-)
|
|
|
|
diff --git a/linux-user/mmap.c b/linux-user/mmap.c
|
|
index 994c02b..e24b63a 100644
|
|
--- a/linux-user/mmap.c
|
|
+++ b/linux-user/mmap.c
|
|
@@ -169,7 +169,7 @@ static int mmap_frag(abi_ulong real_start,
|
|
if (prot1 == 0) {
|
|
/* no page was there, so we allocate one */
|
|
void *p = mmap(host_start, qemu_host_page_size, prot,
|
|
- flags | MAP_ANONYMOUS, -1, 0);
|
|
+ flags | MAP_ANONYMOUS | MAP_32BIT, -1, 0);
|
|
if (p == MAP_FAILED)
|
|
return -1;
|
|
prot1 = prot;
|
|
@@ -292,7 +292,7 @@ abi_ulong mmap_find_vma(abi_ulong start, abi_ulong size)
|
|
* - shmat() with SHM_REMAP flag
|
|
*/
|
|
ptr = mmap(g2h(addr), size, PROT_NONE,
|
|
- MAP_ANONYMOUS|MAP_PRIVATE|MAP_NORESERVE, -1, 0);
|
|
+ MAP_ANONYMOUS|MAP_PRIVATE|MAP_NORESERVE|MAP_32BIT, -1, 0);
|
|
|
|
/* ENOMEM, if host address space has no memory */
|
|
if (ptr == MAP_FAILED) {
|
|
@@ -454,14 +454,14 @@ abi_long target_mmap(abi_ulong start, abi_ulong len, int prot,
|
|
especially important if qemu_host_page_size >
|
|
qemu_real_host_page_size */
|
|
p = mmap(g2h(mmap_start),
|
|
- host_len, prot, flags | MAP_FIXED | MAP_ANONYMOUS, -1, 0);
|
|
+ host_len, prot, flags | MAP_FIXED | MAP_ANONYMOUS | MAP_32BIT, -1, 0);
|
|
if (p == MAP_FAILED)
|
|
goto fail;
|
|
/* update start so that it points to the file position at 'offset' */
|
|
host_start = (unsigned long)p;
|
|
if (!(flags & MAP_ANONYMOUS)) {
|
|
p = mmap(g2h(mmap_start), len, prot,
|
|
- flags | MAP_FIXED, fd, host_offset);
|
|
+ flags | MAP_FIXED | MAP_32BIT, fd, host_offset);
|
|
host_start += offset - host_offset;
|
|
}
|
|
start = h2g(host_start);
|
|
@@ -547,7 +547,7 @@ abi_long target_mmap(abi_ulong start, abi_ulong len, int prot,
|
|
else
|
|
offset1 = offset + real_start - start;
|
|
p = mmap(g2h(real_start), real_end - real_start,
|
|
- prot, flags, fd, offset1);
|
|
+ prot, flags | MAP_32BIT, fd, offset1);
|
|
if (p == MAP_FAILED)
|
|
goto fail;
|
|
}
|
|
@@ -603,7 +603,7 @@ static void mmap_reserve(abi_ulong start, abi_ulong size)
|
|
}
|
|
if (real_start != real_end) {
|
|
mmap(g2h(real_start), real_end - real_start, PROT_NONE,
|
|
- MAP_FIXED | MAP_ANONYMOUS | MAP_PRIVATE | MAP_NORESERVE,
|
|
+ MAP_FIXED | MAP_ANONYMOUS | MAP_PRIVATE | MAP_NORESERVE | MAP_32BIT,
|
|
-1, 0);
|
|
}
|
|
}
|
|
--
|
|
1.6.0.2
|
|
|
|
|