[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-ppc] [Qemu-devel] [PATCH 03/12] linux-user: Properly Handle se
From: |
Peter Maydell |
Subject: |
Re: [Qemu-ppc] [Qemu-devel] [PATCH 03/12] linux-user: Properly Handle semun Structure In Cross-Endian Situations |
Date: |
Mon, 4 Aug 2014 18:23:24 +0100 |
On 4 August 2014 17:45, Tom Musta <address@hidden> wrote:
> The semun union used in the semctl system call contains both an int (val) and
> pointers. In cross-endian situations on 64 bit targets, the target memory
> must be byte swapped, otherwise the wrong 32 bits are used for the val
> field.
>
> Signed-off-by: Tom Musta <address@hidden>
>
> diff --git a/linux-user/syscall.c b/linux-user/syscall.c
> index 229c482..fb03e96 100644
> --- a/linux-user/syscall.c
> +++ b/linux-user/syscall.c
> @@ -2647,9 +2647,14 @@ static inline abi_long do_semctl(int semid, int
> semnum, int cmd,
> switch( cmd ) {
> case GETVAL:
> case SETVAL:
> +#if TARGET_ABI_BITS == 64
> + /* In 64 bit cross endian situations, we will erroneously pick up
> + * the wrong half of the union for the "val" element. To rectify
> + * this, the entire structure is byteswaped. */
"byteswapped".
> + target_su.buf = tswapal(target_su.buf);
> +#endif
This feels weird; surely there's a way of phrasing this
that doesn't require an #ifdef on TARGET_ABI_BITS?
> arg.val = tswap32(target_su.val);
> ret = get_errno(semctl(semid, semnum, cmd, arg));
> - target_su.val = tswap32(arg.val);
This deleted line isn't mentioned in the commit message...
> break;
> case GETALL:
> case SETALL:
thanks
-- PMM
- [Qemu-ppc] [PATCH 00/12] target-ppc: Linux-User Mode Bug Fixes for Power, Tom Musta, 2014/08/04
- [Qemu-ppc] [PATCH 01/12] linux-user: PPC64 semid_ds Doesnt Include _unused1 and _unused2, Tom Musta, 2014/08/04
- [Qemu-ppc] [PATCH 02/12] linux-user: Dereference Pointer Argument to ipc/semctl Sys Call, Tom Musta, 2014/08/04
- [Qemu-ppc] [PATCH 03/12] linux-user: Properly Handle semun Structure In Cross-Endian Situations, Tom Musta, 2014/08/04
- Re: [Qemu-ppc] [Qemu-devel] [PATCH 03/12] linux-user: Properly Handle semun Structure In Cross-Endian Situations,
Peter Maydell <=
- [Qemu-ppc] [PATCH 04/12] linux-user: Make ipc syscall's third argument an abi_long, Tom Musta, 2014/08/04
- [Qemu-ppc] [PATCH 05/12] linux-user: Conditionally Pass Attribute Pointer to mq_open(), Tom Musta, 2014/08/04
- [Qemu-ppc] [PATCH 06/12] linux-user: Detect Negative Message Sizes in msgsnd System Call, Tom Musta, 2014/08/04
- [Qemu-ppc] [PATCH 07/12] linux-user: Handle NULL argument to sched_{get, set}param, Tom Musta, 2014/08/04
- [Qemu-ppc] [PATCH 08/12] linux-user: Detect fault in sched_rr_get_interval, Tom Musta, 2014/08/04