From nobody Sun Feb 8 11:05:57 2026 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=1610112214; cv=none; d=zohomail.com; s=zohoarc; b=ERwz6EUeVpjp72sWm9dCAr+jSOheUhE3ScOE6+YgHpO2WfWL6QXbu5PREROaCCfZ4/laupQGwSMd7UV4NQ0ayLYmYiRZwczGe+OHWpxWStBH4JPtNSgBb2OCAYWVvJK4MmtoPEDmvQhXai9Aqt3eXFPbvl3fK++5ogC1/pJaw38= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1610112214; 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=4wl9+mwGeBbaD60x25URY1Epe/mimBi0dflDbNP+Ago=; b=cvOKjQuEuB0IMOjKr8Dq+cZcjGcocn0t+NAo7enbxdGPl4JV68iZkerdG3blHPSZLLmamN9oWzLA+DDupus+3ZAveuKC4G5hF0qsjVlQm7NK8Vd3ML/SdbNoC4xYz9UGRJPmBpS2QlGtMNAUtcPpInjGRvbGKbLtLJN8WzhSfBk= 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 1610112214912842.0566566708468; Fri, 8 Jan 2021 05:23:34 -0800 (PST) Received: from localhost ([::1]:56170 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kxrjo-0007Fk-Qi for importer@patchew.org; Fri, 08 Jan 2021 08:23:32 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:39982) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kxrhU-0005lh-3R for qemu-devel@nongnu.org; Fri, 08 Jan 2021 08:21:08 -0500 Received: from us-smtp-delivery-124.mimecast.com ([63.128.21.124]:27489) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1kxrhO-0002gy-Nb for qemu-devel@nongnu.org; Fri, 08 Jan 2021 08:21:07 -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-102-CzWy8NJAP1iQW1XHVV6F-g-1; Fri, 08 Jan 2021 08:20:59 -0500 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 7CD55804002; Fri, 8 Jan 2021 13:20:58 +0000 (UTC) Received: from t480s.redhat.com (ovpn-114-168.ams2.redhat.com [10.36.114.168]) by smtp.corp.redhat.com (Postfix) with ESMTP id 2A4AA5D9C0; Fri, 8 Jan 2021 13:20:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1610112061; 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=4wl9+mwGeBbaD60x25URY1Epe/mimBi0dflDbNP+Ago=; b=QrIZQ9gFDqZSc//EvHEGkHn/1aZb+yPNDIrcvHxbLgwN0ldbTalYL3gOCh6onkv+xmiAmg HfGNIjeWDNlV80u8VocfijNhBg3he2RoZyzzAD6bPiDdXGUaIqZQ4dbwxbNm16Oww46xRr aChRlVMqXwHm1TpDixnA5HLlTL4bpag= X-MC-Unique: CzWy8NJAP1iQW1XHVV6F-g-1 From: David Hildenbrand To: qemu-devel@nongnu.org Subject: [PATCH v2 1/4] s390x/tcg: Fix ALGSI Date: Fri, 8 Jan 2021 14:20:46 +0100 Message-Id: <20210108132049.8501-2-david@redhat.com> In-Reply-To: <20210108132049.8501-1-david@redhat.com> References: <20210108132049.8501-1-david@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=david@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=63.128.21.124; envelope-from=david@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.247, 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_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham 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: qemu-s390x@nongnu.org, Cornelia Huck , Richard Henderson , Thomas Huth , David Hildenbrand 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" Looks like something went wrong whiel touching that line. Instead of "r1" we need a new temporary. Also, we have to pass MO_TEQ, to indicate that we are working with 64-bit values. Let's revert these changes. Fixes: ff26d287bddc ("target/s390x: Improve cc computation for ADD LOGICAL") Signed-off-by: David Hildenbrand Reviewed-by: Richard Henderson Tested-by: Guenter Roeck Tested-by: Nick Desaulniers --- target/s390x/insn-data.def | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/target/s390x/insn-data.def b/target/s390x/insn-data.def index 26badb663a..eac5136ee5 100644 --- a/target/s390x/insn-data.def +++ b/target/s390x/insn-data.def @@ -76,7 +76,7 @@ /* ADD LOGICAL WITH SIGNED IMMEDIATE */ D(0xeb6e, ALSI, SIY, GIE, la1, i2_32u, new, 0, asi, addu32, MO_TE= UL) C(0xecda, ALHSIK, RIE_d, DO, r3_32u, i2_32u, new, r1_32, add, addu32) - C(0xeb7e, ALGSI, SIY, GIE, la1, i2, r1, 0, asiu64, addu64) + D(0xeb7e, ALGSI, SIY, GIE, la1, i2, new, 0, asiu64, addu64, MO_TEQ) C(0xecdb, ALGHSIK, RIE_d, DO, r3, i2, r1, 0, addu64, addu64) /* ADD LOGICAL WITH SIGNED IMMEDIATE HIGH */ C(0xcc0a, ALSIH, RIL_a, HW, r1_sr32, i2_32u, new, r1_32h, add, addu= 32) --=20 2.29.2 From nobody Sun Feb 8 11:05:58 2026 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=1610112216; cv=none; d=zohomail.com; s=zohoarc; b=LbN1gjPaOxh6l7MXpGmB4V3KexGR0cOrKKC3Kwu//agj9Si/USnEGEiStqOxhdpPdHpMhXRP7m/6V0jwaH5/qOyVYTZ9HfrRXn7iuw5lkAGS3NmNetZ/B/YGq5v9FJEOO+88+IMRDhMCNKOzf7EknWHKcvBQUmDPPz/S3bGw/bI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1610112216; 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=tfwlfPSJfNthqLJwmE6dU+XHB0db33DTkQaV5o9CpFY=; b=ZqtKNirBDAufsGqgB6wK0o1HY0wFHZnvTvNSGPVGshx9+SXkqIVoaaEhO167tdz5XJpsO1aVFGtAArj1iJOKL/JKaYQuzQFjPjDdMh3ShvysNR/mcVY9Fn9siaieVc2JsQUP8BiIJIJ50kfQdKTfjcrGAdXlCyy6YIfwkNXMY+o= 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 1610112216766735.3127869606762; Fri, 8 Jan 2021 05:23:36 -0800 (PST) Received: from localhost ([::1]:56274 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kxrjq-0007IM-Tj for importer@patchew.org; Fri, 08 Jan 2021 08:23:35 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:40010) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kxrhV-0005m4-E8 for qemu-devel@nongnu.org; Fri, 08 Jan 2021 08:21:09 -0500 Received: from us-smtp-delivery-124.mimecast.com ([63.128.21.124]:41693) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1kxrhS-0002m3-I5 for qemu-devel@nongnu.org; Fri, 08 Jan 2021 08:21:09 -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-208--1kzIQH3P3uVvgMppvzfTw-1; Fri, 08 Jan 2021 08:21:01 -0500 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id A3B51107ACFC; Fri, 8 Jan 2021 13:21:00 +0000 (UTC) Received: from t480s.redhat.com (ovpn-114-168.ams2.redhat.com [10.36.114.168]) by smtp.corp.redhat.com (Postfix) with ESMTP id CC9665D9C0; Fri, 8 Jan 2021 13:20:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1610112065; 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=tfwlfPSJfNthqLJwmE6dU+XHB0db33DTkQaV5o9CpFY=; b=H38WzgHDTRHU9DpOJgK//wBVX/BHGyETHQPvFTJCrdn/rsJfGg4XjS5/RAvY7MYpSBP8/F pk7ZCxqGFKby74V3bR8hJouWu5xF2rpZ6wcc9yEbXpaMIDjVe6AtCzhZDjGWahMK46Cfr0 ifPcQ6NBrqMBGfZcGmYJ+eOPIST/3vA= X-MC-Unique: -1kzIQH3P3uVvgMppvzfTw-1 From: David Hildenbrand To: qemu-devel@nongnu.org Subject: [PATCH v2 2/4] s390x/tcg: Fix RISBHG Date: Fri, 8 Jan 2021 14:20:47 +0100 Message-Id: <20210108132049.8501-3-david@redhat.com> In-Reply-To: <20210108132049.8501-1-david@redhat.com> References: <20210108132049.8501-1-david@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=david@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=63.128.21.124; envelope-from=david@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.247, 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_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham 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: Thomas Huth , David Hildenbrand , Richard Henderson , Cornelia Huck , Nick Desaulniers , 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" 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 Cc: Guenter Roeck Cc: Christian Borntraeger Signed-off-by: David Hildenbrand Reviewed-by: Richard Henderson Tested-by: Guenter Roeck Tested-by: Nick Desaulniers --- 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 3d5c0d6106..39e33eeb67 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.29.2 From nobody Sun Feb 8 11:05:58 2026 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=1610112459; cv=none; d=zohomail.com; s=zohoarc; b=izrXo+PUMSNoN+w2Z0lwHB1sm798FzdQWnPiv6YQqy/jaOO3MhudCXJYM4QPiZfDD9Cyz/aDG6Ruygpk0LsRcGHBNU6zhm8Q++MoFVUNq9PCA5JJiEJXgsdZNiF8hRbPlNL0IOoY6ACEnx3tZdXf9DA9ARIkxmu71jA6YZOfCyY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1610112459; 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=7HcHqSvmrMM7rKL0EaaDfO3SAVmfU+tWX+JLtEAfu9U=; b=RuUzoktKsAImrOl/WdKyC8Kzaehxz0WIYfGEJ7uOwiKD/SwuKXsdOUM5fGw7ginMGss3cNMP/SQthOgFdI0tjy5CK3bRtB9S5i7SSdCSeVfW91RyevzzFIy7xWU9SHWJRxIpSnTLZQXbMvHc9/x1WrNSmeAd9H84jNytFg+RAIE= 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 1610112459811244.35487036200857; Fri, 8 Jan 2021 05:27:39 -0800 (PST) Received: from localhost ([::1]:34454 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kxrnm-0001bK-Ow for importer@patchew.org; Fri, 08 Jan 2021 08:27:38 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:40038) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kxrhW-0005n5-Oa for qemu-devel@nongnu.org; Fri, 08 Jan 2021 08:21:10 -0500 Received: from us-smtp-delivery-124.mimecast.com ([63.128.21.124]:52024) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1kxrhU-0002mZ-Mk for qemu-devel@nongnu.org; Fri, 08 Jan 2021 08:21:10 -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-188-Zm892t7NMuWUbQtk-hxpzg-1; Fri, 08 Jan 2021 08:21:04 -0500 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id F2B61801817; Fri, 8 Jan 2021 13:21:02 +0000 (UTC) Received: from t480s.redhat.com (ovpn-114-168.ams2.redhat.com [10.36.114.168]) by smtp.corp.redhat.com (Postfix) with ESMTP id F3DAB5D9C0; Fri, 8 Jan 2021 13:21:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1610112068; 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=7HcHqSvmrMM7rKL0EaaDfO3SAVmfU+tWX+JLtEAfu9U=; b=S1TeJSHqe6smoftap8kv5VxSkkWju+EtqFoL6/ejcp2p+43e6vk12a2tmclisxX5U8vczq iZvR6J2aQMIQ8ZX5miUhbfKu6m6uuEb2hpblDn/GHwrF6SPs1MaWb5/3ZbtQu/ZIctuGU1 V5LpSdS/nCGDzn0GfTwldKO/dBbvjKY= X-MC-Unique: Zm892t7NMuWUbQtk-hxpzg-1 From: David Hildenbrand To: qemu-devel@nongnu.org Subject: [PATCH v2 3/4] s390x/tcg: Only ignore content in r0 when specified via "b" or "x" Date: Fri, 8 Jan 2021 14:20:48 +0100 Message-Id: <20210108132049.8501-4-david@redhat.com> In-Reply-To: <20210108132049.8501-1-david@redhat.com> References: <20210108132049.8501-1-david@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=david@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=63.128.21.124; envelope-from=david@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.247, 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_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham 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: Thomas Huth , David Hildenbrand , Richard Henderson , Heiko Carstens , Cornelia Huck , Nick Desaulniers , 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" Using get_address() with register identifiers comming from an "r" field is wrong: if the "r" field designates "r0", we don't read the content and instead assume 0 - which should only be applied when the register was specified via "b" or "x". PoP 5-11 "Operand-Address Generation": "A zero in any of the B1, B2, X2, B3, or B4 fields indicates the absence of the corresponding address component. For the absent component, a zero is used in forming the intermediate sum, regardless of the contents of general register 0. A displacement of zero has no special significance." This BUG became visible for CSPG as generated by LLVM-12 in the upstream Linux kernel (v5.11-rc2), used while creating the linear mapping in vmem_map_init(): Trying to store to address 0 results in a Low Address Protection exception. Debugging this was more complicated than it could have been: The program interrupt handler in the kernel will try to crash the kernel: doing so, it will enable DAT. As the linear mapping is not created yet (asce=3D0), we run into an addressing exception while tring to walk non-existant DAT tables, resulting in a program exception loop. This allows for booting upstream Linux kernels compiled by clang-12. Most of these cases seem to be broken forever. Reported-by: Nick Desaulniers Cc: Guenter Roeck Cc: Christian Borntraeger Cc: Heiko Carstens Signed-off-by: David Hildenbrand Reviewed-by: Richard Henderson Tested-by: Guenter Roeck Tested-by: Nick Desaulniers --- target/s390x/insn-data.def | 8 ++++---- target/s390x/translate.c | 15 +++++++++------ 2 files changed, 13 insertions(+), 10 deletions(-) diff --git a/target/s390x/insn-data.def b/target/s390x/insn-data.def index eac5136ee5..e5b6efabf3 100644 --- a/target/s390x/insn-data.def +++ b/target/s390x/insn-data.def @@ -1290,8 +1290,8 @@ F(0xe313, LRAY, RXY_a, LD, 0, a2, r1, 0, lra, 0, IF_PRIV) F(0xe303, LRAG, RXY_a, Z, 0, a2, r1, 0, lra, 0, IF_PRIV) /* LOAD USING REAL ADDRESS */ - E(0xb24b, LURA, RRE, Z, 0, 0, new, r1_32, lura, 0, MO_TEUL, IF_= PRIV) - E(0xb905, LURAG, RRE, Z, 0, 0, r1, 0, lura, 0, MO_TEQ, IF_PRIV) + E(0xb24b, LURA, RRE, Z, 0, ra2, new, r1_32, lura, 0, MO_TEUL, I= F_PRIV) + E(0xb905, LURAG, RRE, Z, 0, ra2, r1, 0, lura, 0, MO_TEQ, IF_PRIV) /* MOVE TO PRIMARY */ F(0xda00, MVCP, SS_d, Z, la1, a2, 0, 0, mvcp, 0, IF_PRIV) /* MOVE TO SECONDARY */ @@ -1344,8 +1344,8 @@ /* STORE THEN OR SYSTEM MASK */ F(0xad00, STOSM, SI, Z, la1, 0, 0, 0, stnosm, 0, IF_PRIV) /* STORE USING REAL ADDRESS */ - E(0xb246, STURA, RRE, Z, r1_o, 0, 0, 0, stura, 0, MO_TEUL, IF_PR= IV) - E(0xb925, STURG, RRE, Z, r1_o, 0, 0, 0, stura, 0, MO_TEQ, IF_PRI= V) + E(0xb246, STURA, RRE, Z, r1_o, ra2, 0, 0, stura, 0, MO_TEUL, IF_= PRIV) + E(0xb925, STURG, RRE, Z, r1_o, ra2, 0, 0, stura, 0, MO_TEQ, IF_P= RIV) /* TEST BLOCK */ F(0xb22c, TB, RRE, Z, 0, r2_o, 0, 0, testblock, 0, IF_PRIV) /* TEST PROTECTION */ diff --git a/target/s390x/translate.c b/target/s390x/translate.c index 39e33eeb67..61dd0341e4 100644 --- a/target/s390x/translate.c +++ b/target/s390x/translate.c @@ -3285,8 +3285,7 @@ static DisasJumpType op_lpq(DisasContext *s, DisasOps= *o) #ifndef CONFIG_USER_ONLY static DisasJumpType op_lura(DisasContext *s, DisasOps *o) { - o->addr1 =3D get_address(s, 0, get_field(s, r2), 0); - tcg_gen_qemu_ld_tl(o->out, o->addr1, MMU_REAL_IDX, s->insn->data); + tcg_gen_qemu_ld_tl(o->out, o->in2, MMU_REAL_IDX, s->insn->data); return DISAS_NEXT; } #endif @@ -4234,7 +4233,8 @@ static DisasJumpType op_ectg(DisasContext *s, DisasOp= s *o) tcg_gen_addi_i64(o->in1, regs[b1], d1); o->in2 =3D tcg_temp_new_i64(); tcg_gen_addi_i64(o->in2, regs[b2], d2); - o->addr1 =3D get_address(s, 0, r3, 0); + o->addr1 =3D tcg_temp_new_i64(); + gen_addi_and_wrap_i64(s, o->addr1, regs[r3], 0); =20 /* load the third operand into r3 before modifying anything */ tcg_gen_qemu_ld64(regs[r3], o->addr1, get_mem_index(s)); @@ -4539,8 +4539,7 @@ static DisasJumpType op_stnosm(DisasContext *s, Disas= Ops *o) =20 static DisasJumpType op_stura(DisasContext *s, DisasOps *o) { - o->addr1 =3D get_address(s, 0, get_field(s, r2), 0); - tcg_gen_qemu_st_tl(o->in1, o->addr1, MMU_REAL_IDX, s->insn->data); + tcg_gen_qemu_st_tl(o->in1, o->in2, MMU_REAL_IDX, s->insn->data); =20 if (s->base.tb->flags & FLAG_MASK_PER) { update_psw_addr(s); @@ -5923,7 +5922,11 @@ static void in2_x2l(DisasContext *s, DisasOps *o) =20 static void in2_ra2(DisasContext *s, DisasOps *o) { - o->in2 =3D get_address(s, 0, get_field(s, r2), 0); + int r2 =3D get_field(s, r2); + + /* Note: *don't* treat !r2 as 0, use the reg value. */ + o->in2 =3D tcg_temp_new_i64(); + gen_addi_and_wrap_i64(s, o->in2, regs[r2], 0); } #define SPEC_in2_ra2 0 =20 --=20 2.29.2 From nobody Sun Feb 8 11:05:58 2026 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=1610112461; cv=none; d=zohomail.com; s=zohoarc; b=ByVQl4UPKFjPU9vpKXZAFxIxBfa6UPZMSxzf583/yE5GOVYYcReg099emH+sdfPTHm71p61qi26Sz9wUCc+mMah9+UvxJEsJ3FQs6UQxlLYPeNiNBwjS0ldm1fcqN6sghWxl+wVnUNKJ87eYEIVbEcOh47H/BUTsfZ8GqFOZEL0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1610112461; 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=XzNzABc9kqEGW1XlawqHqkOVM25PLG/URWvedRv0ocM=; b=L7h4Afl6oegU0mWCMojUDqs2/BEu5eJxL+8U2332U6G5/40dE38h2pI4AwDnxEHKsHA6cW4ZJoCc5PqQbHDV1ojt5yIBIDRnMbjP7+rjqKqY8WUY7yH2ZJmJg5Uj6EkCFQQoaUBGZhIwhXnGmU9vl7Xvfj8KCfNLkNkUT/spI74= 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 1610112461286879.7264284490786; Fri, 8 Jan 2021 05:27:41 -0800 (PST) Received: from localhost ([::1]:34576 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kxrno-0001eJ-5q for importer@patchew.org; Fri, 08 Jan 2021 08:27:40 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:40052) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kxrhX-0005o5-IR for qemu-devel@nongnu.org; Fri, 08 Jan 2021 08:21:11 -0500 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:23047) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1kxrhW-0002nQ-0j for qemu-devel@nongnu.org; Fri, 08 Jan 2021 08:21:11 -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-465-AcfoTpzwM065_SUs7y47tA-1; Fri, 08 Jan 2021 08:21:05 -0500 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id A1FD0804002; Fri, 8 Jan 2021 13:21:04 +0000 (UTC) Received: from t480s.redhat.com (ovpn-114-168.ams2.redhat.com [10.36.114.168]) by smtp.corp.redhat.com (Postfix) with ESMTP id 4DC0B5D9C0; Fri, 8 Jan 2021 13:21:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1610112069; 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=XzNzABc9kqEGW1XlawqHqkOVM25PLG/URWvedRv0ocM=; b=HsOfvKzzU7TWX8wrF01h9RixAvAdqWQtctFEhw9CbpZ+BIdHxXZSj+0lUJLeMFVqQHuQdS O7Oz9QEJoEymTysRz1hyR0KxVMBRfHY5eh51sgQCJ9HKpFS5diPjR2Qt6IU+xqt3C0XzAs IFCIVyhhDoaa5m23k9ILCU3su+6E6lQ= X-MC-Unique: AcfoTpzwM065_SUs7y47tA-1 From: David Hildenbrand To: qemu-devel@nongnu.org Subject: [PATCH v2 4/4] s390x/tcg: Ignore register content if b1/b2 is zero when handling EXECUTE Date: Fri, 8 Jan 2021 14:20:49 +0100 Message-Id: <20210108132049.8501-5-david@redhat.com> In-Reply-To: <20210108132049.8501-1-david@redhat.com> References: <20210108132049.8501-1-david@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=david@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=david@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.247, 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: qemu-s390x@nongnu.org, Cornelia Huck , Richard Henderson , Thomas Huth , David Hildenbrand 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" In our EXECUTE fast path, we have to ignore the content of r0, if specified by b1 or b2. Fixes: d376f123c7de ("target/s390x: Re-implement a few EXECUTE target insns= directly") Signed-off-by: David Hildenbrand Reviewed-by: Richard Henderson Reviewed-by: Thomas Huth Tested-by: Guenter Roeck Tested-by: Nick Desaulniers --- target/s390x/mem_helper.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/target/s390x/mem_helper.c b/target/s390x/mem_helper.c index 0108611cc9..1901e9dfc7 100644 --- a/target/s390x/mem_helper.c +++ b/target/s390x/mem_helper.c @@ -2473,8 +2473,8 @@ void HELPER(ex)(CPUS390XState *env, uint32_t ilen, ui= nt64_t r1, uint64_t addr) uint32_t d1 =3D extract64(insn, 32, 12); uint32_t b2 =3D extract64(insn, 28, 4); uint32_t d2 =3D extract64(insn, 16, 12); - uint64_t a1 =3D wrap_address(env, env->regs[b1] + d1); - uint64_t a2 =3D wrap_address(env, env->regs[b2] + d2); + uint64_t a1 =3D wrap_address(env, (b1 ? env->regs[b1] : 0) + d= 1); + uint64_t a2 =3D wrap_address(env, (b2 ? env->regs[b2] : 0) + d= 2); =20 env->cc_op =3D helper(env, l, a1, a2, 0); env->psw.addr +=3D ilen; --=20 2.29.2