From patchwork Sun Jul 9 13:59:34 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 700823 Delivered-To: patch@linaro.org Received: by 2002:adf:fcc5:0:0:0:0:0 with SMTP id f5csp4741147wrs; Sun, 9 Jul 2023 07:02:45 -0700 (PDT) X-Google-Smtp-Source: APBJJlFp6eyaWenepAczNziCCdTwddQeGn18tzHa7qq7tuiVGY2A9QBtmn5D4crFRAolKFCNZj8B X-Received: by 2002:a0c:f394:0:b0:62b:3c25:5ae9 with SMTP id i20-20020a0cf394000000b0062b3c255ae9mr7553857qvk.65.1688911365531; Sun, 09 Jul 2023 07:02:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1688911365; cv=none; d=google.com; s=arc-20160816; b=zfWRKfELQjwixEuIuRqrdveZuvdUCf2t2GupqU+zo9rD2QTBLYqu/LAGOZ3Y5IFZTk VenXnQNa1SpuOpUVXMP3vUn19H0trgvklWNMpjappa6+XtgDt0SGy/6WvCx4p6z2YsZ9 cIxfWhSs9x0Iw2y5Sz9sgkRC4SBYYh6u35Z8EyLGx4O4oyd0iwiGrNW6WYnqHD8LvlyG 4VXvGFFLZTthdsjhvLgdteRHYvUdWcDeAAfki0TkN+ErL974U2EfWii1VofM7Ak+2ZGQ fE1sbZTzaaBP1o+8jyVFX/Rb546+Av/YsfGqsl5Ooe4e7l8ibFAJIgJ8zK6BIntKlujo 9b9A== 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=i1mkeM7bD/ppus3C3v+92ltBBCUUU0zBXrpbYjAjHqE=; b=TUrSMmamAAj6i+YoOo7PdBey+ACOSUuZ0ImEC7lJRAkGkk+6SDXPo8TK2oKSokv096 papXUKC44zIZFksa/l79Lgbk2vSYlNDtYzStMtoGJzxr+qpb8jidbkJOPhHgqK9M49wQ fyfswqhp8V/TlLDxtaZsk88Ut/Qca9iU9jg2Uuu5OAs29Vqdw5RtaEWpXJIb4Yl353r5 7DR86lqhc+lxI+IVUhtfS8nkFnHJEzVkqjm7J4JDSvAu6tTHWzK/ID43/k5TmuRn0Cd+ 3CiuSy8z7P3gpREvLsvtSDRYAwucM7oERakEDtZMTyHfuXJAivK+iCDV7+MKCJvIrIfN nstA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=HRCjT0oc; 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 m6-20020ae9f206000000b00766ff1439e7si4594091qkg.741.2023.07.09.07.02.45 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Sun, 09 Jul 2023 07:02:45 -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=HRCjT0oc; 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 1qIUxi-0000ba-85; Sun, 09 Jul 2023 10:00:30 -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 1qIUxR-0000PK-U3 for qemu-devel@nongnu.org; Sun, 09 Jul 2023 10:00:14 -0400 Received: from mail-wm1-x32e.google.com ([2a00:1450:4864:20::32e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qIUxQ-0000dS-Bp for qemu-devel@nongnu.org; Sun, 09 Jul 2023 10:00:13 -0400 Received: by mail-wm1-x32e.google.com with SMTP id 5b1f17b1804b1-3fbc5d5746cso41875015e9.2 for ; Sun, 09 Jul 2023 07:00:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1688911210; x=1691503210; 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=HRCjT0ocWashqocfuY2t+xUNBU6tYwvdEedjNAlRCNyfik8BN7dM6MMiL4WbyAjexz D2WHeJNk21Vi87ngO8aotsC9u5Zt19P2ggwzMM6oRf7HIEPUc4SEvwh4A+c2vl5bxNMt D/6rmQ0EmTggATLc9n17Rx4ydj//wUTP8aBgv03nC4G5r/argDCEOoQOlFBFWY1u3PoM XYHfMpU5X8U/889eieVlmgekgBpc83jbVOGvMrzmGIZ4aj5l9lZnIE+qC149iU8vQ+zm MOtPxVXLirkU8FcRTtu7mUhLoYDWCf1ppmeqqHyodlJwC5U+oV9zBaOAPE/wzN4uVde4 NS8Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1688911210; x=1691503210; 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=QD04yzI9WqGkYU42U7D2UmJcGaT7NRrKI/bRsjeeZa57AjszBv2DtyNC1qu4pu/T5h mR1Wv1/XPDlwligVElTO+TTtRPnNbNPJmJAsQ/rE0BtcZcL79G8Hwc1WhjhlaUgmMO3+ ytFyV0muNqg78OzzS5pjNi3ROYk9IkDpzmW28hfFpTVtSqmvhkhzs3SLjwBu3GKb7Dpw oIkWkq2IESKtMhETRWUbpAmFr+8T9kJhqFEEHHyd0Lim0emKrt1aOjGDB1cV92yvHI86 E4cCoT5FWQL5XH+tKNAbvJEy4Xf5OdnIuI5SJrsZBQ0P7iFcOvCOQDo4v6rHxlmJPyUa iEhA== X-Gm-Message-State: ABy/qLa9XSkq1OENK4yRZgAJG1AD5tgBi3ahXWKhp4spWdvLkVCx7Qp5 bgudw7lqH/XYt7m5gvEPMBO7rL4AAcFfORjISxVrOQ== X-Received: by 2002:a05:600c:11cf:b0:3fc:e7d:ca3e with SMTP id b15-20020a05600c11cf00b003fc0e7dca3emr1385211wmi.2.1688911209936; Sun, 09 Jul 2023 07:00:09 -0700 (PDT) Received: from stoup.. ([148.252.133.210]) by smtp.gmail.com with ESMTPSA id v18-20020a5d6792000000b003063a92bbf5sm9239422wru.70.2023.07.09.07.00.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 09 Jul 2023 07:00:09 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Subject: [PULL 26/37] target/arm: Use aesdec_ISB_ISR_AK Date: Sun, 9 Jul 2023 14:59:34 +0100 Message-Id: <20230709135945.250311-27-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::32e; envelope-from=richard.henderson@linaro.org; helo=mail-wm1-x32e.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)); }