From patchwork Sun Jun 10 03:00:53 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 138096 Delivered-To: patch@linaro.org Received: by 2002:a2e:970d:0:0:0:0:0 with SMTP id r13-v6csp2581841lji; Sat, 9 Jun 2018 20:17:13 -0700 (PDT) X-Google-Smtp-Source: ADUXVKJ9+XWJIoChBPQsothiXfNOJWmloAKivSzu9DBkZOmZx8lSGBPoJAOYk2dgGt3TQAAqx1o4 X-Received: by 2002:a0c:8c0b:: with SMTP id n11-v6mr10877565qvb.228.1528600632965; Sat, 09 Jun 2018 20:17:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1528600632; cv=none; d=google.com; s=arc-20160816; b=0kMuWTN4r4BXCaXdhVi6Dxte49xD9CdGh8+m+NObyZTuRqYVOxTqRulUQbSWixnfQn dJSBrtvVT2rmPswAOBwZhALT7BsSE8NJS16E/7+GQWisKnaxr1eGT1CYXOzkN/cGjeQv HsYSwea9MEuI8gG4llxQ53V0kYSPvn5lrDwutu6/DYRx6VjpQYVfJd51EQbPmID3gDKm GHUDQOp5VUeeawM1C/hJbeJA41SXQvtH70oGHHV78Sff89LWEXVd8Gv8yaJyxexrArfk M1BQagoYDRN9uPhfeQX9pOcAkLyPFJYpNBTi6aXD9ZmnGJlFQcJ3/m/MiCMFFudivc56 DImg== 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=QiiTLx4J3Rq2i0DJJV9Cz+JFpE6QW7LVFLjNNbjqNzY=; b=z+zyEbVhU5Qz20Fv7DRGjSHXXb3FJVWlgwlvpGeAj97OaQPrU05zeH0HV4ABUnDKFf toctpPiLKV/v2oD7RrsiWi5MQEv/dy/aBw948qMQC9PtzWmz4+kDzdSuHn/AlhdHTI50 ujicv5V8GmZHzeCRbXjwe+gfGMrdYSuhpP2STW3G4SDtp6eLgVXPPHwI+QOq2Oxs5ssm Cabcwa7iSEb5kJMmx+cFAClj9tjq/LbkhEOOjHCAxNZFqbyrdCuQRC/1wGO3ZPZO42LH VcVkpOeH/+0doiUFDY5CHF9ylLlA24FFQ/hN7y2QKdXDnOcnlMn9QkENKu8rVDUMO8v+ GeFQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=A5ym05p9; 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 c18-v6si670664qkg.61.2018.06.09.20.17.12 for (version=TLS1 cipher=AES128-SHA bits=128/128); Sat, 09 Jun 2018 20:17:12 -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=A5ym05p9; 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]:42252 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fRqqu-0005pn-AK for patch@linaro.org; Sat, 09 Jun 2018 23:17:12 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:40300) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fRqdM-00025a-IB for qemu-devel@nongnu.org; Sat, 09 Jun 2018 23:03:15 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fRqdL-0003LC-CC for qemu-devel@nongnu.org; Sat, 09 Jun 2018 23:03:12 -0400 Received: from mail-pg0-x242.google.com ([2607:f8b0:400e:c05::242]:40841) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fRqdL-0003Ku-40 for qemu-devel@nongnu.org; Sat, 09 Jun 2018 23:03:11 -0400 Received: by mail-pg0-x242.google.com with SMTP id l2-v6so8127289pgc.7 for ; Sat, 09 Jun 2018 20:03:10 -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=QiiTLx4J3Rq2i0DJJV9Cz+JFpE6QW7LVFLjNNbjqNzY=; b=A5ym05p9RQEqNofqSk1boSz6+0Q9rtulP5L+CeV0LrOag85Ko4FVPSyaOvXbRX/Lbl 4PYlDqa2rCUL02G2EG0bjEV9wicCD6rfsfGr2nEaiiEJFiXhcYsjYopHiHuyv0dUybd5 AulAIDK50gSWxBZKbxAIAXTI67Hh/u5mpofLQ= 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=QiiTLx4J3Rq2i0DJJV9Cz+JFpE6QW7LVFLjNNbjqNzY=; b=X8t4czaZcrPn3KDJq80A+6xdTKVZ/vu/2C/8gkqEN+xOy4tWLh+DTtR3WthzEjubio xbe1gupX+wGW392KMs+O6rhhlPzb7wKATvTB16vBhR9OBGYzLMOJrROUqgH7XKyY5S/K 9F4Zb8YF6CxxTxbv/KeVVWNdokN1qku1g6Z5VuWtPfUDgz8R4czryzcjF1Xo+/nQYa+H yP/uXuokSr0WiZYQ8prBuDl77GiVXnUrVdMSOad/PMR0Brn1G9bxqdxY/MbqMDOjQRLA 2LjGc2yFDxg/T5+qgrylhGJvPHQexvfZdZqwvWItjhH0HCaWMGZ3s2xKGQQyL11u+L+1 tGnA== X-Gm-Message-State: APt69E3TICZSCxn8b13CwFMhfxDLTug/yqkrL/+LOVXMe7GfPlsmt9Fw 2nHCEbLgHVA9X8Ui0xCCnV8drE+jVDQ= X-Received: by 2002:a65:5d8a:: with SMTP id f10-v6mr10631476pgt.119.1528599789910; Sat, 09 Jun 2018 20:03:09 -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.07 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sat, 09 Jun 2018 20:03:09 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Sat, 9 Jun 2018 17:00:53 -1000 Message-Id: <20180610030220.3777-22-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::242 Subject: [Qemu-devel] [PATCH v2 021/108] linux-user: Split out alarm, pause, stime, utime, utimes 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" Signed-off-by: Richard Henderson --- linux-user/syscall.c | 155 ++++++++++++++++++++++++++----------------- 1 file changed, 93 insertions(+), 62 deletions(-) -- 2.17.1 diff --git a/linux-user/syscall.c b/linux-user/syscall.c index 844e771488..d5f7519e62 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -7871,6 +7871,13 @@ static abi_long impl_##NAME(void *cpu_env, unsigned num, abi_long arg1, \ abi_long arg5, abi_long arg6, abi_long arg7, \ abi_long arg8) +#ifdef TARGET_NR_alarm +IMPL(alarm) +{ + return alarm(arg1); +} +#endif + IMPL(brk) { return do_brk(arg1); @@ -8319,6 +8326,17 @@ IMPL(open_by_handle_at) } #endif +#ifdef TARGET_NR_pause +IMPL(pause) +{ + if (!block_signals()) { + CPUState *cpu = ENV_GET_CPU(cpu_env); + sigsuspend(&((TaskState *)cpu->opaque)->signal_mask); + } + return -TARGET_EINTR; +} +#endif + IMPL(read) { abi_long ret; @@ -8339,6 +8357,17 @@ IMPL(read) return ret; } +#ifdef TARGET_NR_stime +IMPL(stime) +{ + time_t host_time; + if (get_user_sal(host_time, arg1)) { + return -TARGET_EFAULT; + } + return get_errno(stime(&host_time)); +} +#endif + #ifdef TARGET_NR_time IMPL(time) { @@ -8394,6 +8423,55 @@ IMPL(unlinkat) return ret; } +#ifdef TARGET_NR_utime +IMPL(utime) +{ + struct utimbuf tbuf; + char *p; + abi_long ret; + + if (arg2) { + struct target_utimbuf *target_tbuf; + if (!lock_user_struct(VERIFY_READ, target_tbuf, arg2, 1)) { + return -TARGET_EFAULT; + } + tbuf.actime = tswapal(target_tbuf->actime); + tbuf.modtime = tswapal(target_tbuf->modtime); + unlock_user_struct(target_tbuf, arg2, 0); + } + p = lock_user_string(arg1); + if (!p) { + return -TARGET_EFAULT; + } + ret = get_errno(utime(p, arg2 ? &tbuf : NULL)); + unlock_user(p, arg1, 0); + return ret; +} +#endif + +#ifdef TARGET_NR_utimes +IMPL(utimes) +{ + struct timeval tv[2]; + char *p; + abi_long ret; + + if (arg2 && + (copy_from_user_timeval(&tv[0], arg2) || + copy_from_user_timeval(&tv[1], + arg2 + sizeof(struct target_timeval)))) { + return -TARGET_EFAULT; + } + p = lock_user_string(arg1); + if (!p) { + return -TARGET_EFAULT; + } + ret = get_errno(utimes(p, arg2 ? tv : NULL)); + unlock_user(p, arg1, 0); + return ret; +} +#endif + IMPL(waitid) { siginfo_t info; @@ -8467,68 +8545,6 @@ static abi_long do_syscall1(void *cpu_env, unsigned num, abi_long arg1, void *p; switch(num) { -#ifdef TARGET_NR_stime /* not on alpha */ - case TARGET_NR_stime: - { - time_t host_time; - if (get_user_sal(host_time, arg1)) - return -TARGET_EFAULT; - return get_errno(stime(&host_time)); - } -#endif -#ifdef TARGET_NR_alarm /* not on alpha */ - case TARGET_NR_alarm: - return alarm(arg1); -#endif -#ifdef TARGET_NR_pause /* not on alpha */ - case TARGET_NR_pause: - if (!block_signals()) { - sigsuspend(&((TaskState *)cpu->opaque)->signal_mask); - } - return -TARGET_EINTR; -#endif -#ifdef TARGET_NR_utime - case TARGET_NR_utime: - { - struct utimbuf tbuf, *host_tbuf; - struct target_utimbuf *target_tbuf; - if (arg2) { - if (!lock_user_struct(VERIFY_READ, target_tbuf, arg2, 1)) - return -TARGET_EFAULT; - tbuf.actime = tswapal(target_tbuf->actime); - tbuf.modtime = tswapal(target_tbuf->modtime); - unlock_user_struct(target_tbuf, arg2, 0); - host_tbuf = &tbuf; - } else { - host_tbuf = NULL; - } - if (!(p = lock_user_string(arg1))) - return -TARGET_EFAULT; - ret = get_errno(utime(p, host_tbuf)); - unlock_user(p, arg1, 0); - } - return ret; -#endif -#ifdef TARGET_NR_utimes - case TARGET_NR_utimes: - { - struct timeval *tvp, tv[2]; - if (arg2) { - if (copy_from_user_timeval(&tv[0], arg2) - || copy_from_user_timeval(&tv[1], - arg2 + sizeof(struct target_timeval))) - return -TARGET_EFAULT; - tvp = tv; - } else { - tvp = NULL; - } - if (!(p = lock_user_string(arg1))) - return -TARGET_EFAULT; - ret = get_errno(utimes(p, tvp)); - unlock_user(p, arg1, 0); - } - return ret; -#endif #if defined(TARGET_NR_futimesat) case TARGET_NR_futimesat: { @@ -12528,6 +12544,9 @@ static impl_fn *syscall_table(unsigned num) /* * Other syscalls listed in collation order, with '_' ignored. */ +#ifdef TARGET_NR_alarm + SYSCALL(alarm); +#endif SYSCALL(brk); SYSCALL(close); SYSCALL(chdir); @@ -12567,8 +12586,14 @@ static impl_fn *syscall_table(unsigned num) SYSCALL(openat); #ifdef CONFIG_OPEN_BY_HANDLE SYSCALL(open_by_handle_at); +#endif +#ifdef TARGET_NR_pause + SYSCALL(pause); #endif SYSCALL(read); +#ifdef TARGET_NR_stime + SYSCALL(stime); +#endif #ifdef TARGET_NR_time SYSCALL(time); #endif @@ -12579,6 +12604,12 @@ static impl_fn *syscall_table(unsigned num) SYSCALL(unlink); #endif SYSCALL(unlinkat); +#ifdef TARGET_NR_utime + SYSCALL(utime); +#endif +#ifdef TARGET_NR_utimes + SYSCALL(utimes); +#endif SYSCALL(waitid); #ifdef TARGET_NR_waitpid SYSCALL(waitpid);