Skip to contentSkip to conversation

mips-user socket-related syscall support

PATCH In review Raphaël Rigo 3 participants 8 messages Jun 19, 2006 – Jun 24, 2006

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 mips-user socket-related syscall support

Hello,
this patch is a revamped version of the one I posted about 2 months ago, it is much better. It implements the syscalls related to sockets on the MIPS platform (because it has no "socketcall" syscall). I had to create a "socket.h" file defining the constants for the targets because MIPS doesn't have the same as every other platform.

The calls implemented are : accept, bind, connect, getpeername, getsockname, listen, recv, recvfrom, recvmsg, send, sendmsg, sendto, shutdown, socket, socketpair.

Combined with the other patch I just posted (signal handling), qemu-mips is now capable of running a webserver (which is very nice :)

Please consider it for inclusion into mainline.

Raphaël Rigo

? linux-user/sh4/socket.h
Index: linux-user/qemu.h
===================================================================
RCS file: /sources/qemu/qemu/linux-user/qemu.h,v
retrieving revision 1.28

qemu.h +1 -0
diff -u -r1.28 qemu.h
@@ -6,6 +6,7 @@
 #include <signal.h>
 #include <string.h>
 #include "syscall_defs.h"
+#include "socket.h"
 
 #include "cpu.h"
 #include "syscall.h"

Index: linux-user/syscall.c
===================================================================
RCS file: /sources/qemu/qemu/linux-user/syscall.c,v retrieving revision 1.72

syscall.c +198 -32

281 lines not on this page · raw message

Index: linux-user/arm/socket.h
===================================================================
RCS file: linux-user/arm/socket.h

arm/socket.h new file +45 -0

45 lines not on this page · raw message

Index: linux-user/i386/socket.h
===================================================================
RCS file: linux-user/i386/socket.h

i386/socket.h new file +45 -0

45 lines not on this page · raw message

Index: linux-user/mips/socket.h
===================================================================
RCS file: linux-user/mips/socket.h

mips/socket.h new file +87 -0

87 lines not on this page · raw message

Index: linux-user/ppc/socket.h
===================================================================
RCS file: linux-user/ppc/socket.h

ppc/socket.h new file +45 -0

45 lines not on this page · raw message

Index: linux-user/sparc/socket.h
===================================================================
RCS file: linux-user/sparc/socket.h

sparc/socket.h new file +49 -0

49 lines not on this page · raw message

Index: linux-user/sparc64/socket.h
===================================================================
RCS file: linux-user/sparc64/socket.h

sparc64/socket.h new file +49 -0

49 lines not on this page · raw message

#1 lore raw

Hi,

Is it really needed to duplicate socket.h ? What are the differences for mips ?

Regards,

Fabrice.

Quoted 17 lines · Raphaël Rigo

Hello,
this patch is a revamped version of the one I posted about 2 months ago, it is much better. It implements the syscalls related to sockets on the MIPS platform (because it has no "socketcall" syscall). I had to create a "socket.h" file defining the constants for the targets because MIPS doesn't have the same as every other platform.

The calls implemented are : accept, bind, connect, getpeername, getsockname, listen, recv, recvfrom, recvmsg, send, sendmsg, sendto, shutdown, socket, socketpair.

Combined with the other patch I just posted (signal handling), qemu-mips is now capable of running a webserver (which is very nice :)

Please consider it for inclusion into mainline.

Raphaël Rigo

#2 lore raw
Quoted 9 lines · Fabrice Bellard

Hi,

Is it really needed to duplicate socket.h ? What are the differences for mips ?

Regards,

Fabrice.

Hi,
almost all socket related constants are different on MIPS. I thought it would be
cleaner to define all constants for each target, so that if we add support for another platform with different constants, it will be easy.

Raphaël

#3 lore raw
Quoted 6 lines · Raphaël Rigo
Quoted 5 lines · Fabrice Bellard

Hi,

Is it really needed to duplicate socket.h ? What are the differences for mips ?

Quoted 8 lines
Quoted 4 lines

Regards,

Fabrice.

Hi,
almost all socket related constants are different on MIPS. I thought it would be
cleaner to define all constants for each target, so that if we add support for another platform with different constants, it will be easy.

Historically Linux/MIPS followed MIPS Inc.'s RiscOS numbering scheme, this explains most of the seemingly deliberate deviations from i386.

Thiemo

