From nobody Fri Nov 7 11:58:43 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1547848351235345.96548125622667; Fri, 18 Jan 2019 13:52:31 -0800 (PST) Received: from localhost ([127.0.0.1]:47678 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gkc3y-0004a1-4J for importer@patchew.org; Fri, 18 Jan 2019 16:52:30 -0500 Received: from eggs.gnu.org ([209.51.188.92]:55848) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gkbk3-0004qb-Ix for qemu-devel@nongnu.org; Fri, 18 Jan 2019 16:31:56 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gkbk2-0004EU-JZ for qemu-devel@nongnu.org; Fri, 18 Jan 2019 16:31:55 -0500 Received: from mail-pl1-x641.google.com ([2607:f8b0:4864:20::641]:38216) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1gkbk2-0004Dq-DI for qemu-devel@nongnu.org; Fri, 18 Jan 2019 16:31:54 -0500 Received: by mail-pl1-x641.google.com with SMTP id e5so6883429plb.5 for ; Fri, 18 Jan 2019 13:31:54 -0800 (PST) Received: from cloudburst.twiddle.net ([2001:8000:10e0:a000:c673:a6b6:fdef:1933]) by smtp.gmail.com with ESMTPSA id v12sm5833667pgg.41.2019.01.18.13.31.50 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 18 Jan 2019 13:31:52 -0800 (PST) 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=Aqf9UEWPigqViOeOjucwyE9XXkOX9SJjCTh9tkuco54=; b=cVjoLfRMkXL2xpvb1CTCOb5rPutl1FwnmgaEqXbz7/tGIrDvio4bHXWQ15B75bjCXF 4Oud3GAd2xeej8BKa5SQWh4SN4yUQDRoYtyQa8AyhTUDLXNzs7l7a5ug3zmLP9/rAHaJ RM77UTummptIMFUJUnmVGII9NGTxAdTMnUrrQ= 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=Aqf9UEWPigqViOeOjucwyE9XXkOX9SJjCTh9tkuco54=; b=BUziLvop3Ivu+SzH+A6g8MK0Op+nnv74ZZDEbeYuqbuOysMvW4QfS+dfhmf6oMUnfy WgmvQOWdWtns1dkTRGNC1uDsGstYx9xt/ytNWzRZqq8Ng5gkmGPRyItGr6e7zg1KntYK cKv9TO65hww4e4SBeq0UeRaPrT21O3du4OR5Pg5TmFt0jOW5VZrr6eG77j69UbN+1Wqt faL8TGs+vDjTCY2aETMbTqqPlyZkxhHvJi4jriIhFgV5FtvPvHFR4IRbRry3y5Ic9b2Z cQBctBxiZFVFPtB3fK8OYSbjrEBAjRqBYK52zWTzNEUUU+CzvEdh05aSEdobgCdHQDR7 6Hlg== X-Gm-Message-State: AJcUukcTkTxLaaA3Wym6y4B42NLtT4DqcB1iYtRNM5AYdFYBqrbnUR2T eR5LSNuf1CA3nbXb+aZlp1x4E1zqdG4= X-Google-Smtp-Source: ALg8bN7TnMteECP8BH68V7r8H1nvYXumnmIlQK/Toy6kQac+eHlS6HkjV/GXZe+EVXj0mR0ypbgnkQ== X-Received: by 2002:a17:902:14e:: with SMTP id 72mr20873369plb.287.1547847113059; Fri, 18 Jan 2019 13:31:53 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Date: Sat, 19 Jan 2019 08:30:44 +1100 Message-Id: <20190118213122.22865-11-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.2 In-Reply-To: <20190118213122.22865-1-richard.henderson@linaro.org> References: <20190118213122.22865-1-richard.henderson@linaro.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4864:20::641 Subject: [Qemu-devel] [PATCH v6 11/49] linux-user: Split out pread64, pwrite64 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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Signed-off-by: Richard Henderson --- linux-user/syscall-defs.h | 6 ++++ linux-user/syscall-file.inc.c | 62 +++++++++++++++++++++++++++++++++++ linux-user/syscall.c | 36 -------------------- linux-user/strace.list | 6 ---- 4 files changed, 68 insertions(+), 42 deletions(-) diff --git a/linux-user/syscall-defs.h b/linux-user/syscall-defs.h index 130ba7e344..027793d5d0 100644 --- a/linux-user/syscall-defs.h +++ b/linux-user/syscall-defs.h @@ -21,6 +21,12 @@ SYSCALL_DEF(close, ARG_DEC); SYSCALL_DEF(open, ARG_STR, ARG_OPENFLAG, ARG_MODEFLAG); #endif SYSCALL_DEF(openat, ARG_ATDIRFD, ARG_STR, ARG_OPENFLAG, ARG_MODEFLAG); +SYSCALL_DEF_FULL(pread64, .impl =3D impl_pread64, + .args =3D args_pread64_pwrite64, + .arg_type =3D { ARG_DEC, ARG_PTR, ARG_DEC, ARG_DEC64 }); +SYSCALL_DEF_FULL(pwrite64, .impl =3D impl_pwrite64, + .args =3D args_pread64_pwrite64, + .arg_type =3D { ARG_DEC, ARG_PTR, ARG_DEC, ARG_DEC64 }); SYSCALL_DEF(read, ARG_DEC, ARG_PTR, ARG_DEC); #ifdef TARGET_NR_readlink SYSCALL_DEF(readlink, ARG_STR, ARG_PTR, ARG_DEC); diff --git a/linux-user/syscall-file.inc.c b/linux-user/syscall-file.inc.c index 9bd21ac5cd..e79cfabf56 100644 --- a/linux-user/syscall-file.inc.c +++ b/linux-user/syscall-file.inc.c @@ -317,6 +317,68 @@ SYSCALL_IMPL(openat) return do_openat(cpu_env, arg1, arg2, arg3, arg4); } =20 +/* + * Both pread64 and pwrite64 merge args into a 64-bit offset, + * but the input registers and ordering are target specific. + */ +#if TARGET_ABI_BITS =3D=3D 32 +SYSCALL_ARGS(pread64_pwrite64) +{ + /* We have already assigned out[0-2]. */ + int off =3D regpairs_aligned(cpu_env, TARGET_NR_pread64); + out[3] =3D target_offset64(in[3 + off], in[4 + off]); + return def; +} +#else +#define args_pread64_pwrite64 NULL +#endif + +SYSCALL_IMPL(pread64) +{ + int fd =3D arg1; + abi_ulong target_buf =3D arg2; + abi_ulong len =3D arg3; + uint64_t off =3D arg4; + void *p; + abi_long ret; + + if (target_buf =3D=3D 0 && len =3D=3D 0) { + /* Special-case NULL buffer and zero length, which should succeed = */ + p =3D NULL; + } else { + p =3D lock_user(VERIFY_WRITE, target_buf, len, 0); + if (!p) { + return -TARGET_EFAULT; + } + } + ret =3D get_errno(pread64(fd, p, len, off)); + unlock_user(p, target_buf, ret); + return ret; +} + +SYSCALL_IMPL(pwrite64) +{ + int fd =3D arg1; + abi_ulong target_buf =3D arg2; + abi_ulong len =3D arg3; + uint64_t off =3D arg4; + void *p; + abi_long ret; + + if (target_buf =3D=3D 0 && len =3D=3D 0) { + /* Special-case NULL buffer and zero length, which should succeed = */ + p =3D 0; + } else { + p =3D lock_user(VERIFY_READ, target_buf, len, 1); + if (!p) { + return -TARGET_EFAULT; + } + } + ret =3D get_errno(pwrite64(fd, p, len, off)); + unlock_user(p, target_buf, 0); + return ret; +} + SYSCALL_IMPL(read) { int fd =3D arg1; diff --git a/linux-user/syscall.c b/linux-user/syscall.c index df47ee106e..80806c0150 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -9312,42 +9312,6 @@ static abi_long do_syscall1(void *cpu_env, int num, = abi_long arg1, #else #error unreachable #endif -#endif -#ifdef TARGET_NR_pread64 - case TARGET_NR_pread64: - if (regpairs_aligned(cpu_env, num)) { - arg4 =3D arg5; - arg5 =3D arg6; - } - if (arg2 =3D=3D 0 && arg3 =3D=3D 0) { - /* Special-case NULL buffer and zero length, which should succ= eed */ - p =3D 0; - } else { - p =3D lock_user(VERIFY_WRITE, arg2, arg3, 0); - if (!p) { - return -TARGET_EFAULT; - } - } - ret =3D get_errno(pread64(arg1, p, arg3, target_offset64(arg4, arg= 5))); - unlock_user(p, arg2, ret); - return ret; - case TARGET_NR_pwrite64: - if (regpairs_aligned(cpu_env, num)) { - arg4 =3D arg5; - arg5 =3D arg6; - } - if (arg2 =3D=3D 0 && arg3 =3D=3D 0) { - /* Special-case NULL buffer and zero length, which should succ= eed */ - p =3D 0; - } else { - p =3D lock_user(VERIFY_READ, arg2, arg3, 1); - if (!p) { - return -TARGET_EFAULT; - } - } - ret =3D get_errno(pwrite64(arg1, p, arg3, target_offset64(arg4, ar= g5))); - unlock_user(p, arg2, 0); - return ret; #endif case TARGET_NR_getcwd: if (!(p =3D lock_user(VERIFY_WRITE, arg1, arg2, 0))) diff --git a/linux-user/strace.list b/linux-user/strace.list index e02a854cea..c7e573669d 100644 --- a/linux-user/strace.list +++ b/linux-user/strace.list @@ -1025,9 +1025,6 @@ #ifdef TARGET_NR_prctl { TARGET_NR_prctl, "prctl" , NULL, NULL, NULL }, #endif -#ifdef TARGET_NR_pread64 -{ TARGET_NR_pread64, "pread64" , NULL, NULL, NULL }, -#endif #ifdef TARGET_NR_preadv { TARGET_NR_preadv, "preadv" , NULL, NULL, NULL }, #endif @@ -1055,9 +1052,6 @@ #ifdef TARGET_NR_putpmsg { TARGET_NR_putpmsg, "putpmsg" , NULL, NULL, NULL }, #endif -#ifdef TARGET_NR_pwrite64 -{ TARGET_NR_pwrite64, "pwrite64" , NULL, NULL, NULL }, -#endif #ifdef TARGET_NR_pwritev { TARGET_NR_pwritev, "pwritev" , NULL, NULL, NULL }, #endif --=20 2.17.2