qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH] linux-user: map at TARGET_UNMAPPED_BASE with reserved_va
@ 2012-03-03 22:19 Alexander Graf
  2012-03-04  0:33 ` Paul Brook
  0 siblings, 1 reply; 2+ messages in thread
From: Alexander Graf @ 2012-03-03 22:19 UTC (permalink / raw)
  To: qemu-devel qemu-devel
  Cc: Bernhard M. Wiedemann, Riku Voipio, Paul Brook, Peter Maydell

When mmap()'ing memory somewhere where it's not allowed, we should not
default to the "next free page" which could be right after brk()'ed memory,
but rather at TARGET_UNMAPPED_BASE, which ensures that brk() can extend its
space later on.

Reported-by: Bernhard M. Wiedemann <bwiedemann@suse.de>
Signed-off-by: Alexander Graf <agraf@suse.de>
---
 linux-user/mmap.c |    8 +++++++-
 1 files changed, 7 insertions(+), 1 deletions(-)

diff --git a/linux-user/mmap.c b/linux-user/mmap.c
index e4db455..4219b16 100644
--- a/linux-user/mmap.c
+++ b/linux-user/mmap.c
@@ -244,7 +244,13 @@ static abi_ulong mmap_find_vma_reserved(abi_ulong start, abi_ulong size)
         }
         prot = page_get_flags(addr);
         if (prot) {
-            last_addr = addr + qemu_host_page_size;
+            if (addr < mmap_next_start) {
+                /* Someone randomly shot into potential brk space,
+                   better remap higher up when already remapping */
+                last_addr = TASK_UNMAPPED_BASE;
+            } else {
+                last_addr = addr + qemu_host_page_size;
+            }
         }
     }
     mmap_next_start = addr;
-- 
1.6.0.2

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [Qemu-devel] [PATCH] linux-user: map at TARGET_UNMAPPED_BASE with reserved_va
  2012-03-03 22:19 [Qemu-devel] [PATCH] linux-user: map at TARGET_UNMAPPED_BASE with reserved_va Alexander Graf
@ 2012-03-04  0:33 ` Paul Brook
  0 siblings, 0 replies; 2+ messages in thread
From: Paul Brook @ 2012-03-04  0:33 UTC (permalink / raw)
  To: Alexander Graf
  Cc: Bernhard M. Wiedemann, Riku Voipio, qemu-devel qemu-devel,
	Peter Maydell

> When mmap()'ing memory somewhere where it's not allowed, we should not
> default to the "next free page" which could be right after brk()'ed memory,
> but rather at TARGET_UNMAPPED_BASE, which ensures that brk() can extend its
> space later on.

NACK, As discussed on IRC.

Effectively prevents mmap from allocating below TARGET_UNMAPPED_BASE.
This wastes a lot of perfectly good address space.  With small -R values it 
leaves mmap with no usable virtual address space.

Paul

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2012-03-04  0:33 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-03-03 22:19 [Qemu-devel] [PATCH] linux-user: map at TARGET_UNMAPPED_BASE with reserved_va Alexander Graf
2012-03-04  0:33 ` Paul Brook

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).