From patchwork Sun Jun 10 03:01:16 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 138125 Delivered-To: patch@linaro.org Received: by 2002:a2e:970d:0:0:0:0:0 with SMTP id r13-v6csp2594241lji; Sat, 9 Jun 2018 20:39:49 -0700 (PDT) X-Google-Smtp-Source: ADUXVKJBYb0XNTfRKMSwJeDIPLPDT58hFO6dehtnAR+Mxi7OEG26f3ACMd5HJWA/vIWmLpDxdt3m X-Received: by 2002:a0c:8c8a:: with SMTP id p10-v6mr10676641qvb.68.1528601989195; Sat, 09 Jun 2018 20:39:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1528601989; cv=none; d=google.com; s=arc-20160816; b=xhS4yuuVJejNB1fpvjcpgviI3ELnBe5nKAJa3OFai0kWOVzPHYC2jIWKU2qqnLt7EA 2ufWzA1u9EsBubu9DVoDopZBaYsw1aQuNACZa3/+Wx82+l2Vl5yn2RE0ftLu3QgFRsEC pr8v9enXc4uU97y8SDv6BUjA7uAs9HmhsnDEOLJ9d7qTG9GwJzp98DXsAkYtYpfZCjEF eQxwCtWLFQjzUnW2teHl7XaLAWw+uidCb9oLmMKYW8Vg/KfE6d/RPpt2J/XrpbhB90XJ L9ktspoe/MzzgIF+SSoBCEtDCH30c3T1GzjmCeyC7SVPV6Leqro+b8B5LqkSxqitCgd5 oGjA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject:references:in-reply-to :message-id:date:to:from:dkim-signature:arc-authentication-results; bh=nbIFk6joHhHEk0ILieO0O1pHXD5skH7BjGeQK2uTGmQ=; b=HgforJHAb6VAtzy0in8Ja1/R+80RkUoShLZoQdhgQqYU9q6lRUx1VCSXryGDO/wXEP wNOZKEORYPMGLyefGyjmubRu34j4QmO2qgnxqsuwzK1DRl1mVvdtaqgfwpDYU7JXjSbr jznhUW256rfJbWP3m/tf7q3EZWIB9uydQGNiNgBJW07fgW3UNx56cJYIyprbrf8rKNqB auNkTchEhrcnLWQJewkbOTixtToK7LRWW+jCFn/4dg/H7Wh7Vv/S5RT1P9dzUey6Bc5o Kxukvf8HMtjR9K0pVeRugYc7CQXxrh7ZJaCpW1/WG9g2duUYO9pI3DYC3FX6M7o6KH0Z JGXA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=PA1oiOuE; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom=qemu-devel-bounces+patch=linaro.org@nongnu.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id s72-v6si6661559qka.20.2018.06.09.20.39.48 for (version=TLS1 cipher=AES128-SHA bits=128/128); Sat, 09 Jun 2018 20:39:49 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) client-ip=2001:4830:134:3::11; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=PA1oiOuE; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom=qemu-devel-bounces+patch=linaro.org@nongnu.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:42376 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fRrCm-0000nR-LW for patch@linaro.org; Sat, 09 Jun 2018 23:39:48 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:40680) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fRqeD-0002um-LI for qemu-devel@nongnu.org; Sat, 09 Jun 2018 23:04:07 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fRqeB-0003fE-Sx for qemu-devel@nongnu.org; Sat, 09 Jun 2018 23:04:05 -0400 Received: from mail-pl0-x242.google.com ([2607:f8b0:400e:c01::242]:39880) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fRqeB-0003f3-Kc for qemu-devel@nongnu.org; Sat, 09 Jun 2018 23:04:03 -0400 Received: by mail-pl0-x242.google.com with SMTP id f1-v6so10399794plt.6 for ; Sat, 09 Jun 2018 20:04:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=nbIFk6joHhHEk0ILieO0O1pHXD5skH7BjGeQK2uTGmQ=; b=PA1oiOuEQoN1YrQnuWyoIWDU9BkpB7jOnOTCvZTGuHqHW1U1A9wCRlFLUQFW1D2SUd Sh4nNJ+Gjon+tOLyPJsVNM9HYIj5nn5cdTz+08KfT+p5Pc6RwLWYYetXPrUtL+aNl4wc XBjRtheiKlk2UmBzstKffN5Xc8CV1wRgzjcAQ= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=nbIFk6joHhHEk0ILieO0O1pHXD5skH7BjGeQK2uTGmQ=; b=FP4TehYiOAm76m4yqcvNSXfOHYtekRzFxQvyZxZ5OaAGHXpIM6tpBqwrjx30n7rKjZ V5lW4gatReoDg1nerTEOWjfCGm50suEjm+wUqJ4j8EqarGOl7LQLEbYCsIwuS1JB6Roq Wvk+Mg3qriQ3zToSKXe6JCXv2Q3H8Sk1nwqk7uxuCd1ipARtA2GQq+AmOUO0OowV8/lA N/66Y/K1Cg55ih++jzhmC2XjSJ/9g3wTeKlb6RbJlVRr50cfgDASAR5mA7mkWa6OXv1i U1+YLynVdLKxNTaOM7gKKTwWfCY8A4x24FDPnFD4Q1f53MtsgA+GBQC9C0lJXmqp6EO3 t8Pw== X-Gm-Message-State: APt69E3FaWPGtE8aXbyzyRhaYqfYqzGg2KOB5myI44RxlawDrKuehGX4 RrWeV/TXw+eeX7lrwd/3kQvA2OiUnrA= X-Received: by 2002:a17:902:8b8c:: with SMTP id ay12-v6mr12843581plb.74.1528599842460; Sat, 09 Jun 2018 20:04:02 -0700 (PDT) Received: from cloudburst.twiddle.net (rrcs-173-198-77-219.west.biz.rr.com. [173.198.77.219]) by smtp.gmail.com with ESMTPSA id y17-v6sm31712718pfe.33.2018.06.09.20.03.59 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sat, 09 Jun 2018 20:04:01 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Sat, 9 Jun 2018 17:01:16 -1000 Message-Id: <20180610030220.3777-45-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180610030220.3777-1-richard.henderson@linaro.org> References: <20180610030220.3777-1-richard.henderson@linaro.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:400e:c01::242 Subject: [Qemu-devel] [PATCH v2 044/108] linux-user: Split out socketcall X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: laurent@vivier.eu Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" At the same time, merge do_socketcall into the new function. Signed-off-by: Richard Henderson --- linux-user/syscall.c | 194 +++++++++++++++++++++---------------------- 1 file changed, 97 insertions(+), 97 deletions(-) -- 2.17.1 diff --git a/linux-user/syscall.c b/linux-user/syscall.c index 6d8d2eb780..d50c84614e 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -4184,99 +4184,6 @@ fail: return ret; } -#ifdef TARGET_NR_socketcall -/* do_socketcall() must return target values and target errnos. */ -static abi_long do_socketcall(int num, abi_ulong vptr) -{ - static const unsigned nargs[] = { /* number of arguments per operation */ - [TARGET_SYS_SOCKET] = 3, /* domain, type, protocol */ - [TARGET_SYS_BIND] = 3, /* fd, addr, addrlen */ - [TARGET_SYS_CONNECT] = 3, /* fd, addr, addrlen */ - [TARGET_SYS_LISTEN] = 2, /* fd, backlog */ - [TARGET_SYS_ACCEPT] = 3, /* fd, addr, addrlen */ - [TARGET_SYS_GETSOCKNAME] = 3, /* fd, addr, addrlen */ - [TARGET_SYS_GETPEERNAME] = 3, /* fd, addr, addrlen */ - [TARGET_SYS_SOCKETPAIR] = 4, /* domain, type, protocol, tab */ - [TARGET_SYS_SEND] = 4, /* fd, msg, len, flags */ - [TARGET_SYS_RECV] = 4, /* fd, msg, len, flags */ - [TARGET_SYS_SENDTO] = 6, /* fd, msg, len, flags, addr, addrlen */ - [TARGET_SYS_RECVFROM] = 6, /* fd, msg, len, flags, addr, addrlen */ - [TARGET_SYS_SHUTDOWN] = 2, /* fd, how */ - [TARGET_SYS_SETSOCKOPT] = 5, /* fd, level, optname, optval, optlen */ - [TARGET_SYS_GETSOCKOPT] = 5, /* fd, level, optname, optval, optlen */ - [TARGET_SYS_SENDMSG] = 3, /* fd, msg, flags */ - [TARGET_SYS_RECVMSG] = 3, /* fd, msg, flags */ - [TARGET_SYS_ACCEPT4] = 4, /* fd, addr, addrlen, flags */ - [TARGET_SYS_RECVMMSG] = 4, /* fd, msgvec, vlen, flags */ - [TARGET_SYS_SENDMMSG] = 4, /* fd, msgvec, vlen, flags */ - }; - abi_long a[6]; /* max 6 args */ - unsigned i; - - /* check the range of the first argument num */ - /* (TARGET_SYS_SENDMMSG is the highest among TARGET_SYS_xxx) */ - if (num < 1 || num > TARGET_SYS_SENDMMSG) { - return -TARGET_EINVAL; - } - /* ensure we have space for args */ - if (nargs[num] > ARRAY_SIZE(a)) { - return -TARGET_EINVAL; - } - /* collect the arguments in a[] according to nargs[] */ - for (i = 0; i < nargs[num]; ++i) { - if (get_user_ual(a[i], vptr + i * sizeof(abi_long)) != 0) { - return -TARGET_EFAULT; - } - } - /* now when we have the args, invoke the appropriate underlying function */ - switch (num) { - case TARGET_SYS_SOCKET: /* domain, type, protocol */ - return do_socket(a[0], a[1], a[2]); - case TARGET_SYS_BIND: /* sockfd, addr, addrlen */ - return do_bind(a[0], a[1], a[2]); - case TARGET_SYS_CONNECT: /* sockfd, addr, addrlen */ - return do_connect(a[0], a[1], a[2]); - case TARGET_SYS_LISTEN: /* sockfd, backlog */ - return get_errno(listen(a[0], a[1])); - case TARGET_SYS_ACCEPT: /* sockfd, addr, addrlen */ - return do_accept4(a[0], a[1], a[2], 0); - case TARGET_SYS_GETSOCKNAME: /* sockfd, addr, addrlen */ - return do_getsockname(a[0], a[1], a[2]); - case TARGET_SYS_GETPEERNAME: /* sockfd, addr, addrlen */ - return do_getpeername(a[0], a[1], a[2]); - case TARGET_SYS_SOCKETPAIR: /* domain, type, protocol, tab */ - return do_socketpair(a[0], a[1], a[2], a[3]); - case TARGET_SYS_SEND: /* sockfd, msg, len, flags */ - return do_sendto(a[0], a[1], a[2], a[3], 0, 0); - case TARGET_SYS_RECV: /* sockfd, msg, len, flags */ - return do_recvfrom(a[0], a[1], a[2], a[3], 0, 0); - case TARGET_SYS_SENDTO: /* sockfd, msg, len, flags, addr, addrlen */ - return do_sendto(a[0], a[1], a[2], a[3], a[4], a[5]); - case TARGET_SYS_RECVFROM: /* sockfd, msg, len, flags, addr, addrlen */ - return do_recvfrom(a[0], a[1], a[2], a[3], a[4], a[5]); - case TARGET_SYS_SHUTDOWN: /* sockfd, how */ - return get_errno(shutdown(a[0], a[1])); - case TARGET_SYS_SETSOCKOPT: /* sockfd, level, optname, optval, optlen */ - return do_setsockopt(a[0], a[1], a[2], a[3], a[4]); - case TARGET_SYS_GETSOCKOPT: /* sockfd, level, optname, optval, optlen */ - return do_getsockopt(a[0], a[1], a[2], a[3], a[4]); - case TARGET_SYS_SENDMSG: /* sockfd, msg, flags */ - return do_sendrecvmsg(a[0], a[1], a[2], 1); - case TARGET_SYS_RECVMSG: /* sockfd, msg, flags */ - return do_sendrecvmsg(a[0], a[1], a[2], 0); - case TARGET_SYS_ACCEPT4: /* sockfd, addr, addrlen, flags */ - return do_accept4(a[0], a[1], a[2], a[3]); - case TARGET_SYS_RECVMMSG: /* sockfd, msgvec, vlen, flags */ - return do_sendrecvmmsg(a[0], a[1], a[2], a[3], 0); - case TARGET_SYS_SENDMMSG: /* sockfd, msgvec, vlen, flags */ - return do_sendrecvmmsg(a[0], a[1], a[2], a[3], 1); - default: - gemu_log("Unsupported socketcall: %d\n", num); - return -TARGET_EINVAL; - } -} -#endif - #define N_SHM_REGIONS 32 static struct shm_region { @@ -9575,6 +9482,100 @@ IMPL(sigsuspend) } #endif +#ifdef TARGET_NR_socketcall +IMPL(socketcall) +{ + static const unsigned nargs[] = { /* number of arguments per operation */ + [TARGET_SYS_SOCKET] = 3, /* domain, type, protocol */ + [TARGET_SYS_BIND] = 3, /* fd, addr, addrlen */ + [TARGET_SYS_CONNECT] = 3, /* fd, addr, addrlen */ + [TARGET_SYS_LISTEN] = 2, /* fd, backlog */ + [TARGET_SYS_ACCEPT] = 3, /* fd, addr, addrlen */ + [TARGET_SYS_GETSOCKNAME] = 3, /* fd, addr, addrlen */ + [TARGET_SYS_GETPEERNAME] = 3, /* fd, addr, addrlen */ + [TARGET_SYS_SOCKETPAIR] = 4, /* domain, type, protocol, tab */ + [TARGET_SYS_SEND] = 4, /* fd, msg, len, flags */ + [TARGET_SYS_RECV] = 4, /* fd, msg, len, flags */ + [TARGET_SYS_SENDTO] = 6, /* fd, msg, len, flags, addr, addrlen */ + [TARGET_SYS_RECVFROM] = 6, /* fd, msg, len, flags, addr, addrlen */ + [TARGET_SYS_SHUTDOWN] = 2, /* fd, how */ + [TARGET_SYS_SETSOCKOPT] = 5, /* fd, level, optname, optval, optlen */ + [TARGET_SYS_GETSOCKOPT] = 5, /* fd, level, optname, optval, optlen */ + [TARGET_SYS_SENDMSG] = 3, /* fd, msg, flags */ + [TARGET_SYS_RECVMSG] = 3, /* fd, msg, flags */ + [TARGET_SYS_ACCEPT4] = 4, /* fd, addr, addrlen, flags */ + [TARGET_SYS_RECVMMSG] = 4, /* fd, msgvec, vlen, flags */ + [TARGET_SYS_SENDMMSG] = 4, /* fd, msgvec, vlen, flags */ + }; + abi_ulong vptr = arg2; + abi_long a[6]; /* max 6 args */ + unsigned i; + + /* check the range of the first argument num */ + num = arg1; + /* (TARGET_SYS_SENDMMSG is the highest among TARGET_SYS_xxx) */ + if (num < 1 || num > TARGET_SYS_SENDMMSG) { + return -TARGET_EINVAL; + } + /* ensure we have space for args */ + if (nargs[num] > ARRAY_SIZE(a)) { + return -TARGET_EINVAL; + } + /* collect the arguments in a[] according to nargs[] */ + for (i = 0; i < nargs[num]; ++i) { + if (get_user_ual(a[i], vptr + i * sizeof(abi_long)) != 0) { + return -TARGET_EFAULT; + } + } + /* now when we have the args, invoke the appropriate underlying function */ + switch (num) { + case TARGET_SYS_SOCKET: /* domain, type, protocol */ + return do_socket(a[0], a[1], a[2]); + case TARGET_SYS_BIND: /* sockfd, addr, addrlen */ + return do_bind(a[0], a[1], a[2]); + case TARGET_SYS_CONNECT: /* sockfd, addr, addrlen */ + return do_connect(a[0], a[1], a[2]); + case TARGET_SYS_LISTEN: /* sockfd, backlog */ + return get_errno(listen(a[0], a[1])); + case TARGET_SYS_ACCEPT: /* sockfd, addr, addrlen */ + return do_accept4(a[0], a[1], a[2], 0); + case TARGET_SYS_GETSOCKNAME: /* sockfd, addr, addrlen */ + return do_getsockname(a[0], a[1], a[2]); + case TARGET_SYS_GETPEERNAME: /* sockfd, addr, addrlen */ + return do_getpeername(a[0], a[1], a[2]); + case TARGET_SYS_SOCKETPAIR: /* domain, type, protocol, tab */ + return do_socketpair(a[0], a[1], a[2], a[3]); + case TARGET_SYS_SEND: /* sockfd, msg, len, flags */ + return do_sendto(a[0], a[1], a[2], a[3], 0, 0); + case TARGET_SYS_RECV: /* sockfd, msg, len, flags */ + return do_recvfrom(a[0], a[1], a[2], a[3], 0, 0); + case TARGET_SYS_SENDTO: /* sockfd, msg, len, flags, addr, addrlen */ + return do_sendto(a[0], a[1], a[2], a[3], a[4], a[5]); + case TARGET_SYS_RECVFROM: /* sockfd, msg, len, flags, addr, addrlen */ + return do_recvfrom(a[0], a[1], a[2], a[3], a[4], a[5]); + case TARGET_SYS_SHUTDOWN: /* sockfd, how */ + return get_errno(shutdown(a[0], a[1])); + case TARGET_SYS_SETSOCKOPT: /* sockfd, level, optname, optval, optlen */ + return do_setsockopt(a[0], a[1], a[2], a[3], a[4]); + case TARGET_SYS_GETSOCKOPT: /* sockfd, level, optname, optval, optlen */ + return do_getsockopt(a[0], a[1], a[2], a[3], a[4]); + case TARGET_SYS_SENDMSG: /* sockfd, msg, flags */ + return do_sendrecvmsg(a[0], a[1], a[2], 1); + case TARGET_SYS_RECVMSG: /* sockfd, msg, flags */ + return do_sendrecvmsg(a[0], a[1], a[2], 0); + case TARGET_SYS_ACCEPT4: /* sockfd, addr, addrlen, flags */ + return do_accept4(a[0], a[1], a[2], a[3]); + case TARGET_SYS_RECVMMSG: /* sockfd, msgvec, vlen, flags */ + return do_sendrecvmmsg(a[0], a[1], a[2], a[3], 0); + case TARGET_SYS_SENDMMSG: /* sockfd, msgvec, vlen, flags */ + return do_sendrecvmmsg(a[0], a[1], a[2], a[3], 1); + default: + gemu_log("Unsupported socketcall: %d\n", num); + return -TARGET_EINVAL; + } +} +#endif + #ifdef TARGET_NR_ssetmask IMPL(ssetmask) { @@ -9924,10 +9925,6 @@ static abi_long do_syscall1(void *cpu_env, unsigned num, abi_long arg1, void *p; switch(num) { -#ifdef TARGET_NR_socketcall - case TARGET_NR_socketcall: - return do_socketcall(arg1, arg2); -#endif #ifdef TARGET_NR_accept case TARGET_NR_accept: return do_accept4(arg1, arg2, arg3, 0); @@ -12935,6 +12932,9 @@ static impl_fn *syscall_table(unsigned num) #ifdef TARGET_NR_sigsuspend SYSCALL(sigsuspend); #endif +#ifdef TARGET_NR_socketcall + SYSCALL(socketcall); +#endif #ifdef TARGET_NR_ssetmask SYSCALL(ssetmask); #endif