From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 36138606A31C for ; Sun, 29 Nov 2026 15:46:19 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key, unprotected) header.d=nongnu.org header.i=@nongnu.org header.a=rsa-sha256 header.s=lists1p-gnu-org header.b=p3BMRHLs; dkim=fail reason="signature verification failed" (2048-bit key, unprotected) header.d=wii.dev header.i=@wii.dev header.a=rsa-sha256 header.s=x header.b=TWWoxQM0 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=nongnu.org; s=lists1p-gnu-org; h=From:MIME-Version:Date:Subject:To:in-reply-to: references; bh=0U3QJ0dyRonDJefx2Z/htObuO0fdugiPzBKkwZCMuqo=; b=p3BMRHLsOD8DLK 7TjzxgJN4K65QzBARHBD51NswaNShs729q0M7R5rGP3OruDvrlaaHbYFOHqCN7vb/hQ994X4V99xD Q1xd6BJwoQuCIJPgLG5Yl3SXNRUDZirxH/C6gJHRnVSiKotMfRQmYWt+v8vOMOIpDkUtOKTSO29FC 05lkC75/+k19TCFmC1GxwAhpkWuLJjsK8UVJGfQDbEfUSupp6tLHd/jqCQDlDQ72kIm9RMaFtxvWQ Jh0McEpvpoNlcv+JQBfaRRZTFeAc/3cqwS2npASpYMBbCg8JghdtEvc5vXPGH594hxHq718GwMxiC aGkWRj+TF5H0ZhPZSE+w==; Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1xXh5t-0003zj-CM; Sun, 29 Nov 2026 10:45:40 -0500 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 1xXgkK-0002cs-JV for qemu-devel@nongnu.org; Sun, 29 Nov 2026 10:23:25 -0500 Received: from mail-108-mta14.mxroute.com ([136.175.108.14]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1xXgkI-0001L8-32 for qemu-devel@nongnu.org; Sun, 29 Nov 2026 10:23:20 -0500 Received: from filter006.mxroute.com ([136.175.111.3] filter006.mxroute.com) (Authenticated sender: mN4UYu2MZsgR) by mail-108-mta14.mxroute.com (ZoneMTA) with ESMTPSA id 1a227e26442000d084.002 for (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384); Sun, 29 Nov 2026 15:17:57 +0000 X-Zone-Loop: 7a16e74d8356167b20467d630b6cbf6c4ed52f8cb721 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=wii.dev; s=x; h=Content-Transfer-Encoding:MIME-Version:Date:Subject:Cc:To:From:Sender: Reply-To:Content-Type:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References; bh=0U3QJ0dyRonDJefx2Z/htObuO0fdugiPzBKkwZCMuqo=; b=TWWoxQM06miGPfIQZKML74TY/v KeNeutn2o0ag0d1LE8xxlxRq9BwSJZBDvrHnfj7Ai+q8grDz8DQMjJxfbVmDXGkihpGbsTRU/DCsM YA67Spia6TsaX7z0q6CCr72gyK+0J7D/WhvoojW+zKl0ZDl+8xGmjBQkJjzJJxHXC1fNUzD3niqh4 gNo95gHjhyH33n/4/iHsPfF4NpTN7hAMND7L8jy6Lc5PqVKrRfu2d79Tdpu/7VwidI5s3tkp40cjY afU/GdPDzabcehqholAobiKqEH5X010Lho4n/JM4jVlucWvtIZXN7My5No7P1RIf2MhGviaCeg7y5 b3yE+BPQ==; To: qemu-devel@nongnu.org Cc: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , Richard Henderson , qemu-ppc@nongnu.org, qemu-stable@nongnu.org, Richard Patel Subject: [PATCH] host/include/ppc: fix little-endian AES on POWER8 Date: Sun, 29 Nov 2026 09:17:38 -0600 Message-ID: <20261129151738.53319-1-ripatel@wii.dev> X-Archived-By: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Authenticated-Id: ripatel@wii.dev Received-SPF: pass client-ip=136.175.108.14; envelope-from=ripatel@wii.dev; helo=mail-108-mta14.mxroute.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-Mailman-Approved-At: Sun, 29 Nov 2026 10:45:31 -0500 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development List-Archive: List-Post: List-Help: List-Subscribe: , Reply-to: Richard Patel From: Richard Patel via qemu development Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org X-Spam-Status: No, score=-16.1 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_PASS,SPF_PASS autolearn=ham autolearn_force=no version=4.0.1 X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-26) on aws-us-west-2-korg-listserv-alma10-1 aes_accel_{ld,st} produced incorrect AES results on a little- endian POWER8 host with little-endian guests. Update the POWER8 code path to match POWER9. Also prevent the register allocator from overlapping r and rev. Fixes: 57357322e4bd ("host/include/ppc: Implement aes-round.h") Signed-off-by: Richard Patel --- host/include/ppc64/host/crypto/aes-round.h | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/host/include/ppc64/host/crypto/aes-round.h b/host/include/ppc64/host/crypto/aes-round.h index 8062d2a537..06db35a58c 100644 --- a/host/include/ppc64/host/crypto/aes-round.h +++ b/host/include/ppc64/host/crypto/aes-round.h @@ -34,14 +34,17 @@ static inline AESStateVec aes_accel_ld(const AESState *p, bool be) }; asm("lvx %0, 0, %1\n\t" "vperm %0, %0, %0, %2" - : "=v"(r) : "r"(p), "v"(rev), "m"(*p)); + : "=&v"(r) : "r"(p), "v"(rev), "m"(*p)); } else { #ifdef __POWER9_VECTOR__ asm("lxvb16x %x0, 0, %1" : "=v"(r) : "r"(p), "m"(*p)); #else - asm("lxvd2x %x0, 0, %1\n\t" - "xxpermdi %x0, %x0, %x0, 2" - : "=v"(r) : "r"(p), "m"(*p)); + AESStateVec rev = { + 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, + }; + asm("lvx %0, 0, %1\n\t" + "vperm %0, %0, %0, %2" + : "=&v"(r) : "r"(p), "v"(rev), "m"(*p)); #endif } return r; @@ -62,9 +65,12 @@ static void aes_accel_st(AESState *p, AESStateVec r, bool be) #ifdef __POWER9_VECTOR__ asm("stxvb16x %x1, 0, %2" : "=m"(*p) : "v"(r), "r"(p)); #else - asm("xxpermdi %x1, %x1, %x1, 2\n\t" - "stxvd2x %x1, 0, %2" - : "=m"(*p), "+v"(r) : "r"(p)); + AESStateVec rev = { + 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, + }; + asm("vperm %1, %1, %1, %2\n\t" + "stvx %1, 0, %3" + : "=m"(*p), "+v"(r) : "v"(rev), "r"(p)); #endif } } -- 2.56.1