Skip to contentSkip to conversation

Fix networking for s390x-user

PATCH Applied [email protected] 3 participants 8 messages Jan 11, 2014 – Jan 15, 2014

lore
Share & tools
lore
#0 lore raw

cover Fix networking for s390x-user

Pavel Zbitskiy (3):
linux-user: fixed s390x clone() argument order
linux-user: fixed getsockopt() optlen
linux-user: fixed recvfrom() addrlen

 linux-user/s390x/syscall.h | 2 +-
 linux-user/syscall.c       | 4 ++--
 2 files changed, 3 insertions(+), 3 deletions(-)
#1 lore raw

PATCH 1/3 linux-user: fixed s390x clone() argument order

From: Pavel Zbitskiy <[email protected]>

It was broken by 4ce6243dc6216e35b5b691078ffa856463bfa8db, where TARGET_CLONE_BACKWARDS was specified instead of TARGET_CLONE_BACKWARDS2.

---
 linux-user/s390x/syscall.h |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
linux-user/s390x/syscall.h +1 -1
index ea8c304..e5ce30b 100644
@@ -22,4 +22,4 @@ struct target_pt_regs {
 
 #define UNAME_MACHINE "s390x"
 
-#define TARGET_CLONE_BACKWARDS
+#define TARGET_CLONE_BACKWARDS2
Signature · 1 line
1.7.10.4
Reviewed-by on v1 1/3
#2 lore raw

Re: [Qemu-devel] [PATCH 1/3] linux-user: fixed s390x clone() argument order

Quoted 16 lines · On 11 January 2014 09:34, <[email protected]> wrote:

From: Pavel Zbitskiy <[email protected]>

It was broken by 4ce6243dc6216e35b5b691078ffa856463bfa8db, where TARGET_CLONE_BACKWARDS was specified instead of TARGET_CLONE_BACKWARDS2.

---
 linux-user/s390x/syscall.h |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
linux-user/s390x/syscall.h +0 -0
index ea8c304..e5ce30b 100644

linux-user/s390x/syscall.h struct target_pt_regs { · line 25

Quoted 5 lines
linux-user/s390x/syscall.h +1 -1
@@ -22,4 +22,4 @@ struct target_pt_regs {
 
 #define UNAME_MACHINE "s390x"
 
-#define TARGET_CLONE_BACKWARDS
+#define TARGET_CLONE_BACKWARDS2

Yep, kernel config agrees:
http://lxr.free-electrons.com/source/arch/s390/Kconfig#L99

thanks
-- PMM

#3 lore raw

PATCH 2/3 linux-user: fixed getsockopt() optlen

In reply to [email protected]

From: Pavel Zbitskiy <[email protected]>

optlen parameter of getsockopt() of type socklen_t* was read into variable of type socklen_t, that caused zeroing out of upper 4 bytes when running s390x on top of x86_64. This patch changes optlen type to abi_ulong.

---
 linux-user/syscall.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
linux-user/syscall.c +1 -1
index 4a14a43..c2cd2b4 100644
@@ -2389,7 +2389,7 @@ static abi_long do_socketcall(int num, abi_ulong vptr)
             abi_ulong level;
             abi_ulong optname;
             abi_ulong optval;
-            socklen_t optlen;
+            abi_ulong optlen;
 
             if (get_user_ual(sockfd, vptr)
                 || get_user_ual(level, vptr + n)
Signature · 1 line
1.7.10.4
#4 lore raw

Re: [Qemu-devel] [PATCH 2/3] linux-user: fixed getsockopt() optlen

Quoted 6 lines · On 11 January 2014 09:34, <[email protected]> wrote:

From: Pavel Zbitskiy <[email protected]>

optlen parameter of getsockopt() of type socklen_t* was read into variable of type socklen_t, that caused zeroing out of upper 4 bytes when running s390x on top of x86_64. This patch changes optlen type to abi_ulong.

This patch and patch 3 are correct fixes, but shouldn't we be more generally using abi_ulong for every argument we read from the guest in do_socketcall() ?

It might be nicer to fix this by having a lookup table of SOCKOP_* to number-of-arguments, and then hoist the get_user_ual() calls outside the switch() statement to fill in an 'abi_ulong args[]' array. Then the individual calls in the switch would just look like

    do_socket(args[0], args[1], args[2]);

thanks
-- PMM

#5 lore raw

Re: [Qemu-devel] [Qemu-trivial] [PATCH 2/3] linux-user: fixed getsockopt() optlen

Quoted 11 lines · Peter Maydell
Quoted 6 lines · On 11 January 2014 09:34, <[email protected]> wrote:

From: Pavel Zbitskiy <[email protected]>

optlen parameter of getsockopt() of type socklen_t* was read into variable of type socklen_t, that caused zeroing out of upper 4 bytes when running s390x on top of x86_64. This patch changes optlen type to abi_ulong.

This patch and patch 3 are correct fixes, but shouldn't we be more generally using abi_ulong for every argument we read from the guest in do_socketcall() ?

I think the current fix is worth to apply anyway, regareless of further possible rework.

Thanks,

/mjt

#6 lore raw

PATCH 3/3 linux-user: fixed recvfrom() addrlen

In reply to [email protected]

From: Pavel Zbitskiy <[email protected]>

addrlen parameter of recvfrom() of type socklen_t* was read into variable of type socklen_t, that caused zeroing out of upper 4 bytes when running s390x on top of x86_64. This patch changes addrlen type to abi_ulong.

---
 linux-user/syscall.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
linux-user/syscall.c +1 -1
index c2cd2b4..43f54ca 100644
@@ -2325,7 +2325,7 @@ static abi_long do_socketcall(int num, abi_ulong vptr)
             size_t len;
             abi_ulong flags;
             abi_ulong addr;
-            socklen_t addrlen;
+            abi_ulong addrlen;
 
             if (get_user_ual(sockfd, vptr)
                 || get_user_ual(msg, vptr + n)
Signature · 1 line
1.7.10.4