From patchwork Mon Oct 7 15:54:47 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Petar Jovanovic X-Patchwork-Id: 281172 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)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 010B62C007A for ; Tue, 8 Oct 2013 02:58:12 +1100 (EST) Received: from localhost ([::1]:60536 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VTDCE-0000qG-4Z for incoming@patchwork.ozlabs.org; Mon, 07 Oct 2013 11:58:10 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:56348) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VTDBl-0000k7-3u for qemu-devel@nongnu.org; Mon, 07 Oct 2013 11:57:46 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1VTDBf-0008OO-OY for qemu-devel@nongnu.org; Mon, 07 Oct 2013 11:57:41 -0400 Received: from mail.rt-rk.ftn.uns.ac.rs ([147.91.177.140]:36625 helo=mail.rt-rk.com) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VTDBf-0008Nb-9a for qemu-devel@nongnu.org; Mon, 07 Oct 2013 11:57:35 -0400 Received: from mail.rt-rk.com (mail.localdomain [127.0.0.1]) by mail.rt-rk.com (Postfix) with SMTP id 0113125B6B5 for ; Mon, 7 Oct 2013 17:57:31 +0200 (CEST) X-Virus-Scanned: amavisd-new at rt-rk.com From: Petar Jovanovic To: qemu-devel@nongnu.org Date: Mon, 7 Oct 2013 17:54:47 +0200 Message-Id: <1381161287-40027-1-git-send-email-petar.jovanovic@rt-rk.com> X-Mailer: git-send-email 1.7.9.5 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x X-Received-From: 147.91.177.140 Cc: riku.voipio@linaro.org, petar.jovanovic@imgtec.com, aurelien@aurel32.net Subject: [Qemu-devel] [PATCH] linux-user: define ipc_perm and shmid_ds per arch and fix shmctl issue 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 From: Petar Jovanovic Structs ipc_perm and shmid_ds are specific for each architecture and should be defined accordingly. This change does that, and it also fix shmctl issue by passing correct parameter buf to do_shmctl(). Signed-off-by: Petar Jovanovic --- linux-user/syscall.c | 78 +++++++---------- linux-user/syscall_defs.h | 211 +++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 240 insertions(+), 49 deletions(-) diff --git a/linux-user/syscall.c b/linux-user/syscall.c index 4a14a43..abaffde 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -2417,21 +2417,6 @@ static struct shm_region { abi_ulong size; } shm_regions[N_SHM_REGIONS]; -struct target_ipc_perm -{ - abi_long __key; - abi_ulong uid; - abi_ulong gid; - abi_ulong cuid; - abi_ulong cgid; - unsigned short int mode; - unsigned short int __pad1; - unsigned short int __seq; - unsigned short int __pad2; - abi_ulong __unused1; - abi_ulong __unused2; -}; - struct target_semid_ds { struct target_ipc_perm sem_perm; @@ -2453,12 +2438,21 @@ static inline abi_long target_to_host_ipc_perm(struct ipc_perm *host_ip, if (!lock_user_struct(VERIFY_READ, target_sd, target_addr, 1)) return -TARGET_EFAULT; target_ip = &(target_sd->sem_perm); - host_ip->__key = tswapal(target_ip->__key); - host_ip->uid = tswapal(target_ip->uid); - host_ip->gid = tswapal(target_ip->gid); - host_ip->cuid = tswapal(target_ip->cuid); - host_ip->cgid = tswapal(target_ip->cgid); + host_ip->__key = tswap32(target_ip->__key); + host_ip->uid = tswap32(target_ip->uid); + host_ip->gid = tswap32(target_ip->gid); + host_ip->cuid = tswap32(target_ip->cuid); + host_ip->cgid = tswap32(target_ip->cgid); +#if defined(TARGET_ALPHA) || defined(TARGET_MIPS) || defined(TARGET_PPC) + host_ip->mode = tswap32(target_ip->mode); +#else host_ip->mode = tswap16(target_ip->mode); +#endif +#if defined(TARGET_PPC) + host_ip->__seq = tswap32(target_ip->__seq); +#else + host_ip->__seq = tswap16(target_ip->__seq); +#endif unlock_user_struct(target_sd, target_addr, 0); return 0; } @@ -2472,12 +2466,21 @@ static inline abi_long host_to_target_ipc_perm(abi_ulong target_addr, if (!lock_user_struct(VERIFY_WRITE, target_sd, target_addr, 0)) return -TARGET_EFAULT; target_ip = &(target_sd->sem_perm); - target_ip->__key = tswapal(host_ip->__key); - target_ip->uid = tswapal(host_ip->uid); - target_ip->gid = tswapal(host_ip->gid); - target_ip->cuid = tswapal(host_ip->cuid); - target_ip->cgid = tswapal(host_ip->cgid); + target_ip->__key = tswap32(host_ip->__key); + target_ip->uid = tswap32(host_ip->uid); + target_ip->gid = tswap32(host_ip->gid); + target_ip->cuid = tswap32(host_ip->cuid); + target_ip->cgid = tswap32(host_ip->cgid); +#if defined(TARGET_ALPHA) || defined(TARGET_MIPS) || defined(TARGET_PPC) + target_ip->mode = tswap32(host_ip->mode); +#else target_ip->mode = tswap16(host_ip->mode); +#endif +#if defined(TARGET_PPC) + target_ip->__seq = tswap32(host_ip->__seq); +#else + target_ip->__seq = tswap16(host_ip->__seq); +#endif unlock_user_struct(target_sd, target_addr, 1); return 0; } @@ -2908,29 +2911,6 @@ end: return ret; } -struct target_shmid_ds -{ - struct target_ipc_perm shm_perm; - abi_ulong shm_segsz; - abi_ulong shm_atime; -#if TARGET_ABI_BITS == 32 - abi_ulong __unused1; -#endif - abi_ulong shm_dtime; -#if TARGET_ABI_BITS == 32 - abi_ulong __unused2; -#endif - abi_ulong shm_ctime; -#if TARGET_ABI_BITS == 32 - abi_ulong __unused3; -#endif - int shm_cpid; - int shm_lpid; - abi_ulong shm_nattch; - unsigned long int __unused4; - unsigned long int __unused5; -}; - static inline abi_long target_to_host_shmid_ds(struct shmid_ds *host_sd, abi_ulong target_addr) { @@ -3216,7 +3196,7 @@ static abi_long do_ipc(unsigned int call, int first, /* IPC_* and SHM_* command values are the same on all linux platforms */ case IPCOP_shmctl: - ret = do_shmctl(first, second, third); + ret = do_shmctl(first, second, ptr); break; default: gemu_log("Unsupported ipc call: %d (version %d)\n", call, version); diff --git a/linux-user/syscall_defs.h b/linux-user/syscall_defs.h index 5f53a28..079156e 100644 --- a/linux-user/syscall_defs.h +++ b/linux-user/syscall_defs.h @@ -2513,3 +2513,214 @@ struct target_ucred { }; #endif + +#if defined(TARGET_ALPHA) + +struct target_ipc_perm { + abi_int __key; + abi_uint uid; + abi_uint gid; + abi_uint cuid; + abi_uint cgid; + abi_uint mode; + abi_ushort __seq; + abi_ushort __pad1; + abi_ulong __unused1; + abi_ulong __unused2; +}; + +struct target_shmid_ds { + struct target_ipc_perm shm_perm; + abi_long shm_segsz; + abi_ulong shm_atime; + abi_ulong shm_dtime; + abi_ulong shm_ctime; + abi_int shm_cpid; + abi_int shm_lpid; + abi_ulong shm_nattch; + abi_ulong __unused1; + abi_ulong __unused2; +}; + +#elif defined(TARGET_ARM) + +struct target_ipc_perm { + abi_int __key; + abi_uint uid; + abi_uint gid; + abi_uint cuid; + abi_uint cgid; + abi_ushort mode; + abi_ushort __pad1; + abi_ushort __seq; + abi_ushort __pad2; + abi_ulong __unused1; + abi_ulong __unused2; +}; + +struct target_shmid_ds { + struct target_ipc_perm shm_perm; + abi_long shm_segsz; + abi_ulong shm_atime; + abi_ulong __unused1; + abi_ulong shm_dtime; + abi_ulong __unused2; + abi_ulong shm_ctime; + abi_ulong __unused3; + abi_int shm_cpid; + abi_int shm_lpid; + abi_ulong shm_nattch; + abi_ulong __unused4; + abi_ulong __unused5; +}; + +#elif defined(TARGET_MIPS) + +struct target_ipc_perm { + abi_int __key; + abi_uint uid; + abi_uint gid; + abi_uint cuid; + abi_uint cgid; + abi_uint mode; + abi_ushort __seq; + abi_ushort __pad1; + abi_ulong __unused1; + abi_ulong __unused2; +}; + +struct target_shmid_ds { + struct target_ipc_perm shm_perm; + abi_long shm_segsz; + abi_ulong shm_atime; + abi_ulong shm_dtime; + abi_ulong shm_ctime; + abi_int shm_cpid; + abi_int shm_lpid; + abi_ulong shm_nattch; + abi_ulong __unused1; + abi_ulong __unused2; +}; + +#elif defined(TARGET_PPC) + +struct target_ipc_perm { + abi_int __key; + abi_uint uid; + abi_uint gid; + abi_uint cuid; + abi_uint cgid; + abi_uint mode; + uint32_t __seq; + uint32_t __pad1; + uint64_t __unused1; + uint64_t __unused2; +}; + +struct target_shmid_ds { + struct target_ipc_perm shm_perm; +#if TARGET_ABI_BITS == 32 + abi_uint __unused1; +#endif + abi_ulong shm_atime; +#if TARGET_ABI_BITS == 32 + abi_uint __unused2; +#endif + abi_ulong shm_dtime; +#if TARGET_ABI_BITS == 32 + abi_uint __unused3; +#endif + abi_ulong shm_ctime; +#if TARGET_ABI_BITS == 32 + abi_uint __unused4; +#endif + abi_long shm_segsz; + abi_int shm_cpid; + abi_int shm_lpid; + abi_ulong shm_nattch; + abi_ulong __unused5; + abi_ulong __unused6; +}; + +#elif defined(TARGET_SPARC) + +struct target_ipc_perm { + abi_int __key; + abi_uint uid; + abi_uint gid; + abi_uint cuid; + abi_uint cgid; +#if TARGET_ABI_BITS == 32 + abi_ushort __pad1; + abi_ushort mode; + abi_ushort __pad2; +#else + abi_ushort mode; + abi_ushort __pad1; +#endif + abi_ushort __seq; + uint64_t __unused1; + uint64_t __unused2; +}; + +struct target_shmid_ds { + struct target_ipc_perm shm_perm; +#if TARGET_ABI_BITS == 32 + abi_uint __pad1; +#endif + abi_ulong shm_atime; +#if TARGET_ABI_BITS == 32 + abi_uint __pad2; +#endif + abi_ulong shm_dtime; +#if TARGET_ABI_BITS == 32 + abi_uint __pad3; +#endif + abi_ulong shm_ctime; + abi_long shm_segsz; + abi_ulong shm_cpid; + abi_ulong shm_lpid; + abi_long shm_nattch; + abi_ulong __unused1; + abi_ulong __unused2; +}; + +#else + +struct target_ipc_perm { + abi_int __key; + abi_uint uid; + abi_uint gid; + abi_uint cuid; + abi_uint cgid; + abi_ushort mode; + abi_ushort __pad1; + abi_ushort __seq; + abi_ushort __pad2; + abi_ulong __unused1; + abi_ulong __unused2; +}; + +struct target_shmid_ds { + struct target_ipc_perm shm_perm; + abi_long shm_segsz; + abi_ulong shm_atime; +#if TARGET_ABI_BITS == 32 + abi_ulong __unused1; +#endif + abi_ulong shm_dtime; +#if TARGET_ABI_BITS == 32 + abi_ulong __unused2; +#endif + abi_ulong shm_ctime; +#if TARGET_ABI_BITS == 32 + abi_ulong __unused3; +#endif + abi_int shm_cpid; + abi_int shm_lpid; + abi_ulong shm_nattch; + abi_ulong __unused4; + abi_ulong __unused5; +}; + +#endif