From patchwork Tue Oct 13 10:48:25 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Liebler X-Patchwork-Id: 529680 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 96E0A140213 for ; Tue, 13 Oct 2015 21:48:58 +1100 (AEDT) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; secure) header.d=sourceware.org header.i=@sourceware.org header.b=HwWKWkdk; dkim-atps=neutral DomainKey-Signature: a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:to:from:subject:date:message-id:mime-version :content-type; q=dns; s=default; b=hWM5yoqk8ZMbbEVqCWHlwMwFAytSq RGqn0mqqOoq5sMctI1SlDP1mskluEsjgXK0X1KY7b572cuxkERCFmM3FJC3N03+T xp633CyCOBIKUKDJ4o/9dZ11EZbykQU5rTIGp5E//TrmEXo2fskq6M9n978NH671 CqsUGi5xql1C6Q= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:to:from:subject:date:message-id:mime-version :content-type; s=default; bh=m8XnMjFMxTqCiYZFf5rqK+TR37Q=; b=HwW KWkdkl7wKgRGMIQXRMtlCiLbn5ZaNa0d1bpNX1NGZQvcPdZvlUP3yqhcTuqg3pWW t66gh9QYGT8CCaVhQFCs8VQq41ai4L5YSOLK0ro4Fcki8NN/BG3B8A7Vu/UM7yRP WInqDscyfFIRB6iqog6AvIp+nWpcR44iw9RD69EA= Received: (qmail 19337 invoked by alias); 13 Oct 2015 10:48:53 -0000 Mailing-List: contact libc-alpha-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: libc-alpha-owner@sourceware.org Delivered-To: mailing list libc-alpha@sourceware.org Received: (qmail 19326 invoked by uid 89); 13 Oct 2015 10:48:52 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.6 required=5.0 tests=AWL, BAYES_40, RCVD_IN_DNSWL_LOW, SPF_HELO_PASS, SPF_PASS, T_RP_MATCHES_RCVD autolearn=ham version=3.3.2 X-HELO: plane.gmane.org To: libc-alpha@sourceware.org From: Stefan Liebler Subject: [PATCH] S390: Call direct system calls for socket operations. Date: Tue, 13 Oct 2015 12:48:25 +0200 Lines: 185 Message-ID: Mime-Version: 1.0 X-Mozilla-News-Host: news://news.gmane.org:119 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.3.0 Hi, this patch calls direct system calls for socket operations in the same way as power does. The system calls were introduced in kernel commit https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/commit/?id=977108f89c989b1eeb5c8d938e1e71913391eb5f. There are no direct recv, send, accept syscalls available on s390. Thus recvfrom, sendto, accept4 are called instead of the socketcall. See recv.c, send.c, accept.c in sysdeps/unix/sysv/linux/s390 folder. The socketcalls in syscalls.list for s390-64 are removed. They were never used on s390x. Bye Stefan --- 2015-10-13 Stefan Liebler * sysdeps/unix/sysv/linux/s390/kernel-features.h: (__ASSUME_*_SYSCALL) Define new macros. * sysdeps/unix/sysv/linux/s390/s390-64/syscalls.list: Remove socketcall syscalls. * sysdeps/unix/sysv/linux/s390/accept.c: New File. * sysdeps/unix/sysv/linux/s390/recv.c: Likewise. * sysdeps/unix/sysv/linux/s390/send.c: Likewise. diff --git a/sysdeps/unix/sysv/linux/s390/accept.c b/sysdeps/unix/sysv/linux/s390/accept.c new file mode 100644 index 0000000..c491690 --- /dev/null +++ b/sysdeps/unix/sysv/linux/s390/accept.c @@ -0,0 +1,40 @@ +/* Copyright (C) 2015 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + . */ + +#include +#include +#include + +#include +#include +#include +#include + +int +__libc_accept (int fd, __SOCKADDR_ARG addr, socklen_t *len) +{ +#ifdef __ASSUME_ACCEPT4_SYSCALL + /* There does not exist a direct accept syscall on s390, thus accept4 is used. + The kernel also wraps this syscall with additional 0 parameters if called + via socketcall. */ + return SYSCALL_CANCEL (accept4, fd, addr.__sockaddr__, len, 0); +#else + return SOCKETCALL_CANCEL (accept, fd, addr.__sockaddr__, len); +#endif +} +weak_alias (__libc_accept, accept) +libc_hidden_def (accept) diff --git a/sysdeps/unix/sysv/linux/s390/kernel-features.h b/sysdeps/unix/sysv/linux/s390/kernel-features.h index 96f73ef..899421f 100644 --- a/sysdeps/unix/sysv/linux/s390/kernel-features.h +++ b/sysdeps/unix/sysv/linux/s390/kernel-features.h @@ -20,4 +20,29 @@ /* S/390 uses socketcall. */ #define __ASSUME_SOCKETCALL 1 +/* Direct socketcalls available with kernel 4.3. */ +#if __LINUX_KERNEL_VERSION >= 0x040300 +# define __ASSUME_RECVMMSG_SYSCALL 1 +# define __ASSUME_SENDMMSG_SYSCALL 1 +# define __ASSUME_SOCKET_SYSCALL 1 +# define __ASSUME_SOCKETPAIR_SYSCALL 1 +# define __ASSUME_BIND_SYSCALL 1 +# define __ASSUME_CONNECT_SYSCALL 1 +# define __ASSUME_LISTEN_SYSCALL 1 +# define __ASSUME_ACCEPT4_SYSCALL 1 +# define __ASSUME_GETSOCKOPT_SYSCALL 1 +# define __ASSUME_SETSOCKOPT_SYSCALL 1 +# define __ASSUME_GETSOCKNAME_SYSCALL 1 +# define __ASSUME_GETPEERNAME_SYSCALL 1 +# define __ASSUME_SENDTO_SYSCALL 1 +# define __ASSUME_SENDMSG_SYSCALL 1 +# define __ASSUME_RECVFROM_SYSCALL 1 +# define __ASSUME_RECVMSG_SYSCALL 1 +# define __ASSUME_SHUTDOWN_SYSCALL 1 + +/* There are no direct recv, send, accept syscalls available on s390. Thus + recvfrom, sendto, accept4 are called if available instead of the socketcall. + See recv.c, send.c, accept.c in sysdeps/unix/sysv/linux/s390 folder. */ +#endif + #include_next diff --git a/sysdeps/unix/sysv/linux/s390/recv.c b/sysdeps/unix/sysv/linux/s390/recv.c new file mode 100644 index 0000000..9c841fb --- /dev/null +++ b/sysdeps/unix/sysv/linux/s390/recv.c @@ -0,0 +1,41 @@ +/* Copyright (C) 2015 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + . */ + +#include +#include +#include + +#include +#include +#include +#include + +ssize_t +__libc_recv (int fd, void *buf, size_t len, int flags) +{ +#ifdef __ASSUME_RECVFROM_SYSCALL + /* There does not exist a direct recv syscall on s390, thus recvfrom is used. + The kernel also wraps this syscall with additional 0 parameters if called + via socketcall. */ + return SYSCALL_CANCEL (recvfrom, fd, buf, len, flags, NULL, NULL); +#else + return SOCKETCALL_CANCEL (recv, fd, buf, len, flags); +#endif +} +weak_alias (__libc_recv, recv) +weak_alias (__libc_recv, __recv) +libc_hidden_weak (__recv) diff --git a/sysdeps/unix/sysv/linux/s390/s390-64/syscalls.list b/sysdeps/unix/sysv/linux/s390/s390-64/syscalls.list index 5b8c102..9f03d26 100644 --- a/sysdeps/unix/sysv/linux/s390/s390-64/syscalls.list +++ b/sysdeps/unix/sysv/linux/s390/s390-64/syscalls.list @@ -12,22 +12,3 @@ shmget - shmget i:iii __shmget shmget semop - semop i:ipi __semop semop semget - semget i:iii __semget semget semctl - semctl i:iiii __semctl semctl - -# proper socket implementations: -accept - accept Ci:iBN __libc_accept __accept accept -bind - bind i:ipi __bind bind -connect - connect Ci:ipi __libc_connect __connect connect -getpeername - getpeername i:ipp __getpeername getpeername -getsockname - getsockname i:ipp __getsockname getsockname -getsockopt - getsockopt i:iiiBN __getsockopt getsockopt -listen - listen i:ii __listen listen -recv - recv Ci:ibni __libc_recv __recv recv -recvfrom - recvfrom Ci:ibniBN __libc_recvfrom __recvfrom recvfrom -recvmsg - recvmsg Ci:ipi __libc_recvmsg __recvmsg recvmsg -send - send Ci:ibni __libc_send __send send -sendmsg - sendmsg Ci:ipi __libc_sendmsg __sendmsg sendmsg -sendto - sendto Ci:ibnibn __libc_sendto __sendto sendto -setsockopt - setsockopt i:iiibn __setsockopt setsockopt -shutdown - shutdown i:ii __shutdown shutdown -socket - socket i:iii __socket socket -socketpair - socketpair i:iiif __socketpair socketpair diff --git a/sysdeps/unix/sysv/linux/s390/send.c b/sysdeps/unix/sysv/linux/s390/send.c new file mode 100644 index 0000000..e4a695b --- /dev/null +++ b/sysdeps/unix/sysv/linux/s390/send.c @@ -0,0 +1,41 @@ +/* Copyright (C) 2015 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + . */ + +#include +#include +#include + +#include +#include +#include +#include + +ssize_t +__libc_send (int fd, const void *buf, size_t len, int flags) +{ +#ifdef __ASSUME_SENDTO_SYSCALL + /* There does not exist a direct send syscall on s390, thus sendto is used. + The kernel also wraps this syscall with additional 0 parameters if called + via socketcall. */ + return SYSCALL_CANCEL (sendto, fd, buf, len, flags, NULL, 0); +#else + return SOCKETCALL_CANCEL (send, fd, buf, len, flags); +#endif +} +weak_alias (__libc_send, send) +weak_alias (__libc_send, __send) +libc_hidden_def (__send)