From patchwork Thu Aug 4 14:15:04 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Riku Voipio X-Patchwork-Id: 73279 Delivered-To: patch@linaro.org Received: by 10.140.29.52 with SMTP id a49csp1421161qga; Thu, 4 Aug 2016 07:21:02 -0700 (PDT) X-Received: by 10.55.16.218 with SMTP id 87mr7082921qkq.220.1470320462659; Thu, 04 Aug 2016 07:21:02 -0700 (PDT) Return-Path: Received: from lists.gnu.org (lists.gnu.org. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id m186si5767498qke.101.2016.08.04.07.21.02 for (version=TLS1 cipher=AES128-SHA bits=128/128); Thu, 04 Aug 2016 07:21:02 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) client-ip=2001:4830:134:3::11; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom=qemu-devel-bounces+patch=linaro.org@nongnu.org; dmarc=fail (p=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:40159 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bVJWA-0007PD-8i for patch@linaro.org; Thu, 04 Aug 2016 10:21:02 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:44998) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bVJQb-0003Xb-2r for qemu-devel@nongnu.org; Thu, 04 Aug 2016 10:15:18 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bVJQY-0000TF-Rw for qemu-devel@nongnu.org; Thu, 04 Aug 2016 10:15:15 -0400 Received: from mail-lf0-x231.google.com ([2a00:1450:4010:c07::231]:34024) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bVJQY-0000T7-Fi for qemu-devel@nongnu.org; Thu, 04 Aug 2016 10:15:14 -0400 Received: by mail-lf0-x231.google.com with SMTP id l69so182940704lfg.1 for ; Thu, 04 Aug 2016 07:15:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=D/tNf0JpSrFVorEYX5ItO5cYC9fkLXI7zYeE5Y96rvc=; b=NuBhTpo4U6qoqZH/IYTeYYGqjPXymhH4m86NsWVmGB9aIxMx34AuGnRUtL08R+7C4W Lu5ehFrwpZn5ubyL3N/GKdHrFrr1feOYn371rELk0lkL2XEOzZBEM9JnG9O1DQrYNf2T JrwQHm1W6ZtQefkSZhxe5IkGWnE+WGL9ZZSPM= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=D/tNf0JpSrFVorEYX5ItO5cYC9fkLXI7zYeE5Y96rvc=; b=ifg7vPecSoESd/a6hNzdBPX5wSvAavLQYvdPddBUyhUGOfNnC+Vbnbs/i9IT7jYZ6W +8koh42kM8REj9S9wpyWAABQevIA9oFKh22z+Y42PMAo/5m/jyTE2cBwhMbO3ljW2bkk ShH8LM3Xy38kxVRHtzjAWtggQ+cx37qr2SgaeHcgmIQ0RLbxqtDjTw3/k284+14uEIri jVPRtWrFnxjMMYKAuynw3p7/CpJ3RtF/6aZe26Vhg7DuOJjkCL8PAAGkKvrx3IFK9Rdp aacEHdO7fnO0ck/0KpgQK1HI2fsUuyH1932b1yrUo/3H7xPDIzQxnPs/WCC2i0bg58e4 94oA== X-Gm-Message-State: AEkooutxew2PRWCbbVNPPFWrN8F/CciA3WFGAaDUVn1PnY4eTKl15TrzErXEAF46W3QW1LWA X-Received: by 10.25.214.227 with SMTP id p96mr19422996lfi.169.1470320113351; Thu, 04 Aug 2016 07:15:13 -0700 (PDT) Received: from beaming.home (91-157-170-157.elisa-laajakaista.fi. [91.157.170.157]) by smtp.gmail.com with ESMTPSA id r76sm2407266lfi.35.2016.08.04.07.15.12 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 04 Aug 2016 07:15:12 -0700 (PDT) From: riku.voipio@linaro.org To: qemu-devel@nongnu.org Date: Thu, 4 Aug 2016 17:15:04 +0300 Message-Id: <005eb2ae1ff6728de7e6998b7456bd72d4456383.1470319929.git.riku.voipio@linaro.org> X-Mailer: git-send-email 2.1.4 In-Reply-To: References: X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 2a00:1450:4010:c07::231 Subject: [Qemu-devel] [PULL 4/5] linux-user: Fix target_semid_ds structure definition 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: peter.maydell@linaro.org Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" From: Peter Maydell The target_semid_ds structure is not correct for all architectures: the padding fields should only exist for: * 32-bit ABIs * x86 It is also misnamed, since it is following the kernel semid64_ds structure (QEMU doesn't support the legacy semid_ds structure at all). Rename the struct, provide a correct generic definition and allow the oddball x86 architecture to provide its own version. This fixes broken SYSV semaphores for all our 64-bit architectures except x86 and ppc. Signed-off-by: Peter Maydell Signed-off-by: Riku Voipio --- linux-user/syscall.c | 17 ++++++++++------- linux-user/x86_64/target_structs.h | 15 +++++++++++++++ 2 files changed, 25 insertions(+), 7 deletions(-) -- 2.1.4 diff --git a/linux-user/syscall.c b/linux-user/syscall.c index 5bc42c0..df6f2a9 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -3754,27 +3754,30 @@ static struct shm_region { bool in_use; } shm_regions[N_SHM_REGIONS]; -struct target_semid_ds +#ifndef TARGET_SEMID64_DS +/* asm-generic version of this struct */ +struct target_semid64_ds { struct target_ipc_perm sem_perm; abi_ulong sem_otime; -#if !defined(TARGET_PPC64) +#if TARGET_ABI_BITS == 32 abi_ulong __unused1; #endif abi_ulong sem_ctime; -#if !defined(TARGET_PPC64) +#if TARGET_ABI_BITS == 32 abi_ulong __unused2; #endif abi_ulong sem_nsems; abi_ulong __unused3; abi_ulong __unused4; }; +#endif static inline abi_long target_to_host_ipc_perm(struct ipc_perm *host_ip, abi_ulong target_addr) { struct target_ipc_perm *target_ip; - struct target_semid_ds *target_sd; + struct target_semid64_ds *target_sd; if (!lock_user_struct(VERIFY_READ, target_sd, target_addr, 1)) return -TARGET_EFAULT; @@ -3802,7 +3805,7 @@ static inline abi_long host_to_target_ipc_perm(abi_ulong target_addr, struct ipc_perm *host_ip) { struct target_ipc_perm *target_ip; - struct target_semid_ds *target_sd; + struct target_semid64_ds *target_sd; if (!lock_user_struct(VERIFY_WRITE, target_sd, target_addr, 0)) return -TARGET_EFAULT; @@ -3829,7 +3832,7 @@ static inline abi_long host_to_target_ipc_perm(abi_ulong target_addr, static inline abi_long target_to_host_semid_ds(struct semid_ds *host_sd, abi_ulong target_addr) { - struct target_semid_ds *target_sd; + struct target_semid64_ds *target_sd; if (!lock_user_struct(VERIFY_READ, target_sd, target_addr, 1)) return -TARGET_EFAULT; @@ -3845,7 +3848,7 @@ static inline abi_long target_to_host_semid_ds(struct semid_ds *host_sd, static inline abi_long host_to_target_semid_ds(abi_ulong target_addr, struct semid_ds *host_sd) { - struct target_semid_ds *target_sd; + struct target_semid64_ds *target_sd; if (!lock_user_struct(VERIFY_WRITE, target_sd, target_addr, 0)) return -TARGET_EFAULT; diff --git a/linux-user/x86_64/target_structs.h b/linux-user/x86_64/target_structs.h index 3489827..b6e82a8 100644 --- a/linux-user/x86_64/target_structs.h +++ b/linux-user/x86_64/target_structs.h @@ -55,4 +55,19 @@ struct target_shmid_ds { abi_ulong __unused5; }; +/* The x86 definition differs from the generic one in that the + * two padding fields exist whether the ABI is 32 bits or 64 bits. + */ +#define TARGET_SEMID64_DS +struct target_semid64_ds { + struct target_ipc_perm sem_perm; + abi_ulong sem_otime; + abi_ulong __unused1; + abi_ulong sem_ctime; + abi_ulong __unused2; + abi_ulong sem_nsems; + abi_ulong __unused3; + abi_ulong __unused4; +}; + #endif