From patchwork Sun Jun 10 03:01:37 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 138121 Delivered-To: patch@linaro.org Received: by 2002:a2e:970d:0:0:0:0:0 with SMTP id r13-v6csp2592078lji; Sat, 9 Jun 2018 20:35:42 -0700 (PDT) X-Google-Smtp-Source: ADUXVKL4VUJTh6x9wOcp+pD9BJpfJ0y/Nhf4+jEYTMcqd3XKowFlNn2GENPTGGoPWZostPw6HBiE X-Received: by 2002:ac8:247c:: with SMTP id d57-v6mr11558505qtd.155.1528601741923; Sat, 09 Jun 2018 20:35:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1528601741; cv=none; d=google.com; s=arc-20160816; b=kKWRM91smbpDZCEEGOeUL/ZXeDVwQNG0hh58rxoSdFcYGUgxSg6V3r/mqQNoBKjwci EEyU2hPdaSSSb0sBJ7JW5fg23XUIj1vhZQWBhsMx/d2NNvKX8HqMoHrFBDjC6S3BxNnY MDmRxvFNZfkanp9F+E1J15G348mFnhrAFxXfo+FHXOgpPDlkdDnnLiiWr2179WV1oJza PiheSBcfV4SgGfKL7tBdHtchwRnGga/xp+khBWhZS/yLoxQObaX8Oe1lLFquRyJzYJkb 3g8x6zdxWYwyKYgzWsSCKs3SuJyqmJ7s1ekdk5EapT3cnGa0ys3GyKrYTjL2DB42uTfH q/cw== 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=C35LhXR5lkYDxiW/MvH8SV/CPiKRDq1P2MDlJ0nUK2M=; b=BiHWOz2f4MJK6aWsPVMOl2APslHCq0bzgHCRkp87/nq0AfPRwB8SDtqHWsNgm6PuiN eazlHfSKQsmRjbXnaj296OsFcaO0kTmArmmILLYBQ3ge89cyYSG2QiO2Sz5a/NH9gRfC tEbxz4uh78f8f3bsNkuZCji5V2kDmBQpfeWAbt+UQMGBmvkH670MenNusFox8JVI6zPA InCSeXPWydbqK1UMW0TxBvvOHh0ZUSQCxoOCcWoCrEaVEdqstRr7Jaf7LdzBC6vYgYbV Igx6+WEzXyznt0m4KA2oNusRVXQLCpFNYmUbMo4r26FvttnoSvsxfsRZzT3a4cxMPC6S FY3w== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=Y+uJv/7V; 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 a17-v6si15295196qkc.297.2018.06.09.20.35.41 for (version=TLS1 cipher=AES128-SHA bits=128/128); Sat, 09 Jun 2018 20:35: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=Y+uJv/7V; 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]:42355 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fRr8n-0005aC-Ae for patch@linaro.org; Sat, 09 Jun 2018 23:35:41 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:41023) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fRqeu-0003Zo-Kb for qemu-devel@nongnu.org; Sat, 09 Jun 2018 23:04:50 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fRqet-0003zW-6B for qemu-devel@nongnu.org; Sat, 09 Jun 2018 23:04:48 -0400 Received: from mail-pf0-x242.google.com ([2607:f8b0:400e:c00::242]:42385) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fRqes-0003z9-Sw for qemu-devel@nongnu.org; Sat, 09 Jun 2018 23:04:47 -0400 Received: by mail-pf0-x242.google.com with SMTP id w7-v6so8479000pfn.9 for ; Sat, 09 Jun 2018 20:04:46 -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=C35LhXR5lkYDxiW/MvH8SV/CPiKRDq1P2MDlJ0nUK2M=; b=Y+uJv/7Va7/S2NlkSRptd5i8qkdL/I3+IxrEhXdlL111vLYAtcQ5l/lf5O/85Jzn7z w4SG98FPzIb7vt1B3IQzK/WmD7U6KZJfEdoaWRJjwa0WSAstU6SlomJpS5azvi00dz4I HwuaqXUltjwGx2BoMzPs9GCgh/UIbKhgZfttE= 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=C35LhXR5lkYDxiW/MvH8SV/CPiKRDq1P2MDlJ0nUK2M=; b=GRYh6rnwkKSGqVlbg06Be1ZzN8j35uWraw8489HKpZ6aICAvjI2VotkjuV/jvzv5Y2 x2erJ+lbZSJczTgiFE0OSdPOAD4YNUFMWcHVM40entwz7cBX+GKUraYJ7q9VFpt5M5Ud kCngaNVqCSWcK6CeiMiV+dAYmyiMIF9Pw5JmeABzeFHHFvasOsthlKVMc+0HqDdltYkv QbTHspSpYAhsznWVbbwkb6ITBZI8NsUP7It2+MYlyC9SLwMIAaLCzTx2i34/PPiHTJbS kju7ABu7/bP0Mkze1zUhwxGStuilDthV/Czeg5/sXgVotm0azHcSD/nkok136k0rEVWL 7mzg== X-Gm-Message-State: APt69E2WZFyx5HY/l0dApI1R0xk3D6zZZIX58xKNqrdCychoujcSv0Ph R29k2tCB9b0jMNuuGTu6EKN4OrxWyp8= X-Received: by 2002:a65:5d8a:: with SMTP id f10-v6mr10635070pgt.119.1528599885694; Sat, 09 Jun 2018 20:04:45 -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.43 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sat, 09 Jun 2018 20:04:44 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Sat, 9 Jun 2018 17:01:37 -1000 Message-Id: <20180610030220.3777-66-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::242 Subject: [Qemu-devel] [PATCH v2 065/108] linux-user: Split out getcpu, nanosleep, prctl 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 | 214 +++++++++++++++++++++++-------------------- 1 file changed, 114 insertions(+), 100 deletions(-) -- 2.17.1 diff --git a/linux-user/syscall.c b/linux-user/syscall.c index 84f21634c8..ee3a31f06d 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -8132,6 +8132,24 @@ IMPL(futimesat) } #endif +IMPL(getcpu) +{ + unsigned cpu, node; + abi_long ret; + + ret = get_errno(sys_getcpu(arg1 ? &cpu : NULL, arg2 ? &node : NULL, NULL)); + if (is_error(ret)) { + return ret; + } + if (arg1 && put_user_u32(cpu, arg1)) { + return -TARGET_EFAULT; + } + if (arg2 && put_user_u32(node, arg2)) { + return -TARGET_EFAULT; + } + return ret; +} + #ifdef TARGET_NR_getdents IMPL(getdents) { @@ -9004,6 +9022,25 @@ IMPL(name_to_handle_at) } #endif +IMPL(nanosleep) +{ + struct timespec req, rem; + abi_long ret; + + ret = target_to_host_timespec(&req, arg1); + if (ret < 0) { + return ret; + } + ret = safe_nanosleep(&req, &rem); + if (ret < 0) { + return -host_to_target_errno(errno); + } + if (arg2) { + return host_to_target_timespec(arg2, &rem); + } + return 0; +} + #ifdef TARGET_NR__newselect IMPL(_newselect) { @@ -9237,6 +9274,80 @@ IMPL(ppoll) return ret; } +IMPL(prctl) +{ + int deathsig; + void *name; + abi_long ret; + + switch (arg1) { + case PR_GET_PDEATHSIG: + ret = get_errno(prctl(arg1, &deathsig, arg3, arg4, arg5)); + if (!is_error(ret) && arg2 && put_user_ual(deathsig, arg2)) { + return -TARGET_EFAULT; + } + return ret; + +#ifdef PR_GET_NAME + case PR_GET_NAME: + name = lock_user(VERIFY_WRITE, arg2, 16, 1); + if (!name) { + return -TARGET_EFAULT; + } + ret = get_errno(prctl(arg1, (uintptr_t)name, arg3, arg4, arg5)); + unlock_user(name, arg2, 16); + return ret; +#endif +#ifdef PR_SET_NAME + case PR_SET_NAME: + name = lock_user(VERIFY_READ, arg2, 16, 1); + if (!name) { + return -TARGET_EFAULT; + } + ret = get_errno(prctl(arg1, (uintptr_t)name, arg3, arg4, arg5)); + unlock_user(name, arg2, 0); + return ret; +#endif +#ifdef TARGET_AARCH64 + case TARGET_PR_SVE_SET_VL: + /* We cannot support either PR_SVE_SET_VL_ONEXEC + or PR_SVE_VL_INHERIT. Therefore, anything above + ARM_MAX_VQ results in EINVAL. */ + ret = -TARGET_EINVAL; + if (arm_feature(cpu_env, ARM_FEATURE_SVE) + && arg2 >= 0 && arg2 <= ARM_MAX_VQ * 16 && !(arg2 & 15)) { + CPUARMState *env = cpu_env; + int old_vq = (env->vfp.zcr_el[1] & 0xf) + 1; + int vq = MAX(arg2 / 16, 1); + + if (vq < old_vq) { + aarch64_sve_narrow_vq(env, vq); + } + env->vfp.zcr_el[1] = vq - 1; + ret = vq * 16; + } + return ret; + + case TARGET_PR_SVE_GET_VL: + ret = -TARGET_EINVAL; + if (arm_feature(cpu_env, ARM_FEATURE_SVE)) { + CPUARMState *env = cpu_env; + ret = ((env->vfp.zcr_el[1] & 0xf) + 1) * 16; + } + return ret; +#endif /* AARCH64 */ + + case PR_GET_SECCOMP: + case PR_SET_SECCOMP: + /* Disable seccomp to prevent the target disabling syscalls we need. */ + return -TARGET_EINVAL; + + default: + /* Most prctl options have no pointer arguments */ + return get_errno(prctl(arg1, arg2, arg3, arg4, arg5)); + } +} + IMPL(preadv) { struct iovec *vec; @@ -11007,106 +11118,6 @@ static abi_long do_syscall1(void *cpu_env, unsigned num, abi_long arg1, void *p; switch(num) { - case TARGET_NR_getcpu: - { - unsigned cpu, node; - ret = get_errno(sys_getcpu(arg1 ? &cpu : NULL, - arg2 ? &node : NULL, - NULL)); - if (is_error(ret)) { - return ret; - } - if (arg1 && put_user_u32(cpu, arg1)) { - return -TARGET_EFAULT; - } - if (arg2 && put_user_u32(node, arg2)) { - return -TARGET_EFAULT; - } - } - return ret; - case TARGET_NR_nanosleep: - { - struct timespec req, rem; - target_to_host_timespec(&req, arg1); - ret = get_errno(safe_nanosleep(&req, &rem)); - if (is_error(ret) && arg2) { - host_to_target_timespec(arg2, &rem); - } - } - return ret; - case TARGET_NR_prctl: - switch (arg1) { - case PR_GET_PDEATHSIG: - { - int deathsig; - ret = get_errno(prctl(arg1, &deathsig, arg3, arg4, arg5)); - if (!is_error(ret) && arg2 - && put_user_ual(deathsig, arg2)) { - return -TARGET_EFAULT; - } - return ret; - } -#ifdef PR_GET_NAME - case PR_GET_NAME: - { - void *name = lock_user(VERIFY_WRITE, arg2, 16, 1); - if (!name) { - return -TARGET_EFAULT; - } - ret = get_errno(prctl(arg1, (unsigned long)name, - arg3, arg4, arg5)); - unlock_user(name, arg2, 16); - return ret; - } - case PR_SET_NAME: - { - void *name = lock_user(VERIFY_READ, arg2, 16, 1); - if (!name) { - return -TARGET_EFAULT; - } - ret = get_errno(prctl(arg1, (unsigned long)name, - arg3, arg4, arg5)); - unlock_user(name, arg2, 0); - return ret; - } -#endif -#ifdef TARGET_AARCH64 - case TARGET_PR_SVE_SET_VL: - /* We cannot support either PR_SVE_SET_VL_ONEXEC - or PR_SVE_VL_INHERIT. Therefore, anything above - ARM_MAX_VQ results in EINVAL. */ - ret = -TARGET_EINVAL; - if (arm_feature(cpu_env, ARM_FEATURE_SVE) - && arg2 >= 0 && arg2 <= ARM_MAX_VQ * 16 && !(arg2 & 15)) { - CPUARMState *env = cpu_env; - int old_vq = (env->vfp.zcr_el[1] & 0xf) + 1; - int vq = MAX(arg2 / 16, 1); - - if (vq < old_vq) { - aarch64_sve_narrow_vq(env, vq); - } - env->vfp.zcr_el[1] = vq - 1; - ret = vq * 16; - } - return ret; - case TARGET_PR_SVE_GET_VL: - ret = -TARGET_EINVAL; - if (arm_feature(cpu_env, ARM_FEATURE_SVE)) { - CPUARMState *env = cpu_env; - ret = ((env->vfp.zcr_el[1] & 0xf) + 1) * 16; - } - return ret; -#endif /* AARCH64 */ - case PR_GET_SECCOMP: - case PR_SET_SECCOMP: - /* Disable seccomp to prevent the target disabling syscalls we - * need. */ - return -TARGET_EINVAL; - default: - /* Most prctl options have no pointer arguments */ - return get_errno(prctl(arg1, arg2, arg3, arg4, arg5)); - } - break; #ifdef TARGET_NR_arch_prctl case TARGET_NR_arch_prctl: #if defined(TARGET_I386) && !defined(TARGET_ABI32) @@ -13004,6 +13015,7 @@ static impl_fn *syscall_table(unsigned num) #ifdef TARGET_NR_futimesat SYSCALL(futimesat); #endif + SYSCALL(getcpu); #ifdef TARGET_NR_getdents SYSCALL(getdents); #endif @@ -13099,6 +13111,7 @@ static impl_fn *syscall_table(unsigned num) #ifdef CONFIG_OPEN_BY_HANDLE SYSCALL(name_to_handle_at); #endif + SYSCALL(nanosleep); #ifdef TARGET_NR__newselect SYSCALL(_newselect); #endif @@ -13124,6 +13137,7 @@ static impl_fn *syscall_table(unsigned num) SYSCALL(poll); #endif SYSCALL(ppoll); + SYSCALL(prctl); SYSCALL(preadv); SYSCALL(pselect6); SYSCALL(pwritev);