linux-user/syscall: xtensa: fix ipc_perm conversion
PATCH v2 1/1 linux-user/syscall: xtensa: fix ipc_perm conversion
target_ipc_perm::mode and target_ipc_perm::__seq fields are 32-bit wide on xtensa and thus need to use tswap32.
The issue is spotted by the libc-test http://nsz.repo.hu/git/?p=libc-test
on big-endian xtensa core.
---
Changes v1->v2:
- split into a separate patch
linux-user/syscall.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-)
linux-user/syscall.c +6 -4
@@ -3758,12 +3758,13 @@ static inline abi_long target_to_host_ipc_perm(struct ipc_perm *host_ip, 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 ) +#if defined(TARGET_ALPHA ) || defined(TARGET_MIPS ) || defined(TARGET_PPC ) || \ + defined(TARGET_XTENSA ) host_ip->mode =tswap32 (target_ip->mode);#else host_ip->mode =tswap16 (target_ip->mode);#endif -#if defined(TARGET_PPC ) +#if defined(TARGET_PPC ) || defined(TARGET_XTENSA ) host_ip->__seq =tswap32 (target_ip->__seq);#else host_ip->__seq =tswap16 (target_ip->__seq);
@@ -3786,12 +3787,13 @@ static inline abi_long host_to_target_ipc_perm(abi_ulong target_addr, 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 ) +#if defined(TARGET_ALPHA ) || defined(TARGET_MIPS ) || defined(TARGET_PPC ) || \ + defined(TARGET_XTENSA ) target_ip->mode =tswap32 (host_ip->mode);#else target_ip->mode =tswap16 (host_ip->mode);#endif -#if defined(TARGET_PPC ) +#if defined(TARGET_PPC ) || defined(TARGET_XTENSA ) target_ip->__seq =tswap32 (host_ip->__seq);#else target_ip->__seq =tswap16 (host_ip->__seq);
Signature · 1 line
2.39.2
Quoted 8 lines · Max Filippov
target_ipc_perm::modeandtarget_ipc_perm::__seqfields are 32-bit wide on xtensa and thus need to use tswap32.
The issue is spotted by the libc-test http://nsz.repo.hu/git/?p=libc-test
on big-endian xtensa core.Fixes a3da8be5126b ("target/xtensa: linux-user: fix sysv IPC structures")Signed-off-by Max Filippov <[email protected]>
Quoted 6 lines
---
Changesv1->v2:
- split into a separate patchlinux-user/syscall.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-)
Quoted 20 lines · Max Filippov
target_ipc_perm::modeandtarget_ipc_perm::__seqfields are 32-bit wide on xtensa and thus need to use tswap32.
The issue is spotted by the libc-test http://nsz.repo.hu/git/?p=libc-test
on big-endian xtensa core.Fixes a3da8be5126b ("target/xtensa: linux-user: fix sysv IPC structures")Signed-off-by Max Filippov <[email protected]>---
Changesv1->v2:
- split into a separate patchlinux-user/syscall.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-)linux-user/syscall.c +0
-0
linux-user/syscall.c static inline abi_long target_to_host_ipc_perm(struct ipc_perm *host_ip, · line 3766
Quoted 10 lines
linux-user/syscall.c +2
-1@@ -3758,12 +3758,13 @@ static inline abi_long target_to_host_ipc_perm(struct ipc_perm *host_ip, 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 ) +#if defined(TARGET_ALPHA ) || defined(TARGET_MIPS ) || defined(TARGET_PPC ) || \ + defined(TARGET_XTENSA ) host_ip->mode =tswap32 (target_ip->mode);#else host_ip->mode =tswap16 (target_ip->mode);#endif
Oof. I think we should rewrite these along the lines of __get_user_e, using __builtin_choose_expr and sizeof to choose the correct routine.
r~