From patchwork Wed Jul 11 16:40:25 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Vivier X-Patchwork-Id: 942602 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 41QlFK64vCzB4MN for ; Thu, 12 Jul 2018 02:41:09 +1000 (AEST) Received: from localhost ([::1]:54700 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fdIAt-0002g7-6L for incoming@patchwork.ozlabs.org; Wed, 11 Jul 2018 12:41:07 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:43552) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fdIAX-0002fo-V5 for qemu-devel@nongnu.org; Wed, 11 Jul 2018 12:40:46 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fdIAT-0001DP-3H for qemu-devel@nongnu.org; Wed, 11 Jul 2018 12:40:46 -0400 Received: from mout.kundenserver.de ([217.72.192.74]:46639) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fdIAS-0001CZ-Qm for qemu-devel@nongnu.org; Wed, 11 Jul 2018 12:40:41 -0400 Received: from localhost.localdomain ([78.238.229.36]) by mrelayeu.kundenserver.de (mreue105 [212.227.15.183]) with ESMTPSA (Nemesis) id 0M9pN2-1foGVq3RFo-00B0rD; Wed, 11 Jul 2018 18:40:31 +0200 From: Laurent Vivier To: qemu-devel@nongnu.org Date: Wed, 11 Jul 2018 18:40:25 +0200 Message-Id: <20180711164025.10924-1-laurent@vivier.eu> X-Mailer: git-send-email 2.17.1 X-Provags-ID: V03:K1:aK7iS/bYCUBzmqji1TexWzrX5kr6vLxUSO2C7A4tdnXsC9nWsla Ei3BCwt1sdC9lmU9bhTAYLpkrXerXZxrwiyblxtFIub2h07ZsbC99wTjNSSS1/kBPPUENh3 Oa43+IrKhpIT9Z7v61a3iiogaAi3Ey0b3oPvBB/pvOy7k+qHLZ0jua+7bYRxaqEqs4CnBym xRGbkS/hO+kJnQ9L2vMMQ== X-UI-Out-Filterresults: notjunk:1; V01:K0:F5phrOwQFg8=:5vgsrS3hI0NJSJk7LsF3Ks Sg+raQ1ehWG3UfmadSGTUHroPGiM45YsvucFBXXlWwtfpMLqct8Th4gaAzN2EIt/F1Pw7N0F9 esSr7LiWN3iMV5G6iYVhyJ0PJFC1tZijaoqds9gUszAlaEZqYHEVUBNsOeiCZXwDGbOu5BhI2 AyCccuazjMs46+BGT97rZmW8d7W1hdfLBB7EHrt2Y7gJMyupuSgU6kH8h2mmz7raY1UTgKGsW j01ICp6LrIF974k+GRo9k11m4WWIW/Rkm6SmkYJSX4TcS8WJufLTpx2AlKP7Hy2MjK5U/34ja 2VCMDSCszu05vNoVraonRCeZlYAS5w2kooa6hOYfGXKccqYKBUEn+djSTPaYVrGMt9T095rhI kdK9YsSnXgecGevujOMoICG7/7NN1c9x5Kq6vXxcXWT8Pl9cSqcOLKi0czrD04EYL+RboVXXs MiJTwOrSFVTCdripWhcQ2ihfhrj006zIgQu61Zvk1b/NlEHrkmp16BqaoP8XPKy+yRj0Yk9lR fwOrsPePNwhG+iAvJtVZQoxW0trYXeBt7MsheHeAv+n6TiXLea9QLZhngQ8rD6Su+aurrc81X bBlQvso+YC/Gy7F38K9tjpyN3GYA0e5kgafqaARjkP2Intz0nhid94F9gXi4siBOtjt+jJw/F tfSI55TPNDz+4uiI98vXRKi+fSbEfwM3QkgXgT2iQKJj78jEvlDUxWmMT2EKNXQyQ3u8= X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 217.72.192.74 Subject: [Qemu-devel] [PATCH v2] 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 --- Notes: v2: fix typo s/has/as/ linux-user/main.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/linux-user/main.c b/linux-user/main.c index 52b5a618fe..15299e9dd7 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 + * as 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.