From patchwork Sat Oct 3 15:14:06 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Vivier X-Patchwork-Id: 525939 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org 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 2D3CD1402CC for ; Sun, 4 Oct 2015 01:14:35 +1000 (AEST) Received: from localhost ([::1]:38971 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZiOW8-00049V-SS for incoming@patchwork.ozlabs.org; Sat, 03 Oct 2015 11:14:32 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:59909) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZiOVu-0003rg-GD for qemu-devel@nongnu.org; Sat, 03 Oct 2015 11:14:19 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZiOVq-0004fH-Fs for qemu-devel@nongnu.org; Sat, 03 Oct 2015 11:14:18 -0400 Received: from smtp4-g21.free.fr ([212.27.42.4]:2126) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZiOVq-0004eD-AU for qemu-devel@nongnu.org; Sat, 03 Oct 2015 11:14:14 -0400 Received: from Quad.localdomain (unknown [78.238.229.36]) by smtp4-g21.free.fr (Postfix) with ESMTPS id E07004C8027; Sat, 3 Oct 2015 17:14:10 +0200 (CEST) From: Laurent Vivier To: Riku Voipio Date: Sat, 3 Oct 2015 17:14:06 +0200 Message-Id: <1443885246-11520-1-git-send-email-laurent@vivier.eu> X-Mailer: git-send-email 2.4.3 X-detected-operating-system: by eggs.gnu.org: Windows NT kernel [generic] [fuzzy] X-Received-From: 212.27.42.4 Cc: Peter Maydell , Alexander Graf , qemu-devel@nongnu.org, Laurent Vivier Subject: [Qemu-devel] [PATCH] linux-user: correctly align target_epoll_event X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org According to comments in /usr/include/linux/eventpoll.h, poll_event is packed only on x86_64. And to be sure fields are correctly aligned in epoll_data, use abi_XXX types for all of them. Moreover, fd type is wrong: fd is int, not ulong. This has been tested with a ppc guest on an x86_64 host: without this patch, systemd crashes (core). CC: Alexander Graf CC: Peter Maydell Signed-off-by: Laurent Vivier --- I cc' Alexander because it has added the padding and the packed attribute, Peter because it is the author of the original structure. linux-user/syscall_defs.h | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/linux-user/syscall_defs.h b/linux-user/syscall_defs.h index 7ca33a6..f4e4122 100644 --- a/linux-user/syscall_defs.h +++ b/linux-user/syscall_defs.h @@ -2503,20 +2503,23 @@ struct target_mq_attr { #define FUTEX_CMD_MASK ~(FUTEX_PRIVATE_FLAG | FUTEX_CLOCK_REALTIME) #ifdef CONFIG_EPOLL +#if defined(TARGET_X86_64) +#define TARGET_EPOLL_PACKED QEMU_PACKED +#else +#define TARGET_EPOLL_PACKED +#endif + typedef union target_epoll_data { abi_ulong ptr; - abi_ulong fd; - uint32_t u32; - uint64_t u64; + abi_int fd; + abi_uint u32; + abi_ullong u64; } target_epoll_data_t; struct target_epoll_event { - uint32_t events; -#if defined(TARGET_ARM) || defined(TARGET_MIPS) || defined(TARGET_MIPS64) - uint32_t __pad; -#endif + abi_uint events; target_epoll_data_t data; -} QEMU_PACKED; +} TARGET_EPOLL_PACKED; #endif struct target_rlimit64 { uint64_t rlim_cur;