From nobody Sun Feb 8 16:17:47 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 Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1646127759629188.88639693693165; Tue, 1 Mar 2022 01:42:39 -0800 (PST) Received: from localhost ([::1]:35474 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nOz1j-0004m4-2e for importer@patchew.org; Tue, 01 Mar 2022 04:42:39 -0500 Received: from eggs.gnu.org ([209.51.188.92]:38482) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nOykT-0004NZ-2q for qemu-devel@nongnu.org; Tue, 01 Mar 2022 04:24:51 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:40219) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nOykN-0002Mg-BZ for qemu-devel@nongnu.org; Tue, 01 Mar 2022 04:24:48 -0500 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-82-Ttyf3HWMNdyYZW2w4bpJ4A-1; Tue, 01 Mar 2022 04:24:39 -0500 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 49A521006AA6; Tue, 1 Mar 2022 09:24:38 +0000 (UTC) Received: from thuth.com (dhcp-192-205.str.redhat.com [10.33.192.205]) by smtp.corp.redhat.com (Postfix) with ESMTP id 04A671F460; Tue, 1 Mar 2022 09:24:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1646126682; 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; bh=V35TrTmT4KMPMsAPx/5wSoa+znLjFAkhAS5Jn4lK5zQ=; b=TAW+8wR0V7jtj4eiTdMyjHFN+I/0mv2xs83KCnICFEkP56P4qgupgc/isoVaYrOdKAcNJt KDMXmfGyVUV7YpQQKJ/D8S5vkjcAiAaC/Yhw1ARsCLsId6qhz3oHgWkgxmfeHLqyKIndDz nGwAVsPr/mEvat3QYhOcAtVIaIBPYiU= X-MC-Unique: Ttyf3HWMNdyYZW2w4bpJ4A-1 From: Thomas Huth To: qemu-s390x@nongnu.org, David Hildenbrand , Richard Henderson Subject: [PATCH] tests/tcg/s390x: Fix the exrl-trt* tests with Clang Date: Tue, 1 Mar 2022 10:24:31 +0100 Message-Id: <20220301092431.1448419-1-thuth@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=thuth@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=170.10.133.124; envelope-from=thuth@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -28 X-Spam_score: -2.9 X-Spam_bar: -- X-Spam_report: (-2.9 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.082, 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_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Pavel Zbitskiy , =?UTF-8?q?Alex=20Benn=C3=A9e?= , qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1646127761233100001 Content-Type: text/plain; charset="utf-8" The exrl-trt* tests use two pre-initialized variables for the results of the assembly code: uint64_t r1 =3D 0xffffffffffffffffull; uint64_t r2 =3D 0xffffffffffffffffull; But then the assembly code copies over the full contents of the register into the output variable, without taking care of this pre-initialized values: " lgr %[r1],%%r1\n" " lgr %[r2],%%r2\n" The code then finally compares the register contents to a value that apparently depends on the pre-initialized values: if (r2 !=3D 0xffffffffffffffaaull) { write(1, "bad r2\n", 7); return 1; } This all works with GCC, since the 0xffffffffffffffff got into the r2 register there by accident, but it fails completely with Clang. Let's fix this by declaring the r1 and r2 variables as proper register variables instead, so the pre-initialized values get correctly passed into the inline assembly code. Signed-off-by: Thomas Huth Reviewed-by: David Hildenbrand Reviewed-by: Richard Henderson --- tests/tcg/s390x/exrl-trt.c | 8 +++----- tests/tcg/s390x/exrl-trtr.c | 8 +++----- 2 files changed, 6 insertions(+), 10 deletions(-) diff --git a/tests/tcg/s390x/exrl-trt.c b/tests/tcg/s390x/exrl-trt.c index 16711a3181..451f777b9d 100644 --- a/tests/tcg/s390x/exrl-trt.c +++ b/tests/tcg/s390x/exrl-trt.c @@ -5,8 +5,8 @@ int main(void) { char op1[] =3D "hello"; char op2[256]; - uint64_t r1 =3D 0xffffffffffffffffull; - uint64_t r2 =3D 0xffffffffffffffffull; + register uint64_t r1 asm("r1") =3D 0xffffffffffffffffull; + register uint64_t r2 asm("r2") =3D 0xffffffffffffffffull; uint64_t cc; int i; =20 @@ -21,8 +21,6 @@ int main(void) " j 2f\n" "1: trt 0(1,%[op1]),%[op2]\n" "2: exrl %[op1_len],1b\n" - " lgr %[r1],%%r1\n" - " lgr %[r2],%%r2\n" " ipm %[cc]\n" : [r1] "+r" (r1), [r2] "+r" (r2), @@ -30,7 +28,7 @@ int main(void) : [op1] "a" (&op1), [op1_len] "a" (5), [op2] "Q" (op2) - : "r1", "r2", "cc"); + : "cc"); cc =3D (cc >> 28) & 3; if (cc !=3D 2) { write(1, "bad cc\n", 7); diff --git a/tests/tcg/s390x/exrl-trtr.c b/tests/tcg/s390x/exrl-trtr.c index 5f30cda6bd..422f7f385a 100644 --- a/tests/tcg/s390x/exrl-trtr.c +++ b/tests/tcg/s390x/exrl-trtr.c @@ -5,8 +5,8 @@ int main(void) { char op1[] =3D {0, 1, 2, 3}; char op2[256]; - uint64_t r1 =3D 0xffffffffffffffffull; - uint64_t r2 =3D 0xffffffffffffffffull; + register uint64_t r1 asm("r1") =3D 0xffffffffffffffffull; + register uint64_t r2 asm("r2") =3D 0xffffffffffffffffull; uint64_t cc; int i; =20 @@ -21,8 +21,6 @@ int main(void) " j 2f\n" "1: trtr 3(1,%[op1]),%[op2]\n" "2: exrl %[op1_len],1b\n" - " lgr %[r1],%%r1\n" - " lgr %[r2],%%r2\n" " ipm %[cc]\n" : [r1] "+r" (r1), [r2] "+r" (r2), @@ -30,7 +28,7 @@ int main(void) : [op1] "a" (&op1), [op1_len] "a" (3), [op2] "Q" (op2) - : "r1", "r2", "cc"); + : "cc"); cc =3D (cc >> 28) & 3; if (cc !=3D 1) { write(1, "bad cc\n", 7); --=20 2.27.0