From patchwork Mon Oct 31 14:13:27 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Paolo Bonzini X-Patchwork-Id: 80177 Delivered-To: patch@linaro.org Received: by 10.140.97.247 with SMTP id m110csp140094qge; Mon, 31 Oct 2016 07:16:16 -0700 (PDT) X-Received: by 10.55.166.131 with SMTP id p125mr26535893qke.174.1477923376755; Mon, 31 Oct 2016 07:16:16 -0700 (PDT) Return-Path: Received: from lists.gnu.org (lists.gnu.org. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id v33si1456582qtd.48.2016.10.31.07.16.16 for (version=TLS1 cipher=AES128-SHA bits=128/128); Mon, 31 Oct 2016 07:16:16 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) client-ip=2001:4830:134:3::11; Authentication-Results: mx.google.com; dkim=fail header.i=@gmail.com; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom=qemu-devel-bounces+patch=linaro.org@nongnu.org Received: from localhost ([::1]:35908 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1c1DNo-0001UU-7j for patch@linaro.org; Mon, 31 Oct 2016 10:16:16 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:33398) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1c1DLU-00007i-2P for qemu-devel@nongnu.org; Mon, 31 Oct 2016 10:13:52 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1c1DLT-0002u4-AT for qemu-devel@nongnu.org; Mon, 31 Oct 2016 10:13:52 -0400 Received: from mail-wm0-x243.google.com ([2a00:1450:400c:c09::243]:35891) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1c1DLT-0002tG-3k for qemu-devel@nongnu.org; Mon, 31 Oct 2016 10:13:51 -0400 Received: by mail-wm0-x243.google.com with SMTP id c17so18622822wmc.3 for ; Mon, 31 Oct 2016 07:13:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=Bgz/MyNmrVaZ2AvikanfNTddVqzbq1/NBpWOMp3WMf8=; b=M69X7FoGBPp2pLQnYg0usZ2bhO8mlk9A3MLLXEUipVGSEg44UKxNpcIWGNLJ5t2BZJ gO9Qp1t56OmwP2VccUOQeHn0HFrEJ7mO6Id022Q2lpEoPAFeyBjTOEsTFTJnooj/l90L xCi/KB9U22QGHsL92WcOEBrSPCnrJGMrfIw2u+q8XW5DYI3Ljj+43+MuxwRrYd3U23GJ dHVkPu1zhJU0HE5m0/o9n4HP3/5QdziJPp7andFurDdRxSnANzISMaDeV9ZTdBel5hUK DV1kx1XPH+/L2LZw2FDzXZ0AvzC3nJkJWyDccHWWlPViiSJ4b0HU/zGeBlgEN3EXJuR+ dcXg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=Bgz/MyNmrVaZ2AvikanfNTddVqzbq1/NBpWOMp3WMf8=; b=FraIeXgrBcEi2YR6D2JNre/MuLkwS1YhdGeoxBJ4xW4FJHnsjUl4c3zGZYD2preoNJ Mi582BkADxdxR2pBmwwfLPY2UozzMG+AjgoRLTn3b85O8STKKiTxM6/Vq2ILeHoeOSl9 ul3u1Bvo1E/l0MaclcLNvDQSatWxgOo3cioZbgXlSY2A3W/egtUs2GwtRMAJ23fPtU1k FiFRoyNhF3OFaNfdVY09xJUrC8J1/YRbnrXf43B0d9nX4MovU1JoRaJwoExMkWtaxa9L UprQS1xnWJLDP3biMS3UHYdpb2zoHof4OZE6S8olPScN7VWlkGhZb6n0zLaHw2qP+K+L SObw== X-Gm-Message-State: ABUngvdYg+V7NgGoM8iEVHQUpWMsgYhhuBckKcA8lNnhLFNS8PVHEtgHjC4QD5QMRS+ObA== X-Received: by 10.195.17.165 with SMTP id gf5mr22005678wjd.114.1477923229840; Mon, 31 Oct 2016 07:13:49 -0700 (PDT) Received: from donizetti.lan (dynamic-adsl-78-12-246-178.clienti.tiscali.it. [78.12.246.178]) by smtp.gmail.com with ESMTPSA id p13sm25052133wmd.20.2016.10.31.07.13.48 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 31 Oct 2016 07:13:49 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Date: Mon, 31 Oct 2016 15:13:27 +0100 Message-Id: <1477923215-30323-7-git-send-email-pbonzini@redhat.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1477923215-30323-1-git-send-email-pbonzini@redhat.com> References: <1477923215-30323-1-git-send-email-pbonzini@redhat.com> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 2a00:1450:400c:c09::243 Subject: [Qemu-devel] [PULL 06/14] linux-user/elfload: ensure mmap_lock() held while setting up 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: =?UTF-8?q?Alex=20Benn=C3=A9e?= Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" From: Alex Bennée Future patches will enforce the holding of mmap_lock() when we are manipulating internal memory structures. Technically it doesn't matter in the case of elfload as we haven't started executing yet. However it is easier to grab the lock when required than special case the translate-all API. Signed-off-by: Alex Bennée Reviewed-by: Richard Henderson Message-Id: <20161027151030.20863-8-alex.bennee@linaro.org> Signed-off-by: Paolo Bonzini --- linux-user/elfload.c | 4 ++++ 1 file changed, 4 insertions(+) -- 2.7.4 diff --git a/linux-user/elfload.c b/linux-user/elfload.c index 816272a..547053c 100644 --- a/linux-user/elfload.c +++ b/linux-user/elfload.c @@ -1842,6 +1842,8 @@ static void load_elf_image(const char *image_name, int image_fd, info->pt_dynamic_addr = 0; #endif + mmap_lock(); + /* Find the maximum size of the image and allocate an appropriate amount of memory to handle that. */ loaddr = -1, hiaddr = 0; @@ -2002,6 +2004,8 @@ static void load_elf_image(const char *image_name, int image_fd, load_symbols(ehdr, image_fd, load_bias); } + mmap_unlock(); + close(image_fd); return;