Received: from eggs.gnu.org ([2001:4830:134:3::10]:51584) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bjnZE-0007CR-93 for qemu-devel@nongnu.org; Tue, 13 Sep 2016 09:16:08 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bjnZA-00018H-Mu for qemu-devel@nongnu.org; Tue, 13 Sep 2016 09:16:03 -0400 Received: from mail-lf0-f67.google.com ([209.85.215.67]:33912) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bjnZA-0000qQ-Fr for qemu-devel@nongnu.org; Tue, 13 Sep 2016 09:16:00 -0400 Received: by mail-lf0-f67.google.com with SMTP id k12so7106288lfb.1 for ; Tue, 13 Sep 2016 06:15:39 -0700 (PDT) From: Stanislav Shmarov Date: Tue, 13 Sep 2016 16:14:28 +0300 Message-Id: <1473772468-2579745-1-git-send-email-snarpix@gmail.com> Subject: [Qemu-devel] [PATCH] linux-user: Fixed brk syscall memory allocation List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Riku Voipio , Stanislav Shmarov When application is trying to allocate memory through brk QEMU is allocating host memory using mmap. Without MAP_FIXED attribute it is possible that memory will never be allocated in desired place, and brk syscall will act like there is no avalible memory. Signed-off-by: Stanislav Shmarov --- linux-user/syscall.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/linux-user/syscall.c b/linux-user/syscall.c index ca06943..2861db2 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -1030,7 +1030,8 @@ abi_long do_brk(abi_ulong new_brk) new_alloc_size = HOST_PAGE_ALIGN(new_brk - brk_page); mapped_addr = get_errno(target_mmap(brk_page, new_alloc_size, PROT_READ|PROT_WRITE, - MAP_ANON|MAP_PRIVATE, 0, 0)); + MAP_ANON | MAP_PRIVATE | MAP_FIXED, + 0, 0)); if (mapped_addr == brk_page) { /* Heap contents are initialized to zero, as for anonymous -- 1.9.3