From patchwork Fri Jun 9 02:23:45 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 690873 Delivered-To: patch@linaro.org Received: by 2002:a5d:4d8a:0:0:0:0:0 with SMTP id b10csp598631wru; Thu, 8 Jun 2023 19:29:54 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ4lDGO8vJMJbZH1ERQjV3P1i22VpvD7pEWNmpszMHSNKaY9XZ1IW+M6DJXod5tXQ08zatFb X-Received: by 2002:a05:622a:11d1:b0:3f5:3991:97a5 with SMTP id n17-20020a05622a11d100b003f5399197a5mr257761qtk.54.1686277794528; Thu, 08 Jun 2023 19:29:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686277794; cv=none; d=google.com; s=arc-20160816; b=04Fvtww/fyP49Yh35GCQ18qp5j6AARc4lwIkCuWzHrVVzTYculCKPN13ktbmdQiXel TrTUWdKJQCfF11W0/Dv8BpQSbj7kXPXmgnZoUhDrM90TZ0JkQOULi4w54gx0m2fT4vUR /P5G7dxWvgYd6S6smqpnbRclvuJ8P+xVJDSb21KaE48lr9itxzlBtmBR6P0ppvdXE1nK //FsJ5PYmdaaccqx3+CmiDvFU1ENVsjRamzVVluw3nGf2lFMrJH98Mt9w/JF8ikyte7G C9dpDkY1tom+Gf00NHUHGBlL7UQq4yInOAfNYe565ZNP30VZ+XqTzRylh1ISPVvS3EHE A/hA== 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=wdQDFrqLzCXuyC5QVWRK2B0IpJSLb3HFq2dAPlM4rgJneR+IBkHcuUXd7vYAP8Xcoa K9D6HPI/KerBQXb2pm4Zsom2ZVSsH2dze2NmEhtnmy4w9m8qGPna0yTkiNbC+pDGGijM hKE+lM2iHSh8z4WpNbX7JTAZdl64XRB8z/U8mmSu5d9/2/KQ3E53pBrLr+fweTp8RxWV ap1oFp44FtfVN3FOXFYipn+UYuZUpqk8nxG+w6LPdkiuLfoJQdVqFhiys9CklL9Uy+8L 2B9hlvXxV2D8nmDSjFA7ZFqmXVRcY2R/8EKBquOjb84PafELsXLugKeTX0H2qmtnRR23 TD8w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=fr93+Q1U; 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 a17-20020a05622a065100b003f88f2f6f99si1551890qtb.733.2023.06.08.19.29.54 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 08 Jun 2023 19:29:54 -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=fr93+Q1U; 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 1q7RpC-0005T5-2M; Thu, 08 Jun 2023 22:26:02 -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 1q7Ro9-0002zh-1F for qemu-devel@nongnu.org; Thu, 08 Jun 2023 22:24:58 -0400 Received: from mail-ot1-x32c.google.com ([2607:f8b0:4864:20::32c]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1q7Rne-0005iV-GV for qemu-devel@nongnu.org; Thu, 08 Jun 2023 22:24:56 -0400 Received: by mail-ot1-x32c.google.com with SMTP id 46e09a7af769-6b16cbe4fb6so267648a34.1 for ; Thu, 08 Jun 2023 19:24:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1686277463; x=1688869463; 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=fr93+Q1U2PD+JQfSLYE6ejXnlf/9aJU8i+mopYExeIEYgsnW8LEt3U38UvZtFgE8Wa tEAf0AtoBWkuawdczPFJvl2wspjamDs/1qIWS2Q6cqW3ayM0FOqXXI/uZn6rNLLDrtIy /4rDb5YIlbjyhRL2w9YfYYFgAqrBitob3rGUWClMxfWjQZVGhaR/CmFKlxt2X++PEynf Tvx0GVt1xaYzDCiUs4W4BX5iNX4W6oqRRw393+DYANfuiVoCt3uOIRuttBSWg95QRbl2 Qg4ED6JZTv9HThCyAq7d8a4Ez4kuOyBNR0TwJLPoaxbETkx2qjCzJkDwAuTvQHFfkvxM BDrQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1686277463; x=1688869463; 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=L5un1hWpDi3Gio2DdZqYBkxPJo+moZLqVKKHHb6OtzqcNK1nyqY+UmFQv9yMIXxMGf Oww0FxwMRQh3sbueaGpV3eWJtWe7A0rtjPh/tthXcqQ+Gczvo4Rbuf0ah5+OWCL9prx9 tfUyg7syG4MZ8jfgG/angsL3PWbNw/7/z9G9FxK5HpGKDVureuoDl+0JJf+zCapkhVbo 49aXWa2XpQi6k9TbI2UHq2D6PlU/e+PHxGIa40XTwMGzq45UeZxMYcJYCI7CcexRi2Ii fDf7LkPE1oB8ia0onBq5G0/i60mqCJEYGIfi0c4wdt1J9jelib72foPsZ4YLe9gdwvMP ZIAg== X-Gm-Message-State: AC+VfDyMWfq6sjOp1TXZaosQfwRIaKv04kNcKvJ17/zn7W3SSRNZ4Sgu 6Ld7POXotVsOux9MfGUKHRYoomYg9LEcSHrqQXo= X-Received: by 2002:a9d:6187:0:b0:6b2:9608:4333 with SMTP id g7-20020a9d6187000000b006b296084333mr215057otk.16.1686277463381; Thu, 08 Jun 2023 19:24:23 -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.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 08 Jun 2023 19:24:23 -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 22/38] target/riscv: Use aesdec_IMC Date: Thu, 8 Jun 2023 19:23:45 -0700 Message-Id: <20230609022401.684157-23-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::32c; envelope-from=richard.henderson@linaro.org; helo=mail-ot1-x32c.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,