From nobody Wed Nov 5 17:27:42 2025 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.zoho.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 1496798095259897.6418840563963; Tue, 6 Jun 2017 18:14:55 -0700 (PDT) Received: from localhost ([::1]:40752 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dIPYj-00026l-Lf for importer@patchew.org; Tue, 06 Jun 2017 21:14:53 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:34370) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dIOto-0003Un-LC for qemu-devel@nongnu.org; Tue, 06 Jun 2017 20:32:37 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dIOtn-0002FY-Im for qemu-devel@nongnu.org; Tue, 06 Jun 2017 20:32:36 -0400 Received: from mail-qt0-x243.google.com ([2607:f8b0:400d:c0d::243]:34083) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1dIOtn-0002FQ-F0 for qemu-devel@nongnu.org; Tue, 06 Jun 2017 20:32:35 -0400 Received: by mail-qt0-x243.google.com with SMTP id o21so22863055qtb.1 for ; Tue, 06 Jun 2017 17:32:35 -0700 (PDT) Received: from bigtime.twiddle.net.com (71-217-91-69.tukw.qwest.net. [71.217.91.69]) by smtp.gmail.com with ESMTPSA id m47sm29286qtc.36.2017.06.06.17.32.33 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 06 Jun 2017 17:32:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references; bh=h4RuZ57yDJwk0W7cRl6L+jphFefUipej2+QivMFpoxQ=; b=CpNUCKC6C92UUCnmvkIUphxkaFHIDFXQWLtNe1aVPHfNiigX9RCEKF46y5f316GQI/ +rt3gtkBuExWF310i9Q+kqLMYTvWkRkMEcci+9WZPH8K+nm9TUdWVpPZfcQeC8uU1552 FFhNGUVF+nSZhDlhivglo3U+Wje7wnPCnCQe823VyEqdfCQPp1n1jCRR5WzWGt0ROzuG eraJGc4Tlikx1irO1NkAkU8MUSeLiBx7QRUz0RawgbhR0RyrbFTdtHtCz14G1W8Su2+Y syusPZIbKVu+4xVvruZujju9DPeiz7Y6YmeDLyEy+sNbgOLqtq6i0k9hkI9E6J5oKUWB kucw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references; bh=h4RuZ57yDJwk0W7cRl6L+jphFefUipej2+QivMFpoxQ=; b=jkGahtvqzCoPYO9nIwRA9IdDkJxvqm4yMtpWhCQWdUzTYnfk74fdFTwh9fd4eAHp/Z o6a+bQ3nUHsOfey//IbqexLHrIxDAiZeTvv8PIE/RtEEaDUNdhey9dk64S8cERqV4MN4 prmrVQcfRPXcRJ14fBJUjj890DBLL8/TPhv18tZsF//nBBJbFEU95hQ4iT2aUG11iwXx jXoX8mqzsYsJW9nbwd9IHoXMWSDeQugesJKc2mg/7SevUOdONi6MrhpmqgNws1DzdE3q 0RhCBgeHdxoIz1gkAtqltQR8A3QIYYVT63HlTxd9UewIjP8SOVQRt/bag+0E+hLciq2w JCVQ== X-Gm-Message-State: AODbwcClwsqnLFvqiicd5fzN/2fnaVdMWzCWKfB+ApQHzW9sWi++nDL9 Law8qtS+8BUESezltKE= X-Received: by 10.237.60.218 with SMTP id e26mr26679653qtf.106.1496795554716; Tue, 06 Jun 2017 17:32:34 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Tue, 6 Jun 2017 17:31:03 -0700 Message-Id: <20170607003119.14778-55-rth@twiddle.net> X-Mailer: git-send-email 2.9.4 In-Reply-To: <20170607003119.14778-1-rth@twiddle.net> References: <20170607003119.14778-1-rth@twiddle.net> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:400d:c0d::243 Subject: [Qemu-devel] [PULL v2 54/70] target/s390x: fix COMPARE LOGICAL LONG EXTENDED 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@linaro.org, aurelien@aurel32.net 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" From: Aurelien Jarno There are multiple issues with the COMPARE LOGICAL LONG EXTENDED instruction: - The test between the two operands is inverted, leading to an inversion of the cc values 1 and 2. - The address and length of an operand continue to be decreased after reaching the end of this operand. These values are then wrong write back to the registers. - We should limit the amount of bytes to process, so that interrupts can be served correctly. At the same time rename dest into src1 and src into src3 to match the operand names and make the code less confusing. Reviewed-by: Richard Henderson Signed-off-by: Aurelien Jarno Message-Id: <20170531220129.27724-18-aurelien@aurel32.net> Signed-off-by: Richard Henderson --- target/s390x/mem_helper.c | 54 ++++++++++++++++++++++++++++++++-----------= ---- target/s390x/translate.c | 20 +++++++++++++----- 2 files changed, 52 insertions(+), 22 deletions(-) diff --git a/target/s390x/mem_helper.c b/target/s390x/mem_helper.c index 83c32c4..e30020c 100644 --- a/target/s390x/mem_helper.c +++ b/target/s390x/mem_helper.c @@ -666,35 +666,55 @@ uint32_t HELPER(clcle)(CPUS390XState *env, uint32_t r= 1, uint64_t a2, uint32_t r3) { uintptr_t ra =3D GETPC(); - uint64_t destlen =3D get_length(env, r1 + 1); - uint64_t dest =3D get_address(env, r1); - uint64_t srclen =3D get_length(env, r3 + 1); - uint64_t src =3D get_address(env, r3); + uint64_t src1len =3D get_length(env, r1 + 1); + uint64_t src1 =3D get_address(env, r1); + uint64_t src3len =3D get_length(env, r3 + 1); + uint64_t src3 =3D get_address(env, r3); uint8_t pad =3D a2 & 0xff; + uint64_t len =3D MAX(src1len, src3len); uint32_t cc =3D 0; =20 - if (!(destlen || srclen)) { + if (!len) { return cc; } =20 - if (srclen > destlen) { - srclen =3D destlen; + /* Lest we fail to service interrupts in a timely manner, limit the + amount of work we're willing to do. For now, let's cap at 8k. */ + if (len > 0x2000) { + len =3D 0x2000; + cc =3D 3; } =20 - for (; destlen || srclen; src++, dest++, destlen--, srclen--) { - uint8_t v1 =3D srclen ? cpu_ldub_data_ra(env, src, ra) : pad; - uint8_t v2 =3D destlen ? cpu_ldub_data_ra(env, dest, ra) : pad; - if (v1 !=3D v2) { - cc =3D (v1 < v2) ? 1 : 2; + for (; len; len--) { + uint8_t v1 =3D pad; + uint8_t v3 =3D pad; + + if (src1len) { + v1 =3D cpu_ldub_data_ra(env, src1, ra); + } + if (src3len) { + v3 =3D cpu_ldub_data_ra(env, src3, ra); + } + + if (v1 !=3D v3) { + cc =3D (v1 < v3) ? 1 : 2; break; } + + if (src1len) { + src1++; + src1len--; + } + if (src3len) { + src3++; + src3len--; + } } =20 - set_length(env, r1 + 1, destlen); - /* can't use srclen here, we trunc'ed it */ - set_length(env, r3 + 1, env->regs[r3 + 1] - src - env->regs[r3]); - set_address(env, r1, dest); - set_address(env, r3, src); + set_length(env, r1 + 1, src1len); + set_length(env, r3 + 1, src3len); + set_address(env, r1, src1); + set_address(env, r3, src3); =20 return cc; } diff --git a/target/s390x/translate.c b/target/s390x/translate.c index a21de09..ecd0a91 100644 --- a/target/s390x/translate.c +++ b/target/s390x/translate.c @@ -1922,11 +1922,21 @@ static ExitStatus op_clc(DisasContext *s, DisasOps = *o) =20 static ExitStatus op_clcle(DisasContext *s, DisasOps *o) { - TCGv_i32 r1 =3D tcg_const_i32(get_field(s->fields, r1)); - TCGv_i32 r3 =3D tcg_const_i32(get_field(s->fields, r3)); - gen_helper_clcle(cc_op, cpu_env, r1, o->in2, r3); - tcg_temp_free_i32(r1); - tcg_temp_free_i32(r3); + int r1 =3D get_field(s->fields, r1); + int r3 =3D get_field(s->fields, r3); + TCGv_i32 t1, t3; + + /* r1 and r3 must be even. */ + if (r1 & 1 || r3 & 1) { + gen_program_exception(s, PGM_SPECIFICATION); + return EXIT_NORETURN; + } + + t1 =3D tcg_const_i32(r1); + t3 =3D tcg_const_i32(r3); + gen_helper_clcle(cc_op, cpu_env, t1, o->in2, t3); + tcg_temp_free_i32(t1); + tcg_temp_free_i32(t3); set_cc_static(s); return NO_EXIT; } --=20 2.9.4