From nobody Tue Nov 18 15:28:28 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1611231633; cv=none; d=zohomail.com; s=zohoarc; b=IJpqNg7aUD5ScvhNjz0GP76g3exW5PjBGhnOo6Gxtsh9y34nXt16W6zkjpvNcU3GbPc3A5KzAAR6Zyeo/L9BjLJKCojeIY2LnqFXAZa0ihGGbtUSfkVekLwgI4fxJry9hpNexGi821iDzuHCD8sD19oorZKyTYM0MvsWqYpy5mQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1611231633; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=AFQcCH1x0EcoR3ut99CgQp+Pz9H6x5dlfO6zjfwVsjY=; b=W5uyeWpV06/n7sKsYOPUP0IVVjVsewcbHzF2Erm6hyRXqH0JD92/IKJCQTxUvKivnsQ4/CsKMZYqiq9JTK8XD2jj7bxNqugUjmvK2Vu90eTYls4lS59PUEV0F/8QY/qc5W2Ow0K8z/ZR5zqOwB1IzaYkLuc7f7nhqCYU9l+qBvw= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 161123163332090.23035197767445; Thu, 21 Jan 2021 04:20:33 -0800 (PST) Received: from localhost ([::1]:60124 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1l2Ywy-00055H-8A for importer@patchew.org; Thu, 21 Jan 2021 07:20:32 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:35270) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1l2YtM-0008Gm-LP for qemu-devel@nongnu.org; Thu, 21 Jan 2021 07:16:48 -0500 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:33536) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1l2YtK-0005S0-4H for qemu-devel@nongnu.org; Thu, 21 Jan 2021 07:16:48 -0500 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-243-jS9SzspJO3uZirSPOLxh1A-1; Thu, 21 Jan 2021 07:16:42 -0500 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 5A28A8066EB; Thu, 21 Jan 2021 12:16:41 +0000 (UTC) Received: from gondolin.redhat.com (ovpn-113-94.ams2.redhat.com [10.36.113.94]) by smtp.corp.redhat.com (Postfix) with ESMTP id 76DDA100AE3E; Thu, 21 Jan 2021 12:16:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1611231405; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=AFQcCH1x0EcoR3ut99CgQp+Pz9H6x5dlfO6zjfwVsjY=; b=QXYH4rz2Yu8ARuwhePTdCzTtcISern7oUaH8SsjcRJtGyd6o9/vcPmH9x2a6l27zbhVfnm Z9weP8gIY47pVR5EdahM7wcOcL9g6y1c0dxOwoWfv4VPAIRcmC4p35yMNGgrSEw7qCJpYZ bRAoxSOyKaxE1rhm2zdRkUMq4S8vJRU= X-MC-Unique: jS9SzspJO3uZirSPOLxh1A-1 From: Cornelia Huck To: Peter Maydell Subject: [PULL 2/9] s390x/tcg: Fix RISBHG Date: Thu, 21 Jan 2021 13:16:22 +0100 Message-Id: <20210121121629.530506-3-cohuck@redhat.com> In-Reply-To: <20210121121629.530506-1-cohuck@redhat.com> References: <20210121121629.530506-1-cohuck@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=cohuck@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=216.205.24.124; envelope-from=cohuck@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -29 X-Spam_score: -3.0 X-Spam_bar: --- X-Spam_report: (-3.0 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.168, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: David Hildenbrand , Nick Desaulniers , Cornelia Huck , Richard Henderson , qemu-devel@nongnu.org, Christian Borntraeger , qemu-s390x@nongnu.org, Guenter Roeck Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" From: David Hildenbrand RISBHG is broken and currently hinders clang-11 builds of upstream kernels from booting: the kernel crashes early, while decompressing the image. [...] Kernel fault: interruption code 0005 ilc:2 Kernel random base: 0000000000000000 PSW : 0000200180000000 0000000000017a1e R:0 T:0 IO:0 EX:0 Key:0 M:0 W:0 P:0 AS:0 CC:2 PM:0 RI:0 EA:3 GPRS: 0000000000000001 0000000c00000000 00000003fffffff4 00000000fffffff0 0000000000000000 00000000fffffff4 000000000000000c 00000000fffffff0 00000000fffffffc 0000000000000000 00000000fffffff8 00000000008e25a8 0000000000000009 0000000000000002 0000000000000008 000000000000bce0 One example of a buggy instruction is: 17dde: ec 1e 00 9f 20 5d risbhg %r1,%r14,0,159,32 With %r14 =3D 0x9 and %r1 =3D 0x7 should result in %r1 =3D 0x900000007, how= ever, results in %r1 =3D 0. Let's interpret values of i3/i4 as documented in the PoP and make computation of "mask" only based on i3 and i4 and use "pmask" only at the very end to make sure wrapping is only applied to the high/low doubleword. With this patch, I can successfully boot a v5.11-rc2 kernel built with clang-11, and gcc builds keep on working. Fixes: 2d6a869833d9 ("target-s390: Implement RISBG") Reported-by: Nick Desaulniers Reviewed-by: Richard Henderson Tested-by: Guenter Roeck Tested-by: Nick Desaulniers Cc: Guenter Roeck Cc: Christian Borntraeger Signed-off-by: David Hildenbrand Message-Id: <20210111163845.18148-3-david@redhat.com> Signed-off-by: Cornelia Huck --- target/s390x/translate.c | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/target/s390x/translate.c b/target/s390x/translate.c index 3d5c0d61064c..39e33eeb67f0 100644 --- a/target/s390x/translate.c +++ b/target/s390x/translate.c @@ -3815,22 +3815,23 @@ static DisasJumpType op_risbg(DisasContext *s, Disa= sOps *o) pmask =3D 0xffffffff00000000ull; break; case 0x51: /* risblg */ - i3 &=3D 31; - i4 &=3D 31; + i3 =3D (i3 & 31) + 32; + i4 =3D (i4 & 31) + 32; pmask =3D 0x00000000ffffffffull; break; default: g_assert_not_reached(); } =20 - /* MASK is the set of bits to be inserted from R2. - Take care for I3/I4 wraparound. */ - mask =3D pmask >> i3; + /* MASK is the set of bits to be inserted from R2. */ if (i3 <=3D i4) { - mask ^=3D pmask >> i4 >> 1; + /* [0...i3---i4...63] */ + mask =3D (-1ull >> i3) & (-1ull << (63 - i4)); } else { - mask |=3D ~(pmask >> i4 >> 1); + /* [0---i4...i3---63] */ + mask =3D (-1ull >> i3) | (-1ull << (63 - i4)); } + /* For RISBLG/RISBHG, the wrapping is limited to the high/low doublewo= rd. */ mask &=3D pmask; =20 /* IMASK is the set of bits to be kept from R1. In the case of the hi= gh/low @@ -3843,9 +3844,6 @@ static DisasJumpType op_risbg(DisasContext *s, DisasO= ps *o) len =3D i4 - i3 + 1; pos =3D 63 - i4; rot =3D i5 & 63; - if (s->fields.op2 =3D=3D 0x5d) { - pos +=3D 32; - } =20 /* In some cases we can implement this with extract. */ if (imask =3D=3D 0 && pos =3D=3D 0 && len > 0 && len <=3D rot) { --=20 2.26.2