From patchwork Tue Jun 20 11:07:42 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 694485 Delivered-To: patch@linaro.org Received: by 2002:adf:e885:0:0:0:0:0 with SMTP id d5csp247152wrm; Tue, 20 Jun 2023 04:16:34 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ6bQ74kH9PTVdopMYXUZ+9NLXc+MWtNbi3S2R+BpuE8PTp1YSHeKRieCewAxPVJiasLnJux X-Received: by 2002:a05:6214:f01:b0:62f:ef74:a304 with SMTP id gw1-20020a0562140f0100b0062fef74a304mr16996436qvb.8.1687259794255; Tue, 20 Jun 2023 04:16:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1687259794; cv=none; d=google.com; s=arc-20160816; b=V2CHCNQgaAYDzgTEDakzxpdnMloPcEDwuXzBQhA+yDARQZyU77bZT9fCnRUrg3nLnD MVWY3dhYqVzWcOZkeIcslB3lAhHtROES1lxhX4dRPswrFXKSpp2lvea4xoQqI7zCDDUi 4Z6p5u5hjaOtEaVJG6Y4uwtEcHz+2jZm9KVqZ+4Q3f0CeVpWnG9nlz2LNWeCpGZWDpXp G1wrf6sh8UXpBDsKy4HXHriFm5EgpSjWfu7+4wKe26R9ByTC/LJXcGnqcKodPasCpYo2 /IsjctDi1x2gTGyRNArMQgdHfaXHefQ6vWisq0ZU19HZCBTOlgupRTo060W3JKGCju9s trDw== 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=4pOjdTU6VTsEkj/YPCvRrXcIKg2xairdxfu8316FBss=; b=NGJN6DbicAMOIl7QNERM14t+CjkVvxKYlh+JANZkOqSdy3M1ZJeKZIY9+HCM1dbcY5 +NxW8Wo/YOh0VobkL9cZX0mxawtT5TDU6Ui0CkGYTjOXB5W4fpG2XvsSgWS7gaxbxTvc j3U3iU2IZGMeGQ1D0Jtr1w4LmF/ICwoq4hUyIVyvEmjQMTytiAx87fXHUkq8XvKTIamm am3UVRwZI2d+GX987jMerMvs/+EPacpJm2JIfdxBvnVG++0WZqyR2BiOevciSiF394Ul 9gfz8j/LDon6M850qrBJY/96uBx/I+LjtYlW4RccfTbdnlNxTAOuBvFalxt6vxeF3gtm uTLQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=hYiqw96J; 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 im5-20020a056214246500b0062dfad6c53bsi721532qvb.289.2023.06.20.04.16.34 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 20 Jun 2023 04:16:34 -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=hYiqw96J; 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 1qBZDv-0006Oh-Ue; Tue, 20 Jun 2023 07:08:35 -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 1qBZDu-0006La-3G for qemu-devel@nongnu.org; Tue, 20 Jun 2023 07:08:34 -0400 Received: from mail-ej1-x630.google.com ([2a00:1450:4864:20::630]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qBZDr-0004Pu-09 for qemu-devel@nongnu.org; Tue, 20 Jun 2023 07:08:33 -0400 Received: by mail-ej1-x630.google.com with SMTP id a640c23a62f3a-988a076a7d3so331313066b.3 for ; Tue, 20 Jun 2023 04:08:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1687259309; x=1689851309; 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=4pOjdTU6VTsEkj/YPCvRrXcIKg2xairdxfu8316FBss=; b=hYiqw96JSEdcqpEPp3u5DEbaGKLEdjTy+QYbCk4Zo6bvKleWnKhKLFc+MQ/8O1pc/h SpnCzIsLz3NzW9mM5r4MipbYOb+a0t5PV+sWRxBdwEHNz4MPDyLulOTLkqC5dTxPk1pC e1SXfkgOppUTo05lShREFAmak8QM092AXruxsz6sJSJQR/zwiNKMyI7k3XTbAirO6y/L uk/pRe2kpoDcWxuR0GNl30FUlEkTtN0pNndgrP3DuOHWA/zncnJOt+il3WUMhmEWMAhn 8B1099REepqbrXsSRQGEbZ04UF+++VM7TJb1CTB4Q1hjw0EH6/A5WP0d2f3i8/KAlVXu eGOw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1687259309; x=1689851309; 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=4pOjdTU6VTsEkj/YPCvRrXcIKg2xairdxfu8316FBss=; b=YYLtUDyjUfhWOBO/nlYHZDU6BRghZ44IrxH3HxWkIaFfqdhEjbPt67j2c+aFYCN/uY Ga3khl8s2aXk56ubWv5WQBnEHroviLpR1NonNIQDn5rdV0LV4X83bDitDDP2nD9xNBG4 SonvHmZ6QGwGjB9zYBFz9JohTFJ3B1ZcsnCqLmU0OVTgYrnlvNHi3Ak4drUjiRWfWmTT BeEekiEdL1XUMQ7C0zsggk2Dvk3jJooGICUYkjzxrtiJBF2pppuoeMLDe2QX/dhMdFqi ZIZrF/YgDvE7jXAgltTMSwQI7BZAeBO4mepAHod+gBKMqHxG9TFkuy7T7pt8CfHTL1YQ m59w== X-Gm-Message-State: AC+VfDxExrt7Z1v6NbS2Yq27psohE4pWi3XdGqH2TYI1dHPa7DqzLeZJ OYbdAMogqwzP8nlqOGxuO9xRPw6jpHsY+zpHNR/7NNAl X-Received: by 2002:a17:907:72c1:b0:96f:a891:36cb with SMTP id du1-20020a17090772c100b0096fa89136cbmr11715525ejc.0.1687259309674; Tue, 20 Jun 2023 04:08:29 -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.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 20 Jun 2023 04:08:29 -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 21/37] target/riscv: Use aesdec_IMC Date: Tue, 20 Jun 2023 13:07:42 +0200 Message-Id: <20230620110758.787479-22-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::630; envelope-from=richard.henderson@linaro.org; helo=mail-ej1-x630.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 AES64IM instruction. Signed-off-by: Richard Henderson --- target/riscv/crypto_helper.c | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/target/riscv/crypto_helper.c b/target/riscv/crypto_helper.c index e61f7fe1e5..505166ce5a 100644 --- a/target/riscv/crypto_helper.c +++ b/target/riscv/crypto_helper.c @@ -272,17 +272,12 @@ target_ulong HELPER(aes64ks1i)(target_ulong rs1, target_ulong rnum) target_ulong HELPER(aes64im)(target_ulong rs1) { - uint64_t RS1 = rs1; - uint32_t col_0 = RS1 & 0xFFFFFFFF; - uint32_t col_1 = RS1 >> 32; - target_ulong result; + AESState t; - col_0 = AES_INVMIXCOLUMN(col_0); - col_1 = AES_INVMIXCOLUMN(col_1); - - result = ((uint64_t)col_1 << 32) | col_0; - - return result; + t.d[HOST_BIG_ENDIAN] = rs1; + t.d[!HOST_BIG_ENDIAN] = 0; + aesdec_IMC(&t, &t, false); + return t.d[HOST_BIG_ENDIAN]; } target_ulong HELPER(sm4ed)(target_ulong rs1, target_ulong rs2,