From patchwork Fri Jun 1 07:30:39 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 137487 Delivered-To: patch@linaro.org Received: by 2002:a2e:9706:0:0:0:0:0 with SMTP id r6-v6csp619846lji; Fri, 1 Jun 2018 00:53:41 -0700 (PDT) X-Google-Smtp-Source: ADUXVKKan1M+o1HyR9OUKbGY4ZUlxeTQZc271qpJ2FgxW0QsaG/UcWCZzA9vHqBKqBGmH9XBh3zG X-Received: by 2002:a0c:8cc5:: with SMTP id q5-v6mr9531012qvb.60.1527839621173; Fri, 01 Jun 2018 00:53:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1527839621; cv=none; d=google.com; s=arc-20160816; b=IIA0/k4AjwUSbiftFdM4a9Bg11nvtesjiKdhh7+cyNyGGVTpSFDjPFzGTrIS+EU9sU Ii2ENJ7Ql9JsyuwTOCkrjmfPp2b4vMqOLZReU59wsUqypD9fbOFXRBTaQ5aUv+Gvh+cN 0PpBzD/aOFUIzjKM5KRTFeX0ec+GEPdrF9V/z2TK0LWUbdy9Ve0kFEPaJeGKk7ljCVda ZFwp9GFVWF4gyzpWp0hNXTFQ2W9nvZh04saSsxcXDO9xUC7PlNfY+hHJ8xf4YbLkqxy0 2UvmOl+19UZB2A1mhStQs2IKGxkOyTBeC7oF6FuDLt2F6yrr1XoVZP8EH/SF/wpRGhdK YVgA== 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=ZvVg5wK8954hL+atm32Ly9+uBWGfMj4n89S+TMlRezQ=; b=Pn+jRw+E9y6L4VlE7TvniBDahHDliu78Z+2KT6meAajqHXte3XIPBbPIfUEpQ8unnZ 9hcuZflIZdvCvfRbUY2kNxQJekqMogMLXBLVZH/Pu1aIi1taBeSDEk80SaospgJCqAw7 01/5m/5tH6IINyJx+rYdxUGwohIFsP83mzlm0LcCvWcmV3bdgsMyRlvlbg/VcWRrAMa2 dIbX5o8elvaGpE0lNVqlNqccyBr2tyUU7lbUmvoEp4lo54QHv5tFoHQ2LgvjvsZtsrjq BJeUDd/ZC+VLj+g1DzviJMQ4cILvf3bNxCmKsO4RVAXTx14eNDXvxqMAVqhfyxslWjM8 isYA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=AJmfXCBP; 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 e37-v6si6936847qtb.5.2018.06.01.00.53.40 for (version=TLS1 cipher=AES128-SHA bits=128/128); Fri, 01 Jun 2018 00:53:41 -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=AJmfXCBP; 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]:47928 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fOesW-0005q4-KU for patch@linaro.org; Fri, 01 Jun 2018 03:53:40 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:57599) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fOeX2-0005mN-HM for qemu-devel@nongnu.org; Fri, 01 Jun 2018 03:31:29 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fOeX0-0000fp-9G for qemu-devel@nongnu.org; Fri, 01 Jun 2018 03:31:28 -0400 Received: from mail-pg0-x244.google.com ([2607:f8b0:400e:c05::244]:33008) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fOeX0-0000eX-1q for qemu-devel@nongnu.org; Fri, 01 Jun 2018 03:31:26 -0400 Received: by mail-pg0-x244.google.com with SMTP id e11-v6so1684922pgq.0 for ; Fri, 01 Jun 2018 00:31:25 -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=ZvVg5wK8954hL+atm32Ly9+uBWGfMj4n89S+TMlRezQ=; b=AJmfXCBPnQ4bWtRMWx+mMGJZYKu+RuKAo07SYb8PeUVDvZsboBUlok6eM0sD0sPlu3 kHeHz0OMqrIUMXNQca8TBfVTR8pLS1WEwp9MQ9U+/NoYoPxC4PreLTvBJxTgchg8BxaN oL4KA0JORINlfSc5RsfAVPWTqeIoK0chMLzoU= 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=ZvVg5wK8954hL+atm32Ly9+uBWGfMj4n89S+TMlRezQ=; b=KznbJY8BLtZ45c+XsaM+dH53+WJApH292X1Ne10c/CsoMmYXEAw5USPcyrU8GUIKyF svJLNaO+clHQ6MfHSR4YIUEEERT7Pjr5yz4Lv1/g4TJRhKsevZsjs6uSwfjtpD1A1ABW cmGEUi/j7TnFYgpXPcVxy0s3Dvht0z+fK7fmEFhOVBI/hfhs1qUil143CsElI2OvYhE9 dGHlESXmWXzWCMBd+hNtGZbn8j2yo1rgmQJwaGsEtf4hyjlDc7RoELvbav7RVYCHO9ez N45EIqHmnwP7odvOA+r8ybsxFWBB1a7D7NsDX/XGCyFgMMjl/ct9XzeT+IyzyPYp7VhD KvaA== X-Gm-Message-State: ALKqPwd05EnN77NARuT1uiLOfLN5EbdR+dNxnQGYIIUfrVmhMluy6Zud PoVh3+UB9MvnLwrhpx5bKtRcBMUzGZc= X-Received: by 2002:a62:4c04:: with SMTP id z4-v6mr9671130pfa.205.1527838284798; Fri, 01 Jun 2018 00:31:24 -0700 (PDT) Received: from cloudburst.twiddle.net (97-126-112-211.tukw.qwest.net. [97.126.112.211]) by smtp.gmail.com with ESMTPSA id c4-v6sm4431782pgv.86.2018.06.01.00.31.23 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 01 Jun 2018 00:31:23 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Fri, 1 Jun 2018 00:30:39 -0700 Message-Id: <20180601073050.8054-23-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180601073050.8054-1-richard.henderson@linaro.org> References: <20180601073050.8054-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::244 Subject: [Qemu-devel] [PATCH 22/33] 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 | 156 ++++++++++++++++++++++++++----------------- 1 file changed, 94 insertions(+), 62 deletions(-) -- 2.17.0 diff --git a/linux-user/syscall.c b/linux-user/syscall.c index 53eac58ec0..b3838c5161 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -7894,6 +7894,13 @@ IMPL(enosys) return do_unimplemented(num); } +#ifdef TARGET_NR_alarm +IMPL(alarm) +{ + return alarm(arg1); +} +#endif + IMPL(brk) { return do_brk(arg1); @@ -8379,6 +8386,18 @@ IMPL(open_by_handle_at) } #endif +#ifdef TARGET_NR_pause +IMPL(pause) +{ + CPUState *cpu = ENV_GET_CPU(cpu_env); + + if (!block_signals()) { + sigsuspend(&((TaskState *)cpu->opaque)->signal_mask); + } + return -TARGET_EINTR; +} +#endif + IMPL(read) { abi_long ret; @@ -8402,6 +8421,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) { @@ -8463,6 +8493,55 @@ IMPL(unlinkat) } #endif +#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 + #ifdef TARGET_NR_waitid IMPL(waitid) { @@ -8539,68 +8618,6 @@ IMPL(everything_else) char *fn; 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: if (is_hostfd(arg1)) { @@ -12856,6 +12873,9 @@ IMPL(everything_else) } static impl_fn * const syscall_table[] = { +#ifdef TARGET_NR_alarm + [TARGET_NR_alarm] = impl_alarm, +#endif [TARGET_NR_brk] = impl_brk, [TARGET_NR_close] = impl_close, [TARGET_NR_chdir] = impl_chdir, @@ -12899,8 +12919,14 @@ static impl_fn * const syscall_table[] = { [TARGET_NR_openat] = impl_openat, #if defined(TARGET_NR_open_by_handle_at) && defined(CONFIG_OPEN_BY_HANDLE) [TARGET_NR_open_by_handle_at] = impl_open_by_handle_at, +#endif +#ifdef TARGET_NR_pause + [TARGET_NR_pause] = impl_pause, #endif [TARGET_NR_read] = impl_read, +#ifdef TARGET_NR_stime + [TARGET_NR_stime] = impl_stime, +#endif #ifdef TARGET_NR_time [TARGET_NR_time] = impl_time, #endif @@ -12913,6 +12939,12 @@ static impl_fn * const syscall_table[] = { #if TARGET_NR_unlinkat [TARGET_NR_unlinkat] = impl_unlinkat, #endif +#ifdef TARGET_NR_utime + [TARGET_NR_utime] = impl_utime, +#endif +#ifdef TARGET_NR_utimes + [TARGET_NR_utimes] = impl_utimes, +#endif #ifdef TARGET_NR_waitid [TARGET_NR_waitid] = impl_waitid, #endif