From patchwork Sun Jul 9 18:29:08 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 700895 Delivered-To: patch@linaro.org Received: by 2002:adf:fcc5:0:0:0:0:0 with SMTP id f5csp4829151wrs; Sun, 9 Jul 2023 11:38:57 -0700 (PDT) X-Google-Smtp-Source: APBJJlEFV1EgKi1BrVShKaIgzmeRhPYutXgTl9iaPPrUUmKTIPUpGdx67x49jMQXCDPXHOQbcgei X-Received: by 2002:a0c:e004:0:b0:622:199c:c4dc with SMTP id j4-20020a0ce004000000b00622199cc4dcmr9745258qvk.51.1688927937733; Sun, 09 Jul 2023 11:38:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1688927937; cv=none; d=google.com; s=arc-20160816; b=Feu+7+G4f/2uqSiWaoYR6upZveonOyvPlWlTCNkKasrDpd2xmGMczuOko0n/A7rHAA UlqOZGIqsPxShlL+lJWjwTloio+cKiLlw8OTB8vDBeLmmB054TrAhSnasZ2tF0NhMOvC D0Rk6pBkiiJNhxnhlRG1UNUWXeMiUPG7mThOBQ6QQWPXJ6tqa5/NfQsH2mB3lC7zivdA GHX6ZXCGOqiDEmwPuX3NKy6QxjY3BCP2lypZ9eutcGmWYEQFj/AY/TQhsXu+CD6wH0fF baN3igmL04VLUgOsfB89KVjiuzyTNFA62bj+YZnlVkJlK46V8TwyABegLl05YN3ROV4d Rveg== 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=ZNJt+xQSaKcqRS2slBC4RsFLFu+ocScsUgiRpjPIdes=; fh=3IEiF/YPZ00TE94rna3Orj/L+TRFhpuNf7ElRJz3ubE=; b=YszFiKbEkAKqEq0B4EhBnetXkN91jXUmnVJAYpnNr6ZvDKM97m1fGX8TEMJyFJd7aV oPb7UUpJEgCJozjem55zc2QKoHKX2PkAh66uiuWuqvrg/t6nf6fanyigBanEUjucJdVr eCTB1eifvpfwRFZkYslvciG+fub8H3k+RXeaqp3GDsklUbicvaBXzD+z4imIfYCaE6cC 2tS2uSTPgXecl9318FauU+vrk7nFXiITEvzKpV3psYhbpxDy0kKMFuay0ZoUAXlCAqnH O3gNM4hz0GwnW4AVFz45kf10F3h7ltKSa67J1Ahq+Hcv3ppP/WeQ2TXUk0sEXX6JMAWT judQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=FxZvPlWT; 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 d15-20020a0ce44f000000b006376e60c92csi4836965qvm.159.2023.07.09.11.38.57 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Sun, 09 Jul 2023 11:38:57 -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=FxZvPlWT; 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 1qIZEA-0004b7-HC; Sun, 09 Jul 2023 14:33:46 -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 1qIZDu-0003Wo-D7 for qemu-devel@nongnu.org; Sun, 09 Jul 2023 14:33:33 -0400 Received: from mail-wm1-x32f.google.com ([2a00:1450:4864:20::32f]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qIZDq-0004El-9j for qemu-devel@nongnu.org; Sun, 09 Jul 2023 14:33:29 -0400 Received: by mail-wm1-x32f.google.com with SMTP id 5b1f17b1804b1-3fbef8ad9bbso42002125e9.0 for ; Sun, 09 Jul 2023 11:33:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1688927605; x=1691519605; 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=ZNJt+xQSaKcqRS2slBC4RsFLFu+ocScsUgiRpjPIdes=; b=FxZvPlWTr/jm9Mpm7/6AppNvIqAR9ZwESYc68AEZ4IzHMTdTkKlrkRKx9Bhwg+qUqt d1cUP4dJTd9+164djJcx3bJSNge8d+E/5HBrhYcw+uYbZKjXeGQh49a0kPJtatqfuTIt avnHEL+PNR1dGPvxjUCBvLGphfGqZe/hn0Mi9xrAR6u/ID2//p1wpUdwBxNkYr5UmZoB 8QJcG3OadYA0jaG7z+iobNsW84KEYHm8wDlVS6a/f25EBsWlUMeG+C2R0m4b5LxRLYM6 suqyRop0yIiHPb8WHwC1OV1HIW4fMX7UTl/Lg7eF8qQwuGB7Z8P/ovNuEBlA950BcDNJ mixQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1688927605; x=1691519605; 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=ZNJt+xQSaKcqRS2slBC4RsFLFu+ocScsUgiRpjPIdes=; b=CN8vrMQsJFt86XrpX9LR2hDiNocdAa0c4mF7Yp37W/id8QsSDnvDWbhOoQXH0/CKI4 jfqzzemwfOFlJfedrkwxlLqaceQsY80JbiozRMkxZtNGNibMti6WFYJC5dSlpZeh6Ynm iR+KzLpxqxbCcKZX3wjtJkEGJcaQwEJFan/Cg6anaqbJpfgOTOMaM+UBU256594uv+iI hVQnSJ2PSmFYTlmiNMKZqN8P110nwocuCNP68LV20Vpo2H+wajJweRr54XWDIcQBE5E2 pQa27udHLC8e2yCOfjxuHf4LelXGIOVX6oHaM8OwxMO/b0t39tsMpzxu915vIFaG7mRv 9mHg== X-Gm-Message-State: ABy/qLYHeDQHwR2De9mMIv3UGAmE4AUlGGMqtLTEWYaHo0J+biuD0kc8 14eXfQLI3r0e1C7NsQdjP1m3gJh38UzTMlvhkhuCKA== X-Received: by 2002:a05:600c:294a:b0:3fc:1a9:7900 with SMTP id n10-20020a05600c294a00b003fc01a97900mr3217935wmd.16.1688927604868; Sun, 09 Jul 2023 11:33:24 -0700 (PDT) Received: from stoup.. ([148.252.133.210]) by smtp.gmail.com with ESMTPSA id e17-20020a5d4e91000000b0031433760a92sm9635256wru.115.2023.07.09.11.33.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 09 Jul 2023 11:33:24 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: laurent@vivier.eu, =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Subject: [PULL 28/37] target/arm: Use aesdec_IMC Date: Sun, 9 Jul 2023 19:29:08 +0100 Message-Id: <20230709182934.309468-57-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230709182934.309468-1-richard.henderson@linaro.org> References: <20230709182934.309468-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::32f; envelope-from=richard.henderson@linaro.org; helo=mail-wm1-x32f.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=ham 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. Reviewed-by: Philippe Mathieu-Daudé 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)); }