From nobody Fri May 3 22:55:23 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.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 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=gmail.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 152289262257473.16672215910171; Wed, 4 Apr 2018 18:43:42 -0700 (PDT) Received: from localhost ([::1]:46585 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1f3twD-0007ia-Pw for importer@patchew.org; Wed, 04 Apr 2018 21:43:41 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:58754) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1f3tuP-0006hJ-Is for qemu-devel@nongnu.org; Wed, 04 Apr 2018 21:41:50 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1f3tuO-0003LC-NE for qemu-devel@nongnu.org; Wed, 04 Apr 2018 21:41:49 -0400 Received: from mail-wm0-x243.google.com ([2a00:1450:400c:c09::243]:37777) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1f3tuO-0003Js-Gu for qemu-devel@nongnu.org; Wed, 04 Apr 2018 21:41:48 -0400 Received: by mail-wm0-x243.google.com with SMTP id r131so2208959wmb.2 for ; Wed, 04 Apr 2018 18:41:48 -0700 (PDT) Received: from octofox.hsd1.ca.comcast.net. (jcmvbkbc-1-pt.tunnel.tserv24.sto1.ipv6.he.net. [2001:470:27:1fa::2]) by smtp.gmail.com with ESMTPSA id k66sm1088032lje.82.2018.04.04.18.41.44 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 04 Apr 2018 18:41:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=xUEbcO2omjpCOy0q7IsqSzcqSJaRrfWMWbo3fKCAeaw=; b=TXH55d+tEIV6jhFsXZSSORQ0+edAo05QTFexRo/Hsf1dA1iPc/18n8p84GrzI+OU05 nbr8mgimsPAUbOzjdLKu9+wHWgWZ3Rxo6yRXFEJjB+WTUQLJTvEeEsw9wjd7Q2ZaZqQp YaSfvwS0RcliueiHI9UNeXVkcY4A/kTbouQFR372OEOn+MAO1uhXRspPEibMJmbbEbKE yb8B14iNmWnoh8Vys7igi/3iTf74v0mVX5dbdx5SNueXOvaZ4VcUu1Pe+MhoTcJocgBG qSjzZeYJJT+J13g6cr9m3d02ydlaUlsbauwH1YfL+14Zw3oqRl8QSeQKjXUWcpH2mXDr MQSA== 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; bh=xUEbcO2omjpCOy0q7IsqSzcqSJaRrfWMWbo3fKCAeaw=; b=rr+vprp+SuaGJxdQZTsgvzF4WnKOQlYNW+vzz50Lzj7GCcp1XLYqQn4KkKzvJWqFqv ZtsBdCVrxGoTa7h2IUwwfnATGzSDoJhfu76Jwbustfypmk1AKuEmNC0cS5VSvYj6X4xQ RKeuEWMVr09GTtITK41HKBOUVz9yqnyF36fX8r/8A+kWQJeL1yL0RRgJ/9ptxGAEdjEi 1gGbeRWKkheey8mrAadj44Xp/F6nkTGMTWL3gsPRNj/+svt+XcwhBR3S4vejJLLMu2Z9 hWIWOlOFa4p8PiHEpchyIAp2jR15xvlSUH7BQk3dXVkpSnpB8R4wKXSEUUVRxVadGsbc Yv9g== X-Gm-Message-State: ALQs6tC6K68QY4lxPwyB78XwczQeRIR7gBMWEdYH/UbTfdVqlXd90/CF Gk1A9pghhB9QO3xmHuBTl79AWQ== X-Google-Smtp-Source: AIpwx4+PG6s2wCv1lacCaL1yRb9XTHviJKr8yP6VOAxKo4ULDgEndhhg8r8yPeUdq2hT2CuULihreQ== X-Received: by 10.46.153.73 with SMTP id r9mr12332137ljj.7.1522892507105; Wed, 04 Apr 2018 18:41:47 -0700 (PDT) From: Max Filippov To: qemu-devel@nongnu.org Date: Wed, 4 Apr 2018 18:41:35 -0700 Message-Id: <20180405014135.3235-1-jcmvbkbc@gmail.com> X-Mailer: git-send-email 2.11.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:400c:c09::243 Subject: [Qemu-devel] [PATCH v2] linux-user: fix preadv/pwritev offsets 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: Peter Maydell , Riku Voipio , Laurent Vivier , Max Filippov Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" preadv/pwritev accept low and high parts of file offset in two separate parameters. When host bitness doesn't match guest bitness these parts must be appropriately recombined. Introduce target_low_high_to_host_low_high that does this recombination and use it in preadv/pwritev syscalls. This fixes glibc testsuite test misc/tst-preadvwritev64. Signed-off-by: Max Filippov --- Changes v1->v2: - fix host high computation in TARGET_LONG_BITS > HOST_LONG_BITS case linux-user/syscall.c | 27 +++++++++++++++++++++++++-- 1 file changed, 25 insertions(+), 2 deletions(-) diff --git a/linux-user/syscall.c b/linux-user/syscall.c index 5ef517613577..7e014066260a 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -3386,6 +3386,23 @@ static abi_long do_getsockopt(int sockfd, int level,= int optname, return ret; } =20 +static void target_low_high_to_host_low_high(abi_ulong tlow, + abi_ulong thigh, + unsigned long *hlow, + unsigned long *hhigh) +{ +#if TARGET_LONG_BITS =3D=3D HOST_LONG_BITS + *hlow =3D tlow; + *hhigh =3D thigh; +#elif TARGET_LONG_BITS < HOST_LONG_BITS + *hlow =3D tlow | (unsigned long)thigh << TARGET_LONG_BITS; + *hhigh =3D 0; +#else + *hlow =3D (unsigned long)tlow; + *hhigh =3D (unsigned long)(tlow >> HOST_LONG_BITS); +#endif +} + static struct iovec *lock_iovec(int type, abi_ulong target_addr, abi_ulong count, int copy) { @@ -10449,7 +10466,10 @@ abi_long do_syscall(void *cpu_env, int num, abi_lo= ng arg1, { struct iovec *vec =3D lock_iovec(VERIFY_WRITE, arg2, arg3, 0); if (vec !=3D NULL) { - ret =3D get_errno(safe_preadv(arg1, vec, arg3, arg4, arg5)= ); + unsigned long low, high; + + target_low_high_to_host_low_high(arg4, arg5, &low, &high); + ret =3D get_errno(safe_preadv(arg1, vec, arg3, low, high)); unlock_iovec(vec, arg2, arg3, 1); } else { ret =3D -host_to_target_errno(errno); @@ -10462,7 +10482,10 @@ abi_long do_syscall(void *cpu_env, int num, abi_lo= ng arg1, { struct iovec *vec =3D lock_iovec(VERIFY_READ, arg2, arg3, 1); if (vec !=3D NULL) { - ret =3D get_errno(safe_pwritev(arg1, vec, arg3, arg4, arg5= )); + unsigned long low, high; + + target_low_high_to_host_low_high(arg4, arg5, &low, &high); + ret =3D get_errno(safe_pwritev(arg1, vec, arg3, low, high)= ); unlock_iovec(vec, arg2, arg3, 0); } else { ret =3D -host_to_target_errno(errno); --=20 2.11.0