linux-user: fix layout of struct target_msq_id_ds
PATCH 1/1 linux-user: fix layout of struct target_msq_id_ds
The msg_lspid and msg_lrpid members are of type pid_t, which is a 32-bit integer.
--- linux-user/syscall.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-)
linux-user/syscall.c +6 -6
@@ -4185,8 +4185,8 @@ struct target_msqid_dsabi_ulong __msg_cbytes;abi_ulong msg_qnum;abi_ulong msg_qbytes; -abi_ulong msg_lspid; -abi_ulong msg_lrpid; +unsigned int msg_lspid; +unsigned int msg_lrpid;abi_ulong __unused4;abi_ulong __unused5; };
@@ -4206,8 +4206,8 @@ static inline abi_long target_to_host_msqid_ds(struct msqid_ds *host_md, host_md->__msg_cbytes =tswapal (target_md->__msg_cbytes); host_md->msg_qnum =tswapal (target_md->msg_qnum); host_md->msg_qbytes =tswapal (target_md->msg_qbytes); - host_md->msg_lspid =tswapal (target_md->msg_lspid); - host_md->msg_lrpid =tswapal (target_md->msg_lrpid); + host_md->msg_lspid =tswap32 (target_md->msg_lspid); + host_md->msg_lrpid =tswap32 (target_md->msg_lrpid);unlock_user_struct (target_md, target_addr,0 );return 0 ; }
@@ -4227,8 +4227,8 @@ static inline abi_long host_to_target_msqid_ds(abi_ulong target_addr, target_md->__msg_cbytes =tswapal (host_md->__msg_cbytes); target_md->msg_qnum =tswapal (host_md->msg_qnum); target_md->msg_qbytes =tswapal (host_md->msg_qbytes); - target_md->msg_lspid =tswapal (host_md->msg_lspid); - target_md->msg_lrpid =tswapal (host_md->msg_lrpid); + target_md->msg_lspid =tswap32 (host_md->msg_lspid); + target_md->msg_lrpid =tswap32 (host_md->msg_lrpid);unlock_user_struct (target_md, target_addr,1 );return 0 ; }
Signature · 7 lines
2.51.0 -- Andreas Schwab, SUSE Labs, [email protected] GPG Key fingerprint = 0196 BAD8 1CE9 1970 F4BE 1748 E4D4 88E3 0EEA B9D7 "And now for something completely different."
Hi Andreas,
Quoted 13 lines · Andreas Schwab
The
msg_lspidandmsg_lrpidmembers are of typepid_t, which is a 32-bit integer.Signed-off-by Andreas Schwab <[email protected]>--- linux-user/syscall.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-)linux-user/syscall.c +0
-0
linux-user/syscall.c struct target_msqid_ds · line 4189
Quoted 7 lines
linux-user/syscall.c +2
-2@@ -4185,8 +4185,8 @@ struct target_msqid_dsabi_ulong __msg_cbytes;abi_ulong msg_qnum;abi_ulong msg_qbytes; -abi_ulong msg_lspid; -abi_ulong msg_lrpid; +unsigned int msg_lspid; +unsigned int msg_lrpid;
Why not use the explicit 'uint32_t' type?
Quoted 25 lines
linux-user/syscall.c +4
-4abi_ulong __unused4;abi_ulong __unused5; };@@ -4206,8 +4206,8 @@ static inline abi_long target_to_host_msqid_ds(struct msqid_ds *host_md, host_md->__msg_cbytes =tswapal (target_md->__msg_cbytes); host_md->msg_qnum =tswapal (target_md->msg_qnum); host_md->msg_qbytes =tswapal (target_md->msg_qbytes); - host_md->msg_lspid =tswapal (target_md->msg_lspid); - host_md->msg_lrpid =tswapal (target_md->msg_lrpid); + host_md->msg_lspid =tswap32 (target_md->msg_lspid); + host_md->msg_lrpid =tswap32 (target_md->msg_lrpid);unlock_user_struct (target_md, target_addr,0 );return 0 ; }@@ -4227,8 +4227,8 @@ static inline abi_long host_to_target_msqid_ds(abi_ulong target_addr, target_md->__msg_cbytes =tswapal (host_md->__msg_cbytes); target_md->msg_qnum =tswapal (host_md->msg_qnum); target_md->msg_qbytes =tswapal (host_md->msg_qbytes); - target_md->msg_lspid =tswapal (host_md->msg_lspid); - target_md->msg_lrpid =tswapal (host_md->msg_lrpid); + target_md->msg_lspid =tswap32 (host_md->msg_lspid); + target_md->msg_lrpid =tswap32 (host_md->msg_lrpid);unlock_user_struct (target_md, target_addr,1 );return 0 ; }
Quoted 15 lines · Philippe Mathieu-Daudé
Hi Andreas,
Quoted 12 lines · Andreas Schwab
The
msg_lspidandmsg_lrpidmembers are of typepid_t, which is a 32-bit integer.Signed-off-by Andreas Schwab <[email protected]>--- linux-user/syscall.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-)linux-user/syscall.c +0
-0@@ -4185,8 +4185,8 @@ struct target_msqid_dsabi_ulong __msg_cbytes;
Quoted 8 lines
linux-user/syscall.c struct target_msqid_ds · line 4189
Quoted 6 lines
linux-user/syscall.c +2
-2abi_ulong msg_qnum;abi_ulong msg_qbytes; -abi_ulong msg_lspid; -abi_ulong msg_lrpid; +unsigned int msg_lspid; +unsigned int msg_lrpid;Why not use the explicit '
uint32_t' type?
linux-user/syscall.c often just uses int for 32-bit integers, and it's the same as x86_64/target_syscall.h:struct target_msgid64_ds.
Signature · 3 lines
Andreas Schwab, SUSE Labs, [email protected] GPG Key fingerprint = 0196 BAD8 1CE9 1970 F4BE 1748 E4D4 88E3 0EEA B9D7 "And now for something completely different."
Quoted 13 lines · Andreas Schwab
The
msg_lspidandmsg_lrpidmembers are of typepid_t, which is a 32-bit integer.Signed-off-by Andreas Schwab <[email protected]>--- linux-user/syscall.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-)linux-user/syscall.c +0
-0
linux-user/syscall.c struct target_msqid_ds · line 4189
Quoted 7 lines
linux-user/syscall.c +2
-2@@ -4185,8 +4185,8 @@ struct target_msqid_dsabi_ulong __msg_cbytes;abi_ulong msg_qnum;abi_ulong msg_qbytes; -abi_ulong msg_lspid; -abi_ulong msg_lrpid; +unsigned int msg_lspid; +unsigned int msg_lrpid;
This should be target_pid_t.
r~
Quoted 9 lines · Richard Henderson
Quoted 8 lines · Andreas Schwab
The
msg_lspidandmsg_lrpidmembers are of typepid_t, which is a 32-bit integer.Signed-off-by Andreas Schwab <[email protected]>---
linux-user/syscall.c| 12 ++++++------1 file changed, 6 insertions(+), 6 deletions(-)
Quoted 14 lines
linux-user/syscall.c struct target_msqid_ds · line 4189
Quoted 12 lines
linux-user/syscall.c +2
-2@@ -4185,8 +4185,8 @@ struct target_msqid_ds abi_ulong __msg_cbytes; abi_ulong msg_qnum; abi_ulong msg_qbytes; - abi_ulong msg_lspid; - abi_ulong msg_lrpid; + unsigned int msg_lspid; + unsigned int msg_lrpid;This should be
target_pid_t.
Ho hum, target_pid_t is private to elfload.c.
Since this is
include/uapi/asm-generic/posix_types.h:typedef int __kernel_ipc_pid_t; include/uapi/linux/msg.h: __kernel_ipc_pid_t msg_lspid; /* pid of last msgsnd */ include/uapi/linux/msg.h: __kernel_ipc_pid_t msg_lrpid; /* last receive pid */
I.e. not really just pid_t, then let's go ahead and use abi_int and have a comment.
r~