From patchwork Sun Jul 9 13:59:37 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 700846 Delivered-To: patch@linaro.org Received: by 2002:adf:fcc5:0:0:0:0:0 with SMTP id f5csp4743085wrs; Sun, 9 Jul 2023 07:06:26 -0700 (PDT) X-Google-Smtp-Source: APBJJlFWmCT6vbBVGhNsqD6JpH9Ylyzi1dOJvw68wXDZ1UWV2qBmVWZ1HQRAjEVTWcz8si0creU2 X-Received: by 2002:a05:620a:3905:b0:767:fbe:f4b with SMTP id qr5-20020a05620a390500b007670fbe0f4bmr10836268qkn.72.1688911586638; Sun, 09 Jul 2023 07:06:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1688911586; cv=none; d=google.com; s=arc-20160816; b=v4JuY/dtMtGcdnc5/evjXrA0idcuXfln+llWz6GBQzn3AbyzzdWwFL0qeShq122cOQ FyIBoUOWrW70KkfQLNomgWVtI586hYkK8Lq30Ix6zw6w7WHrSZ7WLW3qBeRbngMhpc9G JF9+D6ASuKE6oS+DOMC31IBagA0CT7egsuGP7/XNwGOJQmbY3EgblGigS2MNxXHTRtTx 4P2kiNVKOhRX/+f+Re2fb3D4kfhQXV/IBUpvk1optMXWYOrIpzTqAEAFu5eF/NWjGi7g U/FKbKuXIMLBE41wcvDoo6lYSswmLOOexu9MUT5pHkevH7G9PmjGvInog3YCJglB2djI QjnQ== 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=5cwUPdSqiTi+cpvjs0+320/XSt6FYwReeMeUR4tviQI=; fh=i1mkeM7bD/ppus3C3v+92ltBBCUUU0zBXrpbYjAjHqE=; b=iCa+IKXXWDxCyxXwEEiB1A1+tyZcsT3U4H09idfjOhyEnQbuYOEJ5aO6QuZazRsQ0C HT+l+hQoc5zHl38RW2c7v+JAKi8RCjlnbV7OGnogZET0f9iW+hOruZrjLDVQOJvg063d 1TryGIk/l8ylh4EqiaEQxwfLtJHNRAx39+B7rWxPqBAr+alIUzQ9SLKhcwNc/iO5ji6Z Z9EdAaDOQpRh4oNmxapFEzDqV91ypO/tlF1BMqadpV+wGYGW4yMCxE/0PwJpTuiOD4eJ XdyImu00r4HEFBTUqXDy+bcpzE/eeT0eKjSWHf92QW6tQDFcL0BF/AjLPDc3NSPmDid+ vgqg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=LNk6Rza+; 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 bk16-20020a05620a1a1000b00767d0e575dasi367169qkb.229.2023.07.09.07.06.26 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Sun, 09 Jul 2023 07:06:26 -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=LNk6Rza+; 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 1qIUxj-0000fA-N5; Sun, 09 Jul 2023 10:00:31 -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 1qIUxW-0000T4-Dv for qemu-devel@nongnu.org; Sun, 09 Jul 2023 10:00:18 -0400 Received: from mail-wm1-x329.google.com ([2a00:1450: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 1qIUxR-0000eG-K8 for qemu-devel@nongnu.org; Sun, 09 Jul 2023 10:00:18 -0400 Received: by mail-wm1-x329.google.com with SMTP id 5b1f17b1804b1-3fbf1b82dc7so37582515e9.2 for ; Sun, 09 Jul 2023 07:00:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1688911212; x=1691503212; 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=5cwUPdSqiTi+cpvjs0+320/XSt6FYwReeMeUR4tviQI=; b=LNk6Rza+MfQaL+5IWRKbAUw+W61RgR/z03p5ElAPllXpfQOuJCqj0Tj07Ir0HwW/2c cyEf7nMJXrM2MlYrgOxg5E+iNt32HpJ6eRpIEuoToU946zsbcn+poHimNe0F4zEp4fe2 xPCPF++fEEAY+nl5AjQDU4mjEWyGv2HwCUa6ZmWSAEaArABAbEm+L4kLbN96utWb80mW WR236VIZ+8gLA8F1dTFO+gKHNSmXXeSzspHPpYuEbOXnb/zVjgkLNh6YEA0wUhic02l4 DiCzUAf7DVm7OL+7TBFPEMgjnuzeYywpFRhys0OnM3akdRhKDJgnsIKjGZpvY54+uIv4 gYAw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1688911212; x=1691503212; 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=5cwUPdSqiTi+cpvjs0+320/XSt6FYwReeMeUR4tviQI=; b=PvPZ/dAVhZ98pbOmHDzavzeZTDdFHN3TAMxjNtbGNQ2EaRtuiV6DK+GB/LyokqhSzq O5gYH/ntVLhG3wfHOl1XiShSThTiS214eCfsPtpfYtlI2qK+jimxJczreD1O2m2q5mK2 I1PTVUiViK/boNhzNOH7WWDApRZrUacVz9ug83wQgmlzy+/YtguMH3KDtgz15/YpyLkU SHuhoN+fvnkQ9ZarfDHuXyXkmXqir77DEPYaG4fDKxxJGr+GSbficws1yMkBbWM8M5Jk ZC0qr2C6GoAl3JsxQ9VWw70f8D6FDtipuZpQsBEo/7uzo4XyRMvc8MrcTtkpBWSQx1d8 W4ng== X-Gm-Message-State: ABy/qLaSElO24xn3Xr+dFu/lQCfFM9Zijaenn7SufJDdn8DWAILE5O3U epu4WlxDS63dJSgtiWelAld1WW1RCdrcK12dpsFtPg== X-Received: by 2002:a1c:7c08:0:b0:3fb:b6f3:e528 with SMTP id x8-20020a1c7c08000000b003fbb6f3e528mr9007714wmc.25.1688911212327; Sun, 09 Jul 2023 07:00:12 -0700 (PDT) Received: from stoup.. ([148.252.133.210]) by smtp.gmail.com with ESMTPSA id v18-20020a5d6792000000b003063a92bbf5sm9239422wru.70.2023.07.09.07.00.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 09 Jul 2023 07:00:12 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Subject: [PULL 29/37] target/riscv: Use aesenc_SB_SR_AK Date: Sun, 9 Jul 2023 14:59:37 +0100 Message-Id: <20230709135945.250311-30-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230709135945.250311-1-richard.henderson@linaro.org> References: <20230709135945.250311-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::329; envelope-from=richard.henderson@linaro.org; helo=mail-wm1-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=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 AES64ES instruction. Reviewed-by: Philippe Mathieu-Daudé 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)