aboutsummaryrefslogtreecommitdiff
path: root/linux-user
diff options
context:
space:
mode:
authorPaolo Bonzini <pbonzini@redhat.com>2015-12-02 13:00:54 +0100
committerPaolo Bonzini <pbonzini@redhat.com>2015-12-02 13:12:30 +0100
commit0c2d70c448b7853a91cfa63659aa3cc6630fb9be (patch)
tree7327dbaa1da19f0e397dfef405a45755ff61a92c /linux-user
parent21a24302e85024dd7b2a151158adbc1f5dc5c4dd (diff)
downloadqemu-0c2d70c448b7853a91cfa63659aa3cc6630fb9be.zip
qemu-0c2d70c448b7853a91cfa63659aa3cc6630fb9be.tar.gz
qemu-0c2d70c448b7853a91cfa63659aa3cc6630fb9be.tar.bz2
translate-all: ensure host page mask is always extended with 1's
Anthony reported that >4GB guests on Xen with 32bit QEMU broke after commit 4ed023c ("Round up RAMBlock sizes to host page sizes", 2015-11-05). In that patch sizes are masked against qemu_host_page_size/mask which are uintptr_t, and thus 32bit on a 32bit QEMU, even though the ram space might be bigger than 4GB on Xen. Since ram_addr_t is not available on user-mode emulation targets, ensure that we get a sign extension when masking away the low bits of the address. Remove the ~10 year old scary comment that the type of these variables is probably wrong, with another equally scary comment. The new comment however does not have "???" in it, which is arguably an improvement. For completeness use the alignment macros in linux-user and bsd-user instead of manually doing an &. linux-user and bsd-user are not affected by the Xen issue, however. Reviewed-by: Juan Quintela <quintela@redhat.com> Reported-by: Anthony PERARD <anthony.perard@citrix.com> Fixes: 4ed023ce2a39ab5812d33cf4d819def168965a7f Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Diffstat (limited to 'linux-user')
-rw-r--r--linux-user/elfload.c3
-rw-r--r--linux-user/mmap.c4
2 files changed, 2 insertions, 5 deletions
diff --git a/linux-user/elfload.c b/linux-user/elfload.c
index d68f5a1..8b17c0e 100644
--- a/linux-user/elfload.c
+++ b/linux-user/elfload.c
@@ -1478,8 +1478,7 @@ static void zero_bss(abi_ulong elf_bss, abi_ulong last_bss, int prot)
host_start = (uintptr_t) g2h(elf_bss);
host_end = (uintptr_t) g2h(last_bss);
- host_map_start = (host_start + qemu_real_host_page_size - 1);
- host_map_start &= -qemu_real_host_page_size;
+ host_map_start = REAL_HOST_PAGE_ALIGN(host_start);
if (host_map_start < host_end) {
void *p = mmap((void *)host_map_start, host_end - host_map_start,
diff --git a/linux-user/mmap.c b/linux-user/mmap.c
index 5606bcd..7b459d5 100644
--- a/linux-user/mmap.c
+++ b/linux-user/mmap.c
@@ -444,9 +444,7 @@ abi_long target_mmap(abi_ulong start, abi_ulong len, int prot,
/* If so, truncate the file map at eof aligned with
the hosts real pagesize. Additional anonymous maps
will be created beyond EOF. */
- len = (sb.st_size - offset);
- len += qemu_real_host_page_size - 1;
- len &= ~(qemu_real_host_page_size - 1);
+ len = REAL_HOST_PAGE_ALIGN(sb.st_size - offset);
}
}