Root/toolchain/uClibc/patches-0.9.31/901-MIPS-restore-INLINE_SYSCALL-macro.patch

1From 911bf867eb82e28799e81578c50d82ee166cebb5 Mon Sep 17 00:00:00 2001
2From: Gabor Juhos <juhosg@openwrt.org>
3Date: Tue, 6 Apr 2010 17:25:56 +0200
4Subject: [PATCH] MIPS: restore INLINE_SYSCALL macro
5
6The MIPS specific INLINE_SYSCALL macro has been renamed to
7INLINE_SYSCALL_NCS with:
8
9  763bbf9e9a27426c9be8322dca5ddf2cb4dbc464
10
11  syscall: unify part 2: NCS variety
12
13  Declare common NCS (non-constant syscall) variants and convert the
14  existing ports over to this.
15
16This change breaks system calls. The code generated with using of the
17new macro does not obey the restartable syscall convention used by the
18linux kernel. When it tries to restart the syscall the errno value is
19not being replaced by the syscall number.
20
21This causes weird behaviour of the 'ping' command in busybox for
22example:
23
24root@OpenWrt:/# ping 192.168.1.254
25PING 192.168.1.254 (192.168.1.254): 56 data bytes
2664 bytes from 192.168.1.254: seq=0 ttl=128 time=6.292 ms
27ping: recvfrom: Function not implemented
2864 bytes from 192.168.1.254: seq=1 ttl=128 time=0.719 ms
29ping: recvfrom: Function not implemented
3064 bytes from 192.168.1.254: seq=2 ttl=128 time=0.489 ms
31ping: recvfrom: Function not implemented
3264 bytes from 192.168.1.254: seq=3 ttl=128 time=0.486 ms
33ping: recvfrom: Function not implemented
3464 bytes from 192.168.1.254: seq=4 ttl=128 time=0.487 ms
35ping: recvfrom: Function not implemented
3664 bytes from 192.168.1.254: seq=5 ttl=128 time=0.939 ms
37ping: recvfrom: Function not implemented
3864 bytes from 192.168.1.254: seq=6 ttl=128 time=0.971 ms
39ping: recvfrom: Function not implemented
4064 bytes from 192.168.1.254: seq=7 ttl=128 time=0.488 ms
41ping: recvfrom: Funct^C
42--- 192.168.1.254 ping statistics ---
439 packets transmitted, 9 packets received, 0% packet loss
44round-trip min/avg/max = 0.486/1.307/6.292 ms
45root@OpenWrt:/#
46
47Here is the relevant assembler code parts of the 'recvfrom' function:
48
49with the current INLINE_SYSCALL_NCS:
5000000000 <__GI_recvfrom>:
51  ...
52  2c: 24021050 li v0,4176
53  30: 8fd1003c lw s1,60(s8)
54  34: 8fd00038 lw s0,56(s8)
55  38: 27bdffe0 addiu sp,sp,-32
56  3c: afb00010 sw s0,16(sp)
57  40: afb10014 sw s1,20(sp) <-- wrong
58  44: 0000000c syscall
59  48: 27bd0020 addiu sp,sp,32
60  ...
61
62with the old INLINE_SYSCALL:
6300000000 <__libc_recvfrom>:
64  ...
65  28: 8fd0003c lw s0,60(s8)
66  2c: 8fc20038 lw v0,56(s8)
67  30: 27bdffe0 addiu sp,sp,-32
68  34: afa20010 sw v0,16(sp)
69  38: afb00014 sw s0,20(sp)
70  3c: 24021050 li v0,4176 <-- good
71  40: 0000000c syscall
72  44: 27bd0020 addiu sp,sp,32
73  ...
74
75Signed-off-by: Gabor Juhos <juhosg@openwrt.org>
76Cc: Mike Frysinger <vapier@gentoo.org>
77---
78Notes:
79
80The ideal solution would to fix the 'internal_syscall' macros to generate
81correct code for the NCS case as well. However the INLINE_SYSCALL macro
82generates smaller code if the syscall number is constant, so it is
83useful in such cases.
84
85Additionally, the current INLINE_SYSCALL_NCS in the 'mips/bits/syscall.h'
86is a duplicate of the one in the 'common/bits/syscalls-common.h' so it
87should be removed anyway.
88---
89 libc/sysdeps/linux/mips/bits/syscalls.h | 4 ++--
90 1 files changed, 2 insertions(+), 2 deletions(-)
91
92diff --git a/libc/sysdeps/linux/mips/bits/syscalls.h b/libc/sysdeps/linux/mips/bits/syscalls.h
93index 28b0f91..944d038 100644
94--- a/libc/sysdeps/linux/mips/bits/syscalls.h
95+++ b/libc/sysdeps/linux/mips/bits/syscalls.h
96@@ -19,9 +19,9 @@
97 
98 /* Define a macro which expands into the inline wrapper code for a system
99    call. */
100-#define INLINE_SYSCALL_NCS(name, nr, args...) \
101+#define INLINE_SYSCALL(name, nr, args...) \
102   ({ INTERNAL_SYSCALL_DECL(err); \
103- long result_var = INTERNAL_SYSCALL_NCS (name, err, nr, args); \
104+ long result_var = INTERNAL_SYSCALL(name, err, nr, args); \
105      if ( INTERNAL_SYSCALL_ERROR_P (result_var, err) ) \
106        { \
107      __set_errno (INTERNAL_SYSCALL_ERRNO (result_var, err)); \
108--
1091.5.3.2
110
111

Archive Download this file



interactive