From nobody Wed Feb 11 01:09:05 2026 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=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1528603318701779.79236142105; Sat, 9 Jun 2018 21:01:58 -0700 (PDT) Received: from localhost ([::1]:42503 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fRrY6-0005Wg-UP for importer@patchew.org; Sun, 10 Jun 2018 00:01:51 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:41285) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fRqfU-00048D-9f for qemu-devel@nongnu.org; Sat, 09 Jun 2018 23:05:25 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fRqfS-0004Rp-Px for qemu-devel@nongnu.org; Sat, 09 Jun 2018 23:05:24 -0400 Received: from mail-pg0-x243.google.com ([2607:f8b0:400e:c05::243]:38930) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fRqfS-0004QX-B0 for qemu-devel@nongnu.org; Sat, 09 Jun 2018 23:05:22 -0400 Received: by mail-pg0-x243.google.com with SMTP id w12-v6so8139803pgc.6 for ; Sat, 09 Jun 2018 20:05:22 -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.05.19 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sat, 09 Jun 2018 20:05:20 -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=OXhzWrCzOnky8k7+EQTtpUJxLpSgxeCkisL1amDlPa4=; b=MMRP6Ft/HTwnpZn8ieOBlReaYXl1m16/jw71GaGLHuY9sQ+qYzOZCOasGdOSW87Pcf qW7tZ71cD+eAl79OOm98h/imDs32o/bKaipQEXVaBZWAUSjEGTgqBzVWR533Ef9AuOcw s75oTd8pvXOII6OhLYvKKik/jAOtX63UmZwmY= 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=OXhzWrCzOnky8k7+EQTtpUJxLpSgxeCkisL1amDlPa4=; b=RKS/T08Jqe/7YK+ZqGlMsX1JKDaSyc9vlazBIs8Zt1XkKEzEbkEauBuMTxyOv5mobt n9n3MEqw88U2V7dz71FRzHcVkEy/xuaxRgNg6VGtw9YxVdIsasxAs0rzapoDMrqQP21K pBk4oPIG53uE6ZkfvlvKkc4ULMDLfFITBbCoZ79/SZIDtNOtG+6/HQKrmeJCo3tc1rSN b6LY/OWdLa52NreMONbZA0pJ7rvEuAeH7aDjRGcSZxXqV1XsVpWFL9nrvlscWbJly+76 p+OMm0hF7hAOV1LTvS4c3qdMzHXW3lkzDMYho7bIy6WlUI41wBxXm/gHA5LBKQMPpZR/ p46A== X-Gm-Message-State: APt69E1CUdUDYA7zGs1BLZTZbKjjWc1/M1/jj7meH5RFxpjC9MFOa+lS JCjkgdM8EgX3t6HTP2c0xzmVNC+u1jE= X-Google-Smtp-Source: ADUXVKL45K13pTDdQ0l33grycgFSMExPKoHPZdszH4hHQG8uTphfay3tBWFTZUfpqc3BW8fE7k2k6Q== X-Received: by 2002:a65:60d2:: with SMTP id r18-v6mr5032809pgv.306.1528599921141; Sat, 09 Jun 2018 20:05:21 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Sat, 9 Jun 2018 17:01:56 -1000 Message-Id: <20180610030220.3777-85-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:c05::243 Subject: [Qemu-devel] [PATCH v2 084/108] linux-user: Split out fadvise64, fadvise64_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: 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) 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" Generalize the s390x guest advice frobbing to support s390x as a host. Signed-off-by: Richard Henderson --- linux-user/syscall.c | 189 ++++++++++++++++++++++++++----------------- 1 file changed, 113 insertions(+), 76 deletions(-) diff --git a/linux-user/syscall.c b/linux-user/syscall.c index afe6df5efa..5f056cf660 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -8110,6 +8110,109 @@ IMPL(faccessat) return ret; } =20 +/* The advise values for DONTNEED and NOREUSE differ for s390x. + * Which means that we need to translate for the host as well. + */ +static int target_to_host_fadvise64_advice(int advice) +{ + switch (advice) { + case 0 ... 3: + return advice; +#ifdef TARGET_S390X + case 6: + return POSIX_FADV_DONTNEED; + case 7: + return POSIX_FADV_NOREUSE; +#else + case 4: + return POSIX_FADV_DONTNEED; + case 5: + return POSIX_FADV_NOREUSE; +#endif + default: + return -TARGET_EINVAL; + } +} + +#if TARGET_ABI_BITS =3D=3D 32 +# ifdef TARGET_NR_fadvise64 +IMPL(fadvise64) +{ + abi_long ret; + off_t off, len; + int advice; + + /* 5 args: fd, offset (high, low), len, advice */ + if (regpairs_aligned(cpu_env, num)) { + /* offset is in (3,4), len in 5 and advice in 6 */ + off =3D target_offset64(arg3, arg4); + len =3D arg5; + advice =3D arg6; + } else { + off =3D target_offset64(arg2, arg3); + len =3D arg4; + advice =3D arg5; + } + advice =3D target_to_host_fadvise64_advice(advice); + if (advice < 0) { + return advice; + } + ret =3D posix_fadvise(arg1, off, len, advice); + return -host_to_target_errno(ret); +} +# endif +/* ??? TARGET_NR_arm_fadvise64_64 should be TARGET_NR_fadvise64_64. + * The argument ordering is the same as ppc32 and xtensa anyway. + */ +# ifdef TARGET_NR_arm_fadvise64_64 +# define TARGET_NR_fadvise64_64 TARGET_NR_arm_fadvise64_64 +# endif +# ifdef TARGET_NR_fadvise64_64 +IMPL(fadvise64_64) +{ + abi_long ret; + off_t off, len; + int advice; + +# if defined(TARGET_ARM) || defined(TARGET_PPC) || defined(TARGET_XTENSA) + /* 6 args: fd, advice, offset (high, low), len (high, low) */ + advice =3D arg2; + off =3D target_offset64(arg3, arg4); + len =3D target_offset64(arg5, arg6); +# else + /* 6 args: fd, offset (high, low), len (high, low), advice */ + if (regpairs_aligned(cpu_env, num)) { + /* offset is in (3,4), len in (5,6) and advice in 7 */ + off =3D target_offset64(arg3, arg4); + len =3D target_offset64(arg5, arg6); + advice =3D arg7; + } else { + off =3D target_offset64(arg2, arg3); + len =3D target_offset64(arg4, arg5); + advice =3D arg6; + } +# endif + advice =3D target_to_host_fadvise64_advice(advice); + if (advice < 0) { + return advice; + } + ret =3D posix_fadvise(arg1, off, len, advice); + return -host_to_target_errno(ret); +} +# endif +#else /* TARGET_ABI_BITS =3D=3D 64 */ +# if defined(TARGET_NR_fadvise64_64) || defined(TARGET_NR_fadvise64) +IMPL(fadvise64) +{ + int advice =3D target_to_host_fadvise64_advice(arg4); + if (advice < 0) { + return advice; + } + return -host_to_target_errno(posix_fadvise(arg1, arg2, arg3, advice)); +} +# endif +#endif /* end fadvise64 handling */ + IMPL(fchdir) { return get_errno(fchdir(arg1)); @@ -12011,82 +12114,6 @@ static abi_long do_syscall1(void *cpu_env, unsigne= d num, abi_long arg1, void *p; =20 switch(num) { -#ifdef TARGET_NR_arm_fadvise64_64 - case TARGET_NR_arm_fadvise64_64: - /* arm_fadvise64_64 looks like fadvise64_64 but - * with different argument order: fd, advice, offset, len - * rather than the usual fd, offset, len, advice. - * Note that offset and len are both 64-bit so appear as - * pairs of 32-bit registers. - */ - ret =3D posix_fadvise(arg1, target_offset64(arg3, arg4), - target_offset64(arg5, arg6), arg2); - return -host_to_target_errno(ret); -#endif - -#if TARGET_ABI_BITS =3D=3D 32 - -#ifdef TARGET_NR_fadvise64_64 - case TARGET_NR_fadvise64_64: -#if defined(TARGET_PPC) || defined(TARGET_XTENSA) - /* 6 args: fd, advice, offset (high, low), len (high, low) */ - ret =3D arg2; - arg2 =3D arg3; - arg3 =3D arg4; - arg4 =3D arg5; - arg5 =3D arg6; - arg6 =3D ret; -#else - /* 6 args: fd, offset (high, low), len (high, low), advice */ - 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; - arg4 =3D arg5; - arg5 =3D arg6; - arg6 =3D arg7; - } -#endif - ret =3D posix_fadvise(arg1, target_offset64(arg2, arg3), - target_offset64(arg4, arg5), arg6); - return -host_to_target_errno(ret); -#endif - -#ifdef TARGET_NR_fadvise64 - case TARGET_NR_fadvise64: - /* 5 args: fd, offset (high, low), len, advice */ - if (regpairs_aligned(cpu_env, num)) { - /* offset is in (3,4), len in 5 and advice in 6 */ - arg2 =3D arg3; - arg3 =3D arg4; - arg4 =3D arg5; - arg5 =3D arg6; - } - ret =3D posix_fadvise(arg1, target_offset64(arg2, arg3), arg4, arg= 5); - return -host_to_target_errno(ret); -#endif - -#else /* not a 32-bit ABI */ -#if defined(TARGET_NR_fadvise64_64) || defined(TARGET_NR_fadvise64) -#ifdef TARGET_NR_fadvise64_64 - case TARGET_NR_fadvise64_64: -#endif -#ifdef TARGET_NR_fadvise64 - case TARGET_NR_fadvise64: -#endif -#ifdef TARGET_S390X - switch (arg4) { - case 4: arg4 =3D POSIX_FADV_NOREUSE + 1; break; /* make sure it's = an invalid value */ - case 5: arg4 =3D POSIX_FADV_NOREUSE + 2; break; /* ditto */ - case 6: arg4 =3D POSIX_FADV_DONTNEED; break; - case 7: arg4 =3D POSIX_FADV_NOREUSE; break; - default: break; - } -#endif - return -host_to_target_errno(posix_fadvise(arg1, arg2, arg3, arg4)= ); -#endif -#endif /* end of 64-bit ABI fadvise handling */ - #ifdef TARGET_NR_madvise case TARGET_NR_madvise: /* A straight passthrough may not be safe because qemu sometimes @@ -13189,6 +13216,16 @@ static impl_fn *syscall_table(unsigned num) SYSCALL_WITH(exit_group, enosys); #endif SYSCALL(faccessat); +#ifdef TARGET_NR_fadvise64 + SYSCALL(fadvise64); +#endif +#ifdef TARGET_NR_fadvise64_64 +# if TARGET_ABI_BITS =3D=3D 32 + SYSCALL(fadvise64_64); +# else + SYSCALL_WITH(fadvise64_64, fadvise64); +# endif +#endif SYSCALL(fchdir); SYSCALL(fchmod); SYSCALL(fchmodat); --=20 2.17.1