From patchwork Tue Jun 20 11:07: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: 694463 Delivered-To: patch@linaro.org Received: by 2002:adf:e885:0:0:0:0:0 with SMTP id d5csp245100wrm; Tue, 20 Jun 2023 04:11:48 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ4Xtqx5oU7c9A8fGB+5jVNn9dIEufmthwBNtcPY1DKCxLcR9+3S0wtwtPVumnHE7HhQe0/e X-Received: by 2002:a05:620a:4542:b0:75b:23a1:830c with SMTP id u2-20020a05620a454200b0075b23a1830cmr17197230qkp.7.1687259507907; Tue, 20 Jun 2023 04:11:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1687259507; cv=none; d=google.com; s=arc-20160816; b=RRNTXVnJfv+F+Li1Y58LqGwLH56nQVOcesV7RgxQ+xZBcfD6wTrTSTJqkoSBJf/XMO tNL7e3iYIoWIbK3dgiEy2YOezlnRqVjQTIc5fUVNTMZBh+3rmoVPAyt6aimVCU8+6zE6 OgSzrpTwUMAhZ4Cya9/afltHM0Lt9cFfEloQOKlLNVisYFV9mgcmmaZWRD6IkfGOPytc 0esytevTqB77FKPY2eaLnQZ+moYEKIeIK8VrCEnu1eX/cnmedRM3SNniZyHz3o2Ac74n uHJRPuartz8PCxlXA8gV8ZI6iPixIScFFN5n1sqnyOEjRHvXvvU4ZBJYMq6GsFjUx+M5 5s8A== 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=UEsv77WByzgBc2oRedydI0QuEnu20ntgk1P70X2mStE=; b=vQFx+YvajyxGQyd/3uSVuT5hOIZRL/s+s6mQ5akHMCYkKFhZzhpiJtXXbGf6UMEmOl DLzqHPuAvxqNIzAg4F3phs4EDPKYprqLkCMeUQvEF0N2W710l1z5at1DmTe4C8Znscvf oRgeYJugPsqzjPsuD08JCnzy61uYZNpVqu17Lazo4PxWNayP1OloDPJ+NFplRF6pN448 hw3dXYRT6h3ij33vyJpsovG7HzN5OX8KEp9DMPawB7ct0ndFxOeEtrjc9Ir2JsLimDDo q4VYkeLUI0gMPlzVXez29I4eMniGBThkCmzkXw9td8WPi1DroPaWCmmojJvvyqCbLurS 8gbw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=ZwEB19DP; 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 c24-20020a05620a165800b00763acf99b68si524405qko.113.2023.06.20.04.11.47 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 20 Jun 2023 04:11:47 -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=ZwEB19DP; 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 1qBZDl-00069E-Ej; Tue, 20 Jun 2023 07:08:25 -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 1qBZDj-00067J-By for qemu-devel@nongnu.org; Tue, 20 Jun 2023 07:08:23 -0400 Received: from mail-ej1-x632.google.com ([2a00:1450:4864:20::632]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qBZDh-0004Jf-0g for qemu-devel@nongnu.org; Tue, 20 Jun 2023 07:08:22 -0400 Received: by mail-ej1-x632.google.com with SMTP id a640c23a62f3a-987341238aeso542383566b.3 for ; Tue, 20 Jun 2023 04:08:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1687259299; x=1689851299; 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=UEsv77WByzgBc2oRedydI0QuEnu20ntgk1P70X2mStE=; b=ZwEB19DP0Y51HvcDx58pBIGaunhwqG0Iig5hiyxnmvTQbN3qvDT00cMtGJUIWLNARu UOV3epHi6fsBKOP+X1iw5k5UoCGhiRWeGZSIUiWrBhsu1kIpyIJhbDNXZQDaorSsfCau uI3Snu+9wae4lbTb3rKhWK9auoU/r/sPqX1/QUTz83Z30yIaB9CTAWhMucjzq7LI2zro 9tPJOYgvL67s727uWY4xQdNqrlNDMlmwI/grJKl7n5Q3kBDEBfqu6Vez4Te+3gQjwATk YOnVMB+3PYsJ87nmvSPimR9j4cm3VC2fb1nsq0TaZgB7DavZQ72RB2FmEkMMQHllJeIE XkEw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1687259299; x=1689851299; 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=UEsv77WByzgBc2oRedydI0QuEnu20ntgk1P70X2mStE=; b=VWM+3inXq75XTv/572dg7pgSVhi4YGuQyErtmp9ohHwkbFnMTU0iR7HxQG9FO9vSvv vrjM7rloJp1N3sngZfTmPuiCvmPL5u1VpamnDHxHOHUVs3cMUBv+uSxRRJB31Pmq9TWD 0t8pRRySdwoqJ9666MvDnx9MooBgWph2xTbkjWfSN6rEOhabCH0T74fcOYT+t8WI6DWs Ts88aTHQf3kk13nQRIyoJa2IYA9VNSR/WsMpkQ2cM294Whsd7YwKphOyPhY5VerdMWVd ksMPLaf4hC0PmV8fSuBxYHlEf9XHJG7ZpA5vyF+cot9X/6rYtL2l/oXmyPCSeJr2ASxG 1x8A== X-Gm-Message-State: AC+VfDzJG586nI5KpJfWO+JiCYcJjJ1FA2EgPBDsN28jOFwF9Jyjt6ch N2qFUf8yQFS/qklYK3kGnsyS1cjuYZIRABPuVdppRUx/ X-Received: by 2002:a17:907:2d91:b0:977:cbaf:bc56 with SMTP id gt17-20020a1709072d9100b00977cbafbc56mr12474904ejc.43.1687259299761; Tue, 20 Jun 2023 04:08:19 -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.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 20 Jun 2023 04:08:19 -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 13/37] target/arm: Use aesdec_ISB_ISR_AK Date: Tue, 20 Jun 2023 13:07:34 +0200 Message-Id: <20230620110758.787479-14-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::632; envelope-from=richard.henderson@linaro.org; helo=mail-ej1-x632.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 AESD instruction. Signed-off-by: Richard Henderson --- target/arm/tcg/crypto_helper.c | 37 +++++++++++++++------------------- 1 file changed, 16 insertions(+), 21 deletions(-) diff --git a/target/arm/tcg/crypto_helper.c b/target/arm/tcg/crypto_helper.c index 00f3b21507..d2cb74e7fc 100644 --- a/target/arm/tcg/crypto_helper.c +++ b/target/arm/tcg/crypto_helper.c @@ -48,26 +48,6 @@ static void clear_tail_16(void *vd, uint32_t desc) static const AESState aes_zero = { }; -static void do_crypto_aese(uint64_t *rd, uint64_t *rn, uint64_t *rm, - const uint8_t *sbox, const uint8_t *shift) -{ - union CRYPTO_STATE rk = { .l = { rm[0], rm[1] } }; - union CRYPTO_STATE st = { .l = { rn[0], rn[1] } }; - int i; - - /* xor state vector with round key */ - rk.l[0] ^= st.l[0]; - rk.l[1] ^= st.l[1]; - - /* combine ShiftRows operation and sbox substitution */ - for (i = 0; i < 16; i++) { - CR_ST_BYTE(st, i) = sbox[CR_ST_BYTE(rk, shift[i])]; - } - - rd[0] = st.l[0]; - rd[1] = st.l[1]; -} - void HELPER(crypto_aese)(void *vd, void *vn, void *vm, uint32_t desc) { intptr_t i, opr_sz = simd_oprsz(desc); @@ -102,7 +82,22 @@ void HELPER(crypto_aesd)(void *vd, void *vn, void *vm, uint32_t desc) intptr_t i, opr_sz = simd_oprsz(desc); for (i = 0; i < opr_sz; i += 16) { - do_crypto_aese(vd + i, vn + i, vm + i, AES_isbox, AES_ishifts); + AESState *ad = (AESState *)(vd + i); + AESState *st = (AESState *)(vn + i); + AESState *rk = (AESState *)(vm + i); + AESState t; + + /* Our uint64_t are in the wrong order for big-endian. */ + if (HOST_BIG_ENDIAN) { + t.d[0] = st->d[1] ^ rk->d[1]; + t.d[1] = st->d[0] ^ rk->d[0]; + aesdec_ISB_ISR_AK(&t, &t, &aes_zero, false); + ad->d[0] = t.d[1]; + ad->d[1] = t.d[0]; + } else { + t.v = st->v ^ rk->v; + aesdec_ISB_ISR_AK(ad, &t, &aes_zero, false); + } } clear_tail(vd, opr_sz, simd_maxsz(desc)); }