From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:57405) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bXrqV-0003eu-VT for qemu-devel@nongnu.org; Thu, 11 Aug 2016 11:24:36 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bXrqS-0006aB-0B for qemu-devel@nongnu.org; Thu, 11 Aug 2016 11:24:35 -0400 Received: from mail-wm0-x22d.google.com ([2a00:1450:400c:c09::22d]:38726) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bXrqR-0006a0-PD for qemu-devel@nongnu.org; Thu, 11 Aug 2016 11:24:31 -0400 Received: by mail-wm0-x22d.google.com with SMTP id o80so3114387wme.1 for ; Thu, 11 Aug 2016 08:24:31 -0700 (PDT) From: =?UTF-8?q?Alex=20Benn=C3=A9e?= Date: Thu, 11 Aug 2016 16:24:03 +0100 Message-Id: <1470929064-4092-8-git-send-email-alex.bennee@linaro.org> In-Reply-To: <1470929064-4092-1-git-send-email-alex.bennee@linaro.org> References: <1470929064-4092-1-git-send-email-alex.bennee@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Subject: [Qemu-devel] [RFC v4 07/28] linux-user/elfload: ensure mmap_lock() held while setting up List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: mttcg@listserver.greensocs.com, qemu-devel@nongnu.org, fred.konrad@greensocs.com, a.rigo@virtualopensystems.com, cota@braap.org, bobby.prani@gmail.com, nikunj@linux.vnet.ibm.com Cc: mark.burton@greensocs.com, pbonzini@redhat.com, jan.kiszka@siemens.com, serge.fdrv@gmail.com, rth@twiddle.net, peter.maydell@linaro.org, claudio.fontana@huawei.com, =?UTF-8?q?Alex=20Benn=C3=A9e?= , Riku Voipio 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 --- v4 - split from assert patch --- linux-user/elfload.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/linux-user/elfload.c b/linux-user/elfload.c index f807baf..4b125b9 100644 --- a/linux-user/elfload.c +++ b/linux-user/elfload.c @@ -1838,6 +1838,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; @@ -1998,6 +2000,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; -- 2.7.4