#4 lore raw
In reply to Raphaël Rigo

Another point is that doing:

+ target_long args[6];
+

+    tputl(args, arg1);
+    tputl(args+1, arg2);
+    tputl(args+2, arg3);
+    tputl(args+3, arg4);
+    tputl(args+4, arg5);
+    tputl(args+5, arg6);

at the start of every syscall is not acceptable. You should add a specific socket call wrapper which takes arg1... arg6 as arguments.

Regards,

Fabrice.

Quoted 17 lines · Raphaël Rigo

Hello,
this patch is a revamped version of the one I posted about 2 months ago, it is much better. It implements the syscalls related to sockets on the MIPS platform (because it has no "socketcall" syscall). I had to create a "socket.h" file defining the constants for the targets because MIPS doesn't have the same as every other platform.

The calls implemented are : accept, bind, connect, getpeername, getsockname, listen, recv, recvfrom, recvmsg, send, sendmsg, sendto, shutdown, socket, socketpair.

Combined with the other patch I just posted (signal handling), qemu-mips is now capable of running a webserver (which is very nice :)

Please consider it for inclusion into mainline.

Raphaël Rigo

#5 lore raw
Quoted 11 lines · Fabrice Bellard

Another point is that doing:

(quoted diff) +8 -0
+    target_long args[6];
+
+    tputl(args, arg1);
+    tputl(args+1, arg2);
+    tputl(args+2, arg3);
+    tputl(args+3, arg4);
+    tputl(args+4, arg5);
+    tputl(args+5, arg6);
Quoted 5 lines

at the start of every syscall is not acceptable. You should add a specific socket call wrapper which takes arg1... arg6 as arguments.

Regards,

Fabrice.

Thanks for reviewing it, the new attached version should be much cleaner.

Regards,
Raphaël

Index: linux-user/qemu.h
===================================================================
RCS file: /sources/qemu/qemu/linux-user/qemu.h,v
retrieving revision 1.28

qemu.h +1 -0
diff -u -r1.28 qemu.h
@@ -6,6 +6,7 @@
 #include <signal.h>
 #include <string.h>
 #include "syscall_defs.h"
+#include "socket.h"
 
 #include "cpu.h"
 #include "syscall.h"

Index: linux-user/socket.h
===================================================================
RCS file: linux-user/socket.h

socket.h new file +138 -0

138 lines not on this page · raw message

Index: linux-user/syscall.c
===================================================================
RCS file: /sources/qemu/qemu/linux-user/syscall.c,v retrieving revision 1.72

syscall.c +205 -32

288 lines not on this page · raw message

#6 lore raw
Quoted 15 lines · Raphaël Rigo
Quoted 14 lines · Fabrice Bellard

Another point is that doing:

syscall.c +8 -0
+    target_long args[6];
+
+    tputl(args, arg1);
+    tputl(args+1, arg2);
+    tputl(args+2, arg3);
+    tputl(args+3, arg4);
+    tputl(args+4, arg5);
+    tputl(args+5, arg6);

at the start of every syscall is not acceptable. You should add a specific socket call wrapper which takes arg1... arg6 as arguments.

Quoted 7 lines
Quoted 3 lines

Regards,

Fabrice.

Thanks for reviewing it, the new attached version should be much cleaner.

Regards,
Raphaël

Sorry to insist, but can you please include it in the CVS? I really think it's useful.

Thanks,
Raphaël

#7 lore raw
Quoted 22 lines · Raphaël Rigo
Quoted 20 lines · Raphaël Rigo
Quoted 17 lines · Fabrice Bellard

Another point is that doing:

syscall.c +8 -0
+    target_long args[6];
+
+    tputl(args, arg1);
+    tputl(args+1, arg2);
+    tputl(args+2, arg3);
+    tputl(args+3, arg4);
+    tputl(args+4, arg5);
+    tputl(args+5, arg6);

at the start of every syscall is not acceptable. You should add a specific socket call wrapper which takes arg1... arg6 as arguments.

Regards,

Fabrice.

Quoted 7 lines
Quoted 4 lines

Thanks for reviewing it, the new attached version should be much cleaner.

Regards,
Raphaël

Sorry to insist, but can you please include it in the CVS? I really think it's useful.

I applied it and added "getsockopt". In fact, you should completely suppress do_socketcallwrapper() (using tputl and tgetl for non user access is bad).

Regards,

Fabrice.