From patchwork Tue Sep 13 13:14:28 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stanislav Shmarov X-Patchwork-Id: 669370 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3sYQl05Zm3z9sf6 for ; Tue, 13 Sep 2016 23:39:24 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b=B+yeiP6p; dkim-atps=neutral Received: from localhost ([::1]:48869 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bjnvm-0000OJ-2D for incoming@patchwork.ozlabs.org; Tue, 13 Sep 2016 09:39:22 -0400 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) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id; bh=2yjRERP7Es9v+YvdfVGhJsli8XybFT66488Iy4TAB5o=; b=B+yeiP6pXTLptvV2OnCADIReSESH2e4f+LCA99ZnqAtIqxtPIWUelhb1nTRyUQWv+G NSPHK7zOOSTwTqw8yujw11XArHD3SPylCh2fkdX8qdc6q3SZNIj7nCqsa+Qigj4l9gnv vBV0PjnWzPNRggrEJhJwD9yiQjni0PfGgjmVY6Xq81HNcKQmO1JRkCwZQPRXxvVasqzB f7db1a8ANaTJJSOudQfeOa/FuM3ogiecy7C3ipbLkY7y8KjU2UPS0Mj8BPFXVCRAsCA5 bTyIR/15Z3f/YdYjPYinsQt1+FkDtB9TcRI55EORv1FIfO/u3yVenGUyNZBXDRyI9vpr 73JQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=2yjRERP7Es9v+YvdfVGhJsli8XybFT66488Iy4TAB5o=; b=diIbx8FstPR3gLFat47aFjSmeQCWdmlAI7U0G5J/NhA9RAf0YD7DPknfYTBWpzvMeC pQpjfNZ28D92xa2H1cHnt19wPSptwti4D2lNkm8MSwA61LngvuFjo1B+rxQAIaPVy1l8 eSp0H5Rbpxf6RsV/Ev5O2cD7tfqjhLAa8vffyBXGhpFzhiGRRrDqHjGoYIXbVxp2mE8A b3S4p9d1D4aY6qosftJVAAPleCYMpk0lV8JCF6dhyqFJxPpYXgm0rltu3iia0sY8x9Je HCRpxwwMkFr5monpMrI9w3tzXY1W0fBSmSXNBvJLIx8QZm/9EtQBAk1jDUC/gSRA8rWg +/3Q== X-Gm-Message-State: AE9vXwOLmVx2I95yevL47cp2gW1EiAwzYtGnxHkS+bRZ+cjq3L/m6W3g4GbrNKwCaxaFog== X-Received: by 10.25.160.144 with SMTP id j138mr1429802lfe.105.1473772478448; Tue, 13 Sep 2016 06:14:38 -0700 (PDT) Received: from mlogin26.smware.local ([213.243.91.10]) by smtp.gmail.com with ESMTPSA id f64sm3770498lji.29.2016.09.13.06.14.37 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 13 Sep 2016 06:14:37 -0700 (PDT) From: Stanislav Shmarov To: qemu-devel@nongnu.org Date: Tue, 13 Sep 2016 16:14:28 +0300 Message-Id: <1473772468-2579745-1-git-send-email-snarpix@gmail.com> X-Mailer: git-send-email 1.9.3 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.85.215.67 Subject: [Qemu-devel] [PATCH] linux-user: Fixed brk syscall memory allocation X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Riku Voipio , Stanislav Shmarov Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" 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