From patchwork Sun Jun 10 03:02: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: 138181 Delivered-To: patch@linaro.org Received: by 2002:a2e:970d:0:0:0:0:0 with SMTP id r13-v6csp2618746lji; Sat, 9 Jun 2018 21:22:37 -0700 (PDT) X-Google-Smtp-Source: ADUXVKI0uzfxGDAJh22bBpTqZIVlddLfSWQSlOVs0UWyA5N3lYieg0ZOxgOinxgqO17Nw6CXOFgx X-Received: by 2002:a0c:b665:: with SMTP id q37-v6mr11005603qvf.43.1528604557458; Sat, 09 Jun 2018 21:22:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1528604557; cv=none; d=google.com; s=arc-20160816; b=cHQpwQRd0xNWvayeHHadVECr4Hfyf7CCV+Kl8BL3kjb7109JfmqVkvbEGC282TSB2y 6ujRpleP2m25whb/9tRtrAgCTd2JEwIW63+Y6HA4M+TD1MprKj3BW1lEzZ5nq9+3qhXu PdzEzi6O86JL3fvhX10F4L/LKz/r7o1DtrZa7Y+67spiPdWxQT7WDs5NjK1LpaMdRUK5 yOQhLCPwIjJCZ0HBNX30/TqjNVg3utH9yYaqXcx2VM1Nwa4tHFMu0ry0AM7WcnRC6Wjg 77kpCncTp6pfsW+kQ3YDdl5bzk/hwzvEwMk9XvFzSj6vEJKIKgEDez8xjEDv/XG2X2dY w6bg== 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=7qCJP7ZHZAElHYDOl7dU420vTS9NMofEHdWiPaABl+E=; b=TEDZuorY9EpvrzNvHDqJklYbk0VgEbtFUFy0evvaU0lVvUCgRy09kwFR1HixNrO1cu 2193PsuI62hJehjMK9gF+O9LrXnjqSiMEYT1dqLSRwnTl2TneFhTSSzyO/AJYv+tPCuv aB3g/7JhMNH/b5kdewsh/3khgFVlEj1mXeg0/4eD8LdMM16lwSvTX4Gi2FD+taHM0h8K 6jgqWWDRuo4H5vUIszG9cZL/PiZmQinDe+ssJoIzyRzPgU45psFV8VSIDeXEXTxnRimg 0Hb2cFhjdXN38hf0gL/aiOjRKa5WdQ7NF1jicYWm2MmtCJvQwgzAcynyfdFDgryYl1Lb sJsQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=IU8yjdyt; 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 v47-v6si4815295qtg.403.2018.06.09.21.22.37 for (version=TLS1 cipher=AES128-SHA bits=128/128); Sat, 09 Jun 2018 21:22:37 -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=IU8yjdyt; 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]:42630 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fRrsC-0007OY-Vn for patch@linaro.org; Sun, 10 Jun 2018 00:22:37 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:41568) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fRqg4-0004jk-Ni for qemu-devel@nongnu.org; Sat, 09 Jun 2018 23:06:02 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fRqg3-0004pV-8L for qemu-devel@nongnu.org; Sat, 09 Jun 2018 23:06:00 -0400 Received: from mail-pg0-x241.google.com ([2607:f8b0:400e:c05::241]:44846) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fRqg3-0004pD-0K for qemu-devel@nongnu.org; Sat, 09 Jun 2018 23:05:59 -0400 Received: by mail-pg0-x241.google.com with SMTP id p21-v6so8128974pgd.11 for ; Sat, 09 Jun 2018 20:05:58 -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=7qCJP7ZHZAElHYDOl7dU420vTS9NMofEHdWiPaABl+E=; b=IU8yjdytTUiFcNsfX7Af1c3BVgaQZt10cYojRT39hCPqhMLSIz2L2uTSfGZQAQsJmB m1cimEWTry1t0firGY36+Lm3ZbPuj+rCiyRolPHn3zXfwlQxxXDFl+YAjuDDMAHtY4ww mnub3kTsUYuicP2Nz1vnGNCzvzFufwtwVKF74= 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=7qCJP7ZHZAElHYDOl7dU420vTS9NMofEHdWiPaABl+E=; b=XxxnqqtUoiNHH+etE3zHq5HBfjOA4IkqzLRe5RSglK6P4zHqxfMPtgXl9sDa1wdGtr 6kNyywoVvk2p+c7SYsbsPHbTCzMizfud7ArqkV0tM2w/0Bli2FogE26XNvpAEnLHXALu F7IhBWjban6OC+P2NG/+7KSrn8f5/a1qFThKfJjnaXOWsBgFkG9rkfc3lzdrbfwyuEir 37s4HbVAQbYrWgHJiR1nG5iwkRg9HvkwYivEFu9VADtrBly33Kq0BMaR45iXVTP8uCGc TR9qVoBdNZiiAlEDHElh13UHKx9l4w7XcKUR/V2rS3HIBfuNJ+v79frVNcEWLFMUDjoz UQ5Q== X-Gm-Message-State: APt69E3w9sEn6K0OYucwvXr0K0t9lFpu6rzsrY7q3i3+/8+Jle9VYKl2 SAOnmJhjjYUbtZHPNaGLsvKwGh4Abgk= X-Received: by 2002:a63:2b15:: with SMTP id r21-v6mr10438248pgr.269.1528599957847; Sat, 09 Jun 2018 20:05:57 -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.55 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sat, 09 Jun 2018 20:05:57 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Sat, 9 Jun 2018 17:02:16 -1000 Message-Id: <20180610030220.3777-105-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:c05::241 Subject: [Qemu-devel] [PATCH v2 104/108] linux-user: Split out timer 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+patch=linaro.org@nongnu.org Sender: "Qemu-devel" This includes timer_create, timer_delete, timer_getoverrun, timer_gettime, and timer_settime. All targets define all of these; remove the ifdefs. Signed-off-by: Richard Henderson --- linux-user/syscall.c | 234 ++++++++++++++++++++----------------------- 1 file changed, 111 insertions(+), 123 deletions(-) -- 2.17.1 diff --git a/linux-user/syscall.c b/linux-user/syscall.c index 5d60872587..0f12a945ea 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -640,7 +640,6 @@ _syscall4(int, sys_prlimit64, pid_t, pid, int, resource, const struct host_rlimit64 *, new_limit, struct host_rlimit64 *, old_limit) -#if defined(TARGET_NR_timer_create) /* Maxiumum of 32 active POSIX timers allowed at any one time. */ static timer_t g_posix_timers[32] = { 0, } ; @@ -656,7 +655,6 @@ static inline int next_free_host_timer(void) } return -1; } -#endif /* ARM EABI and MIPS expect 64bit types aligned even on pairs or registers */ #ifdef TARGET_ARM @@ -12685,6 +12683,112 @@ IMPL(times) return host_to_target_clock_t(ret); } +IMPL(timer_create) +{ + /* args: clockid_t clockid, struct sigevent *sevp, timer_t *timerid */ + struct sigevent host_sevp, *phost_sevp = NULL; + int clkid = arg1; + int timer_index; + timer_t *phtimer; + abi_long ret; + + timer_index = next_free_host_timer(); + if (timer_index < 0) { + return -TARGET_EAGAIN; + } + + phtimer = g_posix_timers + timer_index; + if (arg2) { + phost_sevp = &host_sevp; + ret = target_to_host_sigevent(phost_sevp, arg2); + if (ret != 0) { + return ret; + } + } + + ret = get_errno(timer_create(clkid, phost_sevp, phtimer)); + if (!ret && put_user(TIMER_MAGIC | timer_index, arg3, target_timer_t)) { + /* ??? Leak timer. */ + return -TARGET_EFAULT; + } + return ret; +} + +IMPL(timer_delete) +{ + /* args: timer_t timerid */ + target_timer_t timerid = get_timer_id(arg1); + timer_t htimer; + abi_long ret; + + if (timerid < 0) { + return timerid; + } + htimer = g_posix_timers[timerid]; + ret = get_errno(timer_delete(htimer)); + g_posix_timers[timerid] = 0; + return ret; +} + +IMPL(timer_getoverrun) +{ + /* args: timer_t timerid */ + target_timer_t timerid = get_timer_id(arg1); + timer_t htimer; + abi_long ret; + + if (timerid < 0) { + return timerid; + } + htimer = g_posix_timers[timerid]; + ret = get_errno(timer_getoverrun(htimer)); + fd_trans_unregister(ret); + return ret; +} + +IMPL(timer_gettime) +{ + /* args: timer_t timerid, struct itimerspec *curr_value */ + target_timer_t timerid = get_timer_id(arg1); + struct itimerspec hspec; + timer_t htimer; + abi_long ret; + + if (timerid < 0) { + return timerid; + } + htimer = g_posix_timers[timerid]; + ret = get_errno(timer_gettime(htimer, &hspec)); + if (!ret && host_to_target_itimerspec(arg2, &hspec)) { + ret = -TARGET_EFAULT; + } + return ret; +} + +IMPL(timer_settime) +{ + /* args: timer_t timerid, int flags, const struct itimerspec *new_value, + * struct itimerspec * old_value + */ + struct itimerspec hspec_new, hspec_old; + target_timer_t timerid = get_timer_id(arg1); + timer_t htimer; + abi_long ret; + + if (timerid < 0) { + return timerid; + } + if (target_to_host_itimerspec(&hspec_new, arg3)) { + return -TARGET_EFAULT; + } + htimer = g_posix_timers[timerid]; + ret = get_errno(timer_settime(htimer, arg2, &hspec_new, &hspec_old)); + if (!ret && arg4 && host_to_target_itimerspec(arg4, &hspec_old)) { + return -TARGET_EFAULT; + } + return ret; +} + IMPL(tkill) { return get_errno(safe_tkill((int)arg1, target_to_host_signal(arg2))); @@ -13048,127 +13152,6 @@ static abi_long do_syscall1(void *cpu_env, unsigned num, abi_long arg1, abi_long ret; switch(num) { -#ifdef TARGET_NR_timer_create - case TARGET_NR_timer_create: - { - /* args: clockid_t clockid, struct sigevent *sevp, timer_t *timerid */ - - struct sigevent host_sevp = { {0}, }, *phost_sevp = NULL; - - int clkid = arg1; - int timer_index = next_free_host_timer(); - - if (timer_index < 0) { - ret = -TARGET_EAGAIN; - } else { - timer_t *phtimer = g_posix_timers + timer_index; - - if (arg2) { - phost_sevp = &host_sevp; - ret = target_to_host_sigevent(phost_sevp, arg2); - if (ret != 0) { - return ret; - } - } - - ret = get_errno(timer_create(clkid, phost_sevp, phtimer)); - if (ret) { - phtimer = NULL; - } else { - if (put_user(TIMER_MAGIC | timer_index, arg3, target_timer_t)) { - return -TARGET_EFAULT; - } - } - } - return ret; - } -#endif - -#ifdef TARGET_NR_timer_settime - case TARGET_NR_timer_settime: - { - /* args: timer_t timerid, int flags, const struct itimerspec *new_value, - * struct itimerspec * old_value */ - target_timer_t timerid = get_timer_id(arg1); - - if (timerid < 0) { - ret = timerid; - } else if (arg3 == 0) { - ret = -TARGET_EINVAL; - } else { - timer_t htimer = g_posix_timers[timerid]; - struct itimerspec hspec_new = {{0},}, hspec_old = {{0},}; - - if (target_to_host_itimerspec(&hspec_new, arg3)) { - return -TARGET_EFAULT; - } - ret = get_errno( - timer_settime(htimer, arg2, &hspec_new, &hspec_old)); - if (arg4 && host_to_target_itimerspec(arg4, &hspec_old)) { - return -TARGET_EFAULT; - } - } - return ret; - } -#endif - -#ifdef TARGET_NR_timer_gettime - case TARGET_NR_timer_gettime: - { - /* args: timer_t timerid, struct itimerspec *curr_value */ - target_timer_t timerid = get_timer_id(arg1); - - if (timerid < 0) { - ret = timerid; - } else if (!arg2) { - ret = -TARGET_EFAULT; - } else { - timer_t htimer = g_posix_timers[timerid]; - struct itimerspec hspec; - ret = get_errno(timer_gettime(htimer, &hspec)); - - if (host_to_target_itimerspec(arg2, &hspec)) { - ret = -TARGET_EFAULT; - } - } - return ret; - } -#endif - -#ifdef TARGET_NR_timer_getoverrun - case TARGET_NR_timer_getoverrun: - { - /* args: timer_t timerid */ - target_timer_t timerid = get_timer_id(arg1); - - if (timerid < 0) { - ret = timerid; - } else { - timer_t htimer = g_posix_timers[timerid]; - ret = get_errno(timer_getoverrun(htimer)); - } - fd_trans_unregister(ret); - return ret; - } -#endif - -#ifdef TARGET_NR_timer_delete - case TARGET_NR_timer_delete: - { - /* args: timer_t timerid */ - target_timer_t timerid = get_timer_id(arg1); - - if (timerid < 0) { - ret = timerid; - } else { - timer_t htimer = g_posix_timers[timerid]; - ret = get_errno(timer_delete(htimer)); - g_posix_timers[timerid] = 0; - } - return ret; - } -#endif - #if defined(TARGET_NR_timerfd_create) && defined(CONFIG_TIMERFD) case TARGET_NR_timerfd_create: return get_errno(timerfd_create(arg1, @@ -13908,6 +13891,11 @@ static impl_fn *syscall_table(unsigned num) SYSCALL(time); #endif SYSCALL(times); + SYSCALL(timer_create); + SYSCALL(timer_delete); + SYSCALL(timer_getoverrun); + SYSCALL(timer_gettime); + SYSCALL(timer_settime); SYSCALL(tkill); SYSCALL(truncate); #ifdef TARGET_NR_truncate64