From patchwork Sun Jun 10 03:01:25 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 138137 Delivered-To: patch@linaro.org Received: by 2002:a2e:970d:0:0:0:0:0 with SMTP id r13-v6csp2598695lji; Sat, 9 Jun 2018 20:48:08 -0700 (PDT) X-Google-Smtp-Source: ADUXVKJVqt1/5UW9pRhWRy47ck8ZSXa+7hdnvP0s6X0CBYNG5ROfA97+7H1RqrNgX44ZgTY299WT X-Received: by 2002:a37:660f:: with SMTP id a15-v6mr10547529qkc.440.1528602488529; Sat, 09 Jun 2018 20:48:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1528602488; cv=none; d=google.com; s=arc-20160816; b=YzbmrSvTui1axQt6LyrsELJmFBjoDFlpOhx2ttnVro+iP1gVgyjC+HsfqtvwqSueDG d2TUow1PtKp+KZVbrd2bTeocJVJVrZWUsShEP6o3ZAn7Gg3JCvh1cqoW1vqlFAFpKF0h kQUJDxPQLgCE9d9u/6tC4spZtCtyRMJYOhkvbwrjlk173bPPK3EYf3+PQuUzY8PJds+T TlqO7ruf4gxjpeeqTsp23MMfMat+Pm3lubbMc30kOVbKy372BZPrGjF5IAj5Dr39DJYn 0VvmGjfnT8SBXIAdPwLYFzch/kbdrr6sLjgi0kyYRaBbO4iYN5igSAei+N9++fbDB2VX seqA== 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=r/JZ9Kq3fbaGkjGRdS3WOr/GkHVFl9LVGQIvJBANdVs=; b=dILBbbHU1A8hGS4e7n6Rwjk/RyHbRAdyIYCYuqwt2BWx52q5EvTck609n5IAXnoLb+ O50gmne+J6bX9Lv2FTLncbSRvSUdwN+DJ1PP21tjZFWksFiJ0baKk6zBdFngaiFLjSN/ pQ9qR2TLd8xE7YEKvnkSw87uQCJSwQYafvAG0Jn3tJHoxo44dR6vgvxVKVOaW0fOLBL+ R52teRxN088JA+YtcVieJqu60BTguy+1XyCc8VCmO4eeUyfsXeMzWQQZPkOqdy5C6dSL pRgQxpN5IB/2h7l4gP9xiIFGEaZQSKIJM3eWfBC5CPuLPu9VV7lz+06whihqELw3O3Ik 71vA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=JZCDQ5Ir; 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 38-v6si2628729qtg.165.2018.06.09.20.48.08 for (version=TLS1 cipher=AES128-SHA bits=128/128); Sat, 09 Jun 2018 20:48:08 -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=JZCDQ5Ir; 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]:42424 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fRrKp-0000e1-V5 for patch@linaro.org; Sat, 09 Jun 2018 23:48:07 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:40825) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fRqeW-0003B8-4V for qemu-devel@nongnu.org; Sat, 09 Jun 2018 23:04:25 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fRqeU-0003lh-65 for qemu-devel@nongnu.org; Sat, 09 Jun 2018 23:04:23 -0400 Received: from mail-pf0-x244.google.com ([2607:f8b0:400e:c00::244]:34416) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fRqeT-0003lT-Ua for qemu-devel@nongnu.org; Sat, 09 Jun 2018 23:04:22 -0400 Received: by mail-pf0-x244.google.com with SMTP id a63-v6so8499317pfl.1 for ; Sat, 09 Jun 2018 20:04:21 -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=r/JZ9Kq3fbaGkjGRdS3WOr/GkHVFl9LVGQIvJBANdVs=; b=JZCDQ5Ir18RhlWJhqKYGxFrrVMyzrfnMqLXnbvFnsda+2f3QJuB4DqINggZlnOe6z+ gLhZ1a36CnsxtZAxyyNUByUWKe1ciTQXK9w3eyyQB87cCg9HWY+A+9vGSnTUCz+LAsXq UiVKdTCIJkOCbbS0KLCGPfIPRJ2eixEqZyX7Q= 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=r/JZ9Kq3fbaGkjGRdS3WOr/GkHVFl9LVGQIvJBANdVs=; b=S9V7bU7ZJw3Ta5eX9cvv8wHzTbPNrwvB3I66A0BTAk0qczRf4+Wj544vx2XGUlclz7 C00mAQdkWn0Tsl1iem6r93qILgGtyGEtGBBtiEqR43s6reAGUw9rnQ++4jtbPzmHIaWN DVwaAMsli8XLvKUbP7ms9tTPBGxaETRjy+Y7cQZbvDTTorMAVvYaaSgeBnLWXgbMqKyl lXSwnaI8hYGliuovuUNMkzI3i50Ojp8g6GHrG8SIvgHzeGgOuPuJUAKEf+ma4SSir0Ow Q5DPXG2etmRqVzX++3IdbJ+SwKry1BBl+jJq3gEvP8sZ9+APtuSCNLxgZDGsNj7l5vzW NXkQ== X-Gm-Message-State: APt69E1tbK0dVI395TgM4littVNpVQR67rYlxw1ztKQ0B+jRWQheAwxw YxkqYM3RkI3c1xtNOoRWTnUxOKI5fcE= X-Received: by 2002:a63:5ec4:: with SMTP id s187-v6mr10210562pgb.72.1528599860759; Sat, 09 Jun 2018 20:04:20 -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.04.18 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sat, 09 Jun 2018 20:04:19 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Sat, 9 Jun 2018 17:01:25 -1000 Message-Id: <20180610030220.3777-54-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::244 Subject: [Qemu-devel] [PATCH v2 053/108] linux-user: Split out swapoff, sysinfo, vhangup, wait4 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" All targets define swapoff; remove the ifdef. Signed-off-by: Richard Henderson --- linux-user/syscall.c | 140 +++++++++++++++++++++++-------------------- 1 file changed, 76 insertions(+), 64 deletions(-) -- 2.17.1 diff --git a/linux-user/syscall.c b/linux-user/syscall.c index 87374014b1..a0fbbbbb4a 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -9903,6 +9903,19 @@ IMPL(stime) } #endif +IMPL(swapoff) +{ + char *p = lock_user_string(arg1); + abi_long ret; + + if (!p) { + return -TARGET_EFAULT; + } + ret = get_errno(swapoff(p)); + unlock_user(p, arg1, 0); + return ret; +} + IMPL(swapon) { char *p = lock_user_string(arg1); @@ -9959,6 +9972,36 @@ IMPL(syncfs) } #endif +IMPL(sysinfo) +{ + struct sysinfo value; + abi_long ret = get_errno(sysinfo(&value)); + + if (!is_error(ret) && arg1) { + struct target_sysinfo *target_value; + + if (!lock_user_struct(VERIFY_WRITE, target_value, arg1, 0)) { + return -TARGET_EFAULT; + } + __put_user(value.uptime, &target_value->uptime); + __put_user(value.loads[0], &target_value->loads[0]); + __put_user(value.loads[1], &target_value->loads[1]); + __put_user(value.loads[2], &target_value->loads[2]); + __put_user(value.totalram, &target_value->totalram); + __put_user(value.freeram, &target_value->freeram); + __put_user(value.sharedram, &target_value->sharedram); + __put_user(value.bufferram, &target_value->bufferram); + __put_user(value.totalswap, &target_value->totalswap); + __put_user(value.freeswap, &target_value->freeswap); + __put_user(value.procs, &target_value->procs); + __put_user(value.totalhigh, &target_value->totalhigh); + __put_user(value.freehigh, &target_value->freehigh); + __put_user(value.mem_unit, &target_value->mem_unit); + unlock_user_struct(target_value, arg1, 1); + } + return ret; +} + IMPL(syslog) { abi_long ret; @@ -10156,6 +10199,35 @@ IMPL(utimes) } #endif +IMPL(vhangup) +{ + return get_errno(vhangup()); +} + +IMPL(wait4) +{ + int status; + struct rusage rusage; + abi_long ret; + + ret = get_errno(safe_wait4(arg1, &status, arg3, &rusage)); + if (!is_error(ret)) { + if (ret && arg2) { + status = host_to_target_waitstatus(status); + if (put_user_s32(status, arg2)) { + return -TARGET_EFAULT; + } + } + if (arg4) { + abi_long err = host_to_target_rusage(arg4, &rusage); + if (err) { + return err; + } + } + } + return ret; +} + IMPL(waitid) { siginfo_t info; @@ -10228,70 +10300,6 @@ static abi_long do_syscall1(void *cpu_env, unsigned num, abi_long arg1, void *p; switch(num) { - case TARGET_NR_vhangup: - return get_errno(vhangup()); - case TARGET_NR_wait4: - { - int status; - abi_long status_ptr = arg2; - struct rusage rusage, *rusage_ptr; - abi_ulong target_rusage = arg4; - abi_long rusage_err; - if (target_rusage) - rusage_ptr = &rusage; - else - rusage_ptr = NULL; - ret = get_errno(safe_wait4(arg1, &status, arg3, rusage_ptr)); - if (!is_error(ret)) { - if (status_ptr && ret) { - status = host_to_target_waitstatus(status); - if (put_user_s32(status, status_ptr)) - return -TARGET_EFAULT; - } - if (target_rusage) { - rusage_err = host_to_target_rusage(target_rusage, &rusage); - if (rusage_err) { - ret = rusage_err; - } - } - } - } - return ret; -#ifdef TARGET_NR_swapoff - case TARGET_NR_swapoff: - if (!(p = lock_user_string(arg1))) - return -TARGET_EFAULT; - ret = get_errno(swapoff(p)); - unlock_user(p, arg1, 0); - return ret; -#endif - case TARGET_NR_sysinfo: - { - struct target_sysinfo *target_value; - struct sysinfo value; - ret = get_errno(sysinfo(&value)); - if (!is_error(ret) && arg1) - { - if (!lock_user_struct(VERIFY_WRITE, target_value, arg1, 0)) - return -TARGET_EFAULT; - __put_user(value.uptime, &target_value->uptime); - __put_user(value.loads[0], &target_value->loads[0]); - __put_user(value.loads[1], &target_value->loads[1]); - __put_user(value.loads[2], &target_value->loads[2]); - __put_user(value.totalram, &target_value->totalram); - __put_user(value.freeram, &target_value->freeram); - __put_user(value.sharedram, &target_value->sharedram); - __put_user(value.bufferram, &target_value->bufferram); - __put_user(value.totalswap, &target_value->totalswap); - __put_user(value.freeswap, &target_value->freeswap); - __put_user(value.procs, &target_value->procs); - __put_user(value.totalhigh, &target_value->totalhigh); - __put_user(value.freehigh, &target_value->freehigh); - __put_user(value.mem_unit, &target_value->mem_unit); - unlock_user_struct(target_value, arg1, 1); - } - } - return ret; #ifdef TARGET_NR_ipc case TARGET_NR_ipc: return do_ipc(cpu_env, arg1, arg2, arg3, arg4, arg5, arg6); @@ -13100,6 +13108,7 @@ static impl_fn *syscall_table(unsigned num) #ifdef TARGET_NR_stime SYSCALL(stime); #endif + SYSCALL(swapoff); SYSCALL(swapon); #ifdef TARGET_NR_symlink SYSCALL(symlink); @@ -13109,6 +13118,7 @@ static impl_fn *syscall_table(unsigned num) #ifdef CONFIG_SYNCFS SYSCALL(syncfs); #endif + SYSCALL(sysinfo); SYSCALL(syslog); #ifdef TARGET_NR_time SYSCALL(time); @@ -13130,6 +13140,8 @@ static impl_fn *syscall_table(unsigned num) #ifdef TARGET_NR_utimes SYSCALL(utimes); #endif + SYSCALL(vhangup); + SYSCALL(wait4); SYSCALL(waitid); #ifdef TARGET_NR_waitpid SYSCALL(waitpid);