diff options
author | Tom Musta <tommusta@gmail.com> | 2014-05-29 09:12:23 -0500 |
---|---|---|
committer | Alexander Graf <agraf@suse.de> | 2014-06-16 13:24:40 +0200 |
commit | f46e9a0b9911fcfbc13f85f3a8808067990a0f5c (patch) | |
tree | fdd6216ff10318759f83514714f7fd84d0f90205 /linux-user/elfload.c | |
parent | 5b274ed74d21929c5ec399b32f47ad46105b3721 (diff) | |
download | qemu-f46e9a0b9911fcfbc13f85f3a8808067990a0f5c.zip qemu-f46e9a0b9911fcfbc13f85f3a8808067990a0f5c.tar.gz qemu-f46e9a0b9911fcfbc13f85f3a8808067990a0f5c.tar.bz2 |
target-ppc: Confirm That .bss Pages Are Valid
The existing code does a check to ensure that a .bss region is properly
mmap'd. When additional mmap is required, the (guest) pages are also
validated. However, this code has a bug: when host page size is larger
than target page size, it is possible for the .bss pages to already be
(host) mapped but the guest .bss pages may not be valid.
The check to mmap additional space is separated from the flagging of the
target (guest) pages, thus ensuring that both aspects are done properly.
Signed-off-by: Tom Musta <tommusta@gmail.com>
Signed-off-by: Alexander Graf <agraf@suse.de>
Diffstat (limited to 'linux-user/elfload.c')
-rw-r--r-- | linux-user/elfload.c | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/linux-user/elfload.c b/linux-user/elfload.c index d08fc80..eb8d3ad 100644 --- a/linux-user/elfload.c +++ b/linux-user/elfload.c @@ -1425,10 +1425,11 @@ static void zero_bss(abi_ulong elf_bss, abi_ulong last_bss, int prot) perror("cannot mmap brk"); exit(-1); } + } - /* Since we didn't use target_mmap, make sure to record - the validity of the pages with qemu. */ - page_set_flags(elf_bss & TARGET_PAGE_MASK, last_bss, prot|PAGE_VALID); + /* Ensure that the bss page(s) are valid */ + if ((page_get_flags(last_bss-1) & prot) != prot) { + page_set_flags(elf_bss & TARGET_PAGE_MASK, last_bss, prot | PAGE_VALID); } if (host_start < host_map_start) { |