From patchwork Sun Jul 9 18:29:04 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 700918 Delivered-To: patch@linaro.org Received: by 2002:adf:fcc5:0:0:0:0:0 with SMTP id f5csp4830238wrs; Sun, 9 Jul 2023 11:43:17 -0700 (PDT) X-Google-Smtp-Source: APBJJlHt7jNJgPqqmvaQn84ReF0VnwxNgn1oLr64fqZmv/ycBk9WZk/HQsqu2M0KPcPZqpq+Zga/ X-Received: by 2002:a0c:8ccf:0:b0:632:1aa1:1a8c with SMTP id q15-20020a0c8ccf000000b006321aa11a8cmr8300459qvb.25.1688928196915; Sun, 09 Jul 2023 11:43:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1688928196; cv=none; d=google.com; s=arc-20160816; b=dlHf5duphrpmmAVQYZtlytZ4pv44vj/v0loNT6soe5hhMWdjjcDCjQLXzCaebtBKlC m1xhK5KEmkYglWz0pwRtOAU7OEMG/7IlImpmVB39jAgKt9agKgoyLTYjaSkuMha8ALsr jkn/ket3ZhUriA0a3mTXdwrU8XlgJ5dXPb3J2CKGZrHA8CJNPq3ZjAVYA8NE8GHaWzN6 eJeQQGETKO8wkBJP18S+2XVwGzr42UK/MwoUGjuNTeeT3bpxE1UqwNvRjEqLvchw8jsW ZQuNX/haiVe3P2/d1kCRiyJ5bbksx/b9hkC5BjwhoRT7lI7vpO1SDrrTeckzrBP2RXT9 AfVg== 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=cKGE3OvFNd5jAIbGE9ocD3KdoxUzDMvYMbDIoK+kebA=; fh=3IEiF/YPZ00TE94rna3Orj/L+TRFhpuNf7ElRJz3ubE=; b=Ztq8gofoAEj55RZ/S++fwTC9nXW8fHt9lvORb72sukYdepQXnx48r4bDJ/v6pGnMvm fqGM+TUoZeG0YJF73B6IDuHCyAjKVc9XE39nKePQE74hvZcI7WF4rN3ZNtNwdydXlZvt uWss1zn5I3QVFk9+Jzs/9IyVT93qxp4p3YkRcQqEOXMc4p5CasYdTEkeWJnuVm8qaS9m OAKslUDmo0dVkIqxpZR0Qtb/+77MNM6Haf2thBEoe2ZXV166+GHQNWzxrjI3Tx8Xe4+U vgYfQNeMvtuYX4QlqNA0oFcYSF1N2CE3YcD2chuZij65nTxI8kYfQMPlEvZuI5Np6hhH 29yA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=vScQjbkP; 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 k10-20020a0cf28a000000b005ef6e5c03a0si4885986qvl.224.2023.07.09.11.43.16 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Sun, 09 Jul 2023 11:43:16 -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=vScQjbkP; 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 1qIZEH-0005hX-FV; Sun, 09 Jul 2023 14:33:53 -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 1qIZDp-0003Rw-EY for qemu-devel@nongnu.org; Sun, 09 Jul 2023 14:33:26 -0400 Received: from mail-wr1-x42d.google.com ([2a00:1450:4864:20::42d]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qIZDm-0004D4-QF for qemu-devel@nongnu.org; Sun, 09 Jul 2023 14:33:25 -0400 Received: by mail-wr1-x42d.google.com with SMTP id ffacd0b85a97d-313fb7f0f80so3705454f8f.2 for ; Sun, 09 Jul 2023 11:33:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1688927601; x=1691519601; 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=cKGE3OvFNd5jAIbGE9ocD3KdoxUzDMvYMbDIoK+kebA=; b=vScQjbkPhMpo8WTzIasfj9G1DPhrTyZftcLRkAUP3To/+U3FCPZvwizKS8tBbSs5/9 5U/3xZ91St20qOvWNaqkpAaog6yGfC7lylujnyAMPZUP12aM38w1i7nGooC7UcbJKq5n zlX3pWxxd4UUKf279DqlHZ0vPyMTCRXCnUabjecvA9eiX/uYRMbJdN4JdMhDVd4JfMNW 0BR0fNxUr0GRYbS1xl+ZfUV8N2k4fNSJ//dMRiTZjWIzEkmUIOs9SJopf2CYovFUz+Nk LLYWdsRAdN7Ltaj7szvE83pn9/EtQBmQQkUMja4z8kpCpLsF4C/Tkba59X6HhwGnatlb AJoQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1688927601; x=1691519601; 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=cKGE3OvFNd5jAIbGE9ocD3KdoxUzDMvYMbDIoK+kebA=; b=fPhwvFXsr1DzVc4r/V+hAxEQg9HvtTBzm/xrDOxpl0rKMNVdP3kJpKOBT4CZPZ04X8 MfpvGiZ1Mr04FIt+n8oN0pP8m8aR8VB9EKJbW3QvXHQA/swmhjtxjS9p5KjorOWwPXR2 27gVIzCJyX54k6lSru3ItBbxjGSMFcT44ZcZkOcaAYxe0IoCyj0TZRnYaY1p8wb/QRYB 454K30o4pRUrI//im7xHSugHB9GqJ0NiXH+3JUytbblLTB1cvCj87JbAINBtounSeKno z49DaQNK0zN/2Rr2MNtwDymAkR3zty8f5OAmZTrJLRbh4z+MKO4xp8d7hxpoHpl37rTT kipQ== X-Gm-Message-State: ABy/qLbmhmQauQ8SIOpBbFmSBKbYJrBSQDszajzQSVox3OMa0TdCLpPj SKq2pBu1D2DwU+9BXw+GXPTiULDhDKm58CMWuMzZuA== X-Received: by 2002:a5d:4109:0:b0:30f:c1ab:a039 with SMTP id l9-20020a5d4109000000b0030fc1aba039mr8156992wrp.40.1688927601477; Sun, 09 Jul 2023 11:33:21 -0700 (PDT) Received: from stoup.. ([148.252.133.210]) by smtp.gmail.com with ESMTPSA id e17-20020a5d4e91000000b0031433760a92sm9635256wru.115.2023.07.09.11.33.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 09 Jul 2023 11:33:21 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: laurent@vivier.eu, =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Subject: [PULL 26/37] target/arm: Use aesdec_ISB_ISR_AK Date: Sun, 9 Jul 2023 19:29:04 +0100 Message-Id: <20230709182934.309468-53-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230709182934.309468-1-richard.henderson@linaro.org> References: <20230709182934.309468-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::42d; envelope-from=richard.henderson@linaro.org; helo=mail-wr1-x42d.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. Reviewed-by: Philippe Mathieu-Daudé 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)); }