i386: remove special handling of socketcall
authorH. Peter Anvin <hpa@linux.intel.com>
Wed, 6 Jan 2016 00:43:50 +0000 (16:43 -0800)
committerBen Hutchings <ben@decadent.org.uk>
Thu, 19 Jul 2018 00:13:54 +0000 (01:13 +0100)
As of kernel 4.3, i386 now has direct system calls for sockets, so
drop the special handling for i386 socketcall.  If built on older
kernels, it will still generate socketcall stubs although they will be
less efficient.

Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
[bwh: Backported to 2.0.4: adjust context]

Gbp-Pq: Name klibc-i386-remove-special-handling-of-socketcall.patch

usr/klibc/arch/i386/Kbuild
usr/klibc/arch/i386/socketcall.S [deleted file]
usr/klibc/socketcalls.pl

index 16423742919c130355fe441060fc7b38689a2875..f1b5ad2746199656366ae032ed2b986b6bdd2c07 100644 (file)
@@ -2,7 +2,7 @@
 # klibc .o files for i386
 #
 
-klib-y := archinit.o socketcall.o setjmp.o syscall.o varsyscall.o
+klib-y := archinit.o setjmp.o syscall.o varsyscall.o
 klib-y += open.o openat.o vfork.o
 klib-y += libgcc/__ashldi3.o libgcc/__ashrdi3.o libgcc/__lshrdi3.o
 klib-y += libgcc/__muldi3.o  libgcc/__negdi2.o
diff --git a/usr/klibc/arch/i386/socketcall.S b/usr/klibc/arch/i386/socketcall.S
deleted file mode 100644 (file)
index 44e2004..0000000
+++ /dev/null
@@ -1,55 +0,0 @@
-#
-# socketcall.S
-#
-# Socketcalls use the following convention:
-# %eax = __NR_socketcall
-# %ebx = socketcall number
-# %ecx = pointer to arguments (up to 6)
-#
-
-#include <asm/unistd.h>
-
-#ifdef __i386__
-
-       .text
-       .align 4
-       .globl __socketcall_common
-       .type __socketcall_common, @function
-
-__socketcall_common:
-       xchgl   %ebx,(%esp)     # The stub passes the socketcall # on stack
-
-#ifdef _REGPARM
-       pushl   16(%esp)        # Arg 6
-       pushl   16(%esp)        # Arg 5
-       pushl   16(%esp)        # Arg 4
-       pushl   %ecx
-       pushl   %edx
-       pushl   %eax
-       movl    %esp,%ecx
-#else
-       leal    8(%esp),%ecx    # Arguments already contiguous on-stack
-#endif
-
-       movl    $__NR_socketcall,%eax
-       call    *__syscall_entry
-
-#ifdef _REGPARM
-       addl    $6*4, %esp
-#endif
-
-       cmpl    $-4095,%eax     # Error return?
-
-       popl    %ebx
-
-       jb      1f
-
-       negl    %eax
-       movl    %eax,errno
-       orl     $-1,%eax        # Return -1
-1:
-       ret
-
-       .size __socketcall_common,.-__socketcall_common
-
-#endif
index 3dac096a99033b86ce2ba56974de6d81f9df4531..9df5949417a723a463d84c9cd113307fc27f697b 100644 (file)
@@ -42,44 +42,27 @@ while ( defined($line = <FILE>) ) {
        $nargs = $i;
        print " \\\n\t${name}.o";
 
-       if ( $arch eq 'i386' ) {
-           open(OUT, "> ${outputdir}/${name}.S")
-               or die "$0: Cannot open ${outputdir}/${name}.S\n";
+       open(OUT, "> ${outputdir}/${name}.c")
+           or die "$0: Cannot open ${outputdir}/${name}.c\n";
 
-           print OUT "#include <sys/socketcalls.h>\n";
-           print OUT "\n";
-           print OUT "\t.text\n";
-           print OUT "\t.align 4\n";
-           print OUT "\t.globl ${name}\n";
-           print OUT "\t.type  ${name},\@function\n";
-           print OUT "${name}:\n";
-           print OUT "\tpushl  \$SYS_\U${name}\n";
-           print OUT "\tjmp    __socketcall_common\n";
-           print OUT "\t.size ${name},.-${name}\n";
-           close(OUT);
-       } else {
-           open(OUT, "> ${outputdir}/${name}.c")
-               or die "$0: Cannot open ${outputdir}/${name}.c\n";
-
-           print OUT "#include \"socketcommon.h\"\n";
-           print OUT "\n";
-           print OUT "#if _KLIBC_SYS_SOCKETCALL || !defined(__NR_${name})\n\n";
+       print OUT "#include \"socketcommon.h\"\n";
+       print OUT "\n";
+       print OUT "#if _KLIBC_SYS_SOCKETCALL || !defined(__NR_${name})\n\n";
 
-           print OUT "extern long __socketcall(int, const unsigned long *);\n\n";
+       print OUT "extern long __socketcall(int, const unsigned long *);\n\n";
 
-           print OUT "$type $name (", join(', ', @cargs), ")\n";
-           print OUT "{\n";
-           print OUT "    unsigned long args[$nargs];\n";
-           for ( $i = 0 ; $i < $nargs ; $i++ ) {
-               print OUT "    args[$i] = (unsigned long)a$i;\n";
-           }
-           print OUT "    return ($type) __socketcall(SYS_\U${name}\E, args);\n";
-           print OUT "}\n\n";
+       print OUT "$type $name (", join(', ', @cargs), ")\n";
+       print OUT "{\n";
+       print OUT "    unsigned long args[$nargs];\n";
+       for ( $i = 0 ; $i < $nargs ; $i++ ) {
+           print OUT "    args[$i] = (unsigned long)a$i;\n";
+       }
+       print OUT "    return ($type) __socketcall(SYS_\U${name}\E, args);\n";
+       print OUT "}\n\n";
 
-           print OUT "#endif\n";
+       print OUT "#endif\n";
 
-           close(OUT);
-       }
+       close(OUT);
     } else {
        die "$file:$.: Could not parse input\n";
     }