From patchwork Fri Jan 18 21:30:44 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 156071 Delivered-To: patch@linaro.org Received: by 2002:a02:48:0:0:0:0:0 with SMTP id 69csp3740436jaa; Fri, 18 Jan 2019 13:50:47 -0800 (PST) X-Google-Smtp-Source: ALg8bN4BMEGcusqTvTivy+AlA4k3XuyPHZS+NKVrLA7d42mzybW0nNUe/wgcEbMWdEBXC/5ItpJ4 X-Received: by 2002:adf:9b11:: with SMTP id b17mr18488117wrc.168.1547848247288; Fri, 18 Jan 2019 13:50:47 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1547848247; cv=none; d=google.com; s=arc-20160816; b=XtbtNK7yV+ukX/NUkzxWs1A/qeY4lr3CFz0/zQ6OCGaNuYKFcr1ZIN+3KTzOtNALNp XGjJzO4mbEEUT0Gxv+6tvQ19lfKe9uZ62b1plDyuVyLccPlhHF4oot/6A2i/PEhOvU4T RDGciNAlP7YQBMZZEqj61lXREq1Cmt2v5mGzKWKFKhBENBYIUD5ULNK2yje8kHzJehEi 8ncEzOBrj8w7UJAwiy/31fcHq0QSPipTv/qVkYaBSQoiRuqcbpoErd2sRlapsCiQXTkO UhcSapezQz5Us9ma2dN7foi+R/iKLsbi7R7Pi87p4LwFpCqh4OZNjW2gyWfYf9XkXyag IXrg== 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; bh=Aqf9UEWPigqViOeOjucwyE9XXkOX9SJjCTh9tkuco54=; b=r4O35Rb/VnsLHKlCR4cpcIYYmPNx3q2q8e8ykfxu6nH+UEsdAk0ouGnm6U3QlREsDd 66HzQO0yOfGCB5xJY5pW8XY94B9Oz3+8trr75M7eJPK+r+lVwOJuZKuNCCuj7n+k2a6v JpOVRbwwUUT6MO+epixx8YQhQbiW4lVwfqy+VX2/VUI3uNvK4FzRlWfbiE1Ydjzr/G+Y bTOX1q1eNC+NAS2Swa3VT4u/ltON1XYtxx8eN7BVdp0GC9AJy20bk64Law5WwHBJQSpy oGxMk6sy7kXI14oWFIxBfzPATKcp978Wl0vkN0qgeZ3vfuHvzcGD7cvTZ5GSFkF+78EE bJqQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=cVjoLfRM; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 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. [209.51.188.17]) by mx.google.com with ESMTPS id n4si30180025wrv.386.2019.01.18.13.50.47 for (version=TLS1 cipher=AES128-SHA bits=128/128); Fri, 18 Jan 2019 13:50:47 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=cVjoLfRM; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 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 ([127.0.0.1]:47667 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gkc2I-0003Nh-3N for patch@linaro.org; Fri, 18 Jan 2019 16:50:46 -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) 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-Received: by 2002:a17:902:14e:: with SMTP id 72mr20873369plb.287.1547847113059; Fri, 18 Jan 2019 13:31:53 -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) 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+patch=linaro.org@nongnu.org Sender: "Qemu-devel" 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(-) -- 2.17.2 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 = impl_pread64, + .args = args_pread64_pwrite64, + .arg_type = { ARG_DEC, ARG_PTR, ARG_DEC, ARG_DEC64 }); +SYSCALL_DEF_FULL(pwrite64, .impl = impl_pwrite64, + .args = args_pread64_pwrite64, + .arg_type = { 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); } +/* + * Both pread64 and pwrite64 merge args into a 64-bit offset, + * but the input registers and ordering are target specific. + */ +#if TARGET_ABI_BITS == 32 +SYSCALL_ARGS(pread64_pwrite64) +{ + /* We have already assigned out[0-2]. */ + int off = regpairs_aligned(cpu_env, TARGET_NR_pread64); + out[3] = target_offset64(in[3 + off], in[4 + off]); + return def; +} +#else +#define args_pread64_pwrite64 NULL +#endif + +SYSCALL_IMPL(pread64) +{ + int fd = arg1; + abi_ulong target_buf = arg2; + abi_ulong len = arg3; + uint64_t off = arg4; + void *p; + abi_long ret; + + if (target_buf == 0 && len == 0) { + /* Special-case NULL buffer and zero length, which should succeed */ + p = NULL; + } else { + p = lock_user(VERIFY_WRITE, target_buf, len, 0); + if (!p) { + return -TARGET_EFAULT; + } + } + ret = get_errno(pread64(fd, p, len, off)); + unlock_user(p, target_buf, ret); + return ret; +} + +SYSCALL_IMPL(pwrite64) +{ + int fd = arg1; + abi_ulong target_buf = arg2; + abi_ulong len = arg3; + uint64_t off = arg4; + void *p; + abi_long ret; + + if (target_buf == 0 && len == 0) { + /* Special-case NULL buffer and zero length, which should succeed */ + p = 0; + } else { + p = lock_user(VERIFY_READ, target_buf, len, 1); + if (!p) { + return -TARGET_EFAULT; + } + } + ret = get_errno(pwrite64(fd, p, len, off)); + unlock_user(p, target_buf, 0); + return ret; +} + SYSCALL_IMPL(read) { int fd = 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 = arg5; - arg5 = arg6; - } - if (arg2 == 0 && arg3 == 0) { - /* Special-case NULL buffer and zero length, which should succeed */ - p = 0; - } else { - p = lock_user(VERIFY_WRITE, arg2, arg3, 0); - if (!p) { - return -TARGET_EFAULT; - } - } - ret = get_errno(pread64(arg1, p, arg3, target_offset64(arg4, arg5))); - unlock_user(p, arg2, ret); - return ret; - case TARGET_NR_pwrite64: - if (regpairs_aligned(cpu_env, num)) { - arg4 = arg5; - arg5 = arg6; - } - if (arg2 == 0 && arg3 == 0) { - /* Special-case NULL buffer and zero length, which should succeed */ - p = 0; - } else { - p = lock_user(VERIFY_READ, arg2, arg3, 1); - if (!p) { - return -TARGET_EFAULT; - } - } - ret = get_errno(pwrite64(arg1, p, arg3, target_offset64(arg4, arg5))); - unlock_user(p, arg2, 0); - return ret; #endif case TARGET_NR_getcwd: if (!(p = 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