Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id A78B9C44500 for ; Tue, 7 Jul 2026 12:59:46 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wh5OS-0006jU-Fa; Tue, 07 Jul 2026 08:59:20 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wh5OR-0006iB-6Q for qemu-devel@nongnu.org; Tue, 07 Jul 2026 08:59:19 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wh5OP-0007Dg-OB for qemu-devel@nongnu.org; Tue, 07 Jul 2026 08:59:18 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1783429157; 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=HfbV+Ruqv+I3vl+GtkGeced15bJ0pYPHd3HpZCdKa8k=; b=TJ8aDnj7UJmEN2BWqSIEQBhAZxxrvO4par3E14XunbbP6850k1MLJF37E2TrhE5SeHfKpQ OzODXlpGzzeviJGvF86qYDpPD2WsCKXil1UrHVNwz6W8Wf+6Y2DckOV58nF531zu19SkRa bnOI0cf79mqb4MUOelZ0t0HfmkqCbGo= Received: from mx-prod-mc-03.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-76-q8SqY3ZeNEy1x43uH-KXRQ-1; Tue, 07 Jul 2026 08:59:13 -0400 X-MC-Unique: q8SqY3ZeNEy1x43uH-KXRQ-1 X-Mimecast-MFC-AGG-ID: q8SqY3ZeNEy1x43uH-KXRQ_1783429152 Received: from mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.12]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id CD05019540CD; Tue, 7 Jul 2026 12:59:12 +0000 (UTC) Received: from gondolin.fritz.box (headnet04.pony-001.prod.iad2.dc.redhat.com [10.2.32.116]) by mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 5230F1956040; Tue, 7 Jul 2026 12:59:11 +0000 (UTC) From: Cornelia Huck To: qemu-devel@nongnu.org Cc: qemu-s390x@nongnu.org, Harald Freudenberger , Holger Dengler , Cornelia Huck Subject: [PULL 09/15] target/s390x: Fix wrong address handling in address loops Date: Tue, 7 Jul 2026 14:58:41 +0200 Message-ID: <20260707125847.1785168-10-cohuck@redhat.com> In-Reply-To: <20260707125847.1785168-1-cohuck@redhat.com> References: <20260707125847.1785168-1-cohuck@redhat.com> MIME-Version: 1.0 Content-type: text/plain Content-Transfer-Encoding: 8bit X-Scanned-By: MIMEDefang 3.0 on 10.30.177.12 Received-SPF: pass client-ip=170.10.133.124; envelope-from=cohuck@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: 8 X-Spam_score: 0.8 X-Spam_bar: / X-Spam_report: (0.8 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.445, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_SBL_CSS=3.335, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org From: Harald Freudenberger The loop increments addr by the element stride (+= 4) before calling wrap_address, but then overwrites the loop addr with the wrapped value. On the next iteration the stride is applied to the wrapped address of the previous element, not to the original unwrapped address. This results in every element after the first is read from a wrong (wrapped) address. Fixes: 9f17bfdab4 ("target/s390x: support SHA-512 extensions") Signed-off-by: Harald Freudenberger Reviewed-by: Holger Dengler Message-ID: <20260706094317.17032-2-freude@linux.ibm.com> Signed-off-by: Cornelia Huck --- target/s390x/tcg/crypto_helper.c | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/target/s390x/tcg/crypto_helper.c b/target/s390x/tcg/crypto_helper.c index ae392bce0e73..8fe0a222198a 100644 --- a/target/s390x/tcg/crypto_helper.c +++ b/target/s390x/tcg/crypto_helper.c @@ -126,8 +126,7 @@ static void sha512_read_icv(CPUS390XState *env, const int mmu_idx, const MemOpIdx oi = make_memop_idx(MO_BE | MO_64 | MO_UNALN, mmu_idx); for (int i = 0; i < 8; i++, addr += 8) { - addr = wrap_address(env, addr); - a[i] = cpu_ldq_mmu(env, addr, oi, ra); + a[i] = cpu_ldq_mmu(env, wrap_address(env, addr), oi, ra); } } @@ -137,8 +136,7 @@ static void sha512_write_ocv(CPUS390XState *env, const int mmu_idx, const MemOpIdx oi = make_memop_idx(MO_BE | MO_64 | MO_UNALN, mmu_idx); for (int i = 0; i < 8; i++, addr += 8) { - addr = wrap_address(env, addr); - cpu_stq_mmu(env, addr, a[i], oi, ra); + cpu_stq_mmu(env, wrap_address(env, addr), a[i], oi, ra); } } @@ -148,8 +146,7 @@ static void sha512_read_block(CPUS390XState *env, const int mmu_idx, const MemOpIdx oi = make_memop_idx(MO_BE | MO_64 | MO_UNALN, mmu_idx); for (int i = 0; i < 16; i++, addr += 8) { - addr = wrap_address(env, addr); - a[i] = cpu_ldq_mmu(env, addr, oi, ra); + a[i] = cpu_ldq_mmu(env, wrap_address(env, addr), oi, ra); } } @@ -159,8 +156,7 @@ static void sha512_read_mbl_be64(CPUS390XState *env, const int mmu_idx, const MemOpIdx oi = make_memop_idx(MO_8, mmu_idx); for (int i = 0; i < 16; i++, addr += 1) { - addr = wrap_address(env, addr); - a[i] = cpu_ldb_mmu(env, addr, oi, ra); + a[i] = cpu_ldb_mmu(env, wrap_address(env, addr), oi, ra); } } -- 2.54.0