From nobody Fri May 3 12:00:08 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 Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1505504172699146.73573701350824; Fri, 15 Sep 2017 12:36:12 -0700 (PDT) Received: from localhost ([::1]:54773 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dswPL-00082j-ME for importer@patchew.org; Fri, 15 Sep 2017 15:36:11 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:33253) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dswNM-00074e-0v for qemu-devel@nongnu.org; Fri, 15 Sep 2017 15:34:09 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dswNI-0007xb-1k for qemu-devel@nongnu.org; Fri, 15 Sep 2017 15:34:08 -0400 Received: from mail-wr0-x230.google.com ([2a00:1450:400c:c0c::230]:44098) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1dswNH-0007x8-OH for qemu-devel@nongnu.org; Fri, 15 Sep 2017 15:34:03 -0400 Received: by mail-wr0-x230.google.com with SMTP id v109so2564646wrc.1 for ; Fri, 15 Sep 2017 12:34:03 -0700 (PDT) Received: from Jamess-MacBook.local (global-184-8.nat-1.net.cam.ac.uk. [131.111.184.8]) by smtp.gmail.com with ESMTPSA id r16sm1478877wrb.43.2017.09.15.12.34.01 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 15 Sep 2017 12:34:01 -0700 (PDT) Received: by Jamess-MacBook.local (Postfix, from userid 501) id 977842555803; Fri, 15 Sep 2017 20:34:00 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=jrtc27.com; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :references:references:references; bh=UW3GxxrOv6cNhJFBmED6xBDWMobweEaOOoI05AsX7Bk=; b=lj91W6yLcBWf7IdvefdH6ual+aKKgWgRjgHHX97PM/6ZBWXHnNpG9IxuvOxXwR5ff/ gBoynpk5CXeNN2C7zu+qq0zYomh7HZo/aGAplFpF0q+MYeLtJRw3zCrLFFAV35dqNITz LoB7Jq5Yk1pVdz3AW1hYLPOZnKApDyq/YijqI= 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:references:references:references; bh=UW3GxxrOv6cNhJFBmED6xBDWMobweEaOOoI05AsX7Bk=; b=ssFFtccbZJDjIsrbXXApEMpSA/MMEs8hSTy6FVz011Wv4l4zGPqAkaMcxdvi8cXBE9 0QF8ZOhn+/ko8zfCsW10alBYxxojugnpTziPrRJenziUuLZMckaaR/nI2SC/2MwgVsAG j/VACL+RTnrEcPNkrkcHRIieh9TchKSUeoLuBBqt+i0NiNPfYGMzRI9fLvrUvQt4XD0y flm9t07VOeOk1UiWkGl8tkVaKBDXJUPIf25qnh4u5KKgPc9qaivkn35+cO8znpRCZH0C 3hxV7+7YJ2NBhSqNzbkdKTT6UOivUHSO/DiFWqzQ6pw3wKoVDGwqnVLB4LQpkP8oWCLS FlBw== X-Gm-Message-State: AHPjjUgcSBMEmzWlwxk6U+RTPQ7wqVgIDYoa+gRlMPfmDDEe8oSLnl5v PjX8+aBFNpZkpuv+ X-Google-Smtp-Source: ADKCNb58QfpFd6JHZNhriko0kQh8x7RhT6AyTm44luEOeWGZofo2DExOCaVAAdBIrtdUoWYS9531Iw== X-Received: by 10.223.146.4 with SMTP id 4mr23035612wrj.16.1505504042478; Fri, 15 Sep 2017 12:34:02 -0700 (PDT) From: James Clarke To: QEMU Developers Date: Fri, 15 Sep 2017 20:33:13 +0100 Message-Id: <20170915193313.86362-1-jrtc27@jrtc27.com> X-Mailer: git-send-email 2.14.1 In-Reply-To: <20170915190748.82389-1-jrtc27@jrtc27.com> References: <20170915065821.16600-1-jrtc27@jrtc27.com> References: <2f7283ca-6ecd-165f-c572-a0f2a781aba7@amsat.org> References: References: <20170915190748.82389-1-jrtc27@jrtc27.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:400c:c0c::230 Subject: [Qemu-devel] [PATCH v3] linux-user/syscall.c: Handle SH4's exceptional alignment for p{read, write}64 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 , Richard Henderson , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Laurent Vivier , John Paul Adrian Glaubitz , James Clarke 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" Fixes: https://bugs.launchpad.net/qemu/+bug/1716767 Signed-off-by: James Clarke Reviewed-by: Laurent Vivier Reviewed-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Richard Henderson Tested-By: John Paul Adrian Glaubitz --- Changes since v2: * Fixed opening curly brace formatting, both for my new SH4-specific regpairs_aligned function, as well as the Arm one I touched, to appease checkpatch.pl Changes since v1: * Removed all changes in v1 :) * Added syscall num argument to regpairs_aligned * Added SH4-specific implementation of regpairs_aligned to return 1 for p{read,write}64 linux-user/syscall.c | 36 +++++++++++++++++++++++++----------- 1 file changed, 25 insertions(+), 11 deletions(-) diff --git a/linux-user/syscall.c b/linux-user/syscall.c index 9b6364a266..0c1bd80bed 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -667,18 +667,32 @@ static inline int next_free_host_timer(void) =20 /* ARM EABI and MIPS expect 64bit types aligned even on pairs or registers= */ #ifdef TARGET_ARM -static inline int regpairs_aligned(void *cpu_env) { +static inline int regpairs_aligned(void *cpu_env, int num) +{ return ((((CPUARMState *)cpu_env)->eabi) =3D=3D 1) ; } #elif defined(TARGET_MIPS) && (TARGET_ABI_BITS =3D=3D 32) -static inline int regpairs_aligned(void *cpu_env) { return 1; } +static inline int regpairs_aligned(void *cpu_env, int num) { return 1; } #elif defined(TARGET_PPC) && !defined(TARGET_PPC64) /* SysV AVI for PPC32 expects 64bit parameters to be passed on odd/even pa= irs * of registers which translates to the same as ARM/MIPS, because we start= with * r3 as arg1 */ -static inline int regpairs_aligned(void *cpu_env) { return 1; } +static inline int regpairs_aligned(void *cpu_env, int num) { return 1; } +#elif defined(TARGET_SH4) +/* SH4 doesn't align register pairs, except for p{read,write}64 */ +static inline int regpairs_aligned(void *cpu_env, int num) +{ + switch (num) { + case TARGET_NR_pread64: + case TARGET_NR_pwrite64: + return 1; + + default: + return 0; + } +} #else -static inline int regpairs_aligned(void *cpu_env) { return 0; } +static inline int regpairs_aligned(void *cpu_env, int num) { return 0; } #endif =20 #define ERRNO_TABLE_SIZE 1200 @@ -6857,7 +6871,7 @@ static inline abi_long target_truncate64(void *cpu_en= v, const char *arg1, abi_long arg3, abi_long arg4) { - if (regpairs_aligned(cpu_env)) { + if (regpairs_aligned(cpu_env, TARGET_NR_truncate64)) { arg2 =3D arg3; arg3 =3D arg4; } @@ -6871,7 +6885,7 @@ static inline abi_long target_ftruncate64(void *cpu_e= nv, abi_long arg1, abi_long arg3, abi_long arg4) { - if (regpairs_aligned(cpu_env)) { + if (regpairs_aligned(cpu_env, TARGET_NR_ftruncate64)) { arg2 =3D arg3; arg3 =3D arg4; } @@ -10495,7 +10509,7 @@ abi_long do_syscall(void *cpu_env, int num, abi_lon= g arg1, #endif #ifdef TARGET_NR_pread64 case TARGET_NR_pread64: - if (regpairs_aligned(cpu_env)) { + if (regpairs_aligned(cpu_env, num)) { arg4 =3D arg5; arg5 =3D arg6; } @@ -10505,7 +10519,7 @@ abi_long do_syscall(void *cpu_env, int num, abi_lon= g arg1, unlock_user(p, arg2, ret); break; case TARGET_NR_pwrite64: - if (regpairs_aligned(cpu_env)) { + if (regpairs_aligned(cpu_env, num)) { arg4 =3D arg5; arg5 =3D arg6; } @@ -11275,7 +11289,7 @@ abi_long do_syscall(void *cpu_env, int num, abi_lon= g arg1, arg6 =3D ret; #else /* 6 args: fd, offset (high, low), len (high, low), advice */ - if (regpairs_aligned(cpu_env)) { + if (regpairs_aligned(cpu_env, num)) { /* offset is in (3,4), len in (5,6) and advice in 7 */ arg2 =3D arg3; arg3 =3D arg4; @@ -11294,7 +11308,7 @@ abi_long do_syscall(void *cpu_env, int num, abi_lon= g arg1, #ifdef TARGET_NR_fadvise64 case TARGET_NR_fadvise64: /* 5 args: fd, offset (high, low), len, advice */ - if (regpairs_aligned(cpu_env)) { + if (regpairs_aligned(cpu_env, num)) { /* offset is in (3,4), len in 5 and advice in 6 */ arg2 =3D arg3; arg3 =3D arg4; @@ -11407,7 +11421,7 @@ abi_long do_syscall(void *cpu_env, int num, abi_lon= g arg1, #ifdef TARGET_NR_readahead case TARGET_NR_readahead: #if TARGET_ABI_BITS =3D=3D 32 - if (regpairs_aligned(cpu_env)) { + if (regpairs_aligned(cpu_env, num)) { arg2 =3D arg3; arg3 =3D arg4; arg4 =3D arg5; --=20 2.13.2