From patchwork Fri Jun 9 02:23:44 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 690879 Delivered-To: patch@linaro.org Received: by 2002:a5d:4d8a:0:0:0:0:0 with SMTP id b10csp598836wru; Thu, 8 Jun 2023 19:30:43 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5BkEsQPyqt5Cw0ABvIsH8keo0FuWmAfvIiCPjHg7SzxeDAEigg1rH7N4ZwPP+MS9Cpm3gI X-Received: by 2002:a05:6214:76d:b0:625:aa49:c34a with SMTP id f13-20020a056214076d00b00625aa49c34amr269711qvz.62.1686277842770; Thu, 08 Jun 2023 19:30:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686277842; cv=none; d=google.com; s=arc-20160816; b=JbNSIAjQVlmmFCwkpg84qsfv8vrDy4mkbzqW2lW+sI3WPnv4NOvVvwBBv9bW4Dth2G FcaJ2745ObmLYKMV/ASBAK1MoQMDLZiZ5Bhtsg73n0F0t1brOLBtMUHVJSxQ7VTsK1O2 loR0kZ5ptO9VTRcuEBC9v461vNSQeBW1aeYAWgJjt96OgH44IdQbpP1XQgpnOcYMa9NY 2pmn+7S/aFLurcg13kk/JKr7OnHBIkP+9NsTKMKaUf/eOlHISMg2+27mfHH28dw1L3/l kTmWwgpKK32TWylDHAPtVaplb7AVu2JenvgW3xXzIY6XHZA0ZgDxL04wCx7tsDF3yTSL kVUQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=F8c22mTwcbWMs129JigZzKtfDDKQP2XGxgtoSuBUoiE=; b=euDRNpw3ex2ssjxUNurUqtRuw8qiO/rpZH3KojItA8WSYUZrRS27yUSFxjNYbEImF3 Mq/S/tdILtjO98ga6p3fpeTlCymyzfkf7492if0eGoLgLXcej4yTRnUFH3ukmmfXlbjI 8W9PmdvaHih5K488ReSsLfQ27TmqemfBzMZGinAD732+eZ84TtFs5oyZYQotcg9WRiWl gOLMh76rcrcIqbbTt4hDS2F3swvYZ3A3rRCSZeuGhcjOaJ4hAFrA+ZhYnhngn5FyCWo1 KmzP0a1A2f9Og8Wy32UUkkU4WVZDrWxIza8eLdRWc+0l8QDA0fyhd8MC19PEIGzdv8wT xr8g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=o4dpDnPk; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id q3-20020ad45ca3000000b006262b0bde0dsi1702619qvh.403.2023.06.08.19.30.42 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 08 Jun 2023 19:30:42 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=o4dpDnPk; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1q7Roa-0003d1-Ua; Thu, 08 Jun 2023 22:25:25 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1q7Ro7-0002z8-BK for qemu-devel@nongnu.org; Thu, 08 Jun 2023 22:24:56 -0400 Received: from mail-ot1-x329.google.com ([2607:f8b0:4864:20::329]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1q7Rnc-0005i8-VY for qemu-devel@nongnu.org; Thu, 08 Jun 2023 22:24:55 -0400 Received: by mail-ot1-x329.google.com with SMTP id 46e09a7af769-6b291d55f52so256166a34.2 for ; Thu, 08 Jun 2023 19:24:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1686277462; x=1688869462; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=F8c22mTwcbWMs129JigZzKtfDDKQP2XGxgtoSuBUoiE=; b=o4dpDnPkLPLPDOMiRBxKaP/P9jKnyd0RWhw0MRtoNyGJjaTL1ksQsfpZT6fsOA3tPJ gv+J8/xpXj9OTt0Oj0JfmKdK77SzpdWkVA9slVi5fVFH2+VoF4KmefLV4KsEOrVzI6qD OA/grzJhbg6Ddx8vSL7C/dHJsjJWY5aSUDnxkR3d+T+Vzre/VERA7fVkfbxUP03ZuQ8n 4/4GvOJTAJCIsMKX6ozxpvqj4rj6fAho1Z62G2k0RYIj+tsv88IvmMPDEY1Dtj7PjkJP pvDbzaszSsS/1dZqQEaPRiBRZ27wrB/IasDCSbL4pTIHLSL7PCH7OdohYg6EAXkbcY1o KYmA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1686277462; x=1688869462; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=F8c22mTwcbWMs129JigZzKtfDDKQP2XGxgtoSuBUoiE=; b=MdcYcisGcpJAKmNFOlaSfagNxTOaZrS15jHQCyOtbLWj/OWiXuZxSGWZmTsaad7x9W 7JUJK5ZwXcxzalPshwmXLNo2dGypy9MmGQJWZs1V7HDVzh/RnYfGpM2kb5W8JcXB/juM C0zhI/dR7FNdcyz0GdsH3XKGQuQrPDrXVXe58dCafl2qQ+Um3hj/PrGQzUzZpqkH/MwG gJqQCVnBOvTw32R/OM5lJJixlbajtYJkqR41XloDsVAZeOrjQnJI9NWM4llNCYgnB3kO MBRZ24y9IFFjhhoc1NEEqveT3+yHXa4qBM/G0KlfFpgdyeI+t1Mqt/Oul8ROy/kBGej8 n7rA== X-Gm-Message-State: AC+VfDxm4WEUY3eEOjxrGNLA1Lf6hDtNHz/ztza6jxAr97pGpnCEe/7n 9RvbbyurdhUTme1BvFLKNxXZXT57H87+5fzAObI= X-Received: by 2002:a05:6830:130c:b0:6b1:655c:376 with SMTP id p12-20020a056830130c00b006b1655c0376mr219015otq.7.1686277462532; Thu, 08 Jun 2023 19:24:22 -0700 (PDT) Received: from stoup.. ([2602:ae:1598:4c01:b071:df63:5761:f449]) by smtp.gmail.com with ESMTPSA id x25-20020a62fb19000000b0063afb08afeesm1686458pfm.67.2023.06.08.19.24.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 08 Jun 2023 19:24:22 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: ardb@kernel.org, berrange@redhat.com, qemu-ppc@nongnu.org, qemu-arm@nongnu.org, qemu-riscv@nongnu.org, pbonzini@redhat.com Subject: [PATCH v2 21/38] target/arm: Use aesdec_IMC Date: Thu, 8 Jun 2023 19:23:44 -0700 Message-Id: <20230609022401.684157-22-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230609022401.684157-1-richard.henderson@linaro.org> References: <20230609022401.684157-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::329; envelope-from=richard.henderson@linaro.org; helo=mail-ot1-x329.google.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, RCVD_IN_DNSWL_NONE=-0.0001, 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: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org This implements the AESIMC instruction. We have converted everything to crypto/aes-round.h; crypto/aes.h is no longer needed. Signed-off-by: Richard Henderson --- target/arm/tcg/crypto_helper.c | 33 ++++++++++++++------------------- 1 file changed, 14 insertions(+), 19 deletions(-) diff --git a/target/arm/tcg/crypto_helper.c b/target/arm/tcg/crypto_helper.c index 1952aaac58..fdd70abbfd 100644 --- a/target/arm/tcg/crypto_helper.c +++ b/target/arm/tcg/crypto_helper.c @@ -14,7 +14,6 @@ #include "cpu.h" #include "exec/helper-proto.h" #include "tcg/tcg-gvec-desc.h" -#include "crypto/aes.h" #include "crypto/aes-round.h" #include "crypto/sm4.h" #include "vec_internal.h" @@ -102,23 +101,6 @@ void HELPER(crypto_aesd)(void *vd, void *vn, void *vm, uint32_t desc) clear_tail(vd, opr_sz, simd_maxsz(desc)); } -static void do_crypto_aesmc(uint64_t *rd, uint64_t *rm, const uint32_t *mc) -{ - union CRYPTO_STATE st = { .l = { rm[0], rm[1] } }; - int i; - - for (i = 0; i < 16; i += 4) { - CR_ST_WORD(st, i >> 2) = - mc[CR_ST_BYTE(st, i)] ^ - rol32(mc[CR_ST_BYTE(st, i + 1)], 8) ^ - rol32(mc[CR_ST_BYTE(st, i + 2)], 16) ^ - rol32(mc[CR_ST_BYTE(st, i + 3)], 24); - } - - rd[0] = st.l[0]; - rd[1] = st.l[1]; -} - void HELPER(crypto_aesmc)(void *vd, void *vm, uint32_t desc) { intptr_t i, opr_sz = simd_oprsz(desc); @@ -147,7 +129,20 @@ void HELPER(crypto_aesimc)(void *vd, void *vm, uint32_t desc) intptr_t i, opr_sz = simd_oprsz(desc); for (i = 0; i < opr_sz; i += 16) { - do_crypto_aesmc(vd + i, vm + i, AES_imc_rot); + AESState *ad = (AESState *)(vd + i); + AESState *st = (AESState *)(vm + i); + AESState t; + + /* Our uint64_t are in the wrong order for big-endian. */ + if (HOST_BIG_ENDIAN) { + t.d[0] = st->d[1]; + t.d[1] = st->d[0]; + aesdec_IMC(&t, &t, false); + ad->d[0] = t.d[1]; + ad->d[1] = t.d[0]; + } else { + aesdec_IMC(ad, st, false); + } } clear_tail(vd, opr_sz, simd_maxsz(desc)); }