From patchwork Mon Jul 3 10:05:11 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 698647 Delivered-To: patch@linaro.org Received: by 2002:adf:fcc5:0:0:0:0:0 with SMTP id f5csp1665471wrs; Mon, 3 Jul 2023 03:11:26 -0700 (PDT) X-Google-Smtp-Source: APBJJlF9Ts9sEfZFFpDa3/lwNvYnBeAD3psZWws4Rta2Wx4MmGWnwuEjDsBaqUI/DCSQA2tyloLN X-Received: by 2002:a05:620a:258a:b0:767:346c:4b2f with SMTP id x10-20020a05620a258a00b00767346c4b2fmr11957808qko.3.1688379085907; Mon, 03 Jul 2023 03:11:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1688379085; cv=none; d=google.com; s=arc-20160816; b=b40SJwXljYZIZvNG6BzfZlgDazTKHGY+01scy56HE/fsjuObjGPhA5uGL34M7/R6LX MbUoTY8iYE7nlw7pXJL7mgNqxpdwe2ODoz5CzWLgctUEMrxtnOoZ5WxCfSzmA+aizXFF aGwbPXqR7ijDtoFlTKcGCntxj7Cq+dGzHxS7e1/YLfJGHliFU4TqDn/Hvwkn/fPP1CR7 odsFxDthaUEw/32EuO0YOASNAGLufEalN+kI572M+fh4FyVqv3LqbsOItXFneN83ZEWP avClARdIEvL8reBWO/NeNBfO5ocPdEOw9jS/egUC8IjcyFokT9VPvZLicI8Md4GLONKp HOkw== 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=; fh=DiqGMcF5+wJ0/Fe6a4a0YfMDHaiC5n3qovds/BNTPmI=; b=WM8au4/yc3kkeGnPznBpqfBJFNEk0D88tVn454lyfuxcEqpKApser6BxaZu5FiEn11 FD71zqn5PgyFJT4NaRJzJ2MhboNIiWfUhMTDFU1bpJmfnfBTsqp9RF68qQwrQ1+eUI9L BQozhNH76vFbHLC/dkt5kZA9ZcPCXRk3YfoqlcQTRujgy3UFR0tT1UEx5q0zQLyUJQbc Q89eY90OibrJ9lcERpYm/K+e05LSygd0dx3SEnSFOZOnQ/gibdymQsdBnPVEHizBQZeq 1OpFCyN7vU5L5VjHftNlIa27T813+WHgLP+gBLw5Tw+FrifMpRFm1ub9t7igzWZ8SYa1 GXew== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=KwPKwXtH; 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 g27-20020a05620a13db00b00767522d4938si3784673qkl.655.2023.07.03.03.11.25 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 03 Jul 2023 03:11:25 -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=KwPKwXtH; 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 1qGGSD-0003k2-Vw; Mon, 03 Jul 2023 06:06: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 1qGGRe-000358-MP for qemu-devel@nongnu.org; Mon, 03 Jul 2023 06:06:10 -0400 Received: from mail-wr1-x42f.google.com ([2a00:1450:4864:20::42f]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qGGRN-0005wl-7u for qemu-devel@nongnu.org; Mon, 03 Jul 2023 06:06:10 -0400 Received: by mail-wr1-x42f.google.com with SMTP id ffacd0b85a97d-312824aa384so4702882f8f.1 for ; Mon, 03 Jul 2023 03:05:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1688378752; x=1690970752; 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=KwPKwXtHiSwM+qNiiC3T1qjUtOewzs46RoKAckypIPKVGgw15pHZcBdZ2LGdyiAXNr bii5d1k+heY0WYib0YxJKw18eKcUF3VPf/reMz70l1ytQDiU/KfdEpG93rDFJhLfRsNb fNkPTDDalV2AsugccbUhG5VjdcbpNbJFU8hJC4yrX7jOvPHEK2GFFdXquNfegBRqy8is ICH9vhCsEVop31QBMq9ZplVWfdvR0bHvyDf0GLeG+084Hei3UzFcVTJ5ltQWhFd8XsVJ 6LiXXBIPtfyfcBB7rI+/KFiuMEOoMz5oxc+nzJvRDiZugZFMNDVNX2/b82nv/grHmNd6 XA+A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1688378752; x=1690970752; 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=MjJdAh2e90MczhIMBr3bYqDEUy4Qygn44F3WTz+hXhpPzXQESB0v87t0IZTCQQRUiG qfT9rKnxh+OT4Dij3UOWX+zWvBAIPAnZVjhvoNviPEswGKM2EVIEzf56sy90A7NDjFSx A1DhqwFDmmUsfZVKT+0e5mF9aEOsAP/3YR07jY+U8S+a/opc/pvJTUuMAMvoAMGjQex7 uGgyIBLH3aO/GkYKD5sq8Pz9rN7vrLFfsEP+SJ0JlkZwEAI7w8zv0iINvzUbp+wWg/2b k2zpc0yCQhuHQLYofyyLFbJwyPo/Zm0lp5Ci7jfcVPfHCYoLgJLefafYbSwM90m3KrKQ 35DA== X-Gm-Message-State: ABy/qLbFRJJ59Jpcvji8InFnZ5osKQlqK7cYM0cQcbqxZSmSF6DeUyHs hyUMpY+BFOir77ECa3M/1F3hDDSnzyKWnBtxwuSJyQ== X-Received: by 2002:adf:fcc5:0:b0:314:1ba7:fb29 with SMTP id f5-20020adffcc5000000b003141ba7fb29mr7766310wrs.1.1688378751832; Mon, 03 Jul 2023 03:05:51 -0700 (PDT) Received: from stoup.home (91.232.79.188.dynamic.jazztel.es. [188.79.232.91]) by smtp.gmail.com with ESMTPSA id t5-20020a05600001c500b00313f7b077fesm18446562wrx.59.2023.07.03.03.05.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 03 Jul 2023 03:05:51 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: qemu-arm@nongnu.org, qemu-riscv@nongnu.org, pbonzini@redhat.com, eduardo@habkost.net, alistair.francis@wdc.com, danielhb413@gmail.com Subject: [PATCH v4 28/37] target/arm: Use aesdec_IMC Date: Mon, 3 Jul 2023 12:05:11 +0200 Message-Id: <20230703100520.68224-29-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230703100520.68224-1-richard.henderson@linaro.org> References: <20230703100520.68224-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::42f; envelope-from=richard.henderson@linaro.org; helo=mail-wr1-x42f.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 Reviewed-by: Philippe Mathieu-Daudé --- 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)); }