From patchwork Tue Jun 20 11:07:31 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 694471 Delivered-To: patch@linaro.org Received: by 2002:adf:e885:0:0:0:0:0 with SMTP id d5csp246136wrm; Tue, 20 Jun 2023 04:14:14 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ4vxhgYpxJpbM3IWLUhAw1g5EkabhwE0tJESN8J1tsQ1f7AVQKxqj/EUhH0SuxgZeaMET9F X-Received: by 2002:a05:622a:14c7:b0:3ef:25ad:27fb with SMTP id u7-20020a05622a14c700b003ef25ad27fbmr15383602qtx.30.1687259654555; Tue, 20 Jun 2023 04:14:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1687259654; cv=none; d=google.com; s=arc-20160816; b=xLmk5BxsmLBGwlLPDP3SyzzmIiN/PetbjYH3W85kU2DutIofZLBZ8+G9dSbGhWqbNm NgblqAmgPnc3QgBwUOk8ep8SDc8sx6IC3yfiYNTRMIiIu2NQyfl8TYyyDA6eW0YK+iQM ixofBFwZKhOsX98N1xMakLU9m/ZCKANzXH74wbDEePQFNnZVyM/jpCr5Y9sc9GBuCysp tzRwB88k79bvARLKdbNGCSh8Zi/C+bswnUx/wgPTquHH6uFTlQc74geVQsIy29ld7kct 6JE/an3VwLniWmGj/ipp2i5TDm9D0mTk1iQIRD+DHNbo3xwGUyH6sqhD/spLRVg/ckns RqgQ== 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=pqEpHLv387miC8e5l2/HE3hMgLmxzv9wY41InkeK+gI=; b=K8VXNIN3w/EhsmL3ktWdzBWU4aS+Y/aNH1VY6RrpR6rrn2XbJs9Q1RL1TagiGcTcLo KruJHkRezicMC+zfQtItGBq5vKbb8VgUd+mlYmI/kA9sJO2wo12y2RtsH9wg0Y2pZrTd fV+kWjBIwkn3qfRnlTiMgNQvgvjp/lXDMR6DmG6jvrQNG4k5JtLC7thbfu5NiuMhhcGW DagHbYMn3RUs3s4n0yWHoqcTT3qsHRWRUcZVAa6fKC/8eRDjm0MAMZW+DE/00lJE2WkW amRzkeE5fQC9JJtsiv+6AWs46fqr02Vum/oWuC1kQcqQU+O1xZsuzdyGjKe6+XUAowcM 7lAw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=xQ02uryb; 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 t12-20020a05622a148c00b003faae0e94b1si696343qtx.440.2023.06.20.04.14.14 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 20 Jun 2023 04:14:14 -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=xQ02uryb; 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 1qBZDh-00064p-U8; Tue, 20 Jun 2023 07:08:21 -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 1qBZDg-00063U-6j for qemu-devel@nongnu.org; Tue, 20 Jun 2023 07:08:20 -0400 Received: from mail-ej1-x634.google.com ([2a00:1450:4864:20::634]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qBZDd-0004G0-2z for qemu-devel@nongnu.org; Tue, 20 Jun 2023 07:08:19 -0400 Received: by mail-ej1-x634.google.com with SMTP id a640c23a62f3a-988a2715b8cso399557966b.0 for ; Tue, 20 Jun 2023 04:08:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1687259295; x=1689851295; 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=pqEpHLv387miC8e5l2/HE3hMgLmxzv9wY41InkeK+gI=; b=xQ02urybD0UdA7ZrUaaXUhEzGh88jpXvfJ4bqeLFN+cv/AZTfVvFBgAs40ZbNouhtF KruIR5F5pGhxd/+X7ELeBIsCnZekbWQIWH+MK6vlRYYd+KFoOY0QWIhwfw9hTI3k3kJX CT/u+U2r5++PyO7JnqukFNrJ7txWYNIEjmVtZmaOjYYA3hG8+pb3o18D4O3P9OLSSdTf Tip1zEb0v4Ef5f9LjclgwYq6uw3+CLkivVEDIg8bf5UaMvCU3Vrl21TSBd3QomIP83Px Fjzf0Q9M5P95/sYOIflYRL8JF4vB8eUeHo4HEED1TWolihUhJzQd52//UEurhOSgViKE lVFg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1687259295; x=1689851295; 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=pqEpHLv387miC8e5l2/HE3hMgLmxzv9wY41InkeK+gI=; b=EnUi2qJQrog0f/Bgoej1hv14l3iYQLz6fFDxfI3jBLXM0PNV/62SuWfj5ksw7FiVJQ jP+MfSEeT6Lmwvf3NmXWqFyWBjFgda3SrpZKgwZYHujukErdJupdA20x95aQEtUdAYY+ hsZ502Ih23EsLjPH+3pEwfCFIhlwGvvZnfe2HRDP9KPFiCTXy2JEoHAnILBWvc/VipRu av4j2/P8B99zxDNNRTuugezeREvGNTmD9k1hgQ9l+vmhl7bvXWSfXQpUP1rraNOClTAg 14HxyiO66URBcnLHxkB4SmAYdo/4xG46PdjJBE33UXrPYCg6RQ/kVnrhDJmqN3FPObkT YPxA== X-Gm-Message-State: AC+VfDxUZ9xSISf+/St1SqFXUTzhLkQ8SIKa0GkEGTReZvoXj3J7BcwB eFOW+wSYLC9RFqgVgstZYEdfOdNxM5b8/jeQZckbwOKj X-Received: by 2002:a17:907:6d25:b0:970:28c:f960 with SMTP id sa37-20020a1709076d2500b00970028cf960mr16104251ejc.17.1687259295724; Tue, 20 Jun 2023 04:08:15 -0700 (PDT) Received: from stoup.lan ([176.176.183.29]) by smtp.gmail.com with ESMTPSA id x17-20020a170906711100b009884f015a44sm1170687ejj.49.2023.06.20.04.08.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 20 Jun 2023 04:08:15 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: berrange@redhat.com, qemu-ppc@nongnu.org, qemu-arm@nongnu.org, qemu-riscv@nongnu.org Subject: [PATCH v3 10/37] target/riscv: Use aesenc_SB_SR_AK Date: Tue, 20 Jun 2023 13:07:31 +0200 Message-Id: <20230620110758.787479-11-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230620110758.787479-1-richard.henderson@linaro.org> References: <20230620110758.787479-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::634; envelope-from=richard.henderson@linaro.org; helo=mail-ej1-x634.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 AES64ES instruction. Signed-off-by: Richard Henderson --- target/riscv/crypto_helper.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/target/riscv/crypto_helper.c b/target/riscv/crypto_helper.c index 2ef30281b1..b072fed3e2 100644 --- a/target/riscv/crypto_helper.c +++ b/target/riscv/crypto_helper.c @@ -22,6 +22,7 @@ #include "exec/exec-all.h" #include "exec/helper-proto.h" #include "crypto/aes.h" +#include "crypto/aes-round.h" #include "crypto/sm4.h" #define AES_XTIME(a) \ @@ -136,6 +137,8 @@ target_ulong HELPER(aes32dsi)(target_ulong rs1, target_ulong rs2, AES_INVMIXBYTE(COL, 1, 2, 3, 0) << 8 | \ AES_INVMIXBYTE(COL, 0, 1, 2, 3) << 0) +static const AESState aes_zero = { }; + static inline target_ulong aes64_operation(target_ulong rs1, target_ulong rs2, bool enc, bool mix) { @@ -200,7 +203,12 @@ target_ulong HELPER(aes64esm)(target_ulong rs1, target_ulong rs2) target_ulong HELPER(aes64es)(target_ulong rs1, target_ulong rs2) { - return aes64_operation(rs1, rs2, true, false); + AESState t; + + t.d[HOST_BIG_ENDIAN] = rs1; + t.d[!HOST_BIG_ENDIAN] = rs2; + aesenc_SB_SR_AK(&t, &t, &aes_zero, false); + return t.d[HOST_BIG_ENDIAN]; } target_ulong HELPER(aes64ds)(target_ulong rs1, target_ulong rs2)