From patchwork Fri Jun 9 02:23:34 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 690885 Delivered-To: patch@linaro.org Received: by 2002:a5d:4d8a:0:0:0:0:0 with SMTP id b10csp599096wru; Thu, 8 Jun 2023 19:31:50 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ6kPsHgUOUxEYPUe1IpZZLXbucJy7e+g6+pEXcD2zutNz5wAMzLwTU8Sh0JXfhaC0e/gqLw X-Received: by 2002:ac8:7d0e:0:b0:3f3:8819:67eb with SMTP id g14-20020ac87d0e000000b003f3881967ebmr383507qtb.6.1686277909976; Thu, 08 Jun 2023 19:31:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686277909; cv=none; d=google.com; s=arc-20160816; b=QY467sYFtgWmMxwegTkbQAX9wzi8OdEJXnBRNOSWzlVEOLRrdwJgNrSl7q0FbIHBVn kVYo/zrS2ezDAUaDMVnBBF9zLhey3sOAmsahh8WcQtY0HeLSGkk7mO+owsX1mtE98+6L OlMdH4yIhHfkRpGAwGN8YC4wt/0gF06fGzM7uo2AqcUi2aBGaZBtsphrPhYlxbTdEah4 R8BxfjgpkJQiUa4rfXLu+GTQJ19NHG6oZuMlv1mHV70ulxPS3ttJOuFjLVDxNHz5ak5O ffla0SOHTWue1QxoDMPXqPkhfH0RP5AnSImYIARTKY8I9250ah9uRyzLmPMivW7obRlm xwsw== 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=dvzMt6fB17nSWTwZMBSQ+iu8zHMz2Z0KkPNmskMeSDjPjoMFVcnLtqa1UEfD042My1 XtTD2eHzeuL8c3vnZhdRau5F+oDwjow39cZPb2iTTvRzh0ByMPDj/Uo0f0klStypcb94 DSQwMX4s4/WlpWxFLmrIzSwqUhPjx9jmi7HV6m1wYprvlGLKCGctAd3WzCMg0NCUtQZ6 jDR48N9BwemYXZWJaaCPlfeYoG4eYXS2utAzsU1gVdu36dryf3vfAAU/5J4OQb1ezTMt 4Ssgdxcxp3/sbprLlNLMPspAe2luOvvp9Dr4pl97trdFagZxyPHzRflKaoHqEvg+pFZp a8TA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Q2j94Mv+; 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 d11-20020ac85acb000000b003f7f6123815si1510066qtd.511.2023.06.08.19.31.49 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 08 Jun 2023 19:31:49 -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=Q2j94Mv+; 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 1q7Rno-0002n3-7e; Thu, 08 Jun 2023 22:24:36 -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 1q7Rng-0002e3-GP for qemu-devel@nongnu.org; Thu, 08 Jun 2023 22:24:30 -0400 Received: from mail-pf1-x434.google.com ([2607:f8b0:4864:20::434]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1q7RnS-0005bR-UF for qemu-devel@nongnu.org; Thu, 08 Jun 2023 22:24:28 -0400 Received: by mail-pf1-x434.google.com with SMTP id d2e1a72fcca58-652d1d3e040so1008468b3a.1 for ; Thu, 08 Jun 2023 19:24:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1686277453; x=1688869453; 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=Q2j94Mv+e7Zpjw1sM4pKwrTS4TSbaliX1MWs+rVCYyPore6uwpj6Xbu9DD7l9ytDKp Me+fnnQcE0sCPAi45ggfMD2g8FwkCN9L/4k2tokPse0NmKur8nT1uvYPkLhy57NqN+L0 +j48YxWVRRAB9WRs37bUARbn/4JCdxr/vb8+Q+IAczSGGXwgDHieveGTlykeq+HrCbua BczPH12fvt5sGvPscDZPL7DWa25i1XhnaWG9WbGos28YXZ7v1tozstybz82gW5vOAE+X I76toN/6s5CuKDQq4HqUnMlOE+kBxYxGQuyLkPixKLQ+/pMf5uyC7BEymBE+6m88O8oz rZDA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1686277453; x=1688869453; 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=c1G7mEen0uIf5ZqJTli5YRBdJmkGmSwhrLfuZQULD2N57+Vd+Pf6xM2TcuekL/UGb0 lrzrz4/NlgPOCru3JRovhZAFJ2V0F2jID8uOa9DLmmnRi+iygdjm5+if7DA4NWKnBFq6 V35c1aFmES8Ioum6rlPhkuH5ZUbDHeU/87ouyWHKbGNrvequOcN6BHE7RCJX8Z0cntnZ hkW3MhVVjXae8a0ZvdKnvgoBRa8hYYGwz1gl+ZkcVE7aiJv6WMheBdkPHkaRT9iABC0H eyt1ylKXy5I4Cy6GQVbe2HQsctuNVwCeSyGSzTRuQshdGDdSamNIryPKdDioKOOpcvPG AXKQ== X-Gm-Message-State: AC+VfDy8zHIDiaNrSxs7ZZJHrJ6YyGI+GjXtRJt/F5V2ZPTWfV7VRoEm jcbGFZ8C3Lp3BMDIUb0c+vhVPXXvpo1KZCyECy4= X-Received: by 2002:a05:6a00:1911:b0:663:8255:8cc3 with SMTP id y17-20020a056a00191100b0066382558cc3mr29055pfi.7.1686277453528; Thu, 08 Jun 2023 19:24:13 -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.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 08 Jun 2023 19:24:13 -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 11/38] target/riscv: Use aesenc_SB_SR_AK Date: Thu, 8 Jun 2023 19:23:34 -0700 Message-Id: <20230609022401.684157-12-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::434; envelope-from=richard.henderson@linaro.org; helo=mail-pf1-x434.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)