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: 927226 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=2001:4830:134:3::11; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b="A5ym05p9"; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 413LtQ1FrTz9ry1 for ; Sun, 10 Jun 2018 13:17:34 +1000 (AEST) Received: from localhost ([::1]:42252 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fRqrD-0005pn-OF for incoming@patchwork.ozlabs.org; Sat, 09 Jun 2018 23:17:31 -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-Google-Smtp-Source: ADUXVKIvS+arliR8eQtql1HuMH+xRoSZv1iCoISGViDVW0w6YTNutn9bSWUx+5BoJi9e8g1f/jyZXQ== 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+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" Signed-off-by: Richard Henderson --- linux-user/syscall.c | 155 ++++++++++++++++++++++++++----------------- 1 file changed, 93 insertions(+), 62 deletions(-) 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);