From patchwork Wed Jan 18 19:24:28 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Pranith Kumar X-Patchwork-Id: 9524625 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 2FEEF60113 for ; Wed, 18 Jan 2017 19:26:44 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 217952861E for ; Wed, 18 Jan 2017 19:26:44 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 164732862C; Wed, 18 Jan 2017 19:26:44 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, T_DKIM_INVALID autolearn=ham version=3.3.1 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 mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 98ECE2861E for ; Wed, 18 Jan 2017 19:26:43 +0000 (UTC) Received: from localhost ([::1]:43841 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cTvsY-0003V4-PT for patchwork-qemu-devel@patchwork.kernel.org; Wed, 18 Jan 2017 14:26:42 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:37928) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cTvqU-0002OH-2a for qemu-devel@nongnu.org; Wed, 18 Jan 2017 14:24:35 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cTvqR-0002vA-Kz for qemu-devel@nongnu.org; Wed, 18 Jan 2017 14:24:34 -0500 Received: from mail-yw0-x243.google.com ([2607:f8b0:4002:c05::243]:35785) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1cTvqR-0002uo-GT for qemu-devel@nongnu.org; Wed, 18 Jan 2017 14:24:31 -0500 Received: by mail-yw0-x243.google.com with SMTP id 17so1976734ywk.2 for ; Wed, 18 Jan 2017 11:24:31 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=+U6eOoFeDYoaE5mNgYPCCsdmFmPU4c+mqYo4niJsIOg=; b=cCFgQk2R8/ktd+ytGEhKnKO+p+KKrHLu8HKbAAaHb1lErKVezVRrFYiq9Al8egOzvO r304S1I5AJsdmhUSzOp3U5s2Du+NPAGvIsZ/rqzzz4RJ9/UeLTtOPYoVmjoC9H6Qh0pN 7U9dsunLQv4CxN5WXw0Hhf89KfORdvCKpyr0EltJUslxc+snK5mYMMKP1JDbz8uZkoXu jMRoFcUKk2okLSeoO2h3FtnoV7TUkWzfXIy+ZGE1SzdhEIJ8vjk9/5btwi2GzX71i/rw nDszvSpwTnFZlvefboIMgFaADDTRMVQpyK1uyPzkQoyQbmSNje9V50z06ZaVNgpWuZwy svPQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=+U6eOoFeDYoaE5mNgYPCCsdmFmPU4c+mqYo4niJsIOg=; b=kFacKJq4xZ4alOnm+N74EAVJEakSRYnwtSn8zVdWO+K/joSQE/42WiIlA/eHDMygIP rWRFKayHFuzaOh8xA6KnEFPgFgtiwsFMtncEMnzK38pqyRGDV5dUi7GFcJDX6hBKo8fG MFh74RFHKNw6k4IjrhOjdCXVAFYguoI0vhR6MaGZqK4afiD0aILkbMLY7Aw0F/K6p5Y4 xuglTfR1ed0TEsKqC+J1LywLkBA8JpzksVB0ipuBOVUCOsBHCpXFmEREx1uHI3FcCvip H1cSTaWsv3Q3PLs9b5+IUTFQyDF0/oI9RRVvldX7kpqL90QERZzeuaklBabr5q7pxzz0 XxvQ== X-Gm-Message-State: AIkVDXKy6BvTF2a3oZh6gmRydKTtZLmw4nt1InbFds3LrtUJ4qjdgJqlkmJ2Fx+W3lRTcw== X-Received: by 10.13.207.197 with SMTP id r188mr3761078ywd.88.1484767470719; Wed, 18 Jan 2017 11:24:30 -0800 (PST) Received: from localhost.localdomain (c-73-207-178-95.hsd1.ga.comcast.net. [73.207.178.95]) by smtp.gmail.com with ESMTPSA id i9sm569859ywe.12.2017.01.18.11.24.29 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 18 Jan 2017 11:24:30 -0800 (PST) From: Pranith Kumar To: alex.bennee@linaro.org Date: Wed, 18 Jan 2017 14:24:28 -0500 Message-Id: <20170118192428.2661-2-bobby.prani@gmail.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20170118192428.2661-1-bobby.prani@gmail.com> References: <20170118192428.2661-1-bobby.prani@gmail.com> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 2607:f8b0:4002:c05::243 Subject: [Qemu-devel] [PATCH v2 2/2] linux-user: fix tcg/mmap test 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: peter.maydell@linaro.org, laurent@vivier.eu, qemu-devel@nongnu.org, =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , rth@twiddle.net Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP From: Marc-André Lureau tests/tcg/mmap test fails with values other than default target page size. When creating a map beyond EOF, extra anonymous pages are added up to the target page boundary. Currently, this operation is performed only when qemu_real_host_page_size < TARGET_PAGE_SIZE, but it should be performed if the configured page size (qemu -p) is larger than qemu_real_host_page_size too. Signed-off-by: Marc-André Lureau [pranith: dropped checkpatch changes] Signed-off-by: Pranith Kumar Reviewed-by: Alex Bennée Reviewed-by: Laurent Vivier --- linux-user/mmap.c | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/linux-user/mmap.c b/linux-user/mmap.c index 61685bf79e..d0d494f138 100644 --- a/linux-user/mmap.c +++ b/linux-user/mmap.c @@ -429,20 +429,21 @@ abi_long target_mmap(abi_ulong start, abi_ulong len, int prot, may need to truncate file maps at EOF and add extra anonymous pages up to the targets page boundary. */ - if ((qemu_real_host_page_size < TARGET_PAGE_SIZE) - && !(flags & MAP_ANONYMOUS)) { - struct stat sb; + if ((qemu_real_host_page_size < qemu_host_page_size) && + !(flags & MAP_ANONYMOUS)) { + struct stat sb; - if (fstat (fd, &sb) == -1) - goto fail; + if (fstat(fd, &sb) == -1) { + goto fail; + } /* Are we trying to create a map beyond EOF?. */ - if (offset + len > sb.st_size) { - /* If so, truncate the file map at eof aligned with - the hosts real pagesize. Additional anonymous maps - will be created beyond EOF. */ - len = REAL_HOST_PAGE_ALIGN(sb.st_size - offset); - } + if (offset + len > sb.st_size) { + /* If so, truncate the file map at eof aligned with + the hosts real pagesize. Additional anonymous maps + will be created beyond EOF. */ + len = REAL_HOST_PAGE_ALIGN(sb.st_size - offset); + } } if (!(flags & MAP_FIXED)) {