fix for s390 syscalls > 256

Michael Holzheu HOLZHEU at de.ibm.com
Mon Jun 16 10:46:03 UTC 2003


Hi all,

In Linux 2.2 and 2.4 (s390/s390x) we passed the syscall number encoded in
the svc opcode. With this mechanism it was possible to handle up to 256
syscalls. For Linux 2.5 we changed this handling, since there are now more
than 256 syscalls. Now the svc number is passed in a register (PT_GPR2).
Before PT_GPR2 has always been set to -ENOSYS.

Therefore we can distinguish the two mechanisms by checking PT_GPR2 for
-ENOSYS:

if (GPR2 != -ENOSYS)
      svcnr = GPR2 (new)
else
      svcnr = get from opcode (old)


There is a bug in get_scno() which makes strace always take the old
mechanism.
Here is a patch which should fix this problem:


diff -Naur strace-4.4.98/syscall.c strace-4.4.98-s390-svcreg2/syscall.c
--- strace-4.4.98/syscall.c     2003-06-04 01:29:04.000000000 +0200
+++ strace-4.4.98-s390-svcreg2/syscall.c        2003-06-16
19:16:03.898418364 +0200
@@ -734,14 +734,6 @@

 #ifdef LINUX
 #if defined(S390) || defined(S390X)
-       if (upeek(pid, PT_GPR2, &syscall_mode) < 0)
-               return -1;
-       if (syscall_mode != -ENOSYS) {
-               /*
-                * Since kernel version 2.5.44 the scno gets passed in
gpr2.
-                */
-               scno = syscall_mode;
-       }
        if (tcp->flags & TCB_WAITEXECVE) {
                /*
                 * When the execve system call completes successfully, the
@@ -761,7 +753,16 @@
                tcp->flags &= ~TCB_WAITEXECVE;
                return 0;
        }
-       else {
+
+       if (upeek(pid, PT_GPR2, &syscall_mode) < 0)
+                       return -1;
+
+       if (syscall_mode != -ENOSYS) {
+               /*
+                * Since kernel version 2.5.44 the scno gets passed in
gpr2.
+                */
+               scno = syscall_mode;
+       } else {
                /*
                 * Old style of "passing" the scno via the SVC instruction.
                 */


(See attached file: strace-4.4.98-s390-svcreg2.diff)

Regards

       Michael

------------------------------------------------------------------------
Linux for E-Server Development
Phone: +49-7031-16-2360,  Bld 71032-03-U09
Email: holzheu at de.ibm.com
-------------- next part --------------
A non-text attachment was scrubbed...
Name: strace-4.4.98-s390-svcreg2.diff
Type: application/octet-stream
Size: 965 bytes
Desc: not available
URL: <http://lists.strace.io/pipermail/strace-devel/attachments/20030616/099ad203/attachment.obj>


More information about the Strace-devel mailing list