From patchwork Fri Jul 22 15:06:36 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 9243759 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 1D8A260757 for ; Fri, 22 Jul 2016 15:07:17 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0F8CF266F3 for ; Fri, 22 Jul 2016 15:07:17 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 0288A27FA4; Fri, 22 Jul 2016 15:07:16 +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_SIGNED, 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 ED6C1266F3 for ; Fri, 22 Jul 2016 15:07:15 +0000 (UTC) Received: from localhost ([::1]:47868 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bQc2j-0003mX-UF for patchwork-qemu-devel@patchwork.kernel.org; Fri, 22 Jul 2016 11:07:13 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:59499) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bQc2V-0003m7-1P for qemu-devel@nongnu.org; Fri, 22 Jul 2016 11:07:00 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bQc2S-0006RJ-Ts for qemu-devel@nongnu.org; Fri, 22 Jul 2016 11:06:57 -0400 Received: from mail-vk0-x229.google.com ([2607:f8b0:400c:c05::229]:33806) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bQc2S-0006RF-6T for qemu-devel@nongnu.org; Fri, 22 Jul 2016 11:06:56 -0400 Received: by mail-vk0-x229.google.com with SMTP id s189so160651138vkh.1 for ; Fri, 22 Jul 2016 08:06:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=GhCEk3H+RyuHvMg3aCTvq1Zg203FPL8eSk0CdZEivag=; b=cvc7mUNqPQvyyTVfrbY70+t939+M3dwGxKna2V1tE5J0kGktFlm3ZyVafnmp3hDdMY V4Jbv0Y7wUZp0N7UyTXdcb3Vt5Xv4PDMKDSiim4+Iiadl16pBdcmBuKbUIfLHoeWZ/Bs vHLQ/YaRReEp/bs8gkAXVKfChJMBs/xr8nJCM= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=GhCEk3H+RyuHvMg3aCTvq1Zg203FPL8eSk0CdZEivag=; b=Ma4mcTsC9M4JWx/QzMg5VLYhiGSZIo/bEX8MQfKtLJJsgq347jiew/4SgLkQ8aBvyE TWqcNT+l4iQxDoyCoGtmVE3Elqj6xNsylxJ85/GdGwaHR5Jot0BSuDWk+7fqGHRh7JLO w8j4d/CIdQ1h9hz57rnRlSf4YdQ7fQJGkyu7r8tRNRdiva+N2+wr861tPDD8R+l3pcxH W/HItM2BnJffFUSeQBdhxLriaf9uZPTOGwuhe6SJI0bMxD1k/IdjbJrbvqc66y4EDxES L9POxab4qA3xhCl8IVQ8JWBbkWqraGLCdd+F9KcuSpDBBgNs4polhgb1offsm0UYx5GL UziA== X-Gm-Message-State: AEkoousMoULvPo4yyvT+AFPBI9ZQ4fwp4vdYQg9PFkLiefNlKg9rFAoU+hgDSxr2hnjcPXvSHHuTvc94e1Vbj4yD X-Received: by 10.159.40.67 with SMTP id c61mr2076074uac.82.1469200015657; Fri, 22 Jul 2016 08:06:55 -0700 (PDT) MIME-Version: 1.0 Received: by 10.31.137.69 with HTTP; Fri, 22 Jul 2016 08:06:36 -0700 (PDT) In-Reply-To: <20160722023050.3998-1-icenowy@aosc.xyz> References: <20160722023050.3998-1-icenowy@aosc.xyz> From: Peter Maydell Date: Fri, 22 Jul 2016 16:06:36 +0100 Message-ID: To: Icenowy Zheng X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 2607:f8b0:400c:c05::229 Subject: Re: [Qemu-devel] [PATCH] linux-user: correctly pack target_epoll_event for i386 target 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: Jactry Zeng , Riku Voipio , QEMU Developers Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP On 22 July 2016 at 03:30, Icenowy Zheng wrote: > According to comments in /usr/include/linux/eventpoll.h, x86_64 have > the same memory layout of struct target_epoll_event as i386. So on a > aligned host, if x86_64 should be packed, i386 will also need. > > This has been tested with a i386 guest on an arm host: without the > patch, wineserver crashes (core). > > Signed-off-by: Icenowy Zheng > --- > linux-user/syscall_defs.h | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/linux-user/syscall_defs.h b/linux-user/syscall_defs.h > index b43966e..7380bf5 100644 > --- a/linux-user/syscall_defs.h > +++ b/linux-user/syscall_defs.h > @@ -2547,7 +2547,7 @@ struct target_mq_attr { > #define FUTEX_CMD_MASK ~(FUTEX_PRIVATE_FLAG | FUTEX_CLOCK_REALTIME) > > #ifdef CONFIG_EPOLL > -#if defined(TARGET_X86_64) > +#if defined(TARGET_X86_64) || defined(TARGET_I386) > #define TARGET_EPOLL_PACKED QEMU_PACKED > #else > #define TARGET_EPOLL_PACKED We do indeed not get the right arrangement for this struct for i386, but I don't think this is the right way to fix it. The kernel headers only special case this for x86-64, not i386, and so we should not need to special case i386 either. The underlying problem is that we get the alignment of the 'unsigned long long' type for i386 wrong, treating it as 8-aligned when it should be 4-aligned. This can be fixed by and if you do that I don't think you need to change the handling of the target_epoll_event struct. (and that might in turn fix a bunch of other bugs, or if we're unlucky introduce some new ones by breaking any lurking workarounds for the previous misalignment...) thanks -- PMM diff --git a/include/exec/user/abitypes.h b/include/exec/user/abitypes.h index a09d6c6..ba18860 100644 --- a/include/exec/user/abitypes.h +++ b/include/exec/user/abitypes.h @@ -15,6 +15,10 @@ #define ABI_LLONG_ALIGNMENT 2 #endif +#if defined(TARGET_I386) && !defined(TARGET_X86_64) +#define ABI_LLONG_ALIGNMENT 4 +#endif + #ifndef ABI_SHORT_ALIGNMENT #define ABI_SHORT_ALIGNMENT 2 #endif