From patchwork Wed Jul 11 16:33:45 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Vivier X-Patchwork-Id: 942598 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=2001:4830:134:3::11; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=vivier.eu Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 41Ql5g2p2Bz9rxs for ; Thu, 12 Jul 2018 02:34:31 +1000 (AEST) Received: from localhost ([::1]:54675 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fdI4T-0000cf-4W for incoming@patchwork.ozlabs.org; Wed, 11 Jul 2018 12:34:29 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:42111) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fdI44-0000cZ-AT for qemu-devel@nongnu.org; Wed, 11 Jul 2018 12:34:05 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fdI41-0006b1-7C for qemu-devel@nongnu.org; Wed, 11 Jul 2018 12:34:04 -0400 Received: from mout.kundenserver.de ([212.227.126.133]:39776) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fdI41-0006ae-0E for qemu-devel@nongnu.org; Wed, 11 Jul 2018 12:34:01 -0400 Received: from localhost.localdomain ([78.238.229.36]) by mrelayeu.kundenserver.de (mreue005 [212.227.15.167]) with ESMTPSA (Nemesis) id 0M4muv-1g0rgo1i0r-00z0rz; Wed, 11 Jul 2018 18:33:51 +0200 From: Laurent Vivier To: qemu-devel@nongnu.org Date: Wed, 11 Jul 2018 18:33:45 +0200 Message-Id: <20180711163345.9619-1-laurent@vivier.eu> X-Mailer: git-send-email 2.17.1 X-Provags-ID: V03:K1:qNCB3rajj2PPUi34tQ6A+fPsA6PttvLMfxJmdIB/Df2tn1pMMif jAU5RFaNw5rAREifbGzSLKGyqTsWtQKQFQ5cgOOM2W/HjH7pYZfVipix0YSoMFLWnZi4hji k1xpXAqXR5rp8RNfqL4WQiPd0D8G0M0LT27/ue7cSVtwvK+QzJXV4MSdT4HeSXBHOwYjc9B 2TWyNTGP7qNDWObgf+WrA== X-UI-Out-Filterresults: notjunk:1; V01:K0:ltOtRA1Xa6s=:kd5fAcfcaIHPLd2papBolY BR4PWcUULDGZ1IczxVfQkLe/NEUKruOWeyRjya8xbyLyMON2wWdURm+Uqvhij20buT5Vf1fhz LZtr08ZzbMJlO4IrJXwAqLVOqm2QGsHSiqjSJ0bW1BA9MLNb0tGUG7lbAYam1U/JA+XPrSaqD ln0qdZMBJy1OiTfHcMMIZj/pjltzebITySwC8zLB5BQs+guNV/yzUNe3kBgqVPjm4LX6tfPcr /quL1mU1luHXVqy5h6BthYUs8eOp4zxtwLcyHMzaSetY7HTslsWjTEx81S4kV7zd8B7jM20A+ CMdvEXuX9c4IOBNKgT1tmSpDPuI093OMCk/4towpuCnrCchMy12wp2xXHWeUajNK6Svgo1jYG gF/EK9ARXzr/bS2eXtEeXoOcPqrd9ECi9lXwjcGtMHWpya1pLYdg8eCLXXNTUtATC9JJsdN20 bNVOeAuHvgHFBEm+lTC0Al8JT6qhD0BiNLlHeRGXxZOGI5UdwcKIP/gkJOtMSKnmgVIxi4jbV v3QNjHn+oP1oV57wmfZzGRqn9jvPPAq3norytOyyyOswjRsDkEBKAs9hUZ+UInOlPqDjySr9r r8vECMKvP0idxfu3DnLNkGz3IGHYP+aycOc3jfcirgRyMIJ2nlEw4vepwtxcYju3NpnSNwu8i fWWSHD2i0zB/QJLYp9kAtWtUHuu2Ea15kn7KDw0KrzcJ8WF52s8duSqr9BmBJri6XjKY= X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 212.227.126.133 Subject: [Qemu-devel] [PATCH] linux-user: fix mmap_find_vma_reserved() 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 , Richard Henderson , Laurent Vivier Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" The value given by mmap_find_vma_reserved() is used with mmap(), so it is needed to be aligned with the host page size. Since commit 18e80c55bb, reserved_va is only aligned to TARGET_PAGE_SIZE, and it works well if this size is greater or equal to the host page size. But ppc64 hosts have 64kB page size and when we start a 4kiB page size guest (like i386), it fails when it tries to mmap the stack: mmap stack: Invalid argument Fixes: 18e80c55bb (linux-user: Tidy and enforce reserved_va initialization) Signed-off-by: Laurent Vivier --- linux-user/main.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/linux-user/main.c b/linux-user/main.c index 52b5a618fe..a370b89ee6 100644 --- a/linux-user/main.c +++ b/linux-user/main.c @@ -689,6 +689,11 @@ int main(int argc, char **argv, char **envp) target_environ = envlist_to_environ(envlist, NULL); envlist_free(envlist); + /* reserved_va must be aligned with the host page size + * has it is used with mmap() + */ + reserved_va &= qemu_host_page_mask; + /* * Now that page sizes are configured in tcg_exec_init() we can do * proper page alignment for guest_base.