From nobody Wed Feb 11 01:09:13 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1528604274262696.3836458952153; Sat, 9 Jun 2018 21:17:54 -0700 (PDT) Received: from localhost ([::1]:42598 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fRrnd-00032Q-Hy for importer@patchew.org; Sun, 10 Jun 2018 00:17:53 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:41512) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fRqfw-0004b2-HI for qemu-devel@nongnu.org; Sat, 09 Jun 2018 23:05:54 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fRqfv-0004kU-Ax for qemu-devel@nongnu.org; Sat, 09 Jun 2018 23:05:52 -0400 Received: from mail-pl0-x243.google.com ([2607:f8b0:400e:c01::243]:33749) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fRqfv-0004k3-2B for qemu-devel@nongnu.org; Sat, 09 Jun 2018 23:05:51 -0400 Received: by mail-pl0-x243.google.com with SMTP id n10-v6so10392412plp.0 for ; Sat, 09 Jun 2018 20:05:50 -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.05.48 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sat, 09 Jun 2018 20:05:49 -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=CII5PWAJCoKDXZtRNhlraOIcAUh9jlthYVTcnyEYQws=; b=RFHvoowxr7P9LqNNq53yWWIxv4Ty2nABCQZKQDuG9bbZ0UHvQIEzOsls2wpVTD9FWh 6S2EPxPiFsKAkk3YH92t0NIvmklkjHYe9ud8tOJonWjB/Y5I8BiYKridf8z1cHQnfvAe EL6DNFPIsQgrFFBbj0dmign5wYvz2fQZNZuGo= 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=CII5PWAJCoKDXZtRNhlraOIcAUh9jlthYVTcnyEYQws=; b=O8l+GTTMJe44lhyrQ7y4+G1sD7wd/mdwfGncEoOEX2ML5jbIyYzl8MQAkwJMVmuKgW 9FBd5V4DZOuLBQ0gXssgKvb1GLFC7e/WLfGXRUDmGIVWfYcjhvQ90A7K5/3OIovXSM7w uBtcsKquWXkKpwCu6AGqg2SzmHVVHrOrDA+8AjHEN1ePBRq1PzYha6FqDuw10xews+jl GwJJrDRi6wt66RU/Bm6qTSrBX8ncEEV4RyiiwIOw3RU5tS5qlroBvUvzjWEpGI7Sw0nx t8NGOcD/IbtRVwas9/QRgrAtaKcizTSmSYwVXB18r5iw6Ti9wcnKijzVmW/EbGhWxD7s o1yw== X-Gm-Message-State: APt69E0LbCV8Abo1j/UREBIz3yu6nYJdVOpdXxvvNyAb1yCLcwiUpYqG 6OUzMCyjqhDf2GE4ZTUnwYgVReztMY4= X-Google-Smtp-Source: ADUXVKJg7Ahjn/ViQee7zcItozQkrWy7slsq2TO27IbeKg1K3xuGQWgr5Y3e/tEBMk+QSn25u+/QmA== X-Received: by 2002:a17:902:1029:: with SMTP id b38-v6mr12795421pla.277.1528599949896; Sat, 09 Jun 2018 20:05:49 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Sat, 9 Jun 2018 17:02:12 -1000 Message-Id: <20180610030220.3777-101-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::243 Subject: [Qemu-devel] [PATCH v2 100/108] linux-user: Split out epoll syscalls 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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" This includes epoll_create, epoll_create1, epoll_ctl, epoll_pwait, epoll_wait. All targets define epoll_create1, epoll_ctl, epoll_pwait; remove those ifdefs. Signed-off-by: Richard Henderson --- linux-user/syscall.c | 244 +++++++++++++++++++++++-------------------- 1 file changed, 128 insertions(+), 116 deletions(-) diff --git a/linux-user/syscall.c b/linux-user/syscall.c index e630a43f97..9ce37c1119 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -7897,6 +7897,123 @@ IMPL(dup3) return ret; } =20 +#ifdef CONFIG_EPOLL +# ifdef TARGET_NR_epoll_create +IMPL(epoll_create) +{ + return get_errno(epoll_create(arg1)); +} +# endif + +IMPL(epoll_create1) +{ +# ifdef CONFIG_EPOLL_CREATE1 + return get_errno(epoll_create1(arg1)); +# else + /* If flags are 0, we can emulate with epoll_create. + * The size argument is ignored after linux 2.6.8, + * other than verifying that it is positive. + */ + if (arg1 =3D=3D 0) { + return get_errno(epoll_create(1)); + } + return -TARGET_ENOSYS; +# endif +} + +IMPL(epoll_ctl) +{ + struct epoll_event ep; + struct epoll_event *epp =3D 0; + + if (arg4) { + struct target_epoll_event *target_ep; + if (!lock_user_struct(VERIFY_READ, target_ep, arg4, 1)) { + return -TARGET_EFAULT; + } + ep.events =3D tswap32(target_ep->events); + /* The epoll_data_t union is just opaque data to the kernel, + * so we transfer all 64 bits across and need not worry what + * actual data type it is. + */ + ep.data.u64 =3D tswap64(target_ep->data.u64); + unlock_user_struct(target_ep, arg4, 0); + epp =3D &ep; + } + return get_errno(epoll_ctl(arg1, arg2, arg3, epp)); +} + +IMPL(epoll_pwait_wait) +{ + struct target_epoll_event *target_ep; + struct epoll_event *ep; + int epfd =3D arg1; + int maxevents =3D arg3; + int timeout =3D arg4; + abi_long ret; + + if (maxevents <=3D 0 || maxevents > TARGET_EP_MAX_EVENTS) { + return -TARGET_EINVAL; + } + + target_ep =3D lock_user(VERIFY_WRITE, arg2, + maxevents * sizeof(struct target_epoll_event), 1= ); + if (!target_ep) { + return -TARGET_EFAULT; + } + + ep =3D g_try_new(struct epoll_event, maxevents); + if (!ep) { + unlock_user(target_ep, arg2, 0); + return -TARGET_ENOMEM; + } + + switch (num) { + default: /* TARGET_NR_epoll_pwait */ + if (arg5) { + target_sigset_t *target_set; + sigset_t set; + + if (arg6 !=3D sizeof(target_sigset_t)) { + ret =3D -TARGET_EINVAL; + break; + } + target_set =3D lock_user(VERIFY_READ, arg5, + sizeof(target_sigset_t), 1); + if (!target_set) { + ret =3D -TARGET_EFAULT; + break; + } + target_to_host_sigset(&set, target_set); + unlock_user(target_set, arg5, 0); + + ret =3D get_errno(safe_epoll_pwait(epfd, ep, maxevents, timeou= t, + &set, SIGSET_T_SIZE)); + break; + } + /* fallthru */ +# ifdef TARGET_NR_epoll_wait + case TARGET_NR_epoll_wait: +# endif + ret =3D get_errno(safe_epoll_pwait(epfd, ep, maxevents, + timeout, NULL, 0)); + break; + } + if (!is_error(ret)) { + int i; + for (i =3D 0; i < ret; i++) { + target_ep[i].events =3D tswap32(ep[i].events); + target_ep[i].data.u64 =3D tswap64(ep[i].data.u64); + } + unlock_user(target_ep, arg2, ret * sizeof(struct target_epoll_even= t)); + } else { + unlock_user(target_ep, arg2, 0); + } + g_free(ep); + return ret; +} +#endif /* CONFIG_EPOLL */ + #ifdef CONFIG_EVENTFD # ifdef TARGET_NR_eventfd IMPL(eventfd) @@ -12856,122 +12973,6 @@ static abi_long do_syscall1(void *cpu_env, unsign= ed num, abi_long arg1, abi_long ret; =20 switch(num) { -#if defined(CONFIG_EPOLL) -#if defined(TARGET_NR_epoll_create) - case TARGET_NR_epoll_create: - return get_errno(epoll_create(arg1)); -#endif -#if defined(TARGET_NR_epoll_create1) && defined(CONFIG_EPOLL_CREATE1) - case TARGET_NR_epoll_create1: - return get_errno(epoll_create1(arg1)); -#endif -#if defined(TARGET_NR_epoll_ctl) - case TARGET_NR_epoll_ctl: - { - struct epoll_event ep; - struct epoll_event *epp =3D 0; - if (arg4) { - struct target_epoll_event *target_ep; - if (!lock_user_struct(VERIFY_READ, target_ep, arg4, 1)) { - return -TARGET_EFAULT; - } - ep.events =3D tswap32(target_ep->events); - /* The epoll_data_t union is just opaque data to the kernel, - * so we transfer all 64 bits across and need not worry what - * actual data type it is. - */ - ep.data.u64 =3D tswap64(target_ep->data.u64); - unlock_user_struct(target_ep, arg4, 0); - epp =3D &ep; - } - return get_errno(epoll_ctl(arg1, arg2, arg3, epp)); - } -#endif - -#if defined(TARGET_NR_epoll_wait) || defined(TARGET_NR_epoll_pwait) -#if defined(TARGET_NR_epoll_wait) - case TARGET_NR_epoll_wait: -#endif -#if defined(TARGET_NR_epoll_pwait) - case TARGET_NR_epoll_pwait: -#endif - { - struct target_epoll_event *target_ep; - struct epoll_event *ep; - int epfd =3D arg1; - int maxevents =3D arg3; - int timeout =3D arg4; - - if (maxevents <=3D 0 || maxevents > TARGET_EP_MAX_EVENTS) { - return -TARGET_EINVAL; - } - - target_ep =3D lock_user(VERIFY_WRITE, arg2, - maxevents * sizeof(struct target_epoll_event= ), 1); - if (!target_ep) { - return -TARGET_EFAULT; - } - - ep =3D g_try_new(struct epoll_event, maxevents); - if (!ep) { - unlock_user(target_ep, arg2, 0); - return -TARGET_ENOMEM; - } - - switch (num) { -#if defined(TARGET_NR_epoll_pwait) - case TARGET_NR_epoll_pwait: - { - target_sigset_t *target_set; - sigset_t _set, *set =3D &_set; - - if (arg5) { - if (arg6 !=3D sizeof(target_sigset_t)) { - ret =3D -TARGET_EINVAL; - break; - } - - target_set =3D lock_user(VERIFY_READ, arg5, - sizeof(target_sigset_t), 1); - if (!target_set) { - ret =3D -TARGET_EFAULT; - break; - } - target_to_host_sigset(set, target_set); - unlock_user(target_set, arg5, 0); - } else { - set =3D NULL; - } - - ret =3D get_errno(safe_epoll_pwait(epfd, ep, maxevents, timeou= t, - set, SIGSET_T_SIZE)); - } -#endif -#if defined(TARGET_NR_epoll_wait) - case TARGET_NR_epoll_wait: - ret =3D get_errno(safe_epoll_pwait(epfd, ep, maxevents, timeou= t, - NULL, 0)); - break; -#endif - default: - ret =3D -TARGET_ENOSYS; - } - if (!is_error(ret)) { - int i; - for (i =3D 0; i < ret; i++) { - target_ep[i].events =3D tswap32(ep[i].events); - target_ep[i].data.u64 =3D tswap64(ep[i].data.u64); - } - unlock_user(target_ep, arg2, - ret * sizeof(struct target_epoll_event)); - } else { - unlock_user(target_ep, arg2, 0); - } - g_free(ep); - return ret; - } -#endif -#endif #ifdef TARGET_NR_prlimit64 case TARGET_NR_prlimit64: { @@ -13330,6 +13331,17 @@ static impl_fn *syscall_table(unsigned num) SYSCALL(dup2); #endif SYSCALL(dup3); +#ifdef CONFIG_EPOLL +# ifdef TARGET_NR_epoll_create + SYSCALL(epoll_create); +# endif + SYSCALL(epoll_create1); + SYSCALL(epoll_ctl); + SYSCALL_WITH(epoll_pwait, epoll_pwait_wait); +# ifdef TARGET_NR_epoll_wait + SYSCALL_WITH(epoll_wait, epoll_pwait_wait); +# endif +#endif #ifdef CONFIG_EVENTFD # ifdef TARGET_NR_eventfd SYSCALL(eventfd); --=20 2.17.1