From patchwork Fri Sep 2 17:40:01 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 9311479 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 60AEC60760 for ; Fri, 2 Sep 2016 17:41:16 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5590F29821 for ; Fri, 2 Sep 2016 17:41:16 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 497E629831; Fri, 2 Sep 2016 17:41: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.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI 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 A172129821 for ; Fri, 2 Sep 2016 17:41:15 +0000 (UTC) Received: from localhost ([::1]:43300 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bfsSo-0000Te-Ag for patchwork-qemu-devel@patchwork.kernel.org; Fri, 02 Sep 2016 13:41:14 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:40843) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bfsRm-0008N0-Pc for qemu-devel@nongnu.org; Fri, 02 Sep 2016 13:40:11 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bfsRl-00083G-RL for qemu-devel@nongnu.org; Fri, 02 Sep 2016 13:40:10 -0400 Received: from orth.archaic.org.uk ([2001:8b0:1d0::2]:58714) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bfsRl-0007yM-Kq for qemu-devel@nongnu.org; Fri, 02 Sep 2016 13:40:09 -0400 Received: from pm215 by orth.archaic.org.uk with local (Exim 4.84_2) (envelope-from ) id 1bfsRe-0000Zt-1X; Fri, 02 Sep 2016 18:40:02 +0100 From: Peter Maydell To: qemu-devel@nongnu.org Date: Fri, 2 Sep 2016 18:40:01 +0100 Message-Id: <1472838001-1673-1-git-send-email-peter.maydell@linaro.org> X-Mailer: git-send-email 2.7.4 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 2001:8b0:1d0::2 Subject: [Qemu-devel] [PATCH] linux-user: Fix definition of target_sigevent for 32-bit guests 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 , patches@linaro.org Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP The sigevent structure includes a union with some fields which are pointers. For the QEMU target_sigevent structure we must represent these as abi_ulongs, not host function pointers. This error was causing the compiler to believe it should 8-align the _sigev_un union on a 64-bit host, which meant that the code in target_to_host_sigevent() was looking at the wrong offset to find the _tid field, and timer_create() would spuriously fail with EINVAL. This fixes the final loose end noted in LP:1042388. While we're editing the structure, switch the 'int32_t' fields to 'abi_int'; this will only matter for guests with non-standard integer alignment like m68k. Signed-off-by: Peter Maydell --- linux-user/syscall_defs.h | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/linux-user/syscall_defs.h b/linux-user/syscall_defs.h index dbf6a38..f4417ee 100644 --- a/linux-user/syscall_defs.h +++ b/linux-user/syscall_defs.h @@ -2618,15 +2618,19 @@ typedef int32_t target_timer_t; struct target_sigevent { target_sigval_t sigev_value; - int32_t sigev_signo; - int32_t sigev_notify; + abi_int sigev_signo; + abi_int sigev_notify; union { - int32_t _pad[TARGET_SIGEV_PAD_SIZE]; - int32_t _tid; + abi_int _pad[TARGET_SIGEV_PAD_SIZE]; + abi_int _tid; + /* The kernel (and thus QEMU) never looks at these; + * they're only used as part of the ABI between a + * userspace program and libc. + */ struct { - void (*_function)(sigval_t); - void *_attribute; + abi_ulong _function; + abi_ulong _attribute; } _sigev_thread; } _sigev_un; };