From patchwork Sun Jun 10 03:01:31 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 138144 Delivered-To: patch@linaro.org Received: by 2002:a2e:970d:0:0:0:0:0 with SMTP id r13-v6csp2600873lji; Sat, 9 Jun 2018 20:52:16 -0700 (PDT) X-Google-Smtp-Source: ADUXVKI6kaToQMgsIojtJd8Fszx2FR8PA4YbBOE9LH1qehhx1z3i8yCD+VWdBldeuWKwQ+YWPQIn X-Received: by 2002:ac8:2384:: with SMTP id q4-v6mr11662403qtq.29.1528602736296; Sat, 09 Jun 2018 20:52:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1528602736; cv=none; d=google.com; s=arc-20160816; b=RjV97qcHfELfA2TP7g2RVIN/QQlKvUDKQiVfUT5t+ImreEhls42ZfV7m2Fdh8mtDMy rQhbg9MiKGJ1ZCqYzWbmaGk1TLwbr8xfOK/DjhL0f6V5RBkDZOclviHiqxMphXOk5/Fd KZUnYufiZT4O7S3YeQDIE0M63ZLVDLwia+RlVRDznlDlhtyN+kdZUpPgLbjFEOS3cZzc VdKCWPCeUgIaOWGfkc7gOckwMEBUnP5mp+OkxCrRrkb+5rFdy9MbpIkD84soBDRtmvmb RUAUd+64zQ0xxvtBFXHqXkZl6uS+6d3vgQvCqagdaZzHRbT3ZgPuCN5doBSCsqCPythJ r+IQ== 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=4dqj+cLBsMxzVMwLkE8oWADqdkLghraPxNYeOgC5ufg=; b=Z8Y4vbfMhCKVzbZCLrnoP5nGNtpH90vHwVlboQ/xmx0oiFV+dY2KVE7MMrcoKbjCUz nW/EcAr8vGifjw5PWI/CTwE/35wXRjFr3o7OVHfJ5/zXNtjpr0lG0h4a16fb8CrbASMp z8FNKIp2qzArYMhD2BFdmOWANSDyv05n5J7j0HoSqNl6lsQIeet8p89iW49I5NPFWqfD 9DlUZqlKQ2Av2lGb0PDGM7lfFAcg8LB916InMHfQsM24rXB+7E9sq/8T55ZBFcvQbHYA vNPFtVfIgGsPsnfHcFVTyNqbeLTNqhtKulw4OCG+LqadB0dCDpx2xL5TdFeWebfuRHXa 4dBQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=OKjNqTd7; 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 c27-v6si4034913qta.261.2018.06.09.20.52.16 for (version=TLS1 cipher=AES128-SHA bits=128/128); Sat, 09 Jun 2018 20:52:16 -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=OKjNqTd7; 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]:42446 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fRrOp-0004x1-MR for patch@linaro.org; Sat, 09 Jun 2018 23:52:15 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:40937) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fRqel-0003Q2-DF for qemu-devel@nongnu.org; Sat, 09 Jun 2018 23:04:40 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fRqei-0003rE-7C for qemu-devel@nongnu.org; Sat, 09 Jun 2018 23:04:39 -0400 Received: from mail-pf0-x244.google.com ([2607:f8b0:400e:c00::244]:46988) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fRqeh-0003r9-Vy for qemu-devel@nongnu.org; Sat, 09 Jun 2018 23:04:36 -0400 Received: by mail-pf0-x244.google.com with SMTP id q1-v6so8483019pff.13 for ; Sat, 09 Jun 2018 20:04:35 -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=4dqj+cLBsMxzVMwLkE8oWADqdkLghraPxNYeOgC5ufg=; b=OKjNqTd7RClSHDWfITBXxP/QANsVEglOZvpgZl0bnPheISXDYccqMRgwlZ65gNm31T tNfeTmye1frDmMbbkeNX9CPzQ/WNJiQQBLNkIGYkjg6twOJbG1mBDP0etOGBH+L3Z/IV 1rnT7U18H4PMNLPRLu1PzhgmIBPxE1SViFfB4= 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=4dqj+cLBsMxzVMwLkE8oWADqdkLghraPxNYeOgC5ufg=; b=iZ4iztoFAYMd54CKF5aKVRBhU79/gyBGFi4x3YtLGfvRtc5KA9NbW+Sz0RQCdz88AF P3dRYoRAB8/29xMndRoftPWSA4D3cw5/YRIbBEh4ZZ4OUnftOz26ZYiwUd7VbEGIT8za zeEiUW2ca4urWW90tez+emQeBmHx5/w/6/CeEpagJjMtugsbIWxoARKIy28yxyGwU1jo Gxe+hQeayceBkhd64e3z/Cg5+PUCIw6gXslvs5qnUV7zbbbtMPLtGusvZZ2lDmDnpvNQ 1B9XBS90aJQzMOApII/dktSA5Fpc6IzFsMj0CUKQZWqeavrwVxr8SNd7NTw0gVRPtByZ eDUw== X-Gm-Message-State: APt69E3ZVb/ALrh1MfsAK2sL3JqENWbHpMIl4tsz1NkmQubqrNGioww7 rFCQ1o15xI61ItcVjEeNfbSy2CzwfDE= X-Received: by 2002:a62:3101:: with SMTP id x1-v6mr12038833pfx.246.1528599874790; Sat, 09 Jun 2018 20:04:34 -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.33 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sat, 09 Jun 2018 20:04:33 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Sat, 9 Jun 2018 17:01:31 -1000 Message-Id: <20180610030220.3777-60-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 059/108] linux-user: Split out fchdir, getpgid, llseek, personality 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" Given that we use _LARGEFILE_SOURCE and _FILEOFFSET_BITS == 64, there is no need to special-case llseek on the host side; always use lseek. Define _llseek in terms of llseek, rather than the other way around. Signed-off-by: Richard Henderson --- linux-user/syscall.c | 81 +++++++++++++++++++++++--------------------- 1 file changed, 42 insertions(+), 39 deletions(-) -- 2.17.1 diff --git a/linux-user/syscall.c b/linux-user/syscall.c index 7ff05dd33c..f5f21658a8 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -240,15 +240,6 @@ static type name (type1 arg1,type2 arg2,type3 arg3,type4 arg4,type5 arg5, \ #define __NR_sys_inotify_add_watch __NR_inotify_add_watch #define __NR_sys_inotify_rm_watch __NR_inotify_rm_watch -#if defined(__alpha__) || defined(__x86_64__) || defined(__s390x__) -#define __NR__llseek __NR_lseek -#endif - -/* Newer kernel ports have llseek() instead of _llseek() */ -#if defined(TARGET_NR_llseek) && !defined(TARGET_NR__llseek) -#define TARGET_NR__llseek TARGET_NR_llseek -#endif - /* These definitions produce an ENOSYS from the host kernel. * Performing a bogus syscall is lazier than boilerplating * the replacement functions here in C. @@ -280,10 +271,6 @@ _syscall3(int, sys_getdents, uint, fd, struct linux_dirent *, dirp, uint, count) (defined(TARGET_NR_getdents64) && defined(__NR_getdents64)) _syscall3(int, sys_getdents64, uint, fd, struct linux_dirent64 *, dirp, uint, count); #endif -#if defined(TARGET_NR__llseek) && defined(__NR_llseek) -_syscall5(int, _llseek, uint, fd, ulong, hi, ulong, lo, - loff_t *, res, uint, wh); -#endif _syscall3(int, sys_rt_sigqueueinfo, pid_t, pid, int, sig, siginfo_t *, uinfo) _syscall4(int, sys_rt_tgsigqueueinfo, pid_t, pid, pid_t, tid, int, sig, siginfo_t *, uinfo) @@ -8026,6 +8013,11 @@ IMPL(faccessat) return ret; } +IMPL(fchdir) +{ + return get_errno(fchdir(arg1)); +} + IMPL(fchmod) { return get_errno(fchmod(arg1, arg2)); @@ -8150,6 +8142,11 @@ IMPL(getpeername) } #endif +IMPL(getpgid) +{ + return get_errno(getpgid(arg1)); +} + #ifdef TARGET_NR_getpgrp IMPL(getpgrp) { @@ -8484,6 +8481,27 @@ IMPL(listen) } #endif +/* Older kernel ports have _llseek() instead of llseek() */ +#if defined(TARGET_NR__llseek) && !defined(TARGET_NR_llseek) +#define TARGET_NR_llseek TARGET_NR__llseek +#endif + +#ifdef TARGET_NR_llseek +IMPL(llseek) +{ + off_t res; + + res = lseek(arg1, ((uint64_t)arg2 << 32) | (abi_ulong)arg3, arg5); + if (res == -1) { + return -host_to_target_errno(errno); + } + if (put_user_s64(res, arg4)) { + return -TARGET_EFAULT; + } + return 0; +} +#endif + IMPL(lseek) { return get_errno(lseek(arg1, arg2, arg3)); @@ -8901,6 +8919,11 @@ IMPL(pause) } #endif +IMPL(personality) +{ + return get_errno(personality(arg1)); +} + #ifdef TARGET_NR_pipe IMPL(pipe) { @@ -10462,32 +10485,6 @@ static abi_long do_syscall1(void *cpu_env, unsigned num, abi_long arg1, void *p; switch(num) { - case TARGET_NR_getpgid: - return get_errno(getpgid(arg1)); - case TARGET_NR_fchdir: - return get_errno(fchdir(arg1)); - case TARGET_NR_personality: - return get_errno(personality(arg1)); -#ifdef TARGET_NR__llseek /* Not on alpha */ - case TARGET_NR__llseek: - { - int64_t res; -#if !defined(__NR_llseek) - res = lseek(arg1, ((uint64_t)arg2 << 32) | (abi_ulong)arg3, arg5); - if (res == -1) { - ret = get_errno(res); - } else { - ret = 0; - } -#else - ret = get_errno(_llseek(arg1, arg2, arg3, &res, arg5)); -#endif - if ((ret == 0) && put_user_s64(res, arg4)) { - return -TARGET_EFAULT; - } - } - return ret; -#endif #ifdef TARGET_NR_getdents case TARGET_NR_getdents: #ifdef EMULATE_GETDENTS_WITH_GETDENTS @@ -12924,6 +12921,7 @@ static impl_fn *syscall_table(unsigned num) SYSCALL_WITH(exit_group, enosys); #endif SYSCALL(faccessat); + SYSCALL(fchdir); SYSCALL(fchmod); SYSCALL(fchmodat); #ifdef TARGET_NR_fcntl @@ -12946,6 +12944,7 @@ static impl_fn *syscall_table(unsigned num) #ifdef TARGET_NR_getpeername SYSCALL(getpeername); #endif + SYSCALL(getpgid); #ifdef TARGET_NR_getpgrp SYSCALL(getpgrp); #endif @@ -12980,6 +12979,9 @@ static impl_fn *syscall_table(unsigned num) SYSCALL(linkat); #ifdef TARGET_NR_listen SYSCALL(listen); +#endif +#ifdef TARGET_NR_llseek + SYSCALL(llseek); #endif SYSCALL(lseek); #ifdef TARGET_NR_lstat @@ -13042,6 +13044,7 @@ static impl_fn *syscall_table(unsigned num) #ifdef TARGET_NR_pause SYSCALL(pause); #endif + SYSCALL(personality); #ifdef TARGET_NR_pipe SYSCALL(pipe); #endif