From patchwork Sun Jun 10 03:01:06 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 138108 Delivered-To: patch@linaro.org Received: by 2002:a2e:970d:0:0:0:0:0 with SMTP id r13-v6csp2587310lji; Sat, 9 Jun 2018 20:27:20 -0700 (PDT) X-Google-Smtp-Source: ADUXVKI/8Zt3dvBm7x29F5uz6FjVxcdLAQCvF0A07gw1qJQiQgih4PWBzinC+NmseEwJqYT2FbUC X-Received: by 2002:a0c:fa02:: with SMTP id q2-v6mr10849244qvn.180.1528601240069; Sat, 09 Jun 2018 20:27:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1528601240; cv=none; d=google.com; s=arc-20160816; b=fQEm7KUFs8w8kgTXuuLWVAaE9XdPA3eNA/+97QREQV9gP74NSE7hGU2paIfXMd3Nmc NApFj3489tb1XnRyfKdzoOT1M8IyF3DcWugoBQb2ehhq17f4Y6cQDNjYrKq6y/pm6sV0 GXLNje3XII59Epl+AYjo9+0RKxbSl0jcRtPu58EvhkOHnoLIrFgOkWSIQ92tn0LNuTGZ 9A3tRgdXIJfoAbIX0YN67bzRtgtirXzWhcKGk0Vq7YkGAp7zUqjQ+5UNUqNMApqRHqSQ Bc8yJDn97CdwA9H5jUcV23zeyumV/TIuOMVawefL84IOzaYtNYBT6Ec3H3iHsYoaQftz povA== 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=+mg4OSZtYr0DKnNd7OfrN+O8v56yUUa43TFaTkc9T0w=; b=C+CbW9mS2r7GgE1bhhYIuGSX9cLi1QontysZoMDeUIP3tlRzMkrFFPEWeTMGktVdac TQ9CSow2AhTGJLLatQ/XhPEZJnCmF4J1lCH28OfREc+x8m0XcPadocaihTtaey4tYfAQ 30ZoAUfMkua7M1jbBu/41Eo2WV9poJUO/yJw23ihA3yN8EbPV3gFcW9sStDZtqVjk1DJ RZ2FKlzF3Rph+r74NuDz4UeFxjmrZIN0HuF4v+1vRbgf4ALhZ5Hf7NOs3hza0UVrX9ZX oOzjeloN/1gY1chWK4/gyPZ9AEHmssOlWluGMPNVQhtqZu7xRIJKqiw5uwduQ09IF7t4 VS6A== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=i8y18Wdr; 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 g9-v6si1421706qtb.376.2018.06.09.20.27.19 for (version=TLS1 cipher=AES128-SHA bits=128/128); Sat, 09 Jun 2018 20:27:20 -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=i8y18Wdr; 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]:42306 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fRr0h-0005od-E9 for patch@linaro.org; Sat, 09 Jun 2018 23:27:19 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:40546) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fRqdt-0002aC-16 for qemu-devel@nongnu.org; Sat, 09 Jun 2018 23:03:48 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fRqdp-0003YR-TY for qemu-devel@nongnu.org; Sat, 09 Jun 2018 23:03:45 -0400 Received: from mail-pf0-x231.google.com ([2607:f8b0:400e:c00::231]:43002) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fRqdp-0003YF-Lf for qemu-devel@nongnu.org; Sat, 09 Jun 2018 23:03:41 -0400 Received: by mail-pf0-x231.google.com with SMTP id w7-v6so8478356pfn.9 for ; Sat, 09 Jun 2018 20:03:41 -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=+mg4OSZtYr0DKnNd7OfrN+O8v56yUUa43TFaTkc9T0w=; b=i8y18WdrJEf0632SjsW8Fn8Lz9Ur0gnYc+TvwCrbj/Ls1fk89mnS5kzRKvxgJehTOa 5xfX7BPnNtFgDjgHeBftSLnZRnNfpqTyqW+LtSs1YgkRsnXOMFtaX5sMPCL9vEB0IzaT +o9xVTVd5o28ivDvSikz2UD3xTTmHcJxqJcWA= 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=+mg4OSZtYr0DKnNd7OfrN+O8v56yUUa43TFaTkc9T0w=; b=AA4jrsAFlRYaW4dQR3xrDiP/2vFXUGhfRqY+Vl8x4feW85FgMDqDuuKkM/lkCfbeFb jkBCLbA5Fr+C9tgIJu3b6rMn82XCb9jreKXHEpWjD+UbylfBUz0yiHugXE5TmsMQsPTd 9dcsq24vQaCAvBgmbUQobI+ow0cl6ZvZMhbxelyX+bblc1Ec9R0LEmI/J+ujGCSO7m3H NBT80Wn3SeicD8Qa7LACOwQS03coUBn6wRucd4HwlZ5tGaPxbMe9tRK7GcCP2TXXGnQE YkyJlw+gQkierJwU0KBOokN6QNf19YK8D6kAndftbS/LL4VZbrU525qZ4+5l4K9vzY8U 7OfA== X-Gm-Message-State: APt69E2e3D9I7W7VmfLk1AnuJGDBkDeF0OPdYrrPB9zrv9+6UxUbrRUz sYA/Y72Z99Hb/wYtdZgDR7qwZp5h0bI= X-Received: by 2002:a65:5d8a:: with SMTP id f10-v6mr10632693pgt.119.1528599820414; Sat, 09 Jun 2018 20:03:40 -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.38 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sat, 09 Jun 2018 20:03:39 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Sat, 9 Jun 2018 17:01:06 -1000 Message-Id: <20180610030220.3777-35-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:c00::231 Subject: [Qemu-devel] [PATCH v2 034/108] linux-user: Split out getrlimit, getrusage, gettimeofday, settimeofday 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 | 117 ++++++++++++++++++++++--------------------- 1 file changed, 61 insertions(+), 56 deletions(-) -- 2.17.1 diff --git a/linux-user/syscall.c b/linux-user/syscall.c index ac3592d776..4c5292efed 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -8152,6 +8152,49 @@ IMPL(getppid) } #endif +IMPL(getrlimit) +{ + int resource = target_to_host_resource(arg1); + struct target_rlimit *target_rlim; + struct rlimit rlim; + abi_long ret; + + ret = get_errno(getrlimit(resource, &rlim)); + if (!is_error(ret)) { + if (!lock_user_struct(VERIFY_WRITE, target_rlim, arg2, 0)) { + return -TARGET_EFAULT; + } + target_rlim->rlim_cur = host_to_target_rlim(rlim.rlim_cur); + target_rlim->rlim_max = host_to_target_rlim(rlim.rlim_max); + unlock_user_struct(target_rlim, arg2, 1); + } + return ret; +} + +IMPL(getrusage) +{ + struct rusage rusage; + abi_long ret; + + ret = get_errno(getrusage(arg1, &rusage)); + if (!is_error(ret) && host_to_target_rusage(arg2, &rusage)) { + return -TARGET_EFAULT; + } + return ret; +} + +IMPL(gettimeofday) +{ + struct timeval tv; + abi_long ret; + + ret = get_errno(gettimeofday(&tv, NULL)); + if (!is_error(ret) && copy_to_user_timeval(arg1, &tv)) { + return -TARGET_EFAULT; + } + return ret; +} + #if defined(TARGET_NR_getxpid) && defined(TARGET_ALPHA) IMPL(getxpid) { @@ -8910,6 +8953,20 @@ IMPL(setrlimit) return get_errno(setrlimit(resource, &rlim)); } +IMPL(settimeofday) +{ + struct timeval tv; + struct timezone tz; + + if (arg1 && copy_from_user_timeval(&tv, arg1)) { + return -TARGET_EFAULT; + } + if (arg2 && copy_from_user_timezone(&tz, arg2)) { + return -TARGET_EFAULT; + } + return get_errno(settimeofday(arg1 ? &tv : NULL, arg2 ? &tz : NULL)); +} + IMPL(setsid) { return get_errno(setsid()); @@ -9385,62 +9442,6 @@ static abi_long do_syscall1(void *cpu_env, unsigned num, abi_long arg1, void *p; switch(num) { - case TARGET_NR_getrlimit: - { - int resource = target_to_host_resource(arg1); - struct target_rlimit *target_rlim; - struct rlimit rlim; - - ret = get_errno(getrlimit(resource, &rlim)); - if (!is_error(ret)) { - if (!lock_user_struct(VERIFY_WRITE, target_rlim, arg2, 0)) - return -TARGET_EFAULT; - target_rlim->rlim_cur = host_to_target_rlim(rlim.rlim_cur); - target_rlim->rlim_max = host_to_target_rlim(rlim.rlim_max); - unlock_user_struct(target_rlim, arg2, 1); - } - } - return ret; - case TARGET_NR_getrusage: - { - struct rusage rusage; - ret = get_errno(getrusage(arg1, &rusage)); - if (!is_error(ret)) { - ret = host_to_target_rusage(arg2, &rusage); - } - } - return ret; - case TARGET_NR_gettimeofday: - { - struct timeval tv; - ret = get_errno(gettimeofday(&tv, NULL)); - if (!is_error(ret)) { - if (copy_to_user_timeval(arg1, &tv)) - return -TARGET_EFAULT; - } - } - return ret; - case TARGET_NR_settimeofday: - { - struct timeval tv, *ptv = NULL; - struct timezone tz, *ptz = NULL; - - if (arg1) { - if (copy_from_user_timeval(&tv, arg1)) { - return -TARGET_EFAULT; - } - ptv = &tv; - } - - if (arg2) { - if (copy_from_user_timezone(&tz, arg2)) { - return -TARGET_EFAULT; - } - ptz = &tz; - } - - return get_errno(settimeofday(ptv, ptz)); - } #if defined(TARGET_NR_select) case TARGET_NR_select: #if defined(TARGET_WANT_NI_OLD_SELECT) @@ -12737,6 +12738,9 @@ static impl_fn *syscall_table(unsigned num) #ifdef TARGET_NR_getppid SYSCALL(getppid); #endif + SYSCALL(getrlimit); + SYSCALL(getrusage); + SYSCALL(gettimeofday); #if defined(TARGET_NR_getxpid) && defined(TARGET_ALPHA) SYSCALL(getxpid); #endif @@ -12801,6 +12805,7 @@ static impl_fn *syscall_table(unsigned num) SYSCALL(sethostname); SYSCALL(setpgid); SYSCALL(setrlimit); + SYSCALL(settimeofday); SYSCALL(setsid); #ifdef TARGET_NR_sigaction SYSCALL(sigaction);