qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH] linux-user: correct how SOL_SOCKET is converted from target to host and back
@ 2013-09-13 17:27 Petar Jovanovic
  2013-09-13 17:36 ` Peter Maydell
  0 siblings, 1 reply; 3+ messages in thread
From: Petar Jovanovic @ 2013-09-13 17:27 UTC (permalink / raw)
  To: qemu-devel; +Cc: riku.voipio, petar.jovanovic, aurelien

From: Petar Jovanovic <petar.jovanovic@imgtec.com>

Previous implementation does not take into account that SOL_SOCKET constant
can be arch specific. This change fixes some issues with sendmsg/recvmsg.

Signed-off-by: Petar Jovanovic <petar.jovanovic@imgtec.com>
---
 linux-user/syscall.c |   18 +++++++++++++-----
 1 file changed, 13 insertions(+), 5 deletions(-)

diff --git a/linux-user/syscall.c b/linux-user/syscall.c
index c62d875..c4c26d6 100644
--- a/linux-user/syscall.c
+++ b/linux-user/syscall.c
@@ -1149,11 +1149,15 @@ static inline abi_long target_to_host_cmsg(struct msghdr *msgh,
             break;
         }
 
-        cmsg->cmsg_level = tswap32(target_cmsg->cmsg_level);
+        if (tswap32(target_cmsg->cmsg_level) == TARGET_SOL_SOCKET) {
+            cmsg->cmsg_level = SOL_SOCKET;
+        } else {
+            cmsg->cmsg_level = tswap32(target_cmsg->cmsg_level);
+        }
         cmsg->cmsg_type = tswap32(target_cmsg->cmsg_type);
         cmsg->cmsg_len = CMSG_LEN(len);
 
-        if (cmsg->cmsg_level != TARGET_SOL_SOCKET || cmsg->cmsg_type != SCM_RIGHTS) {
+        if (cmsg->cmsg_level != SOL_SOCKET || cmsg->cmsg_type != SCM_RIGHTS) {
             gemu_log("Unsupported ancillary data: %d/%d\n", cmsg->cmsg_level, cmsg->cmsg_type);
             memcpy(data, target_data, len);
         } else {
@@ -1204,11 +1208,15 @@ static inline abi_long host_to_target_cmsg(struct target_msghdr *target_msgh,
             break;
         }
 
-        target_cmsg->cmsg_level = tswap32(cmsg->cmsg_level);
+        if (cmsg->cmsg_level == SOL_SOCKET) {
+            target_cmsg->cmsg_level = tswap32(TARGET_SOL_SOCKET);
+        } else {
+            target_cmsg->cmsg_level = tswap32(cmsg->cmsg_level);
+        }
         target_cmsg->cmsg_type = tswap32(cmsg->cmsg_type);
         target_cmsg->cmsg_len = tswapal(TARGET_CMSG_LEN(len));
 
-        if ((cmsg->cmsg_level == TARGET_SOL_SOCKET) &&
+        if ((cmsg->cmsg_level == SOL_SOCKET) &&
                                 (cmsg->cmsg_type == SCM_RIGHTS)) {
             int *fd = (int *)data;
             int *target_fd = (int *)target_data;
@@ -1216,7 +1224,7 @@ static inline abi_long host_to_target_cmsg(struct target_msghdr *target_msgh,
 
             for (i = 0; i < numfds; i++)
                 target_fd[i] = tswap32(fd[i]);
-        } else if ((cmsg->cmsg_level == TARGET_SOL_SOCKET) &&
+        } else if ((cmsg->cmsg_level == SOL_SOCKET) &&
                                 (cmsg->cmsg_type == SO_TIMESTAMP) &&
                                 (len == sizeof(struct timeval))) {
             /* copy struct timeval to target */
-- 
1.7.9.5

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [Qemu-devel] [PATCH] linux-user: correct how SOL_SOCKET is converted from target to host and back
  2013-09-13 17:27 [Qemu-devel] [PATCH] linux-user: correct how SOL_SOCKET is converted from target to host and back Petar Jovanovic
@ 2013-09-13 17:36 ` Peter Maydell
  2013-09-21  0:11   ` Petar Jovanovic
  0 siblings, 1 reply; 3+ messages in thread
From: Peter Maydell @ 2013-09-13 17:36 UTC (permalink / raw)
  To: Petar Jovanovic
  Cc: Riku Voipio, QEMU Developers, Aurelien Jarno, Petar Jovanovic

On 13 September 2013 18:27, Petar Jovanovic <petar.jovanovic@rt-rk.com> wrote:
> From: Petar Jovanovic <petar.jovanovic@imgtec.com>
>
> Previous implementation does not take into account that SOL_SOCKET constant
> can be arch specific. This change fixes some issues with sendmsg/recvmsg.
>
> Signed-off-by: Petar Jovanovic <petar.jovanovic@imgtec.com>

Reviewed-by: Peter Maydell <peter.maydell@linaro.org>

-- PMM

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [Qemu-devel] [PATCH] linux-user: correct how SOL_SOCKET is converted from target to host and back
  2013-09-13 17:36 ` Peter Maydell
@ 2013-09-21  0:11   ` Petar Jovanovic
  0 siblings, 0 replies; 3+ messages in thread
From: Petar Jovanovic @ 2013-09-21  0:11 UTC (permalink / raw)
  To: Peter Maydell, Petar Jovanovic
  Cc: Riku Voipio, QEMU Developers, Aurelien Jarno

ping
http://patchwork.ozlabs.org/patch/274816/

________________________________________
From: Peter Maydell [peter.maydell@linaro.org]
Sent: Friday, September 13, 2013 7:36 PM
To: Petar Jovanovic
Cc: QEMU Developers; Riku Voipio; Petar Jovanovic; Aurelien Jarno
Subject: Re: [Qemu-devel] [PATCH] linux-user: correct how SOL_SOCKET is converted from target to host and back

On 13 September 2013 18:27, Petar Jovanovic <petar.jovanovic@rt-rk.com> wrote:
> From: Petar Jovanovic <petar.jovanovic@imgtec.com>
>
> Previous implementation does not take into account that SOL_SOCKET constant
> can be arch specific. This change fixes some issues with sendmsg/recvmsg.
>
> Signed-off-by: Petar Jovanovic <petar.jovanovic@imgtec.com>

Reviewed-by: Peter Maydell <peter.maydell@linaro.org>

-- PMM

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2013-09-21  0:13 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-09-13 17:27 [Qemu-devel] [PATCH] linux-user: correct how SOL_SOCKET is converted from target to host and back Petar Jovanovic
2013-09-13 17:36 ` Peter Maydell
2013-09-21  0:11   ` Petar Jovanovic

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).