From nobody Tue May 14 18:40:19 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1688378788; cv=none; d=zohomail.com; s=zohoarc; b=ase5rNQ9J7ByO88N6vBxEY3Ea+LYR9gwNhTH21gUziEQUMMvmyoz3MWo7xABORVWPabhjEsD5s+jGmBP5gQG0aK7DhIfahLmM919kTEhuCrG32g6ja+j3tqIAKhFuQNOvcj3B4uPBiWXtOvNyUI2rQ7J4hrsfp8KhmuxybO/JD0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1688378788; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=KMA70dMb1SJ/eTe/2+zO5JW0aBcXeIGHYSkfDyZwFgY=; b=b28v0aMe0UhLJsaS0ANUXVr1Rnk1N6BedWG/Iv15cUR0pwkldEU8MNzpRokK7QkwZDK74ZJ1S1QmDKj281X+vYfr5Uq9LDqCO9AIZqQ1/RJMLXoUqqK4nuLQsM2wD/3bi7DJOyq/8I8wt4ae8shTRdI1YgqNuJV9/eK3GkLZy3s= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1688378788361225.9192974322433; Mon, 3 Jul 2023 03:06:28 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qGGRL-0002gM-2n; Mon, 03 Jul 2023 06:05:51 -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 1qGGRF-0002an-E8 for qemu-devel@nongnu.org; Mon, 03 Jul 2023 06:05:45 -0400 Received: from mail-wr1-x433.google.com ([2a00:1450:4864:20::433]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qGGR3-0005gc-F2 for qemu-devel@nongnu.org; Mon, 03 Jul 2023 06:05:39 -0400 Received: by mail-wr1-x433.google.com with SMTP id ffacd0b85a97d-311367a3e12so5737761f8f.2 for ; Mon, 03 Jul 2023 03:05:24 -0700 (PDT) Received: from stoup.home (91.232.79.188.dynamic.jazztel.es. [188.79.232.91]) by smtp.gmail.com with ESMTPSA id t5-20020a05600001c500b00313f7b077fesm18446562wrx.59.2023.07.03.03.05.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 03 Jul 2023 03:05:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1688378723; x=1690970723; 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=KMA70dMb1SJ/eTe/2+zO5JW0aBcXeIGHYSkfDyZwFgY=; b=aYjtH2H7qkJJalV8IVsFnz2q0v3zBLqYSvccnyC+f5R+UoL5Fbs9fOzEo5b+SMIa9f 7uwNk6NJCuXv+Zw7UoTdcJ3Blr+sfWvGynzOImjTnmWCpD9+y2lySoRIErraz5yWJbmk 7zSc+xLSoVWQ4z7ROcttwI2LNNctbIn9Ov7iF6LPB+c26zZnVgo1BTXfoU8vPNnWly9H O27I8l10OygS25j8+TZI7jx3IEAVaqVLilRAHgXCHSGDR7PV+7z1jwrP841Y6F2odDvN v7DJz1FTQI+Rdp9dCvbYr2MxZm+tMZ+CjlyFoJC3V1z2mu0aNVbLL+Z+MeBpIaRQ+v3v nGWw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1688378723; x=1690970723; 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=KMA70dMb1SJ/eTe/2+zO5JW0aBcXeIGHYSkfDyZwFgY=; b=leaisbS+ell5nBT3qcRaqogcnMJjgvM9o1bnMy/fV7mtGAclrBuD19u2jUV/O5orYc qF4YeivPl6D9mYOGD0osgJZbRwyH+DMhkbetB/prC+f9IZ8GTY/L/i+LQ/ZQVQBUz1yE GD3UIOj2NfBSe+BNDj4fKxXdJ/RrSJm5bLxKksKJHdlBqIyiBr89xzmi9kAfAUA0wp08 uD9qGiDHL3johu/NJs9pHkn12T4doJwzgQSQqUUcoSZ76YAyb1zDskzlHDI/PC+Bw7cY 6E8NVe7B0xi8MjiQ8fSEsIoeqvUST6OxLcPZwTVb0Fm8VKDx60AGkl1Nw1ZFpq9EwAzy P3TA== X-Gm-Message-State: ABy/qLYlogNod+QUwhxz0cL9hdwVhaJoEfLeU7qhbN1CZM1Oig9WeFcl /wL+hW6MKPxGoaEORH/MMrO7WktmoPIbfdHpNy6u4w== X-Google-Smtp-Source: APBJJlHWclKS9XEdI+syJ3HOK08iwxcg4XxKcynYmJrrOOdOIgOcZ6KS+IIfC/ztCq5PVztSbMr/Dw== X-Received: by 2002:adf:f00b:0:b0:314:130f:ce65 with SMTP id j11-20020adff00b000000b00314130fce65mr8701501wro.35.1688378723565; Mon, 03 Jul 2023 03:05:23 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: qemu-arm@nongnu.org, qemu-riscv@nongnu.org, pbonzini@redhat.com, eduardo@habkost.net, alistair.francis@wdc.com, danielhb413@gmail.com, =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Subject: [PATCH v4 01/37] util: Add cpuinfo-ppc.c Date: Mon, 3 Jul 2023 12:04:44 +0200 Message-Id: <20230703100520.68224-2-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230703100520.68224-1-richard.henderson@linaro.org> References: <20230703100520.68224-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::433; envelope-from=richard.henderson@linaro.org; helo=mail-wr1-x433.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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1688378790358100003 Move the code from tcg/. Fix a bug in that PPC_FEATURE2_ARCH_3_10 is actually spelled PPC_FEATURE2_ARCH_3_1. Reviewed-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Daniel Henrique Barboza Signed-off-by: Richard Henderson --- host/include/ppc/host/cpuinfo.h | 29 ++++++++++++++++ host/include/ppc64/host/cpuinfo.h | 1 + tcg/ppc/tcg-target.h | 16 ++++----- util/cpuinfo-ppc.c | 56 +++++++++++++++++++++++++++++++ tcg/ppc/tcg-target.c.inc | 44 +----------------------- util/meson.build | 2 ++ 6 files changed, 97 insertions(+), 51 deletions(-) create mode 100644 host/include/ppc/host/cpuinfo.h create mode 100644 host/include/ppc64/host/cpuinfo.h create mode 100644 util/cpuinfo-ppc.c diff --git a/host/include/ppc/host/cpuinfo.h b/host/include/ppc/host/cpuinf= o.h new file mode 100644 index 0000000000..df11e8d417 --- /dev/null +++ b/host/include/ppc/host/cpuinfo.h @@ -0,0 +1,29 @@ +/* + * SPDX-License-Identifier: GPL-2.0-or-later + * Host specific cpu indentification for ppc. + */ + +#ifndef HOST_CPUINFO_H +#define HOST_CPUINFO_H + +/* Digested version of */ + +#define CPUINFO_ALWAYS (1u << 0) /* so cpuinfo is nonzero */ +#define CPUINFO_V2_06 (1u << 1) +#define CPUINFO_V2_07 (1u << 2) +#define CPUINFO_V3_0 (1u << 3) +#define CPUINFO_V3_1 (1u << 4) +#define CPUINFO_ISEL (1u << 5) +#define CPUINFO_ALTIVEC (1u << 6) +#define CPUINFO_VSX (1u << 7) + +/* Initialized with a constructor. */ +extern unsigned cpuinfo; + +/* + * We cannot rely on constructor ordering, so other constructors must + * use the function interface rather than the variable above. + */ +unsigned cpuinfo_init(void); + +#endif /* HOST_CPUINFO_H */ diff --git a/host/include/ppc64/host/cpuinfo.h b/host/include/ppc64/host/cp= uinfo.h new file mode 100644 index 0000000000..2f036a0627 --- /dev/null +++ b/host/include/ppc64/host/cpuinfo.h @@ -0,0 +1 @@ +#include "host/include/ppc/host/cpuinfo.h" diff --git a/tcg/ppc/tcg-target.h b/tcg/ppc/tcg-target.h index c7552b6391..9a41fab8cc 100644 --- a/tcg/ppc/tcg-target.h +++ b/tcg/ppc/tcg-target.h @@ -25,6 +25,8 @@ #ifndef PPC_TCG_TARGET_H #define PPC_TCG_TARGET_H =20 +#include "host/cpuinfo.h" + #define MAX_CODE_GEN_BUFFER_SIZE ((size_t)-1) =20 #define TCG_TARGET_NB_REGS 64 @@ -61,14 +63,12 @@ typedef enum { tcg_isa_3_10, } TCGPowerISA; =20 -extern TCGPowerISA have_isa; -extern bool have_altivec; -extern bool have_vsx; - -#define have_isa_2_06 (have_isa >=3D tcg_isa_2_06) -#define have_isa_2_07 (have_isa >=3D tcg_isa_2_07) -#define have_isa_3_00 (have_isa >=3D tcg_isa_3_00) -#define have_isa_3_10 (have_isa >=3D tcg_isa_3_10) +#define have_isa_2_06 (cpuinfo & CPUINFO_V2_06) +#define have_isa_2_07 (cpuinfo & CPUINFO_V2_07) +#define have_isa_3_00 (cpuinfo & CPUINFO_V3_0) +#define have_isa_3_10 (cpuinfo & CPUINFO_V3_1) +#define have_altivec (cpuinfo & CPUINFO_ALTIVEC) +#define have_vsx (cpuinfo & CPUINFO_VSX) =20 /* optional instructions automatically implemented */ #define TCG_TARGET_HAS_ext8u_i32 0 /* andi */ diff --git a/util/cpuinfo-ppc.c b/util/cpuinfo-ppc.c new file mode 100644 index 0000000000..d95adc8ccd --- /dev/null +++ b/util/cpuinfo-ppc.c @@ -0,0 +1,56 @@ +/* + * SPDX-License-Identifier: GPL-2.0-or-later + * Host specific cpu indentification for ppc. + */ + +#include "qemu/osdep.h" +#include "host/cpuinfo.h" + +#ifdef CONFIG_GETAUXVAL +# include +#else +# include +# include "elf.h" +#endif + +unsigned cpuinfo; + +/* Called both as constructor and (possibly) via other constructors. */ +unsigned __attribute__((constructor)) cpuinfo_init(void) +{ + unsigned info =3D cpuinfo; + unsigned long hwcap, hwcap2; + + if (info) { + return info; + } + + hwcap =3D qemu_getauxval(AT_HWCAP); + hwcap2 =3D qemu_getauxval(AT_HWCAP2); + info =3D CPUINFO_ALWAYS; + + /* Version numbers are monotonic, and so imply all lower versions. */ + if (hwcap2 & PPC_FEATURE2_ARCH_3_1) { + info |=3D CPUINFO_V3_1 | CPUINFO_V3_0 | CPUINFO_V2_07 | CPUINFO_V2= _06; + } else if (hwcap2 & PPC_FEATURE2_ARCH_3_00) { + info |=3D CPUINFO_V3_0 | CPUINFO_V2_07 | CPUINFO_V2_06; + } else if (hwcap2 & PPC_FEATURE2_ARCH_2_07) { + info |=3D CPUINFO_V2_07 | CPUINFO_V2_06; + } else if (hwcap & PPC_FEATURE_ARCH_2_06) { + info |=3D CPUINFO_V2_06; + } + + if (hwcap2 & PPC_FEATURE2_HAS_ISEL) { + info |=3D CPUINFO_ISEL; + } + if (hwcap & PPC_FEATURE_HAS_ALTIVEC) { + info |=3D CPUINFO_ALTIVEC; + /* We only care about the portion of VSX that overlaps Altivec. */ + if (hwcap & PPC_FEATURE_HAS_VSX) { + info |=3D CPUINFO_VSX; + } + } + + cpuinfo =3D info; + return info; +} diff --git a/tcg/ppc/tcg-target.c.inc b/tcg/ppc/tcg-target.c.inc index 5c8378f8f6..c866f2c997 100644 --- a/tcg/ppc/tcg-target.c.inc +++ b/tcg/ppc/tcg-target.c.inc @@ -101,10 +101,7 @@ #define ALL_GENERAL_REGS 0xffffffffu #define ALL_VECTOR_REGS 0xffffffff00000000ull =20 -TCGPowerISA have_isa; -static bool have_isel; -bool have_altivec; -bool have_vsx; +#define have_isel (cpuinfo & CPUINFO_ISEL) =20 #ifndef CONFIG_SOFTMMU #define TCG_GUEST_BASE_REG 30 @@ -3879,45 +3876,6 @@ static TCGConstraintSetIndex tcg_target_op_def(TCGOp= code op) =20 static void tcg_target_init(TCGContext *s) { - unsigned long hwcap =3D qemu_getauxval(AT_HWCAP); - unsigned long hwcap2 =3D qemu_getauxval(AT_HWCAP2); - - have_isa =3D tcg_isa_base; - if (hwcap & PPC_FEATURE_ARCH_2_06) { - have_isa =3D tcg_isa_2_06; - } -#ifdef PPC_FEATURE2_ARCH_2_07 - if (hwcap2 & PPC_FEATURE2_ARCH_2_07) { - have_isa =3D tcg_isa_2_07; - } -#endif -#ifdef PPC_FEATURE2_ARCH_3_00 - if (hwcap2 & PPC_FEATURE2_ARCH_3_00) { - have_isa =3D tcg_isa_3_00; - } -#endif -#ifdef PPC_FEATURE2_ARCH_3_10 - if (hwcap2 & PPC_FEATURE2_ARCH_3_10) { - have_isa =3D tcg_isa_3_10; - } -#endif - -#ifdef PPC_FEATURE2_HAS_ISEL - /* Prefer explicit instruction from the kernel. */ - have_isel =3D (hwcap2 & PPC_FEATURE2_HAS_ISEL) !=3D 0; -#else - /* Fall back to knowing Power7 (2.06) has ISEL. */ - have_isel =3D have_isa_2_06; -#endif - - if (hwcap & PPC_FEATURE_HAS_ALTIVEC) { - have_altivec =3D true; - /* We only care about the portion of VSX that overlaps Altivec. */ - if (hwcap & PPC_FEATURE_HAS_VSX) { - have_vsx =3D true; - } - } - tcg_target_available_regs[TCG_TYPE_I32] =3D 0xffffffff; tcg_target_available_regs[TCG_TYPE_I64] =3D 0xffffffff; if (have_altivec) { diff --git a/util/meson.build b/util/meson.build index 3a93071d27..a375160286 100644 --- a/util/meson.build +++ b/util/meson.build @@ -113,4 +113,6 @@ if cpu =3D=3D 'aarch64' util_ss.add(files('cpuinfo-aarch64.c')) elif cpu in ['x86', 'x86_64'] util_ss.add(files('cpuinfo-i386.c')) +elif cpu in ['ppc', 'ppc64'] + util_ss.add(files('cpuinfo-ppc.c')) endif --=20 2.34.1 From nobody Tue May 14 18:40:19 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1688378798; cv=none; d=zohomail.com; s=zohoarc; b=WTR+QNFqJ4L92HThoLPSOx05DiSCnHCdT/FQBqiNpf+TormrmjPOIThsDpuH90tdn2K1M5miN1EnNqz1KqGyXqYKdvaPUlRLb2tMg6pghkiFOvr+sCBfPR50ducB+Dd+80q8cLnl9+u4s3dRURGskuMrDgxybq4D7U2C4NIpAZM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1688378798; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=mPmUCjpRZwFOi0fix68D6WvDW8xFOeagc+Ir4MNFYrg=; b=jkJz4dM1t2QmBKY5R8C7VrrFmyn9cxzd8h2h+4RBqFJthxgtqY8pcPYyN2XxfW9Iptevd+bIrMSd4kcdgb9rrKZKYV3cwPjOC0CvyiwGVg3/PE5z43pf3AKXyz7jTC6sj/I+d+SNvy+8P83eD8lETRMelXsG0JHo5rwcv7BX6dE= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1688378797891438.2090953143545; Mon, 3 Jul 2023 03:06:37 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qGGRI-0002eA-Tq; Mon, 03 Jul 2023 06:05:49 -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 1qGGR9-0002aI-FL for qemu-devel@nongnu.org; Mon, 03 Jul 2023 06:05:45 -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 1qGGR3-0005gv-6T for qemu-devel@nongnu.org; Mon, 03 Jul 2023 06:05:38 -0400 Received: by mail-wm1-x32e.google.com with SMTP id 5b1f17b1804b1-3fb4146e8fcso36047625e9.0 for ; Mon, 03 Jul 2023 03:05:25 -0700 (PDT) Received: from stoup.home (91.232.79.188.dynamic.jazztel.es. [188.79.232.91]) by smtp.gmail.com with ESMTPSA id t5-20020a05600001c500b00313f7b077fesm18446562wrx.59.2023.07.03.03.05.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 03 Jul 2023 03:05:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1688378725; x=1690970725; 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=mPmUCjpRZwFOi0fix68D6WvDW8xFOeagc+Ir4MNFYrg=; b=BhSqWarOcSNp5PqbEm3/Xek0TVUNfOSjL7eMV2LLLxBlUN/cGYTC34Rn6g0xzh3JQl rt1XtTsy7Vzfw6HD/m6hHVAmdybFNc5KSsBoHzMtkcQndiGnwUJ6OzVWgSuY4SFCvi8b ajBqK9hotpU8EFV4D1xGxI7i1PNLiYaxR7Ml2fFAKMbU3I4VJ43v8Xa5vw7qmUmxb7vE MFwRxi1Z/SJ1L13WeyXwaksnRHK3P9P/8BREW8bQoWTlQ44Q2aKhijMy33Dit6PBNvmq uNMdIH+Yij1EM6Ne5SsFffQwhz5OdYZ7XFeaaP/YRD9FIDgQj8lzVP4tj3oK4dmiPrkc PZyg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1688378725; x=1690970725; 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=mPmUCjpRZwFOi0fix68D6WvDW8xFOeagc+Ir4MNFYrg=; b=WJxIXhe0zYMI5etjsZQYUNl4W9laB7nPlGYB7NrDDcqZKSUPSH30h1LlYxd28QiXEs RkETw21Hzfmr5rGT7KKsm69Hx1pE25uzy4SsDhIj2S8yj8+kOjPE7DYqd4UKO/XmV6U7 tMGD+iG1RP9Fcp+PISU5+knH4VU5fpzYDHYN/UH+iZoOk8xjsnoq8GFhvQlGHrOQltf0 HuY8MNFqyD/11dndIoVfXbIyF1pd6uWMP5P3m8nNp/6rTxvLDddLEt8oWTW5M+glu8t8 S6461FcKU+rlWF9XCX2o9ucjQrZ9iHh7kRcRL3jmfz1m2NC/QmZdXcTvYsa2u9LuRL2B J5ZA== X-Gm-Message-State: AC+VfDy7vjapM4Z61ZDo1vXechbuQQ/X+ohx8qnkZsLfYNElxES+/Ah5 fUPzFPR5reeaQ5WTbgWXrFQ2Sgfbhod9cJB7KFmGtw== X-Google-Smtp-Source: ACHHUZ4OihRehnjJpZh8ECKZ5ZcKf4FPa0h9T0gpcz/jdgSbzUBqz4sJJwtOz0xHfIyccYvPoHxG+g== X-Received: by 2002:a05:600c:1e0b:b0:3fa:955a:9291 with SMTP id ay11-20020a05600c1e0b00b003fa955a9291mr13191697wmb.9.1688378724650; Mon, 03 Jul 2023 03:05:24 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: qemu-arm@nongnu.org, qemu-riscv@nongnu.org, pbonzini@redhat.com, eduardo@habkost.net, alistair.francis@wdc.com, danielhb413@gmail.com, =?UTF-8?q?Alex=20Benn=C3=A9e?= Subject: [PATCH v4 02/37] tests/multiarch: Add test-aes Date: Mon, 3 Jul 2023 12:04:45 +0200 Message-Id: <20230703100520.68224-3-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230703100520.68224-1-richard.henderson@linaro.org> References: <20230703100520.68224-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; 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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1688378800377100001 Use a shared driver and backends for i386, aarch64, ppc64, riscv64. Acked-by: Alex Benn=C3=A9e Signed-off-by: Richard Henderson --- tests/tcg/aarch64/test-aes.c | 58 ++++++++ tests/tcg/i386/test-aes.c | 68 +++++++++ tests/tcg/ppc64/test-aes.c | 116 +++++++++++++++ tests/tcg/riscv64/test-aes.c | 76 ++++++++++ tests/tcg/multiarch/test-aes-main.c.inc | 183 ++++++++++++++++++++++++ tests/tcg/aarch64/Makefile.target | 4 + tests/tcg/i386/Makefile.target | 4 + tests/tcg/ppc64/Makefile.target | 1 + tests/tcg/riscv64/Makefile.target | 13 ++ 9 files changed, 523 insertions(+) create mode 100644 tests/tcg/aarch64/test-aes.c create mode 100644 tests/tcg/i386/test-aes.c create mode 100644 tests/tcg/ppc64/test-aes.c create mode 100644 tests/tcg/riscv64/test-aes.c create mode 100644 tests/tcg/multiarch/test-aes-main.c.inc diff --git a/tests/tcg/aarch64/test-aes.c b/tests/tcg/aarch64/test-aes.c new file mode 100644 index 0000000000..2cd324f09b --- /dev/null +++ b/tests/tcg/aarch64/test-aes.c @@ -0,0 +1,58 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ + +#include "../multiarch/test-aes-main.c.inc" + +bool test_SB_SR(uint8_t *o, const uint8_t *i) +{ + /* aese also adds round key, so supply zero. */ + asm("ld1 { v0.16b }, [%1]\n\t" + "movi v1.16b, #0\n\t" + "aese v0.16b, v1.16b\n\t" + "st1 { v0.16b }, [%0]" + : : "r"(o), "r"(i) : "v0", "v1", "memory"); + return true; +} + +bool test_MC(uint8_t *o, const uint8_t *i) +{ + asm("ld1 { v0.16b }, [%1]\n\t" + "aesmc v0.16b, v0.16b\n\t" + "st1 { v0.16b }, [%0]" + : : "r"(o), "r"(i) : "v0", "memory"); + return true; +} + +bool test_SB_SR_MC_AK(uint8_t *o, const uint8_t *i, const uint8_t *k) +{ + return false; +} + +bool test_ISB_ISR(uint8_t *o, const uint8_t *i) +{ + /* aesd also adds round key, so supply zero. */ + asm("ld1 { v0.16b }, [%1]\n\t" + "movi v1.16b, #0\n\t" + "aesd v0.16b, v1.16b\n\t" + "st1 { v0.16b }, [%0]" + : : "r"(o), "r"(i) : "v0", "v1", "memory"); + return true; +} + +bool test_IMC(uint8_t *o, const uint8_t *i) +{ + asm("ld1 { v0.16b }, [%1]\n\t" + "aesimc v0.16b, v0.16b\n\t" + "st1 { v0.16b }, [%0]" + : : "r"(o), "r"(i) : "v0", "memory"); + return true; +} + +bool test_ISB_ISR_AK_IMC(uint8_t *o, const uint8_t *i, const uint8_t *k) +{ + return false; +} + +bool test_ISB_ISR_IMC_AK(uint8_t *o, const uint8_t *i, const uint8_t *k) +{ + return false; +} diff --git a/tests/tcg/i386/test-aes.c b/tests/tcg/i386/test-aes.c new file mode 100644 index 0000000000..199395e6cc --- /dev/null +++ b/tests/tcg/i386/test-aes.c @@ -0,0 +1,68 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ + +#include "../multiarch/test-aes-main.c.inc" +#include + +static bool test_SB_SR(uint8_t *o, const uint8_t *i) +{ + __m128i vi =3D _mm_loadu_si128((const __m128i_u *)i); + + /* aesenclast also adds round key, so supply zero. */ + vi =3D _mm_aesenclast_si128(vi, _mm_setzero_si128()); + + _mm_storeu_si128((__m128i_u *)o, vi); + return true; +} + +static bool test_MC(uint8_t *o, const uint8_t *i) +{ + return false; +} + +static bool test_SB_SR_MC_AK(uint8_t *o, const uint8_t *i, const uint8_t *= k) +{ + __m128i vi =3D _mm_loadu_si128((const __m128i_u *)i); + __m128i vk =3D _mm_loadu_si128((const __m128i_u *)k); + + vi =3D _mm_aesenc_si128(vi, vk); + + _mm_storeu_si128((__m128i_u *)o, vi); + return true; +} + +static bool test_ISB_ISR(uint8_t *o, const uint8_t *i) +{ + __m128i vi =3D _mm_loadu_si128((const __m128i_u *)i); + + /* aesdeclast also adds round key, so supply zero. */ + vi =3D _mm_aesdeclast_si128(vi, _mm_setzero_si128()); + + _mm_storeu_si128((__m128i_u *)o, vi); + return true; +} + +static bool test_IMC(uint8_t *o, const uint8_t *i) +{ + __m128i vi =3D _mm_loadu_si128((const __m128i_u *)i); + + vi =3D _mm_aesimc_si128(vi); + + _mm_storeu_si128((__m128i_u *)o, vi); + return true; +} + +static bool test_ISB_ISR_AK_IMC(uint8_t *o, const uint8_t *i, const uint8_= t *k) +{ + return false; +} + +static bool test_ISB_ISR_IMC_AK(uint8_t *o, const uint8_t *i, const uint8_= t *k) +{ + __m128i vi =3D _mm_loadu_si128((const __m128i_u *)i); + __m128i vk =3D _mm_loadu_si128((const __m128i_u *)k); + + vi =3D _mm_aesdec_si128(vi, vk); + + _mm_storeu_si128((__m128i_u *)o, vi); + return true; +} diff --git a/tests/tcg/ppc64/test-aes.c b/tests/tcg/ppc64/test-aes.c new file mode 100644 index 0000000000..1d2be488e9 --- /dev/null +++ b/tests/tcg/ppc64/test-aes.c @@ -0,0 +1,116 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ + +#include "../multiarch/test-aes-main.c.inc" + +#undef BIG_ENDIAN +#define BIG_ENDIAN (__BYTE_ORDER__ =3D=3D __ORDER_BIG_ENDIAN__) + +static unsigned char bswap_le[16] __attribute__((aligned(16))) =3D { + 8,9,10,11,12,13,14,15, + 0,1,2,3,4,5,6,7 +}; + +bool test_SB_SR(uint8_t *o, const uint8_t *i) +{ + /* vcipherlast also adds round key, so supply zero. */ + if (BIG_ENDIAN) { + asm("lxvd2x 32,0,%1\n\t" + "vspltisb 1,0\n\t" + "vcipherlast 0,0,1\n\t" + "stxvd2x 32,0,%0" + : : "r"(o), "r"(i) : "memory", "v0", "v1"); + } else { + asm("lxvd2x 32,0,%1\n\t" + "lxvd2x 34,0,%2\n\t" + "vspltisb 1,0\n\t" + "vperm 0,0,0,2\n\t" + "vcipherlast 0,0,1\n\t" + "vperm 0,0,0,2\n\t" + "stxvd2x 32,0,%0" + : : "r"(o), "r"(i), "r"(bswap_le) : "memory", "v0", "v1", "v2"= ); + } + return true; +} + +bool test_MC(uint8_t *o, const uint8_t *i) +{ + return false; +} + +bool test_SB_SR_MC_AK(uint8_t *o, const uint8_t *i, const uint8_t *k) +{ + if (BIG_ENDIAN) { + asm("lxvd2x 32,0,%1\n\t" + "lxvd2x 33,0,%2\n\t" + "vcipher 0,0,1\n\t" + "stxvd2x 32,0,%0" + : : "r"(o), "r"(i), "r"(k) : "memory", "v0", "v1"); + } else { + asm("lxvd2x 32,0,%1\n\t" + "lxvd2x 33,0,%2\n\t" + "lxvd2x 34,0,%3\n\t" + "vperm 0,0,0,2\n\t" + "vperm 1,1,1,2\n\t" + "vcipher 0,0,1\n\t" + "vperm 0,0,0,2\n\t" + "stxvd2x 32,0,%0" + : : "r"(o), "r"(i), "r"(k), "r"(bswap_le) + : "memory", "v0", "v1", "v2"); + } + return true; +} + +bool test_ISB_ISR(uint8_t *o, const uint8_t *i) +{ + /* vcipherlast also adds round key, so supply zero. */ + if (BIG_ENDIAN) { + asm("lxvd2x 32,0,%1\n\t" + "vspltisb 1,0\n\t" + "vncipherlast 0,0,1\n\t" + "stxvd2x 32,0,%0" + : : "r"(o), "r"(i) : "memory", "v0", "v1"); + } else { + asm("lxvd2x 32,0,%1\n\t" + "lxvd2x 34,0,%2\n\t" + "vspltisb 1,0\n\t" + "vperm 0,0,0,2\n\t" + "vncipherlast 0,0,1\n\t" + "vperm 0,0,0,2\n\t" + "stxvd2x 32,0,%0" + : : "r"(o), "r"(i), "r"(bswap_le) : "memory", "v0", "v1", "v2"= ); + } + return true; +} + +bool test_IMC(uint8_t *o, const uint8_t *i) +{ + return false; +} + +bool test_ISB_ISR_AK_IMC(uint8_t *o, const uint8_t *i, const uint8_t *k) +{ + if (BIG_ENDIAN) { + asm("lxvd2x 32,0,%1\n\t" + "lxvd2x 33,0,%2\n\t" + "vncipher 0,0,1\n\t" + "stxvd2x 32,0,%0" + : : "r"(o), "r"(i), "r"(k) : "memory", "v0", "v1"); + } else { + asm("lxvd2x 32,0,%1\n\t" + "lxvd2x 33,0,%2\n\t" + "lxvd2x 34,0,%3\n\t" + "vperm 0,0,0,2\n\t" + "vperm 1,1,1,2\n\t" + "vncipher 0,0,1\n\t" + "vperm 0,0,0,2\n\t" + "stxvd2x 32,0,%0" + : : "r"(o), "r"(i), "r"(k), "r"(bswap_le) + : "memory", "v0", "v1", "v2"); + } + return true; +} + +bool test_ISB_ISR_IMC_AK(uint8_t *o, const uint8_t *i, const uint8_t *k) +{ + return false; +} diff --git a/tests/tcg/riscv64/test-aes.c b/tests/tcg/riscv64/test-aes.c new file mode 100644 index 0000000000..3d7ef0e33a --- /dev/null +++ b/tests/tcg/riscv64/test-aes.c @@ -0,0 +1,76 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ + +#include "../multiarch/test-aes-main.c.inc" + +bool test_SB_SR(uint8_t *o, const uint8_t *i) +{ + uint64_t *o8 =3D (uint64_t *)o; + const uint64_t *i8 =3D (const uint64_t *)i; + + asm("aes64es %0,%2,%3\n\t" + "aes64es %1,%3,%2" + : "=3D&r"(o8[0]), "=3D&r"(o8[1]) : "r"(i8[0]), "r"(i8[1])); + return true; +} + +bool test_MC(uint8_t *o, const uint8_t *i) +{ + return false; +} + +bool test_SB_SR_MC_AK(uint8_t *o, const uint8_t *i, const uint8_t *k) +{ + uint64_t *o8 =3D (uint64_t *)o; + const uint64_t *i8 =3D (const uint64_t *)i; + const uint64_t *k8 =3D (const uint64_t *)k; + + asm("aes64esm %0,%2,%3\n\t" + "aes64esm %1,%3,%2\n\t" + "xor %0,%0,%4\n\t" + "xor %1,%1,%5" + : "=3D&r"(o8[0]), "=3D&r"(o8[1]) + : "r"(i8[0]), "r"(i8[1]), "r"(k8[0]), "r"(k8[1])); + return true; +} + +bool test_ISB_ISR(uint8_t *o, const uint8_t *i) +{ + uint64_t *o8 =3D (uint64_t *)o; + const uint64_t *i8 =3D (const uint64_t *)i; + + asm("aes64ds %0,%2,%3\n\t" + "aes64ds %1,%3,%2" + : "=3D&r"(o8[0]), "=3D&r"(o8[1]) : "r"(i8[0]), "r"(i8[1])); + return true; +} + +bool test_IMC(uint8_t *o, const uint8_t *i) +{ + uint64_t *o8 =3D (uint64_t *)o; + const uint64_t *i8 =3D (const uint64_t *)i; + + asm("aes64im %0,%0\n\t" + "aes64im %1,%1" + : "=3Dr"(o8[0]), "=3Dr"(o8[1]) : "0"(i8[0]), "1"(i8[1])); + return true; +} + +bool test_ISB_ISR_AK_IMC(uint8_t *o, const uint8_t *i, const uint8_t *k) +{ + return false; +} + +bool test_ISB_ISR_IMC_AK(uint8_t *o, const uint8_t *i, const uint8_t *k) +{ + uint64_t *o8 =3D (uint64_t *)o; + const uint64_t *i8 =3D (const uint64_t *)i; + const uint64_t *k8 =3D (const uint64_t *)k; + + asm("aes64dsm %0,%2,%3\n\t" + "aes64dsm %1,%3,%2\n\t" + "xor %0,%0,%4\n\t" + "xor %1,%1,%5" + : "=3D&r"(o8[0]), "=3D&r"(o8[1]) + : "r"(i8[0]), "r"(i8[1]), "r"(k8[0]), "r"(k8[1])); + return true; +} diff --git a/tests/tcg/multiarch/test-aes-main.c.inc b/tests/tcg/multiarch/= test-aes-main.c.inc new file mode 100644 index 0000000000..0039f8ba55 --- /dev/null +++ b/tests/tcg/multiarch/test-aes-main.c.inc @@ -0,0 +1,183 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ + +#include +#include +#include +#include +#include + +static bool test_SB_SR(uint8_t *o, const uint8_t *i); +static bool test_MC(uint8_t *o, const uint8_t *i); +static bool test_SB_SR_MC_AK(uint8_t *o, const uint8_t *i, const uint8_t *= k); + +static bool test_ISB_ISR(uint8_t *o, const uint8_t *i); +static bool test_IMC(uint8_t *o, const uint8_t *i); +static bool test_ISB_ISR_AK_IMC(uint8_t *o, const uint8_t *i, const uint8_= t *k); +static bool test_ISB_ISR_IMC_AK(uint8_t *o, const uint8_t *i, const uint8_= t *k); + +/* + * From https://doi.org/10.6028/NIST.FIPS.197-upd1, + * Appendix B -- Cipher Example + * + * Note that the formatting of the 4x4 matrices in the document is + * column-major, whereas C is row-major. Therefore to get the bytes + * in the same order as the text, the matrices are transposed. + * + * Note that we are not going to test SubBytes or ShiftRows separately, + * so the "After SubBytes" column is omitted, using only the combined + * result "After ShiftRows" column. + */ + +/* Ease the inline assembly by aligning everything. */ +typedef struct { + uint8_t b[16] __attribute__((aligned(16))); +} State; + +typedef struct { + State start, after_sr, after_mc, round_key; +} Round; + +static const Round rounds[] =3D { + /* Round 1 */ + { { { 0x19, 0x3d, 0xe3, 0xbe, /* start */ + 0xa0, 0xf4, 0xe2, 0x2b, + 0x9a, 0xc6, 0x8d, 0x2a, + 0xe9, 0xf8, 0x48, 0x08, } }, + + { { 0xd4, 0xbf, 0x5d, 0x30, /* after shiftrows */ + 0xe0, 0xb4, 0x52, 0xae, + 0xb8, 0x41, 0x11, 0xf1, + 0x1e, 0x27, 0x98, 0xe5, } }, + + { { 0x04, 0x66, 0x81, 0xe5, /* after mixcolumns */ + 0xe0, 0xcb, 0x19, 0x9a, + 0x48, 0xf8, 0xd3, 0x7a, + 0x28, 0x06, 0x26, 0x4c, } }, + + { { 0xa0, 0xfa, 0xfe, 0x17, /* round key */ + 0x88, 0x54, 0x2c, 0xb1, + 0x23, 0xa3, 0x39, 0x39, + 0x2a, 0x6c, 0x76, 0x05, } } }, + + /* Round 2 */ + { { { 0xa4, 0x9c, 0x7f, 0xf2, /* start */ + 0x68, 0x9f, 0x35, 0x2b, + 0x6b, 0x5b, 0xea, 0x43, + 0x02, 0x6a, 0x50, 0x49, } }, + + { { 0x49, 0xdb, 0x87, 0x3b, /* after shiftrows */ + 0x45, 0x39, 0x53, 0x89, + 0x7f, 0x02, 0xd2, 0xf1, + 0x77, 0xde, 0x96, 0x1a, } }, + + { { 0x58, 0x4d, 0xca, 0xf1, /* after mixcolumns */ + 0x1b, 0x4b, 0x5a, 0xac, + 0xdb, 0xe7, 0xca, 0xa8, + 0x1b, 0x6b, 0xb0, 0xe5, } }, + + { { 0xf2, 0xc2, 0x95, 0xf2, /* round key */ + 0x7a, 0x96, 0xb9, 0x43, + 0x59, 0x35, 0x80, 0x7a, + 0x73, 0x59, 0xf6, 0x7f, } } }, + + /* Round 3 */ + { { { 0xaa, 0x8f, 0x5f, 0x03, /* start */ + 0x61, 0xdd, 0xe3, 0xef, + 0x82, 0xd2, 0x4a, 0xd2, + 0x68, 0x32, 0x46, 0x9a, } }, + + { { 0xac, 0xc1, 0xd6, 0xb8, /* after shiftrows */ + 0xef, 0xb5, 0x5a, 0x7b, + 0x13, 0x23, 0xcf, 0xdf, + 0x45, 0x73, 0x11, 0xb5, } }, + + { { 0x75, 0xec, 0x09, 0x93, /* after mixcolumns */ + 0x20, 0x0b, 0x63, 0x33, + 0x53, 0xc0, 0xcf, 0x7c, + 0xbb, 0x25, 0xd0, 0xdc, } }, + + { { 0x3d, 0x80, 0x47, 0x7d, /* round key */ + 0x47, 0x16, 0xfe, 0x3e, + 0x1e, 0x23, 0x7e, 0x44, + 0x6d, 0x7a, 0x88, 0x3b, } } }, +}; + +static void verify_log(const char *prefix, const State *s) +{ + printf("%s:", prefix); + for (int i =3D 0; i < sizeof(State); ++i) { + printf(" %02x", s->b[i]); + } + printf("\n"); +} + +static void verify(const State *ref, const State *tst, const char *which) +{ + if (!memcmp(ref, tst, sizeof(State))) { + return; + } + + printf("Mismatch on %s\n", which); + verify_log("ref", ref); + verify_log("tst", tst); + exit(EXIT_FAILURE); +} + +int main() +{ + int i, n =3D sizeof(rounds) / sizeof(Round); + State t; + + for (i =3D 0; i < n; ++i) { + if (test_SB_SR(t.b, rounds[i].start.b)) { + verify(&rounds[i].after_sr, &t, "SB+SR"); + } + } + + for (i =3D 0; i < n; ++i) { + if (test_MC(t.b, rounds[i].after_sr.b)) { + verify(&rounds[i].after_mc, &t, "MC"); + } + } + + /* The kernel of Cipher(). */ + for (i =3D 0; i < n - 1; ++i) { + if (test_SB_SR_MC_AK(t.b, rounds[i].start.b, rounds[i].round_key.b= )) { + verify(&rounds[i + 1].start, &t, "SB+SR+MC+AK"); + } + } + + for (i =3D 0; i < n; ++i) { + if (test_ISB_ISR(t.b, rounds[i].after_sr.b)) { + verify(&rounds[i].start, &t, "ISB+ISR"); + } + } + + for (i =3D 0; i < n; ++i) { + if (test_IMC(t.b, rounds[i].after_mc.b)) { + verify(&rounds[i].after_sr, &t, "IMC"); + } + } + + /* The kernel of InvCipher(). */ + for (i =3D n - 1; i > 0; --i) { + if (test_ISB_ISR_AK_IMC(t.b, rounds[i].after_sr.b, + rounds[i - 1].round_key.b)) { + verify(&rounds[i - 1].after_sr, &t, "ISB+ISR+AK+IMC"); + } + } + + /* + * The kernel of EqInvCipher(). =20 + * We must compute a different round key: apply InvMixColumns to + * the standard round key, per KeyExpansion vs KeyExpansionEIC. + */ + for (i =3D 1; i < n; ++i) { + if (test_IMC(t.b, rounds[i - 1].round_key.b) && + test_ISB_ISR_IMC_AK(t.b, rounds[i].after_sr.b, t.b)) { + verify(&rounds[i - 1].after_sr, &t, "ISB+ISR+IMC+AK"); + } + } + + return EXIT_SUCCESS; +} diff --git a/tests/tcg/aarch64/Makefile.target b/tests/tcg/aarch64/Makefile= .target index 3430fd3cd8..d217474d0d 100644 --- a/tests/tcg/aarch64/Makefile.target +++ b/tests/tcg/aarch64/Makefile.target @@ -74,6 +74,10 @@ endif AARCH64_TESTS +=3D sve-ioctls sve-ioctls: CFLAGS+=3D-march=3Darmv8.1-a+sve =20 +AARCH64_TESTS +=3D test-aes +test-aes: CFLAGS +=3D -O -march=3Darmv8-a+aes +test-aes: test-aes-main.c.inc + # Vector SHA1 sha1-vector: CFLAGS=3D-O3 sha1-vector: sha1.c diff --git a/tests/tcg/i386/Makefile.target b/tests/tcg/i386/Makefile.target index f2ee7a4db7..fdf757c6ce 100644 --- a/tests/tcg/i386/Makefile.target +++ b/tests/tcg/i386/Makefile.target @@ -28,6 +28,10 @@ run-test-i386-bmi2: QEMU_OPTS +=3D -cpu max test-i386-adcox: CFLAGS=3D-O2 run-test-i386-adcox: QEMU_OPTS +=3D -cpu max =20 +test-aes: CFLAGS +=3D -O -msse2 -maes +test-aes: test-aes-main.c.inc +run-test-aes: QEMU_OPTS +=3D -cpu max + # # hello-i386 is a barebones app # diff --git a/tests/tcg/ppc64/Makefile.target b/tests/tcg/ppc64/Makefile.tar= get index b084963b9a..5721c159f2 100644 --- a/tests/tcg/ppc64/Makefile.target +++ b/tests/tcg/ppc64/Makefile.target @@ -36,5 +36,6 @@ run-vector: QEMU_OPTS +=3D -cpu POWER10 =20 PPC64_TESTS +=3D signal_save_restore_xer PPC64_TESTS +=3D xxspltw +PPC64_TESTS +=3D test-aes =20 TESTS +=3D $(PPC64_TESTS) diff --git a/tests/tcg/riscv64/Makefile.target b/tests/tcg/riscv64/Makefile= .target index 9973ba3b5f..4b14a67f48 100644 --- a/tests/tcg/riscv64/Makefile.target +++ b/tests/tcg/riscv64/Makefile.target @@ -1,6 +1,13 @@ # -*- Mode: makefile -*- # RISC-V specific tweaks =20 +config-cc.mak: Makefile + $(quiet-@)( \ + $(call cc-option,-mrv64g_zk, CROSS_CC_HAS_ZK) \ + ) 3> config-cc.mak + +-include config-cc.mak + VPATH +=3D $(SRC_PATH)/tests/tcg/riscv64 TESTS +=3D test-div TESTS +=3D noexec @@ -9,3 +16,9 @@ TESTS +=3D noexec TESTS +=3D test-noc test-noc: LDFLAGS =3D -nostdlib -static run-test-noc: QEMU_OPTS +=3D -cpu rv64,c=3Dfalse + +ifneq ($(CROSS_CC_HAS_ZK),) +TESTS +=3D test-aes +test-aes: CFLAGS +=3D -O -march=3Drv64gzk +run-test-aes: QEMU_OPTS +=3D -cpu rv64,zk=3Don +endif --=20 2.34.1 From nobody Tue May 14 18:40:19 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1688379201; cv=none; d=zohomail.com; s=zohoarc; b=N8LTkTxoIRzFliV4yrk9cO8fLhasFiI5cEfIfnZa++C5CPFruEqSNvBUsBbcJBl7kUnHaT128br8yiyeq2408N8lEkjQkH2D6YuJvF/BpZUp5OIUmU0Zlwu1giXDZmeayrtcaqyyGbqxYVjYDLiEiGpGSw5wC+bJiZ03AhusZXM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1688379201; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=oDegPUeqJ78xBO4pGFYHur8C+Wi6RpRKy5K2/MXINzU=; b=CTxkJUzLjrZBtxuYr90Os4CJNoO8ym3tepbq8MKYOdoj91sfDqdkmIl4Cch7xincDi3iqE0FpgJhsh69JFq2idMxb7KXHN90uNjAIwUZze8QjqQ3iPuZgLxXN1vzV4J09dTQeeb17WWIh4sYsJmV1NO9kqEJvBzBDMQ41ZYOCH8= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1688379201893843.3762907644324; Mon, 3 Jul 2023 03:13:21 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qGGRM-0002is-Hk; Mon, 03 Jul 2023 06:05:52 -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 1qGGRF-0002ar-FA for qemu-devel@nongnu.org; Mon, 03 Jul 2023 06:05:45 -0400 Received: from mail-wr1-x433.google.com ([2a00:1450:4864:20::433]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qGGR3-0005hG-6e for qemu-devel@nongnu.org; Mon, 03 Jul 2023 06:05:39 -0400 Received: by mail-wr1-x433.google.com with SMTP id ffacd0b85a97d-3143798f542so823291f8f.2 for ; Mon, 03 Jul 2023 03:05:26 -0700 (PDT) Received: from stoup.home (91.232.79.188.dynamic.jazztel.es. [188.79.232.91]) by smtp.gmail.com with ESMTPSA id t5-20020a05600001c500b00313f7b077fesm18446562wrx.59.2023.07.03.03.05.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 03 Jul 2023 03:05:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1688378725; x=1690970725; 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=oDegPUeqJ78xBO4pGFYHur8C+Wi6RpRKy5K2/MXINzU=; b=vLG7COb8BBsN/lRZMi0b6txxnJqZ6kNs6ajuT/9Hzc9VVDDc7li9k4BjYbRAt+hDqO ChX2RUhbRDHzacelzbGmuVicwW82ZnxPqqiS641kidNGlX/1tq2l9q5YfLSs5Bj2U99Y 3dFeaK+lMc9Yj8qp09d4DRgavzyxQAXK4gt3yssLUB5RjQrbth+zUur9KXt5qLk6Wbv9 fADUv4OTmnW+uBjAAQ0/f8huoqK74/biTwuWwf477OOMn91Fnmp2lhpYMju8BmQTfkE4 VYVsj1OtajwI/umIP/CTM3i15GOYKO79sc3dQpXLKxytEVUV9nN5/X66vS6qx3ARYT0S 4iLw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1688378725; x=1690970725; 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=oDegPUeqJ78xBO4pGFYHur8C+Wi6RpRKy5K2/MXINzU=; b=eXDI364tcFDJa2ecdfVKS9SE7MXt7kNkV7MO+9++jxhOPPvxwhkg7+q7PbMgOt0E5Y 1wBKTIqD5PUQJpmeAEqX2JGOMHht5ZhmFA0+5DEbSL6XeMSiUcMVzM8M4QR9CIGuIFov /TZcfJCZbsXLL15GFILhu8jRIzDdjyggOugT9l+JC+bZgSwCZRSmJD5zvjG9qIsFH2BJ lfrA6gwEiwqLuaR//hyx+7rv5EznvwedOue+FPH1t37D831Qv3o55DPSN9I2mMfrmm42 d+Bfy8LDugxH2MIlNetdo0wQDY5YIkftHbYelcuMLRJRbT27ls8i0aUlKk4uu+4RZ47X 6AaA== X-Gm-Message-State: ABy/qLbXBXE6wpvMq6tYCgPBiSayxkf/uuzeToD5gnNtVMs+C8xcusBY oDtDi4x3qeo2mtTphlooJdy5qQ3+1CcFZ3gGpOS/mg== X-Google-Smtp-Source: APBJJlH8e7tEnJKo8/91eyVR/cBCFJ/Ja5FdJAWUu0Vy0rAQfBmK3sQJ9VZbyFiM7PrIYjHz8HK2VQ== X-Received: by 2002:adf:f0d2:0:b0:314:dc0:2fca with SMTP id x18-20020adff0d2000000b003140dc02fcamr8863687wro.29.1688378725661; Mon, 03 Jul 2023 03:05:25 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: qemu-arm@nongnu.org, qemu-riscv@nongnu.org, pbonzini@redhat.com, eduardo@habkost.net, alistair.francis@wdc.com, danielhb413@gmail.com, =?UTF-8?q?Daniel=20P=20=2E=20Berrang=C3=A9?= , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Subject: [PATCH v4 03/37] target/arm: Move aesmc and aesimc tables to crypto/aes.c Date: Mon, 3 Jul 2023 12:04:46 +0200 Message-Id: <20230703100520.68224-4-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230703100520.68224-1-richard.henderson@linaro.org> References: <20230703100520.68224-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::433; envelope-from=richard.henderson@linaro.org; helo=mail-wr1-x433.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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1688379203297100001 We do not currently have a table in crypto/ for just MixColumns. Move both tables for consistency. Acked-by: Daniel P. Berrang=C3=A9 Reviewed-by: Philippe Mathieu-Daud=C3=A9 Signed-off-by: Richard Henderson --- include/crypto/aes.h | 6 ++ crypto/aes.c | 140 ++++++++++++++++++++++++++++++++ target/arm/tcg/crypto_helper.c | 143 ++------------------------------- 3 files changed, 151 insertions(+), 138 deletions(-) diff --git a/include/crypto/aes.h b/include/crypto/aes.h index 822d64588c..24b073d569 100644 --- a/include/crypto/aes.h +++ b/include/crypto/aes.h @@ -34,6 +34,12 @@ extern const uint8_t AES_isbox[256]; extern const uint8_t AES_shifts[16]; extern const uint8_t AES_ishifts[16]; =20 +/* AES MixColumns, for use with rot32. */ +extern const uint32_t AES_mc_rot[256]; + +/* AES InvMixColumns, for use with rot32. */ +extern const uint32_t AES_imc_rot[256]; + /* AES InvMixColumns */ /* AES_imc[x][0] =3D [x].[0e, 09, 0d, 0b]; */ /* AES_imc[x][1] =3D [x].[0b, 0e, 09, 0d]; */ diff --git a/crypto/aes.c b/crypto/aes.c index af72ff7779..67bb74b8e3 100644 --- a/crypto/aes.c +++ b/crypto/aes.c @@ -116,6 +116,146 @@ const uint8_t AES_ishifts[16] =3D { 0, 13, 10, 7, 4, 1, 14, 11, 8, 5, 2, 15, 12, 9, 6, 3 }; =20 +/* + * MixColumns lookup table, for use with rot32. + */ +const uint32_t AES_mc_rot[256] =3D { + 0x00000000, 0x03010102, 0x06020204, 0x05030306, + 0x0c040408, 0x0f05050a, 0x0a06060c, 0x0907070e, + 0x18080810, 0x1b090912, 0x1e0a0a14, 0x1d0b0b16, + 0x140c0c18, 0x170d0d1a, 0x120e0e1c, 0x110f0f1e, + 0x30101020, 0x33111122, 0x36121224, 0x35131326, + 0x3c141428, 0x3f15152a, 0x3a16162c, 0x3917172e, + 0x28181830, 0x2b191932, 0x2e1a1a34, 0x2d1b1b36, + 0x241c1c38, 0x271d1d3a, 0x221e1e3c, 0x211f1f3e, + 0x60202040, 0x63212142, 0x66222244, 0x65232346, + 0x6c242448, 0x6f25254a, 0x6a26264c, 0x6927274e, + 0x78282850, 0x7b292952, 0x7e2a2a54, 0x7d2b2b56, + 0x742c2c58, 0x772d2d5a, 0x722e2e5c, 0x712f2f5e, + 0x50303060, 0x53313162, 0x56323264, 0x55333366, + 0x5c343468, 0x5f35356a, 0x5a36366c, 0x5937376e, + 0x48383870, 0x4b393972, 0x4e3a3a74, 0x4d3b3b76, + 0x443c3c78, 0x473d3d7a, 0x423e3e7c, 0x413f3f7e, + 0xc0404080, 0xc3414182, 0xc6424284, 0xc5434386, + 0xcc444488, 0xcf45458a, 0xca46468c, 0xc947478e, + 0xd8484890, 0xdb494992, 0xde4a4a94, 0xdd4b4b96, + 0xd44c4c98, 0xd74d4d9a, 0xd24e4e9c, 0xd14f4f9e, + 0xf05050a0, 0xf35151a2, 0xf65252a4, 0xf55353a6, + 0xfc5454a8, 0xff5555aa, 0xfa5656ac, 0xf95757ae, + 0xe85858b0, 0xeb5959b2, 0xee5a5ab4, 0xed5b5bb6, + 0xe45c5cb8, 0xe75d5dba, 0xe25e5ebc, 0xe15f5fbe, + 0xa06060c0, 0xa36161c2, 0xa66262c4, 0xa56363c6, + 0xac6464c8, 0xaf6565ca, 0xaa6666cc, 0xa96767ce, + 0xb86868d0, 0xbb6969d2, 0xbe6a6ad4, 0xbd6b6bd6, + 0xb46c6cd8, 0xb76d6dda, 0xb26e6edc, 0xb16f6fde, + 0x907070e0, 0x937171e2, 0x967272e4, 0x957373e6, + 0x9c7474e8, 0x9f7575ea, 0x9a7676ec, 0x997777ee, + 0x887878f0, 0x8b7979f2, 0x8e7a7af4, 0x8d7b7bf6, + 0x847c7cf8, 0x877d7dfa, 0x827e7efc, 0x817f7ffe, + 0x9b80801b, 0x98818119, 0x9d82821f, 0x9e83831d, + 0x97848413, 0x94858511, 0x91868617, 0x92878715, + 0x8388880b, 0x80898909, 0x858a8a0f, 0x868b8b0d, + 0x8f8c8c03, 0x8c8d8d01, 0x898e8e07, 0x8a8f8f05, + 0xab90903b, 0xa8919139, 0xad92923f, 0xae93933d, + 0xa7949433, 0xa4959531, 0xa1969637, 0xa2979735, + 0xb398982b, 0xb0999929, 0xb59a9a2f, 0xb69b9b2d, + 0xbf9c9c23, 0xbc9d9d21, 0xb99e9e27, 0xba9f9f25, + 0xfba0a05b, 0xf8a1a159, 0xfda2a25f, 0xfea3a35d, + 0xf7a4a453, 0xf4a5a551, 0xf1a6a657, 0xf2a7a755, + 0xe3a8a84b, 0xe0a9a949, 0xe5aaaa4f, 0xe6abab4d, + 0xefacac43, 0xecadad41, 0xe9aeae47, 0xeaafaf45, + 0xcbb0b07b, 0xc8b1b179, 0xcdb2b27f, 0xceb3b37d, + 0xc7b4b473, 0xc4b5b571, 0xc1b6b677, 0xc2b7b775, + 0xd3b8b86b, 0xd0b9b969, 0xd5baba6f, 0xd6bbbb6d, + 0xdfbcbc63, 0xdcbdbd61, 0xd9bebe67, 0xdabfbf65, + 0x5bc0c09b, 0x58c1c199, 0x5dc2c29f, 0x5ec3c39d, + 0x57c4c493, 0x54c5c591, 0x51c6c697, 0x52c7c795, + 0x43c8c88b, 0x40c9c989, 0x45caca8f, 0x46cbcb8d, + 0x4fcccc83, 0x4ccdcd81, 0x49cece87, 0x4acfcf85, + 0x6bd0d0bb, 0x68d1d1b9, 0x6dd2d2bf, 0x6ed3d3bd, + 0x67d4d4b3, 0x64d5d5b1, 0x61d6d6b7, 0x62d7d7b5, + 0x73d8d8ab, 0x70d9d9a9, 0x75dadaaf, 0x76dbdbad, + 0x7fdcdca3, 0x7cdddda1, 0x79dedea7, 0x7adfdfa5, + 0x3be0e0db, 0x38e1e1d9, 0x3de2e2df, 0x3ee3e3dd, + 0x37e4e4d3, 0x34e5e5d1, 0x31e6e6d7, 0x32e7e7d5, + 0x23e8e8cb, 0x20e9e9c9, 0x25eaeacf, 0x26ebebcd, + 0x2fececc3, 0x2cededc1, 0x29eeeec7, 0x2aefefc5, + 0x0bf0f0fb, 0x08f1f1f9, 0x0df2f2ff, 0x0ef3f3fd, + 0x07f4f4f3, 0x04f5f5f1, 0x01f6f6f7, 0x02f7f7f5, + 0x13f8f8eb, 0x10f9f9e9, 0x15fafaef, 0x16fbfbed, + 0x1ffcfce3, 0x1cfdfde1, 0x19fefee7, 0x1affffe5, +}; + +/* + * Inverse MixColumns lookup table, for use with rot32. + */ +const uint32_t AES_imc_rot[256] =3D { + 0x00000000, 0x0b0d090e, 0x161a121c, 0x1d171b12, + 0x2c342438, 0x27392d36, 0x3a2e3624, 0x31233f2a, + 0x58684870, 0x5365417e, 0x4e725a6c, 0x457f5362, + 0x745c6c48, 0x7f516546, 0x62467e54, 0x694b775a, + 0xb0d090e0, 0xbbdd99ee, 0xa6ca82fc, 0xadc78bf2, + 0x9ce4b4d8, 0x97e9bdd6, 0x8afea6c4, 0x81f3afca, + 0xe8b8d890, 0xe3b5d19e, 0xfea2ca8c, 0xf5afc382, + 0xc48cfca8, 0xcf81f5a6, 0xd296eeb4, 0xd99be7ba, + 0x7bbb3bdb, 0x70b632d5, 0x6da129c7, 0x66ac20c9, + 0x578f1fe3, 0x5c8216ed, 0x41950dff, 0x4a9804f1, + 0x23d373ab, 0x28de7aa5, 0x35c961b7, 0x3ec468b9, + 0x0fe75793, 0x04ea5e9d, 0x19fd458f, 0x12f04c81, + 0xcb6bab3b, 0xc066a235, 0xdd71b927, 0xd67cb029, + 0xe75f8f03, 0xec52860d, 0xf1459d1f, 0xfa489411, + 0x9303e34b, 0x980eea45, 0x8519f157, 0x8e14f859, + 0xbf37c773, 0xb43ace7d, 0xa92dd56f, 0xa220dc61, + 0xf66d76ad, 0xfd607fa3, 0xe07764b1, 0xeb7a6dbf, + 0xda595295, 0xd1545b9b, 0xcc434089, 0xc74e4987, + 0xae053edd, 0xa50837d3, 0xb81f2cc1, 0xb31225cf, + 0x82311ae5, 0x893c13eb, 0x942b08f9, 0x9f2601f7, + 0x46bde64d, 0x4db0ef43, 0x50a7f451, 0x5baafd5f, + 0x6a89c275, 0x6184cb7b, 0x7c93d069, 0x779ed967, + 0x1ed5ae3d, 0x15d8a733, 0x08cfbc21, 0x03c2b52f, + 0x32e18a05, 0x39ec830b, 0x24fb9819, 0x2ff69117, + 0x8dd64d76, 0x86db4478, 0x9bcc5f6a, 0x90c15664, + 0xa1e2694e, 0xaaef6040, 0xb7f87b52, 0xbcf5725c, + 0xd5be0506, 0xdeb30c08, 0xc3a4171a, 0xc8a91e14, + 0xf98a213e, 0xf2872830, 0xef903322, 0xe49d3a2c, + 0x3d06dd96, 0x360bd498, 0x2b1ccf8a, 0x2011c684, + 0x1132f9ae, 0x1a3ff0a0, 0x0728ebb2, 0x0c25e2bc, + 0x656e95e6, 0x6e639ce8, 0x737487fa, 0x78798ef4, + 0x495ab1de, 0x4257b8d0, 0x5f40a3c2, 0x544daacc, + 0xf7daec41, 0xfcd7e54f, 0xe1c0fe5d, 0xeacdf753, + 0xdbeec879, 0xd0e3c177, 0xcdf4da65, 0xc6f9d36b, + 0xafb2a431, 0xa4bfad3f, 0xb9a8b62d, 0xb2a5bf23, + 0x83868009, 0x888b8907, 0x959c9215, 0x9e919b1b, + 0x470a7ca1, 0x4c0775af, 0x51106ebd, 0x5a1d67b3, + 0x6b3e5899, 0x60335197, 0x7d244a85, 0x7629438b, + 0x1f6234d1, 0x146f3ddf, 0x097826cd, 0x02752fc3, + 0x335610e9, 0x385b19e7, 0x254c02f5, 0x2e410bfb, + 0x8c61d79a, 0x876cde94, 0x9a7bc586, 0x9176cc88, + 0xa055f3a2, 0xab58faac, 0xb64fe1be, 0xbd42e8b0, + 0xd4099fea, 0xdf0496e4, 0xc2138df6, 0xc91e84f8, + 0xf83dbbd2, 0xf330b2dc, 0xee27a9ce, 0xe52aa0c0, + 0x3cb1477a, 0x37bc4e74, 0x2aab5566, 0x21a65c68, + 0x10856342, 0x1b886a4c, 0x069f715e, 0x0d927850, + 0x64d90f0a, 0x6fd40604, 0x72c31d16, 0x79ce1418, + 0x48ed2b32, 0x43e0223c, 0x5ef7392e, 0x55fa3020, + 0x01b79aec, 0x0aba93e2, 0x17ad88f0, 0x1ca081fe, + 0x2d83bed4, 0x268eb7da, 0x3b99acc8, 0x3094a5c6, + 0x59dfd29c, 0x52d2db92, 0x4fc5c080, 0x44c8c98e, + 0x75ebf6a4, 0x7ee6ffaa, 0x63f1e4b8, 0x68fcedb6, + 0xb1670a0c, 0xba6a0302, 0xa77d1810, 0xac70111e, + 0x9d532e34, 0x965e273a, 0x8b493c28, 0x80443526, + 0xe90f427c, 0xe2024b72, 0xff155060, 0xf418596e, + 0xc53b6644, 0xce366f4a, 0xd3217458, 0xd82c7d56, + 0x7a0ca137, 0x7101a839, 0x6c16b32b, 0x671bba25, + 0x5638850f, 0x5d358c01, 0x40229713, 0x4b2f9e1d, + 0x2264e947, 0x2969e049, 0x347efb5b, 0x3f73f255, + 0x0e50cd7f, 0x055dc471, 0x184adf63, 0x1347d66d, + 0xcadc31d7, 0xc1d138d9, 0xdcc623cb, 0xd7cb2ac5, + 0xe6e815ef, 0xede51ce1, 0xf0f207f3, 0xfbff0efd, + 0x92b479a7, 0x99b970a9, 0x84ae6bbb, 0x8fa362b5, + 0xbe805d9f, 0xb58d5491, 0xa89a4f83, 0xa397468d, +}; + /* AES_imc[x][0] =3D [x].[0e, 09, 0d, 0b]; */ /* AES_imc[x][1] =3D [x].[0b, 0e, 09, 0d]; */ /* AES_imc[x][2] =3D [x].[0d, 0b, 0e, 09]; */ diff --git a/target/arm/tcg/crypto_helper.c b/target/arm/tcg/crypto_helper.c index d28690321f..06254939d2 100644 --- a/target/arm/tcg/crypto_helper.c +++ b/target/arm/tcg/crypto_helper.c @@ -80,149 +80,16 @@ void HELPER(crypto_aese)(void *vd, void *vn, void *vm,= uint32_t desc) =20 static void do_crypto_aesmc(uint64_t *rd, uint64_t *rm, bool decrypt) { - static uint32_t const mc[][256] =3D { { - /* MixColumns lookup table */ - 0x00000000, 0x03010102, 0x06020204, 0x05030306, - 0x0c040408, 0x0f05050a, 0x0a06060c, 0x0907070e, - 0x18080810, 0x1b090912, 0x1e0a0a14, 0x1d0b0b16, - 0x140c0c18, 0x170d0d1a, 0x120e0e1c, 0x110f0f1e, - 0x30101020, 0x33111122, 0x36121224, 0x35131326, - 0x3c141428, 0x3f15152a, 0x3a16162c, 0x3917172e, - 0x28181830, 0x2b191932, 0x2e1a1a34, 0x2d1b1b36, - 0x241c1c38, 0x271d1d3a, 0x221e1e3c, 0x211f1f3e, - 0x60202040, 0x63212142, 0x66222244, 0x65232346, - 0x6c242448, 0x6f25254a, 0x6a26264c, 0x6927274e, - 0x78282850, 0x7b292952, 0x7e2a2a54, 0x7d2b2b56, - 0x742c2c58, 0x772d2d5a, 0x722e2e5c, 0x712f2f5e, - 0x50303060, 0x53313162, 0x56323264, 0x55333366, - 0x5c343468, 0x5f35356a, 0x5a36366c, 0x5937376e, - 0x48383870, 0x4b393972, 0x4e3a3a74, 0x4d3b3b76, - 0x443c3c78, 0x473d3d7a, 0x423e3e7c, 0x413f3f7e, - 0xc0404080, 0xc3414182, 0xc6424284, 0xc5434386, - 0xcc444488, 0xcf45458a, 0xca46468c, 0xc947478e, - 0xd8484890, 0xdb494992, 0xde4a4a94, 0xdd4b4b96, - 0xd44c4c98, 0xd74d4d9a, 0xd24e4e9c, 0xd14f4f9e, - 0xf05050a0, 0xf35151a2, 0xf65252a4, 0xf55353a6, - 0xfc5454a8, 0xff5555aa, 0xfa5656ac, 0xf95757ae, - 0xe85858b0, 0xeb5959b2, 0xee5a5ab4, 0xed5b5bb6, - 0xe45c5cb8, 0xe75d5dba, 0xe25e5ebc, 0xe15f5fbe, - 0xa06060c0, 0xa36161c2, 0xa66262c4, 0xa56363c6, - 0xac6464c8, 0xaf6565ca, 0xaa6666cc, 0xa96767ce, - 0xb86868d0, 0xbb6969d2, 0xbe6a6ad4, 0xbd6b6bd6, - 0xb46c6cd8, 0xb76d6dda, 0xb26e6edc, 0xb16f6fde, - 0x907070e0, 0x937171e2, 0x967272e4, 0x957373e6, - 0x9c7474e8, 0x9f7575ea, 0x9a7676ec, 0x997777ee, - 0x887878f0, 0x8b7979f2, 0x8e7a7af4, 0x8d7b7bf6, - 0x847c7cf8, 0x877d7dfa, 0x827e7efc, 0x817f7ffe, - 0x9b80801b, 0x98818119, 0x9d82821f, 0x9e83831d, - 0x97848413, 0x94858511, 0x91868617, 0x92878715, - 0x8388880b, 0x80898909, 0x858a8a0f, 0x868b8b0d, - 0x8f8c8c03, 0x8c8d8d01, 0x898e8e07, 0x8a8f8f05, - 0xab90903b, 0xa8919139, 0xad92923f, 0xae93933d, - 0xa7949433, 0xa4959531, 0xa1969637, 0xa2979735, - 0xb398982b, 0xb0999929, 0xb59a9a2f, 0xb69b9b2d, - 0xbf9c9c23, 0xbc9d9d21, 0xb99e9e27, 0xba9f9f25, - 0xfba0a05b, 0xf8a1a159, 0xfda2a25f, 0xfea3a35d, - 0xf7a4a453, 0xf4a5a551, 0xf1a6a657, 0xf2a7a755, - 0xe3a8a84b, 0xe0a9a949, 0xe5aaaa4f, 0xe6abab4d, - 0xefacac43, 0xecadad41, 0xe9aeae47, 0xeaafaf45, - 0xcbb0b07b, 0xc8b1b179, 0xcdb2b27f, 0xceb3b37d, - 0xc7b4b473, 0xc4b5b571, 0xc1b6b677, 0xc2b7b775, - 0xd3b8b86b, 0xd0b9b969, 0xd5baba6f, 0xd6bbbb6d, - 0xdfbcbc63, 0xdcbdbd61, 0xd9bebe67, 0xdabfbf65, - 0x5bc0c09b, 0x58c1c199, 0x5dc2c29f, 0x5ec3c39d, - 0x57c4c493, 0x54c5c591, 0x51c6c697, 0x52c7c795, - 0x43c8c88b, 0x40c9c989, 0x45caca8f, 0x46cbcb8d, - 0x4fcccc83, 0x4ccdcd81, 0x49cece87, 0x4acfcf85, - 0x6bd0d0bb, 0x68d1d1b9, 0x6dd2d2bf, 0x6ed3d3bd, - 0x67d4d4b3, 0x64d5d5b1, 0x61d6d6b7, 0x62d7d7b5, - 0x73d8d8ab, 0x70d9d9a9, 0x75dadaaf, 0x76dbdbad, - 0x7fdcdca3, 0x7cdddda1, 0x79dedea7, 0x7adfdfa5, - 0x3be0e0db, 0x38e1e1d9, 0x3de2e2df, 0x3ee3e3dd, - 0x37e4e4d3, 0x34e5e5d1, 0x31e6e6d7, 0x32e7e7d5, - 0x23e8e8cb, 0x20e9e9c9, 0x25eaeacf, 0x26ebebcd, - 0x2fececc3, 0x2cededc1, 0x29eeeec7, 0x2aefefc5, - 0x0bf0f0fb, 0x08f1f1f9, 0x0df2f2ff, 0x0ef3f3fd, - 0x07f4f4f3, 0x04f5f5f1, 0x01f6f6f7, 0x02f7f7f5, - 0x13f8f8eb, 0x10f9f9e9, 0x15fafaef, 0x16fbfbed, - 0x1ffcfce3, 0x1cfdfde1, 0x19fefee7, 0x1affffe5, - }, { - /* Inverse MixColumns lookup table */ - 0x00000000, 0x0b0d090e, 0x161a121c, 0x1d171b12, - 0x2c342438, 0x27392d36, 0x3a2e3624, 0x31233f2a, - 0x58684870, 0x5365417e, 0x4e725a6c, 0x457f5362, - 0x745c6c48, 0x7f516546, 0x62467e54, 0x694b775a, - 0xb0d090e0, 0xbbdd99ee, 0xa6ca82fc, 0xadc78bf2, - 0x9ce4b4d8, 0x97e9bdd6, 0x8afea6c4, 0x81f3afca, - 0xe8b8d890, 0xe3b5d19e, 0xfea2ca8c, 0xf5afc382, - 0xc48cfca8, 0xcf81f5a6, 0xd296eeb4, 0xd99be7ba, - 0x7bbb3bdb, 0x70b632d5, 0x6da129c7, 0x66ac20c9, - 0x578f1fe3, 0x5c8216ed, 0x41950dff, 0x4a9804f1, - 0x23d373ab, 0x28de7aa5, 0x35c961b7, 0x3ec468b9, - 0x0fe75793, 0x04ea5e9d, 0x19fd458f, 0x12f04c81, - 0xcb6bab3b, 0xc066a235, 0xdd71b927, 0xd67cb029, - 0xe75f8f03, 0xec52860d, 0xf1459d1f, 0xfa489411, - 0x9303e34b, 0x980eea45, 0x8519f157, 0x8e14f859, - 0xbf37c773, 0xb43ace7d, 0xa92dd56f, 0xa220dc61, - 0xf66d76ad, 0xfd607fa3, 0xe07764b1, 0xeb7a6dbf, - 0xda595295, 0xd1545b9b, 0xcc434089, 0xc74e4987, - 0xae053edd, 0xa50837d3, 0xb81f2cc1, 0xb31225cf, - 0x82311ae5, 0x893c13eb, 0x942b08f9, 0x9f2601f7, - 0x46bde64d, 0x4db0ef43, 0x50a7f451, 0x5baafd5f, - 0x6a89c275, 0x6184cb7b, 0x7c93d069, 0x779ed967, - 0x1ed5ae3d, 0x15d8a733, 0x08cfbc21, 0x03c2b52f, - 0x32e18a05, 0x39ec830b, 0x24fb9819, 0x2ff69117, - 0x8dd64d76, 0x86db4478, 0x9bcc5f6a, 0x90c15664, - 0xa1e2694e, 0xaaef6040, 0xb7f87b52, 0xbcf5725c, - 0xd5be0506, 0xdeb30c08, 0xc3a4171a, 0xc8a91e14, - 0xf98a213e, 0xf2872830, 0xef903322, 0xe49d3a2c, - 0x3d06dd96, 0x360bd498, 0x2b1ccf8a, 0x2011c684, - 0x1132f9ae, 0x1a3ff0a0, 0x0728ebb2, 0x0c25e2bc, - 0x656e95e6, 0x6e639ce8, 0x737487fa, 0x78798ef4, - 0x495ab1de, 0x4257b8d0, 0x5f40a3c2, 0x544daacc, - 0xf7daec41, 0xfcd7e54f, 0xe1c0fe5d, 0xeacdf753, - 0xdbeec879, 0xd0e3c177, 0xcdf4da65, 0xc6f9d36b, - 0xafb2a431, 0xa4bfad3f, 0xb9a8b62d, 0xb2a5bf23, - 0x83868009, 0x888b8907, 0x959c9215, 0x9e919b1b, - 0x470a7ca1, 0x4c0775af, 0x51106ebd, 0x5a1d67b3, - 0x6b3e5899, 0x60335197, 0x7d244a85, 0x7629438b, - 0x1f6234d1, 0x146f3ddf, 0x097826cd, 0x02752fc3, - 0x335610e9, 0x385b19e7, 0x254c02f5, 0x2e410bfb, - 0x8c61d79a, 0x876cde94, 0x9a7bc586, 0x9176cc88, - 0xa055f3a2, 0xab58faac, 0xb64fe1be, 0xbd42e8b0, - 0xd4099fea, 0xdf0496e4, 0xc2138df6, 0xc91e84f8, - 0xf83dbbd2, 0xf330b2dc, 0xee27a9ce, 0xe52aa0c0, - 0x3cb1477a, 0x37bc4e74, 0x2aab5566, 0x21a65c68, - 0x10856342, 0x1b886a4c, 0x069f715e, 0x0d927850, - 0x64d90f0a, 0x6fd40604, 0x72c31d16, 0x79ce1418, - 0x48ed2b32, 0x43e0223c, 0x5ef7392e, 0x55fa3020, - 0x01b79aec, 0x0aba93e2, 0x17ad88f0, 0x1ca081fe, - 0x2d83bed4, 0x268eb7da, 0x3b99acc8, 0x3094a5c6, - 0x59dfd29c, 0x52d2db92, 0x4fc5c080, 0x44c8c98e, - 0x75ebf6a4, 0x7ee6ffaa, 0x63f1e4b8, 0x68fcedb6, - 0xb1670a0c, 0xba6a0302, 0xa77d1810, 0xac70111e, - 0x9d532e34, 0x965e273a, 0x8b493c28, 0x80443526, - 0xe90f427c, 0xe2024b72, 0xff155060, 0xf418596e, - 0xc53b6644, 0xce366f4a, 0xd3217458, 0xd82c7d56, - 0x7a0ca137, 0x7101a839, 0x6c16b32b, 0x671bba25, - 0x5638850f, 0x5d358c01, 0x40229713, 0x4b2f9e1d, - 0x2264e947, 0x2969e049, 0x347efb5b, 0x3f73f255, - 0x0e50cd7f, 0x055dc471, 0x184adf63, 0x1347d66d, - 0xcadc31d7, 0xc1d138d9, 0xdcc623cb, 0xd7cb2ac5, - 0xe6e815ef, 0xede51ce1, 0xf0f207f3, 0xfbff0efd, - 0x92b479a7, 0x99b970a9, 0x84ae6bbb, 0x8fa362b5, - 0xbe805d9f, 0xb58d5491, 0xa89a4f83, 0xa397468d, - } }; - union CRYPTO_STATE st =3D { .l =3D { rm[0], rm[1] } }; + const uint32_t *mc =3D decrypt ? AES_imc_rot : AES_mc_rot; int i; =20 for (i =3D 0; i < 16; i +=3D 4) { CR_ST_WORD(st, i >> 2) =3D - mc[decrypt][CR_ST_BYTE(st, i)] ^ - rol32(mc[decrypt][CR_ST_BYTE(st, i + 1)], 8) ^ - rol32(mc[decrypt][CR_ST_BYTE(st, i + 2)], 16) ^ - rol32(mc[decrypt][CR_ST_BYTE(st, i + 3)], 24); + mc[CR_ST_BYTE(st, i)] ^ + rol32(mc[CR_ST_BYTE(st, i + 1)], 8) ^ + rol32(mc[CR_ST_BYTE(st, i + 2)], 16) ^ + rol32(mc[CR_ST_BYTE(st, i + 3)], 24); } =20 rd[0] =3D st.l[0]; --=20 2.34.1 From nobody Tue May 14 18:40:19 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1688379021; cv=none; d=zohomail.com; s=zohoarc; b=OV9nI9M/rRqcThr+1I574RjJZqE7ZusjuGWV4G61Lp0rG2JoNoexYi5g3CXrAUKPX9c78x5LowfqE9nmiWoq5yea1X0knOkPfGuQgOUY5MMsU63UqY8jJxfiKJDy6V7PLjjFTMkWIpiw3fYWkdMUxpEI+kZmGtoVsmFXpZb7qCA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1688379021; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=gLgfXZyf9aATX9TfQItUdKukGg6cdQDyWQ8EagJh33A=; b=JiIXACU9Kcq42ffTMM/9/OcAgX8maCn+3CcDHkzgAyElxbieIUmSUVGirCMkbcIuarYxeynNZ5p/TykYpExT1Uy8CABMAqeSDTxi7sosswc/ndgqwi0hJBBdOu1ebPMIyDOqQCyN7X26SB1JTZXfomSEyv3PuotwkaLeBZ2Mo9M= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1688379021044728.9925135419089; Mon, 3 Jul 2023 03:10:21 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qGGRK-0002fd-7q; Mon, 03 Jul 2023 06:05:50 -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 1qGGRE-0002ae-8D for qemu-devel@nongnu.org; Mon, 03 Jul 2023 06:05:45 -0400 Received: from mail-wr1-x429.google.com ([2a00:1450:4864:20::429]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qGGR5-0005hb-MQ for qemu-devel@nongnu.org; Mon, 03 Jul 2023 06:05:40 -0400 Received: by mail-wr1-x429.google.com with SMTP id ffacd0b85a97d-3112f5ab0b1so4700342f8f.0 for ; Mon, 03 Jul 2023 03:05:27 -0700 (PDT) Received: from stoup.home (91.232.79.188.dynamic.jazztel.es. [188.79.232.91]) by smtp.gmail.com with ESMTPSA id t5-20020a05600001c500b00313f7b077fesm18446562wrx.59.2023.07.03.03.05.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 03 Jul 2023 03:05:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1688378726; x=1690970726; 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=gLgfXZyf9aATX9TfQItUdKukGg6cdQDyWQ8EagJh33A=; b=Pwm1FCcYBssMW/ZiMKlkhySlLJ1mlbpGNDpDn0wMiC1glwRLjTVaHH5ifjW0ad/CTO dmjyRLekq5GnQulOD4U0B64r1TEy2U9/MsnRdDF/9K+PMzUILSxT6lpzqf/uNZkxXQw/ zEcLPGcSosKYDMAYX0fR93xfgsnUk+RnaFdteNtVKMM7vUNsjp6nXpG0CKbaULIT/38f VCcUHEuuc02lxjrJtyPKN500p/rncfFXHcRJai93ycWui8xs70S52fOYUcQG+o4PBbRL j7Dtx51SSC1KA7ek+TFm0dY9QMdigg6lTjcZLefKOHHUtQaTRaN9yFAKpyLuguaUiZZF Eliw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1688378726; x=1690970726; 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=gLgfXZyf9aATX9TfQItUdKukGg6cdQDyWQ8EagJh33A=; b=KPtSrNsEfJVVqLVWbg7U/69He4k7p3NkSX6H2QcVjJsexSusTECTPrY5D4CsroPmJ/ RKIXUs02CzOYbnOQFSTFuUHIIWmmH7ce0PtoNbZ5tCt1mBMXoLAKqTWFe5Q41gRQZLcv +yj7uBF731kK+nOGgzlPBR8mGUZyiExrv1ZwRqonKfM7SpDcpKLSV9Dj9kRrPfSvFSQC 78zkYf5pqlneMI+WG9/MI7zK3vMBxEf+h689Q4nCBvlzUEc8jgq4306EaC7tt4WKx3sB 0QmtqST8ABKjEvIZDZlGYKvTFOACqe7XW5eYS0tGo+gB6s1jd3C4YYVT2G5e5Veqac/k LpoQ== X-Gm-Message-State: ABy/qLYdvdxJ2aDaattjuxvpYSRJjSRJ52lxBiTrTwyFVwvoyczF7zmL 8Wbwt+lf1GB3c8USR2idTnaD4PHYzg/Z1u7cr/icjw== X-Google-Smtp-Source: APBJJlHMNvRgBMS2fdkLtQKX6G6EpezDfKcM92HoF6jyhXre/KAsfcyCZNhyk8cdeD5KrOorow4BuQ== X-Received: by 2002:adf:f7c9:0:b0:311:162a:ce2a with SMTP id a9-20020adff7c9000000b00311162ace2amr7620806wrq.29.1688378726642; Mon, 03 Jul 2023 03:05:26 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: qemu-arm@nongnu.org, qemu-riscv@nongnu.org, pbonzini@redhat.com, eduardo@habkost.net, alistair.francis@wdc.com, danielhb413@gmail.com, =?UTF-8?q?Daniel=20P=20=2E=20Berrang=C3=A9?= , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Subject: [PATCH v4 04/37] crypto/aes: Add AES_SH, AES_ISH macros Date: Mon, 3 Jul 2023 12:04:47 +0200 Message-Id: <20230703100520.68224-5-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230703100520.68224-1-richard.henderson@linaro.org> References: <20230703100520.68224-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::429; envelope-from=richard.henderson@linaro.org; helo=mail-wr1-x429.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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1688379023216100007 These macros will constant fold and avoid the indirection through memory when fully unrolling some new primitives. Acked-by: Daniel P. Berrang=C3=A9 Reviewed-by: Philippe Mathieu-Daud=C3=A9 Signed-off-by: Richard Henderson --- crypto/aes.c | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/crypto/aes.c b/crypto/aes.c index 67bb74b8e3..e65c97e0c1 100644 --- a/crypto/aes.c +++ b/crypto/aes.c @@ -108,12 +108,24 @@ const uint8_t AES_isbox[256] =3D { 0xE1, 0x69, 0x14, 0x63, 0x55, 0x21, 0x0C, 0x7D, }; =20 +/* AES ShiftRows, for complete unrolling. */ +#define AES_SH(X) (((X) * 5) & 15) + const uint8_t AES_shifts[16] =3D { - 0, 5, 10, 15, 4, 9, 14, 3, 8, 13, 2, 7, 12, 1, 6, 11 + AES_SH(0x0), AES_SH(0x1), AES_SH(0x2), AES_SH(0x3), + AES_SH(0x4), AES_SH(0x5), AES_SH(0x6), AES_SH(0x7), + AES_SH(0x8), AES_SH(0x9), AES_SH(0xA), AES_SH(0xB), + AES_SH(0xC), AES_SH(0xD), AES_SH(0xE), AES_SH(0xF), }; =20 +/* AES InvShiftRows, for complete unrolling. */ +#define AES_ISH(X) (((X) * 13) & 15) + const uint8_t AES_ishifts[16] =3D { - 0, 13, 10, 7, 4, 1, 14, 11, 8, 5, 2, 15, 12, 9, 6, 3 + AES_ISH(0x0), AES_ISH(0x1), AES_ISH(0x2), AES_ISH(0x3), + AES_ISH(0x4), AES_ISH(0x5), AES_ISH(0x6), AES_ISH(0x7), + AES_ISH(0x8), AES_ISH(0x9), AES_ISH(0xA), AES_ISH(0xB), + AES_ISH(0xC), AES_ISH(0xD), AES_ISH(0xE), AES_ISH(0xF), }; =20 /* --=20 2.34.1 From nobody Tue May 14 18:40:19 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1688378970; cv=none; d=zohomail.com; s=zohoarc; b=DYb48JCtMRWfKbZ12LB++r8r6prkNaQcZUSz9AKIOi4CL7+FIAI6y0FklgDeaHLv9ESu4vidllEU+Hez/B4NeJC6l2j0HutpQffWf0O3GEy3sWwEjm2kZFAOSJYHmYCfbvh5TL8SZZ3KefsJ/kPW58D2UXholnQi9DTyaerrLwo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1688378970; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=IwEenOSIExv4ocs0aF0VGqlBA7MmMe37v6A4s1oO9f0=; b=kEJWdPfcMVgNT0+3liTBmUeTOKuGLroZVevuRz9O2oeIrt6AFR2COapKn65QQA05Q0116a5FGqe2vjlPUrK9SLXzdBlYKSx3kYBZcM0WYc4OaptMjhMsHVh1FlIQClsBl3V0SHhNLEEXQ/zXrvEAiYq2kvXLUiy7P0392NJIQTs= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1688378970518731.5062937735493; Mon, 3 Jul 2023 03:09:30 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qGGRg-000384-Q8; Mon, 03 Jul 2023 06:06:12 -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 1qGGRX-0002si-Ai for qemu-devel@nongnu.org; Mon, 03 Jul 2023 06:06:03 -0400 Received: from mail-wm1-x32f.google.com ([2a00:1450:4864:20::32f]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qGGRH-0005iJ-A0 for qemu-devel@nongnu.org; Mon, 03 Jul 2023 06:06:02 -0400 Received: by mail-wm1-x32f.google.com with SMTP id 5b1f17b1804b1-3fbc656873eso49084675e9.1 for ; Mon, 03 Jul 2023 03:05:28 -0700 (PDT) Received: from stoup.home (91.232.79.188.dynamic.jazztel.es. [188.79.232.91]) by smtp.gmail.com with ESMTPSA id t5-20020a05600001c500b00313f7b077fesm18446562wrx.59.2023.07.03.03.05.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 03 Jul 2023 03:05:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1688378727; x=1690970727; 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=IwEenOSIExv4ocs0aF0VGqlBA7MmMe37v6A4s1oO9f0=; b=U5K+qWzwE9QEjvBXzat6AyxD/Jthw9/912VSkv0TjiyaQtUykG8TkwNKTsnQ6EhPgu 0SwN4AeTdFREfuy9Y6zIRwm4/Flg8+FCB11pje6dsHUYCFv1H846TOAOOt+xDUyohMW/ D3qEKGSE0b6M4oxax6XZrZz++na3aF+o0zsevNdfR55ngk9H81KKihph+aveZysftAuI O/8yseRyKAspId1WnGLX+YsEQrhraWDwM7FTjJhW4Y1noCosFD2HsHkAw+ec+vFIjyvQ 4xl6sLv2KHx6VBUfSyXw5v/vLM63BlGcW01vJxpvWHXL47ceVedIkptXlA1357Z7lI/J YvfA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1688378727; x=1690970727; 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=IwEenOSIExv4ocs0aF0VGqlBA7MmMe37v6A4s1oO9f0=; b=VnIodPdYKlimjMjipz42zJh/uCN+Yl6oJQGNidArzDJPr3jNyhwFmzgSuhMi8B1h5p //gbGJ95ioJY7xSOW9WigdAC38KFKpegGcbbc3HUG+ZoH6KINjd8W1bmeppwQMIQ+u4r K49iaPhQP8vPcZkZT29mEnTVGdfv/5EZbWyQkNqHfABNp4jjDO24xe2dipgTYJFXi/0a 3dbq9U18JKpj92aVKR0Yg4rfYPx11CA4BHAgd9l76VAGEgt/eWIAL+16w6+40wStoQlr vVSC5QnvZo+1yspUeYe7SrOjgwji4GH9ywsHP1WEM1zFxJg5vVKr9KWB6Xp5q4GfdieT egNg== X-Gm-Message-State: AC+VfDw4d0DkfZeWhLx/Zpk9Kv5uRQS629d25TQckI76x/iZWBDTmm2l mM8xKDUUrzSqxaLN3mQ9xQ2cZ7PGqCiOsmQWhYz3uA== X-Google-Smtp-Source: ACHHUZ6Tn66eLfxXn7UgGV3xGAoD8XGfhuYYdkftTNFgomFuoVlIUlJqhB/b+sh4lIOzs2j3DhymBw== X-Received: by 2002:a7b:c853:0:b0:3f5:fff8:d4f3 with SMTP id c19-20020a7bc853000000b003f5fff8d4f3mr12918229wml.7.1688378727649; Mon, 03 Jul 2023 03:05:27 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: qemu-arm@nongnu.org, qemu-riscv@nongnu.org, pbonzini@redhat.com, eduardo@habkost.net, alistair.francis@wdc.com, danielhb413@gmail.com, =?UTF-8?q?Daniel=20P=20=2E=20Berrang=C3=A9?= Subject: [PATCH v4 05/37] crypto: Add aesenc_SB_SR_AK Date: Mon, 3 Jul 2023 12:04:48 +0200 Message-Id: <20230703100520.68224-6-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230703100520.68224-1-richard.henderson@linaro.org> References: <20230703100520.68224-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::32f; envelope-from=richard.henderson@linaro.org; helo=mail-wm1-x32f.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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1688378972042100001 Start adding infrastructure for accelerating guest AES. Begin with a SubBytes + ShiftRows + AddRoundKey primitive. Acked-by: Daniel P. Berrang=C3=A9 Signed-off-by: Richard Henderson --- MAINTAINERS | 1 + host/include/generic/host/crypto/aes-round.h | 16 +++++++ include/crypto/aes-round.h | 44 +++++++++++++++++++ crypto/aes.c | 46 ++++++++++++++++++++ 4 files changed, 107 insertions(+) create mode 100644 host/include/generic/host/crypto/aes-round.h create mode 100644 include/crypto/aes-round.h diff --git a/MAINTAINERS b/MAINTAINERS index 4feea49a6e..f5e199bb7f 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -3216,6 +3216,7 @@ M: Daniel P. Berrange S: Maintained F: crypto/ F: include/crypto/ +F: host/include/*/host/crypto/ F: qapi/crypto.json F: tests/unit/test-crypto-* F: tests/bench/benchmark-crypto-* diff --git a/host/include/generic/host/crypto/aes-round.h b/host/include/ge= neric/host/crypto/aes-round.h new file mode 100644 index 0000000000..c5d8066179 --- /dev/null +++ b/host/include/generic/host/crypto/aes-round.h @@ -0,0 +1,16 @@ +/* + * No host specific aes acceleration. + * SPDX-License-Identifier: GPL-2.0-or-later + */ + +#ifndef GENERIC_HOST_CRYPTO_AES_ROUND_H +#define GENERIC_HOST_CRYPTO_AES_ROUND_H + +#define HAVE_AES_ACCEL false +#define ATTR_AES_ACCEL + +void aesenc_SB_SR_AK_accel(AESState *, const AESState *, + const AESState *, bool) + QEMU_ERROR("unsupported accel"); + +#endif /* GENERIC_HOST_CRYPTO_AES_ROUND_H */ diff --git a/include/crypto/aes-round.h b/include/crypto/aes-round.h new file mode 100644 index 0000000000..b85db1a30e --- /dev/null +++ b/include/crypto/aes-round.h @@ -0,0 +1,44 @@ +/* + * AES round fragments, generic version + * SPDX-License-Identifier: GPL-2.0-or-later + * + * Copyright (C) 2023 Linaro, Ltd. + */ + +#ifndef CRYPTO_AES_ROUND_H +#define CRYPTO_AES_ROUND_H + +/* Hosts with acceleration will usually need a 16-byte vector type. */ +typedef uint8_t AESStateVec __attribute__((vector_size(16))); + +typedef union { + uint8_t b[16]; + uint32_t w[4]; + uint64_t d[2]; + AESStateVec v; +} AESState; + +#include "host/crypto/aes-round.h" + +/* + * Perform SubBytes + ShiftRows + AddRoundKey. + */ + +void aesenc_SB_SR_AK_gen(AESState *ret, const AESState *st, + const AESState *rk); +void aesenc_SB_SR_AK_genrev(AESState *ret, const AESState *st, + const AESState *rk); + +static inline void aesenc_SB_SR_AK(AESState *r, const AESState *st, + const AESState *rk, bool be) +{ + if (HAVE_AES_ACCEL) { + aesenc_SB_SR_AK_accel(r, st, rk, be); + } else if (HOST_BIG_ENDIAN =3D=3D be) { + aesenc_SB_SR_AK_gen(r, st, rk); + } else { + aesenc_SB_SR_AK_genrev(r, st, rk); + } +} + +#endif /* CRYPTO_AES_ROUND_H */ diff --git a/crypto/aes.c b/crypto/aes.c index e65c97e0c1..408d92b81f 100644 --- a/crypto/aes.c +++ b/crypto/aes.c @@ -29,6 +29,7 @@ */ #include "qemu/osdep.h" #include "crypto/aes.h" +#include "crypto/aes-round.h" =20 typedef uint32_t u32; typedef uint8_t u8; @@ -1215,6 +1216,51 @@ static const u32 rcon[] =3D { 0x1B000000, 0x36000000, /* for 128-bit blocks, Rijndael never uses= more than 10 rcon values */ }; =20 +/* + * Perform SubBytes + ShiftRows + AddRoundKey. + */ +static inline void +aesenc_SB_SR_AK_swap(AESState *ret, const AESState *st, + const AESState *rk, bool swap) +{ + const int swap_b =3D swap ? 15 : 0; + AESState t; + + t.b[swap_b ^ 0x0] =3D AES_sbox[st->b[swap_b ^ AES_SH(0x0)]]; + t.b[swap_b ^ 0x1] =3D AES_sbox[st->b[swap_b ^ AES_SH(0x1)]]; + t.b[swap_b ^ 0x2] =3D AES_sbox[st->b[swap_b ^ AES_SH(0x2)]]; + t.b[swap_b ^ 0x3] =3D AES_sbox[st->b[swap_b ^ AES_SH(0x3)]]; + t.b[swap_b ^ 0x4] =3D AES_sbox[st->b[swap_b ^ AES_SH(0x4)]]; + t.b[swap_b ^ 0x5] =3D AES_sbox[st->b[swap_b ^ AES_SH(0x5)]]; + t.b[swap_b ^ 0x6] =3D AES_sbox[st->b[swap_b ^ AES_SH(0x6)]]; + t.b[swap_b ^ 0x7] =3D AES_sbox[st->b[swap_b ^ AES_SH(0x7)]]; + t.b[swap_b ^ 0x8] =3D AES_sbox[st->b[swap_b ^ AES_SH(0x8)]]; + t.b[swap_b ^ 0x9] =3D AES_sbox[st->b[swap_b ^ AES_SH(0x9)]]; + t.b[swap_b ^ 0xa] =3D AES_sbox[st->b[swap_b ^ AES_SH(0xA)]]; + t.b[swap_b ^ 0xb] =3D AES_sbox[st->b[swap_b ^ AES_SH(0xB)]]; + t.b[swap_b ^ 0xc] =3D AES_sbox[st->b[swap_b ^ AES_SH(0xC)]]; + t.b[swap_b ^ 0xd] =3D AES_sbox[st->b[swap_b ^ AES_SH(0xD)]]; + t.b[swap_b ^ 0xe] =3D AES_sbox[st->b[swap_b ^ AES_SH(0xE)]]; + t.b[swap_b ^ 0xf] =3D AES_sbox[st->b[swap_b ^ AES_SH(0xF)]]; + + /* + * Perform the AddRoundKey with generic vectors. + * This may be expanded to either host integer or host vector code. + * The key and output endianness match, so no bswap required. + */ + ret->v =3D t.v ^ rk->v; +} + +void aesenc_SB_SR_AK_gen(AESState *r, const AESState *s, const AESState *k) +{ + aesenc_SB_SR_AK_swap(r, s, k, false); +} + +void aesenc_SB_SR_AK_genrev(AESState *r, const AESState *s, const AESState= *k) +{ + aesenc_SB_SR_AK_swap(r, s, k, true); +} + /** * Expand the cipher key into the encryption key schedule. */ --=20 2.34.1 From nobody Tue May 14 18:40:19 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1688379124; cv=none; d=zohomail.com; s=zohoarc; b=CgOqrWLG/zDY3oCWP3fN1rngtOlmcfA1wnjE39fcy3ZdQMvXraJ9ASKh9SrWMOiQHJaVHy6hc+wzLRpx7XLQiUFk0QOEuCB22+GaKTxM2ApFFE1P93E//XnbIUS9IZIaVs8sUUyDZ4brNRUjzbqaXgTAZvoEgXWBI2TS9UQ2ZDE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1688379124; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=TOF0YX3biOvYXBmYgvIyMISz7K/doCgseRX4BopoSYk=; b=kvwDXm+jVvMieTJ9Dptab4ZREFV1eDm+o6znFLpxORZ6LOf2Bk35XCexf7LdCV4H/T1jGPQ1jshcZu324KqiQv+0WbxJa22Isc6qGdAs66R88UbQyXCT7ImuYDqRp6kCJJoNLIEtc1RZEhrEysm1kHXq1X3iaz4HJhklXUmZmbk= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1688379124007999.69482087363; Mon, 3 Jul 2023 03:12:04 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qGGRc-00032L-Ay; Mon, 03 Jul 2023 06:06:08 -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 1qGGRP-0002nt-Ew for qemu-devel@nongnu.org; Mon, 03 Jul 2023 06:05:55 -0400 Received: from mail-wr1-x42e.google.com ([2a00:1450:4864:20::42e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qGGRG-0005is-9J for qemu-devel@nongnu.org; Mon, 03 Jul 2023 06:05:55 -0400 Received: by mail-wr1-x42e.google.com with SMTP id ffacd0b85a97d-31438512cafso678684f8f.2 for ; Mon, 03 Jul 2023 03:05:29 -0700 (PDT) Received: from stoup.home (91.232.79.188.dynamic.jazztel.es. [188.79.232.91]) by smtp.gmail.com with ESMTPSA id t5-20020a05600001c500b00313f7b077fesm18446562wrx.59.2023.07.03.03.05.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 03 Jul 2023 03:05:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1688378728; x=1690970728; 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=TOF0YX3biOvYXBmYgvIyMISz7K/doCgseRX4BopoSYk=; b=juAHJCUSKfGNDMLivyUwpPwwjWQ0IdQKBQIFUIloUmLcPcM7lKpA6ZAqZ0tmmkVFyj Lu7crKgK2zcimU68DXrW6nFQASGzN8Kg7+JFohDkLnlquMxSRTUXda47SaBlXzg/AJCU giL77OoMG0nq1SQD4ooHI8GYRgT7soyuUlfbaCvviJAFSZ+vJ4faUGlIR+/jCaLNFa5h Ondb7rV0i0LxR+lO+XR6kBUztc5eqFtZtZMSYMbhvkNR9pYZdNmhQMlBMvJ13kaOCRjG /lPCIldL9gce0196hyecJ7xvzP7vpJQMu4YWrqxcGC1rnZnqhB0o3w2fihsJqOJpwoGU WFAA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1688378728; x=1690970728; 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=TOF0YX3biOvYXBmYgvIyMISz7K/doCgseRX4BopoSYk=; b=lFkhbEv4xWLBbwHCnyqStcWAtUC6baNZ6ZTllaNz9CnsySZkCm8SnrcidWvsH2dbdK sKo0RyiEqdACWUPSexytNbAUFYe6KEvwZ+p0wUfV9Z0TMXurYeyUKcFkP6sssLVIt5Gq F82LebpWMYUgM0x2ydccIwyW9ZmUgyC/pT13xUfHu2W/hakRyPDmLItcZMB939y5rHF/ t62baqH+nJkTD9gbtcv8q8HmnnYMb+57ZwvPb3nUwuvJvjFw9LCNwZWKItJmMPvwwpcH PrmLltGMzCjqsCTFPNKgWF36p2f4b3a9obIbFt2kAgovRaG+UcklnZF3forF990uQTBw o1+Q== X-Gm-Message-State: ABy/qLYStnfL5OvH+cCU9sqlTcpnJ+S+wsc4FYaFIUvHuKcSRqopsOWa Cse7teN0FCtIJ8sMlx9c0V42KO3pb5yQ1ji8H1eiYA== X-Google-Smtp-Source: APBJJlGQk5LJjMjT2APrPLV9LHcdpv4XKBp4lvmyJmpJTKId68h3kB/jmLBUyF25RR88xkKzPqazqA== X-Received: by 2002:a5d:534d:0:b0:314:1fdc:796d with SMTP id t13-20020a5d534d000000b003141fdc796dmr7569578wrv.70.1688378728596; Mon, 03 Jul 2023 03:05:28 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: qemu-arm@nongnu.org, qemu-riscv@nongnu.org, pbonzini@redhat.com, eduardo@habkost.net, alistair.francis@wdc.com, danielhb413@gmail.com, =?UTF-8?q?Daniel=20P=20=2E=20Berrang=C3=A9?= Subject: [PATCH v4 06/37] crypto: Add aesdec_ISB_ISR_AK Date: Mon, 3 Jul 2023 12:04:49 +0200 Message-Id: <20230703100520.68224-7-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230703100520.68224-1-richard.henderson@linaro.org> References: <20230703100520.68224-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::42e; envelope-from=richard.henderson@linaro.org; helo=mail-wr1-x42e.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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1688379124384100001 Add a primitive for InvSubBytes + InvShiftRows + AddRoundKey. Reviewed-by: Daniel P. Berrang=C3=A9 Signed-off-by: Richard Henderson --- host/include/generic/host/crypto/aes-round.h | 4 ++ include/crypto/aes-round.h | 21 +++++++++ crypto/aes.c | 45 ++++++++++++++++++++ 3 files changed, 70 insertions(+) diff --git a/host/include/generic/host/crypto/aes-round.h b/host/include/ge= neric/host/crypto/aes-round.h index c5d8066179..c9b9d732f0 100644 --- a/host/include/generic/host/crypto/aes-round.h +++ b/host/include/generic/host/crypto/aes-round.h @@ -13,4 +13,8 @@ void aesenc_SB_SR_AK_accel(AESState *, const AESState *, const AESState *, bool) QEMU_ERROR("unsupported accel"); =20 +void aesdec_ISB_ISR_AK_accel(AESState *, const AESState *, + const AESState *, bool) + QEMU_ERROR("unsupported accel"); + #endif /* GENERIC_HOST_CRYPTO_AES_ROUND_H */ diff --git a/include/crypto/aes-round.h b/include/crypto/aes-round.h index b85db1a30e..dcf098b97b 100644 --- a/include/crypto/aes-round.h +++ b/include/crypto/aes-round.h @@ -41,4 +41,25 @@ static inline void aesenc_SB_SR_AK(AESState *r, const AE= SState *st, } } =20 +/* + * Perform InvSubBytes + InvShiftRows + AddRoundKey. + */ + +void aesdec_ISB_ISR_AK_gen(AESState *ret, const AESState *st, + const AESState *rk); +void aesdec_ISB_ISR_AK_genrev(AESState *ret, const AESState *st, + const AESState *rk); + +static inline void aesdec_ISB_ISR_AK(AESState *r, const AESState *st, + const AESState *rk, bool be) +{ + if (HAVE_AES_ACCEL) { + aesdec_ISB_ISR_AK_accel(r, st, rk, be); + } else if (HOST_BIG_ENDIAN =3D=3D be) { + aesdec_ISB_ISR_AK_gen(r, st, rk); + } else { + aesdec_ISB_ISR_AK_genrev(r, st, rk); + } +} + #endif /* CRYPTO_AES_ROUND_H */ diff --git a/crypto/aes.c b/crypto/aes.c index 408d92b81f..90274c3706 100644 --- a/crypto/aes.c +++ b/crypto/aes.c @@ -1261,6 +1261,51 @@ void aesenc_SB_SR_AK_genrev(AESState *r, const AESSt= ate *s, const AESState *k) aesenc_SB_SR_AK_swap(r, s, k, true); } =20 +/* + * Perform InvSubBytes + InvShiftRows + AddRoundKey. + */ +static inline void +aesdec_ISB_ISR_AK_swap(AESState *ret, const AESState *st, + const AESState *rk, bool swap) +{ + const int swap_b =3D swap ? 15 : 0; + AESState t; + + t.b[swap_b ^ 0x0] =3D AES_isbox[st->b[swap_b ^ AES_ISH(0x0)]]; + t.b[swap_b ^ 0x1] =3D AES_isbox[st->b[swap_b ^ AES_ISH(0x1)]]; + t.b[swap_b ^ 0x2] =3D AES_isbox[st->b[swap_b ^ AES_ISH(0x2)]]; + t.b[swap_b ^ 0x3] =3D AES_isbox[st->b[swap_b ^ AES_ISH(0x3)]]; + t.b[swap_b ^ 0x4] =3D AES_isbox[st->b[swap_b ^ AES_ISH(0x4)]]; + t.b[swap_b ^ 0x5] =3D AES_isbox[st->b[swap_b ^ AES_ISH(0x5)]]; + t.b[swap_b ^ 0x6] =3D AES_isbox[st->b[swap_b ^ AES_ISH(0x6)]]; + t.b[swap_b ^ 0x7] =3D AES_isbox[st->b[swap_b ^ AES_ISH(0x7)]]; + t.b[swap_b ^ 0x8] =3D AES_isbox[st->b[swap_b ^ AES_ISH(0x8)]]; + t.b[swap_b ^ 0x9] =3D AES_isbox[st->b[swap_b ^ AES_ISH(0x9)]]; + t.b[swap_b ^ 0xa] =3D AES_isbox[st->b[swap_b ^ AES_ISH(0xA)]]; + t.b[swap_b ^ 0xb] =3D AES_isbox[st->b[swap_b ^ AES_ISH(0xB)]]; + t.b[swap_b ^ 0xc] =3D AES_isbox[st->b[swap_b ^ AES_ISH(0xC)]]; + t.b[swap_b ^ 0xd] =3D AES_isbox[st->b[swap_b ^ AES_ISH(0xD)]]; + t.b[swap_b ^ 0xe] =3D AES_isbox[st->b[swap_b ^ AES_ISH(0xE)]]; + t.b[swap_b ^ 0xf] =3D AES_isbox[st->b[swap_b ^ AES_ISH(0xF)]]; + + /* + * Perform the AddRoundKey with generic vectors. + * This may be expanded to either host integer or host vector code. + * The key and output endianness match, so no bswap required. + */ + ret->v =3D t.v ^ rk->v; +} + +void aesdec_ISB_ISR_AK_gen(AESState *r, const AESState *s, const AESState = *k) +{ + aesdec_ISB_ISR_AK_swap(r, s, k, false); +} + +void aesdec_ISB_ISR_AK_genrev(AESState *r, const AESState *s, const AESSta= te *k) +{ + aesdec_ISB_ISR_AK_swap(r, s, k, true); +} + /** * Expand the cipher key into the encryption key schedule. */ --=20 2.34.1 From nobody Tue May 14 18:40:19 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1688379020; cv=none; d=zohomail.com; s=zohoarc; b=Mz+VAoJqkIE7vLheFtJzK+ZgLskE3WJQdpZQAZwt3WoQR8zY2caTtZS3uv0mMM8YPNYNrL8gkndkIhRVB7Ru41igdpzhiMLp1uf6zuhW5RbgPtvEjP53o7Cg5b+UM33mQPNCkO07nphZ/QUwshURm/EOwJmLp7qv4+GBgza4KDw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1688379020; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=OqJ8/74xslZqAPWuseMNlVx/dmpNm7/AQh+6yi6QQ/Q=; b=Gfndz5EsEi9EXkSik/Rvho+zYPrg+kBS5wKpSs5Ti7X4zcY7Bg1n5J5IfLyopM0nOo1M5GG5kWgTVrZ+nXCCcO9KXGPfRLRjK/ERaVGeAZ8NRm8TuJdO9dzeao4gcJsFJ6z8kLF51rxruoXcbQhgY0mN1P34VXKcfIytuS1VVPs= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1688379020915853.6484545302447; Mon, 3 Jul 2023 03:10:20 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qGGRO-0002mO-Dg; Mon, 03 Jul 2023 06:05:54 -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 1qGGRF-0002ap-EO for qemu-devel@nongnu.org; Mon, 03 Jul 2023 06:05:45 -0400 Received: from mail-wm1-x334.google.com ([2a00:1450:4864:20::334]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qGGR5-0005js-Md for qemu-devel@nongnu.org; Mon, 03 Jul 2023 06:05:40 -0400 Received: by mail-wm1-x334.google.com with SMTP id 5b1f17b1804b1-3fbc5d5746cso44947485e9.2 for ; Mon, 03 Jul 2023 03:05:30 -0700 (PDT) Received: from stoup.home (91.232.79.188.dynamic.jazztel.es. [188.79.232.91]) by smtp.gmail.com with ESMTPSA id t5-20020a05600001c500b00313f7b077fesm18446562wrx.59.2023.07.03.03.05.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 03 Jul 2023 03:05:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1688378729; x=1690970729; 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=OqJ8/74xslZqAPWuseMNlVx/dmpNm7/AQh+6yi6QQ/Q=; b=C8o2rooRPqQYMAWpKdzFYgDoGcjTrndOODJvpVXvshPlKOSycu6pVsWJ3hUshe5zNB X3vRUPViH+aYGGNiLrKBvszBjwG4/dBDeoYDwPZ9+VR1+K3DvBeTQEVs2BgybxDlPyeA dW8MyjnctCnOyC4OCq7jhnp3a+O08BbuKy9ma0q/jSydm3TXihqq9o4eVNuCGpWpmRF1 L0joFKggtGGXGIWEhfj1/oMHz3YYIaoFEkYn7Z6JWxWyGVGcHOKIc4BmglTiGiYd3/NE zg2ConM7Q7BSUdaquv3U2oBtltdUof3YOZMqdfmCSJ7qflASPwydkMH5bsj4Wq5KQUEl 1fnQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1688378729; x=1690970729; 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=OqJ8/74xslZqAPWuseMNlVx/dmpNm7/AQh+6yi6QQ/Q=; b=Fn/ubFp6O6yZTicSwhSnS6ZZdEoYsGyN7xr24KstssvykGmbfGop031qKDm5JqkGMW AGvjbz0kd6JceVwpUscpz8VS7ak76R8hChVDms+tLuFKizs+9TBWkBgOnbWh1RyQ+Pjl b9oH4bqvzG04FXD8b7GpehAYo8j8/c8vSAx77AXx+WgN74jDgefeCZjrVB7EZbt4LENy sIGSyiC725ADR1da2z17+73e/LG7O+tbd8rWj3dRY44q03NtXWaooSvvfnzRKBKmYDEZ xs2haVUNfzcQS5w7D2PkVHxRNBbp0YNs5zj477qMvNGj7bYPtkPYGvpDZzcykapK6ARv porQ== X-Gm-Message-State: AC+VfDzsR51DToexGD9dR2Rv+8oLK8wZ/Y/MSXQVhXe/zznt6r0kPh0s 7C9P4b/7PMVN/SGTqycBnkqy0HtFKKOzpUzkS4DkIQ== X-Google-Smtp-Source: ACHHUZ7Cl4txMzydqGeHlW+jr1G1fBwfNgKCGR5v/uRuSGpXAklo50h61YIbVfKntc+rkmwUPOorkw== X-Received: by 2002:a1c:6a07:0:b0:3fa:934c:8356 with SMTP id f7-20020a1c6a07000000b003fa934c8356mr9003317wmc.10.1688378729553; Mon, 03 Jul 2023 03:05:29 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: qemu-arm@nongnu.org, qemu-riscv@nongnu.org, pbonzini@redhat.com, eduardo@habkost.net, alistair.francis@wdc.com, danielhb413@gmail.com, =?UTF-8?q?Daniel=20P=20=2E=20Berrang=C3=A9?= Subject: [PATCH v4 07/37] crypto: Add aesenc_MC Date: Mon, 3 Jul 2023 12:04:50 +0200 Message-Id: <20230703100520.68224-8-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230703100520.68224-1-richard.henderson@linaro.org> References: <20230703100520.68224-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::334; envelope-from=richard.henderson@linaro.org; helo=mail-wm1-x334.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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1688379021211100001 Add a primitive for MixColumns. Acked-by: Daniel P. Berrang=C3=A9 Signed-off-by: Richard Henderson --- host/include/generic/host/crypto/aes-round.h | 2 + include/crypto/aes-round.h | 18 ++++++ crypto/aes.c | 61 ++++++++++++++++++++ 3 files changed, 81 insertions(+) diff --git a/host/include/generic/host/crypto/aes-round.h b/host/include/ge= neric/host/crypto/aes-round.h index c9b9d732f0..1b82afc629 100644 --- a/host/include/generic/host/crypto/aes-round.h +++ b/host/include/generic/host/crypto/aes-round.h @@ -9,6 +9,8 @@ #define HAVE_AES_ACCEL false #define ATTR_AES_ACCEL =20 +void aesenc_MC_accel(AESState *, const AESState *, bool) + QEMU_ERROR("unsupported accel"); void aesenc_SB_SR_AK_accel(AESState *, const AESState *, const AESState *, bool) QEMU_ERROR("unsupported accel"); diff --git a/include/crypto/aes-round.h b/include/crypto/aes-round.h index dcf098b97b..7d2be40a67 100644 --- a/include/crypto/aes-round.h +++ b/include/crypto/aes-round.h @@ -20,6 +20,24 @@ typedef union { =20 #include "host/crypto/aes-round.h" =20 +/* + * Perform MixColumns. + */ + +void aesenc_MC_gen(AESState *ret, const AESState *st); +void aesenc_MC_genrev(AESState *ret, const AESState *st); + +static inline void aesenc_MC(AESState *r, const AESState *st, bool be) +{ + if (HAVE_AES_ACCEL) { + aesenc_MC_accel(r, st, be); + } else if (HOST_BIG_ENDIAN =3D=3D be) { + aesenc_MC_gen(r, st); + } else { + aesenc_MC_genrev(r, st); + } +} + /* * Perform SubBytes + ShiftRows + AddRoundKey. */ diff --git a/crypto/aes.c b/crypto/aes.c index 90274c3706..ec300cda0c 100644 --- a/crypto/aes.c +++ b/crypto/aes.c @@ -28,6 +28,8 @@ * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #include "qemu/osdep.h" +#include "qemu/bswap.h" +#include "qemu/bitops.h" #include "crypto/aes.h" #include "crypto/aes-round.h" =20 @@ -1216,6 +1218,65 @@ static const u32 rcon[] =3D { 0x1B000000, 0x36000000, /* for 128-bit blocks, Rijndael never uses= more than 10 rcon values */ }; =20 +/* + * Perform MixColumns. + */ +static inline void +aesenc_MC_swap(AESState *r, const AESState *st, bool swap) +{ + int swap_b =3D swap * 0xf; + int swap_w =3D swap * 0x3; + bool be =3D HOST_BIG_ENDIAN ^ swap; + uint32_t t; + + /* Note that AES_mc_rot is encoded for little-endian. */ + t =3D ( AES_mc_rot[st->b[swap_b ^ 0x0]] ^ + rol32(AES_mc_rot[st->b[swap_b ^ 0x1]], 8) ^ + rol32(AES_mc_rot[st->b[swap_b ^ 0x2]], 16) ^ + rol32(AES_mc_rot[st->b[swap_b ^ 0x3]], 24)); + if (be) { + t =3D bswap32(t); + } + r->w[swap_w ^ 0] =3D t; + + t =3D ( AES_mc_rot[st->b[swap_b ^ 0x4]] ^ + rol32(AES_mc_rot[st->b[swap_b ^ 0x5]], 8) ^ + rol32(AES_mc_rot[st->b[swap_b ^ 0x6]], 16) ^ + rol32(AES_mc_rot[st->b[swap_b ^ 0x7]], 24)); + if (be) { + t =3D bswap32(t); + } + r->w[swap_w ^ 1] =3D t; + + t =3D ( AES_mc_rot[st->b[swap_b ^ 0x8]] ^ + rol32(AES_mc_rot[st->b[swap_b ^ 0x9]], 8) ^ + rol32(AES_mc_rot[st->b[swap_b ^ 0xA]], 16) ^ + rol32(AES_mc_rot[st->b[swap_b ^ 0xB]], 24)); + if (be) { + t =3D bswap32(t); + } + r->w[swap_w ^ 2] =3D t; + + t =3D ( AES_mc_rot[st->b[swap_b ^ 0xC]] ^ + rol32(AES_mc_rot[st->b[swap_b ^ 0xD]], 8) ^ + rol32(AES_mc_rot[st->b[swap_b ^ 0xE]], 16) ^ + rol32(AES_mc_rot[st->b[swap_b ^ 0xF]], 24)); + if (be) { + t =3D bswap32(t); + } + r->w[swap_w ^ 3] =3D t; +} + +void aesenc_MC_gen(AESState *r, const AESState *st) +{ + aesenc_MC_swap(r, st, false); +} + +void aesenc_MC_genrev(AESState *r, const AESState *st) +{ + aesenc_MC_swap(r, st, true); +} + /* * Perform SubBytes + ShiftRows + AddRoundKey. */ --=20 2.34.1 From nobody Tue May 14 18:40:19 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1688379285; cv=none; d=zohomail.com; s=zohoarc; b=k6h+OOXqbW4gxD4RtIQLRNawiU1BoMVUQk9nAxX6Ry7xhVmIPNp6hszJPaZ6Omdmlps406pHu+jheVj3zlx7WcaOq/vrdvDbaD+aiSZU9YmBcFJSWldY+VZ8TIGWeRc3n324P3MDL6Ds73s/PYlvsBUNCMQOOOhkKJsh4WLQPZw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1688379285; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=1lNVmzIrZ20vaRM4z3bBKO9neuQ8i1reH4ftvygdvPI=; b=YNSkmzFuB6Pk/adBcskj9oXNMjJX4MOwF034DhDQfUpuA6CnUb8IcZ2H32bPdL0E4g/3fo20Fqr4JpSW+P7DSljTQiymcBM5uZJLlqocyBXj/vMFQKfS5/HltSNZH60eFz3UFQWZu9fFA6nSsuQZH2xV4JVVpl9jv15OSXsIW44= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1688379285080273.4024944097408; Mon, 3 Jul 2023 03:14:45 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qGGRb-00030k-BS; Mon, 03 Jul 2023 06:06:07 -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 1qGGRO-0002mD-5D for qemu-devel@nongnu.org; Mon, 03 Jul 2023 06:05:54 -0400 Received: from mail-wr1-x42a.google.com ([2a00:1450:4864:20::42a]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qGGRG-0005lP-5i for qemu-devel@nongnu.org; Mon, 03 Jul 2023 06:05:53 -0400 Received: by mail-wr1-x42a.google.com with SMTP id ffacd0b85a97d-314313f127fso1700374f8f.1 for ; Mon, 03 Jul 2023 03:05:31 -0700 (PDT) Received: from stoup.home (91.232.79.188.dynamic.jazztel.es. [188.79.232.91]) by smtp.gmail.com with ESMTPSA id t5-20020a05600001c500b00313f7b077fesm18446562wrx.59.2023.07.03.03.05.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 03 Jul 2023 03:05:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1688378730; x=1690970730; 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=1lNVmzIrZ20vaRM4z3bBKO9neuQ8i1reH4ftvygdvPI=; b=Oq2U6BJtvZCWo/QGlpNyqGQkg4vJHq1IlhWRHI4sTjAp+jUkyM03l1u0bgm80DJDbk i76G67C32odZpKtUQZx6d8WbV8+D2zrsPekVKzfTMBwTf8uIc9oqfsTQKbfq+YAG7OP2 iF2j95Sig0j0Jk4BDy62R1m78hwKVP6ZfRcI51M2pqjFnPNlxRj9D57geagCSxHQqAxL aJMSf8G9hs3Ey13eRXnFJCpWd0BJ5Pp10ganplvv0UJJfg1A8h68XSus21hycZmBoAsQ G77Jb+xX8NEJL7Jo1OjHY/8hh8Rb47CDRB4mWOeAqkgLQcPJw6uFG08jKnf4g1y3hOdX nTkQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1688378730; x=1690970730; 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=1lNVmzIrZ20vaRM4z3bBKO9neuQ8i1reH4ftvygdvPI=; b=Tak+DKL1JrvovfKs3SQo0+F2b3qulKVsoRthAIuQqYx7BRvjLywk/KhKkfuRQ/SKOU xLyvaXF3CHN3OLlzKxACyy77NEPmeKhwk5OnAiCCL4Kfjk8Hv/2SnbkN7bXFXq7tV8MV P1X3REyxknsfzPo088zI/laJtZ0vtKBzGH/Z1dw5oeTQ2ueXqhYSjOc9f6LHRQMgIprp LMvK1qD5yzcbpQXtVDrSkLToCW0ypcgitagTBEer6awXdrM0n0BS80zshdfciWAlgtd1 9zZcbQ/+S/ntnMdtYM6P69rqLeLSzF/OTopow4+KEDr3wpiEQkILBs0IwYIdXCIJQcsn UBrg== X-Gm-Message-State: ABy/qLbUhPt0glLKJqgraEZ2FwsB8rAMY1YdhFC1ZbAAABkWwLCfsDJ/ Xb7FHrQMugnb7/lOglvhQ9K9f5i6Ija2zxg/is0wjQ== X-Google-Smtp-Source: APBJJlHmfMytgn4KTs+PMo96blHkQ4AOrqPaHTR0AR9LhRjpvvt6ff8w/rVxNl06mWSQltIq1obNiA== X-Received: by 2002:adf:e4cd:0:b0:314:367f:15f3 with SMTP id v13-20020adfe4cd000000b00314367f15f3mr3271427wrm.9.1688378730536; Mon, 03 Jul 2023 03:05:30 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: qemu-arm@nongnu.org, qemu-riscv@nongnu.org, pbonzini@redhat.com, eduardo@habkost.net, alistair.francis@wdc.com, danielhb413@gmail.com, =?UTF-8?q?Daniel=20P=20=2E=20Berrang=C3=A9?= Subject: [PATCH v4 08/37] crypto: Add aesdec_IMC Date: Mon, 3 Jul 2023 12:04:51 +0200 Message-Id: <20230703100520.68224-9-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230703100520.68224-1-richard.henderson@linaro.org> References: <20230703100520.68224-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::42a; envelope-from=richard.henderson@linaro.org; helo=mail-wr1-x42a.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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1688379286462100001 Add a primitive for InvMixColumns. Acked-by: Daniel P. Berrang=C3=A9 Signed-off-by: Richard Henderson --- host/include/generic/host/crypto/aes-round.h | 2 + include/crypto/aes-round.h | 18 ++++++ crypto/aes.c | 59 ++++++++++++++++++++ 3 files changed, 79 insertions(+) diff --git a/host/include/generic/host/crypto/aes-round.h b/host/include/ge= neric/host/crypto/aes-round.h index 1b82afc629..335ec3f11e 100644 --- a/host/include/generic/host/crypto/aes-round.h +++ b/host/include/generic/host/crypto/aes-round.h @@ -15,6 +15,8 @@ void aesenc_SB_SR_AK_accel(AESState *, const AESState *, const AESState *, bool) QEMU_ERROR("unsupported accel"); =20 +void aesdec_IMC_accel(AESState *, const AESState *, bool) + QEMU_ERROR("unsupported accel"); void aesdec_ISB_ISR_AK_accel(AESState *, const AESState *, const AESState *, bool) QEMU_ERROR("unsupported accel"); diff --git a/include/crypto/aes-round.h b/include/crypto/aes-round.h index 7d2be40a67..7be2cc0d8e 100644 --- a/include/crypto/aes-round.h +++ b/include/crypto/aes-round.h @@ -59,6 +59,24 @@ static inline void aesenc_SB_SR_AK(AESState *r, const AE= SState *st, } } =20 +/* + * Perform InvMixColumns. + */ + +void aesdec_IMC_gen(AESState *ret, const AESState *st); +void aesdec_IMC_genrev(AESState *ret, const AESState *st); + +static inline void aesdec_IMC(AESState *r, const AESState *st, bool be) +{ + if (HAVE_AES_ACCEL) { + aesdec_IMC_accel(r, st, be); + } else if (HOST_BIG_ENDIAN =3D=3D be) { + aesdec_IMC_gen(r, st); + } else { + aesdec_IMC_genrev(r, st); + } +} + /* * Perform InvSubBytes + InvShiftRows + AddRoundKey. */ diff --git a/crypto/aes.c b/crypto/aes.c index ec300cda0c..6c05d731f4 100644 --- a/crypto/aes.c +++ b/crypto/aes.c @@ -1322,6 +1322,65 @@ void aesenc_SB_SR_AK_genrev(AESState *r, const AESSt= ate *s, const AESState *k) aesenc_SB_SR_AK_swap(r, s, k, true); } =20 +/* + * Perform InvMixColumns. + */ +static inline void +aesdec_IMC_swap(AESState *r, const AESState *st, bool swap) +{ + int swap_b =3D swap * 0xf; + int swap_w =3D swap * 0x3; + bool be =3D HOST_BIG_ENDIAN ^ swap; + uint32_t t; + + /* Note that AES_imc is encoded for big-endian. */ + t =3D (AES_imc[st->b[swap_b ^ 0x0]][0] ^ + AES_imc[st->b[swap_b ^ 0x1]][1] ^ + AES_imc[st->b[swap_b ^ 0x2]][2] ^ + AES_imc[st->b[swap_b ^ 0x3]][3]); + if (!be) { + t =3D bswap32(t); + } + r->w[swap_w ^ 0] =3D t; + + t =3D (AES_imc[st->b[swap_b ^ 0x4]][0] ^ + AES_imc[st->b[swap_b ^ 0x5]][1] ^ + AES_imc[st->b[swap_b ^ 0x6]][2] ^ + AES_imc[st->b[swap_b ^ 0x7]][3]); + if (!be) { + t =3D bswap32(t); + } + r->w[swap_w ^ 1] =3D t; + + t =3D (AES_imc[st->b[swap_b ^ 0x8]][0] ^ + AES_imc[st->b[swap_b ^ 0x9]][1] ^ + AES_imc[st->b[swap_b ^ 0xA]][2] ^ + AES_imc[st->b[swap_b ^ 0xB]][3]); + if (!be) { + t =3D bswap32(t); + } + r->w[swap_w ^ 2] =3D t; + + t =3D (AES_imc[st->b[swap_b ^ 0xC]][0] ^ + AES_imc[st->b[swap_b ^ 0xD]][1] ^ + AES_imc[st->b[swap_b ^ 0xE]][2] ^ + AES_imc[st->b[swap_b ^ 0xF]][3]); + if (!be) { + t =3D bswap32(t); + } + r->w[swap_w ^ 3] =3D t; +} + +void aesdec_IMC_gen(AESState *r, const AESState *st) +{ + aesdec_IMC_swap(r, st, false); +} + +void aesdec_IMC_genrev(AESState *r, const AESState *st) +{ + aesdec_IMC_swap(r, st, true); +} + /* * Perform InvSubBytes + InvShiftRows + AddRoundKey. */ --=20 2.34.1 From nobody Tue May 14 18:40:19 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1688379249; cv=none; d=zohomail.com; s=zohoarc; b=H5ZtoiK9LX0oUNXExzYjoGg4LRCnJkrRJi95CMTaV19wieq00n9Ia6wlJHJVbZ/u+K26BSOW+pWM+PewhAH+rar082lWC6na8e6tiWfbq6O8X32Daa7TWF56a9jQONHyHqswWKws3tf85cVPjmC6H/1xi+RriB9rBF+Jl14w3OU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1688379249; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=ne/prNzqsLfpjp4V0V8cndvcCHzJQtvFp1sqS4i2NnA=; b=GreKsopzm1ublVtGekrUOFL9eROvcpw+wkbGlxvH0O8Qi40PM4RPmXL72IfaEU3msqT6w2wK6vPlW2ELkobrNIkcagxlwRj5QqZ2pEYyHF0W3JQbSojjgpcOo9GjB4qlqmrENBv+0K6vXzA8dMn727YoaxNRPKUbd71rKDUeU6A= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1688379249011559.9356464378704; Mon, 3 Jul 2023 03:14:09 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qGGRd-00034X-L7; Mon, 03 Jul 2023 06:06:09 -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 1qGGRU-0002qg-FP for qemu-devel@nongnu.org; Mon, 03 Jul 2023 06:06:01 -0400 Received: from mail-wr1-x431.google.com ([2a00:1450:4864:20::431]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qGGRG-0005m6-Fy for qemu-devel@nongnu.org; Mon, 03 Jul 2023 06:05:59 -0400 Received: by mail-wr1-x431.google.com with SMTP id ffacd0b85a97d-3141fa31c2bso3957490f8f.2 for ; Mon, 03 Jul 2023 03:05:32 -0700 (PDT) Received: from stoup.home (91.232.79.188.dynamic.jazztel.es. [188.79.232.91]) by smtp.gmail.com with ESMTPSA id t5-20020a05600001c500b00313f7b077fesm18446562wrx.59.2023.07.03.03.05.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 03 Jul 2023 03:05:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1688378732; x=1690970732; 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=ne/prNzqsLfpjp4V0V8cndvcCHzJQtvFp1sqS4i2NnA=; b=c+HEn9ajz+YeahAHgWi3CWQxH9BbdU9DrOiVpzU0iu6gIiKzRoiwHRYoQ8ubofwh7j gNm6Bh8TtfwTmm1G2WErLTiGWB5gnvxADwC31jYzCAIN6ynColExZID2k7xWM1W71Be4 ajQonhwTIVuBYlzGGBO8xl4mF066l9SlQLProAkZhedrW9ljD+tueQIRgKHZxhDjNSY7 2U4J64L0LywNsCDPanm/8qNa9RWr6mh5mPsPv5BcsFSKi+2tobnmyMVVgLKlcZtLomMm 05H4/4EnKcgtBdo67hnkhJ31f0UvKTtFzy+0zylR4J7OcuyeJdUsZaHv4QxkPOJ/Y8nj JEfA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1688378732; x=1690970732; 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=ne/prNzqsLfpjp4V0V8cndvcCHzJQtvFp1sqS4i2NnA=; b=QCPKIUEyLqII/B0zDrzu7Yh+ISmxVfG7y9Mikf21ax+QXlYnaNlANTFmNAGYLGiIWQ iopakNxmrqNiveEPhi7g0NkQupUvNd9skHvyHCyZVKPkbsyQuj6VSzLc4pG/5F6mm+dq jeBodRsk0GEXOhXCir1gCEsmD8eQBAuymimzcVnEpVq/U1Hp3Q4qCUuROezPJQVKjvng gDcIYGJUa6HbKvCkQuLsiY5TjojeUmBg6NF0pkAopfCBDr9ko/ya2Bd6E5XNDkiG9WhX rYoEwQa8vlcYjRj8X8zVWyHi3AuSg6g1szUZsA0xedwdcrt2PAMRR68m05YPjjV2zGKL B1ew== X-Gm-Message-State: ABy/qLZesNRYXpkb2DYcKC00tgCj9tMMvqO6lledIdx0TbKnFN/BD3JG Onr5wnD8hPZFuAP5tZviD2bek5jDFOmY0cT100BGOQ== X-Google-Smtp-Source: APBJJlHxrMCPlPi/5H6Ktfs3G8Y4SXKJY9vLU6AreAph6rBj6mpo3aE0yF2P0udjxsq3khiiBXd40A== X-Received: by 2002:a5d:43cd:0:b0:314:182c:19e1 with SMTP id v13-20020a5d43cd000000b00314182c19e1mr8090106wrr.17.1688378731767; Mon, 03 Jul 2023 03:05:31 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: qemu-arm@nongnu.org, qemu-riscv@nongnu.org, pbonzini@redhat.com, eduardo@habkost.net, alistair.francis@wdc.com, danielhb413@gmail.com, =?UTF-8?q?Daniel=20P=20=2E=20Berrang=C3=A9?= Subject: [PATCH v4 09/37] crypto: Add aesenc_SB_SR_MC_AK Date: Mon, 3 Jul 2023 12:04:52 +0200 Message-Id: <20230703100520.68224-10-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230703100520.68224-1-richard.henderson@linaro.org> References: <20230703100520.68224-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::431; envelope-from=richard.henderson@linaro.org; helo=mail-wr1-x431.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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1688379250833100004 Add a primitive for SubBytes + ShiftRows + MixColumns + AddRoundKey. Acked-by: Daniel P. Berrang=C3=A9 Signed-off-by: Richard Henderson --- host/include/generic/host/crypto/aes-round.h | 3 + include/crypto/aes-round.h | 21 +++++++ crypto/aes.c | 58 ++++++++++++++++++++ 3 files changed, 82 insertions(+) diff --git a/host/include/generic/host/crypto/aes-round.h b/host/include/ge= neric/host/crypto/aes-round.h index 335ec3f11e..9886e81e50 100644 --- a/host/include/generic/host/crypto/aes-round.h +++ b/host/include/generic/host/crypto/aes-round.h @@ -14,6 +14,9 @@ void aesenc_MC_accel(AESState *, const AESState *, bool) void aesenc_SB_SR_AK_accel(AESState *, const AESState *, const AESState *, bool) QEMU_ERROR("unsupported accel"); +void aesenc_SB_SR_MC_AK_accel(AESState *, const AESState *, + const AESState *, bool) + QEMU_ERROR("unsupported accel"); =20 void aesdec_IMC_accel(AESState *, const AESState *, bool) QEMU_ERROR("unsupported accel"); diff --git a/include/crypto/aes-round.h b/include/crypto/aes-round.h index 7be2cc0d8e..03688c8640 100644 --- a/include/crypto/aes-round.h +++ b/include/crypto/aes-round.h @@ -59,6 +59,27 @@ static inline void aesenc_SB_SR_AK(AESState *r, const AE= SState *st, } } =20 +/* + * Perform SubBytes + ShiftRows + MixColumns + AddRoundKey. + */ + +void aesenc_SB_SR_MC_AK_gen(AESState *ret, const AESState *st, + const AESState *rk); +void aesenc_SB_SR_MC_AK_genrev(AESState *ret, const AESState *st, + const AESState *rk); + +static inline void aesenc_SB_SR_MC_AK(AESState *r, const AESState *st, + const AESState *rk, bool be) +{ + if (HAVE_AES_ACCEL) { + aesenc_SB_SR_MC_AK_accel(r, st, rk, be); + } else if (HOST_BIG_ENDIAN =3D=3D be) { + aesenc_SB_SR_MC_AK_gen(r, st, rk); + } else { + aesenc_SB_SR_MC_AK_genrev(r, st, rk); + } +} + /* * Perform InvMixColumns. */ diff --git a/crypto/aes.c b/crypto/aes.c index 6c05d731f4..a193d98d54 100644 --- a/crypto/aes.c +++ b/crypto/aes.c @@ -1322,6 +1322,64 @@ void aesenc_SB_SR_AK_genrev(AESState *r, const AESSt= ate *s, const AESState *k) aesenc_SB_SR_AK_swap(r, s, k, true); } =20 +/* + * Perform SubBytes + ShiftRows + MixColumns + AddRoundKey. + */ +static inline void +aesenc_SB_SR_MC_AK_swap(AESState *r, const AESState *st, + const AESState *rk, bool swap) +{ + int swap_b =3D swap * 0xf; + int swap_w =3D swap * 0x3; + bool be =3D HOST_BIG_ENDIAN ^ swap; + uint32_t w0, w1, w2, w3; + + w0 =3D (AES_Te0[st->b[swap_b ^ AES_SH(0x0)]] ^ + AES_Te1[st->b[swap_b ^ AES_SH(0x1)]] ^ + AES_Te2[st->b[swap_b ^ AES_SH(0x2)]] ^ + AES_Te3[st->b[swap_b ^ AES_SH(0x3)]]); + + w1 =3D (AES_Te0[st->b[swap_b ^ AES_SH(0x4)]] ^ + AES_Te1[st->b[swap_b ^ AES_SH(0x5)]] ^ + AES_Te2[st->b[swap_b ^ AES_SH(0x6)]] ^ + AES_Te3[st->b[swap_b ^ AES_SH(0x7)]]); + + w2 =3D (AES_Te0[st->b[swap_b ^ AES_SH(0x8)]] ^ + AES_Te1[st->b[swap_b ^ AES_SH(0x9)]] ^ + AES_Te2[st->b[swap_b ^ AES_SH(0xA)]] ^ + AES_Te3[st->b[swap_b ^ AES_SH(0xB)]]); + + w3 =3D (AES_Te0[st->b[swap_b ^ AES_SH(0xC)]] ^ + AES_Te1[st->b[swap_b ^ AES_SH(0xD)]] ^ + AES_Te2[st->b[swap_b ^ AES_SH(0xE)]] ^ + AES_Te3[st->b[swap_b ^ AES_SH(0xF)]]); + + /* Note that AES_TeX is encoded for big-endian. */ + if (!be) { + w0 =3D bswap32(w0); + w1 =3D bswap32(w1); + w2 =3D bswap32(w2); + w3 =3D bswap32(w3); + } + + r->w[swap_w ^ 0] =3D rk->w[swap_w ^ 0] ^ w0; + r->w[swap_w ^ 1] =3D rk->w[swap_w ^ 1] ^ w1; + r->w[swap_w ^ 2] =3D rk->w[swap_w ^ 2] ^ w2; + r->w[swap_w ^ 3] =3D rk->w[swap_w ^ 3] ^ w3; +} + +void aesenc_SB_SR_MC_AK_gen(AESState *r, const AESState *st, + const AESState *rk) +{ + aesenc_SB_SR_MC_AK_swap(r, st, rk, false); +} + +void aesenc_SB_SR_MC_AK_genrev(AESState *r, const AESState *st, + const AESState *rk) +{ + aesenc_SB_SR_MC_AK_swap(r, st, rk, true); +} + /* * Perform InvMixColumns. */ --=20 2.34.1 From nobody Tue May 14 18:40:19 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1688379016; cv=none; d=zohomail.com; s=zohoarc; b=UPzzgFqJnpZ6y2vLKQbXxOm3djSVcUQ7jXtEhdl+0NlcVRi5F2qJu4cFcpZZUiH0dSHGUueGK8daiXUF5p8ThBb2eEMDS6KwLJ2zI5pHnP5MzNJ7YUmZ+lJIxVvFQUkmYtKSV3Kt1CwpUhazfbqXBq8Hfap8VJHaIlwO4Z+OR7Q= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1688379016; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=bjel77SnKNWNctLdWi3qeIHBWb+IXzPkj8iWkSio4Cw=; b=Ju1fHnVOX4INEgA1O2+CCSU4iHu85RPpgNQhoWTe2AGmQJseJwIpb4ZqSwTOSPN1xJ8arUoNdvMnEQOUTBSQ2ylixs1JYEnkLuolRpnyq+TxOe3mDjFx7hTH32uAnF/aGFq9tEo7GjQgkZ4mXXxOFj8fcYc+J091e/u4a1nYwyQ= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1688379016444157.76968523548692; Mon, 3 Jul 2023 03:10:16 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qGGRM-0002iu-Kp; Mon, 03 Jul 2023 06:05:52 -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 1qGGRK-0002fc-3g for qemu-devel@nongnu.org; Mon, 03 Jul 2023 06:05:50 -0400 Received: from mail-wr1-x429.google.com ([2a00:1450:4864:20::429]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qGGRF-0005ms-06 for qemu-devel@nongnu.org; Mon, 03 Jul 2023 06:05:49 -0400 Received: by mail-wr1-x429.google.com with SMTP id ffacd0b85a97d-313f61890fbso4703153f8f.3 for ; Mon, 03 Jul 2023 03:05:33 -0700 (PDT) Received: from stoup.home (91.232.79.188.dynamic.jazztel.es. [188.79.232.91]) by smtp.gmail.com with ESMTPSA id t5-20020a05600001c500b00313f7b077fesm18446562wrx.59.2023.07.03.03.05.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 03 Jul 2023 03:05:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1688378733; x=1690970733; 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=bjel77SnKNWNctLdWi3qeIHBWb+IXzPkj8iWkSio4Cw=; b=HaGnuPjg7ggfIjq0iOKzjfMMwCIg/vlKQIducCQ1OB6RnIJWRuUs7DCj1KxisemXfK evsZpCQlXOetx6J1lOpUcKmyg78ieI98KSuXgrOiFdOegKEp4bHLFVxOG6p+puEth4Su Ugi4ejTmMLhoY3e8w4r07RAl9Dc65+3OFcv1LN0DsBeSZvJrbzmfksqaHtJmFfHQyx/i eCflWP4Tj1MNaqXRwP3lSdBsoUgpIdwTXxV+CzNyimZD6MMgEjjc0RjCMHch/d8aSlOn 829pEDrgFYmoiXDjgPLw44SWbR1/Q0bCzE87mD3/GG4dNoaD9l5vryRbCdK7IwURfU1f GEjw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1688378733; x=1690970733; 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=bjel77SnKNWNctLdWi3qeIHBWb+IXzPkj8iWkSio4Cw=; b=bZFLBbo72v57mx9VGGuQVidEPHewbsYmcwMDpIBo5CHrTxY0AU6DSfAvRqQaRhqtnP /XAh2NjkAzgJhsMZMlggxEOHRabwIheWCYC5e0sqUclJtTn/p5yxVTYwiNj7pot+j/3v 8tdslROSj20dGIEikc2TTT5N6nvVxWyGJD8My/3ZblBKknGtbygHVrXDVg+es1nehQnM KrKM2JyWXcXYWee4UTo+5QwjLy/m3ucODonfpvQKjg/LTJhC++gJDttSBmyd3dp+QbHu Ze9D0xguhkDpyky8Wfvy2nZ2+MwMi/xy6w15Y3Vru4Sywxwf37xqLedn+jdwl/QlVjQy SEFg== X-Gm-Message-State: ABy/qLZbTJ3oUR9LRk7DILSqoglH26TCDOZsW9bK9fYzcH/BsFf8Hqh1 kHcKEC1M4NCJQ793Fx6scwc9dGpOjYgV1wsyb9459Q== X-Google-Smtp-Source: APBJJlGOhLr501NKNE5yMProscDjSaZk5fjC4EtcgAROb4vni7fz9WpbpEILHVQ7jqd/rJvZp/gZfQ== X-Received: by 2002:a5d:6349:0:b0:313:e48a:d173 with SMTP id b9-20020a5d6349000000b00313e48ad173mr6952510wrw.68.1688378732913; Mon, 03 Jul 2023 03:05:32 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: qemu-arm@nongnu.org, qemu-riscv@nongnu.org, pbonzini@redhat.com, eduardo@habkost.net, alistair.francis@wdc.com, danielhb413@gmail.com, =?UTF-8?q?Daniel=20P=20=2E=20Berrang=C3=A9?= Subject: [PATCH v4 10/37] crypto: Add aesdec_ISB_ISR_IMC_AK Date: Mon, 3 Jul 2023 12:04:53 +0200 Message-Id: <20230703100520.68224-11-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230703100520.68224-1-richard.henderson@linaro.org> References: <20230703100520.68224-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::429; envelope-from=richard.henderson@linaro.org; helo=mail-wr1-x429.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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1688379018356100003 Add a primitive for InvSubBytes + InvShiftRows + InvMixColumns + AddRoundKey. Acked-by: Daniel P. Berrang=C3=A9 Signed-off-by: Richard Henderson --- host/include/generic/host/crypto/aes-round.h | 3 + include/crypto/aes-round.h | 21 +++++++ crypto/aes.c | 58 ++++++++++++++++++++ 3 files changed, 82 insertions(+) diff --git a/host/include/generic/host/crypto/aes-round.h b/host/include/ge= neric/host/crypto/aes-round.h index 9886e81e50..db8cfe17eb 100644 --- a/host/include/generic/host/crypto/aes-round.h +++ b/host/include/generic/host/crypto/aes-round.h @@ -23,5 +23,8 @@ void aesdec_IMC_accel(AESState *, const AESState *, bool) void aesdec_ISB_ISR_AK_accel(AESState *, const AESState *, const AESState *, bool) QEMU_ERROR("unsupported accel"); +void aesdec_ISB_ISR_IMC_AK_accel(AESState *, const AESState *, + const AESState *, bool) + QEMU_ERROR("unsupported accel"); =20 #endif /* GENERIC_HOST_CRYPTO_AES_ROUND_H */ diff --git a/include/crypto/aes-round.h b/include/crypto/aes-round.h index 03688c8640..9996f1c219 100644 --- a/include/crypto/aes-round.h +++ b/include/crypto/aes-round.h @@ -119,4 +119,25 @@ static inline void aesdec_ISB_ISR_AK(AESState *r, cons= t AESState *st, } } =20 +/* + * Perform InvSubBytes + InvShiftRows + InvMixColumns + AddRoundKey. + */ + +void aesdec_ISB_ISR_IMC_AK_gen(AESState *ret, const AESState *st, + const AESState *rk); +void aesdec_ISB_ISR_IMC_AK_genrev(AESState *ret, const AESState *st, + const AESState *rk); + +static inline void aesdec_ISB_ISR_IMC_AK(AESState *r, const AESState *st, + const AESState *rk, bool be) +{ + if (HAVE_AES_ACCEL) { + aesdec_ISB_ISR_IMC_AK_accel(r, st, rk, be); + } else if (HOST_BIG_ENDIAN =3D=3D be) { + aesdec_ISB_ISR_IMC_AK_gen(r, st, rk); + } else { + aesdec_ISB_ISR_IMC_AK_genrev(r, st, rk); + } +} + #endif /* CRYPTO_AES_ROUND_H */ diff --git a/crypto/aes.c b/crypto/aes.c index a193d98d54..c2546ef12e 100644 --- a/crypto/aes.c +++ b/crypto/aes.c @@ -1484,6 +1484,64 @@ void aesdec_ISB_ISR_AK_genrev(AESState *r, const AES= State *s, const AESState *k) aesdec_ISB_ISR_AK_swap(r, s, k, true); } =20 +/* + * Perform InvSubBytes + InvShiftRows + InvMixColumns + AddRoundKey. + */ +static inline void +aesdec_ISB_ISR_IMC_AK_swap(AESState *r, const AESState *st, + const AESState *rk, bool swap) +{ + int swap_b =3D swap * 0xf; + int swap_w =3D swap * 0x3; + bool be =3D HOST_BIG_ENDIAN ^ swap; + uint32_t w0, w1, w2, w3; + + w0 =3D (AES_Td0[st->b[swap_b ^ AES_ISH(0x0)]] ^ + AES_Td1[st->b[swap_b ^ AES_ISH(0x1)]] ^ + AES_Td2[st->b[swap_b ^ AES_ISH(0x2)]] ^ + AES_Td3[st->b[swap_b ^ AES_ISH(0x3)]]); + + w1 =3D (AES_Td0[st->b[swap_b ^ AES_ISH(0x4)]] ^ + AES_Td1[st->b[swap_b ^ AES_ISH(0x5)]] ^ + AES_Td2[st->b[swap_b ^ AES_ISH(0x6)]] ^ + AES_Td3[st->b[swap_b ^ AES_ISH(0x7)]]); + + w2 =3D (AES_Td0[st->b[swap_b ^ AES_ISH(0x8)]] ^ + AES_Td1[st->b[swap_b ^ AES_ISH(0x9)]] ^ + AES_Td2[st->b[swap_b ^ AES_ISH(0xA)]] ^ + AES_Td3[st->b[swap_b ^ AES_ISH(0xB)]]); + + w3 =3D (AES_Td0[st->b[swap_b ^ AES_ISH(0xC)]] ^ + AES_Td1[st->b[swap_b ^ AES_ISH(0xD)]] ^ + AES_Td2[st->b[swap_b ^ AES_ISH(0xE)]] ^ + AES_Td3[st->b[swap_b ^ AES_ISH(0xF)]]); + + /* Note that AES_TdX is encoded for big-endian. */ + if (!be) { + w0 =3D bswap32(w0); + w1 =3D bswap32(w1); + w2 =3D bswap32(w2); + w3 =3D bswap32(w3); + } + + r->w[swap_w ^ 0] =3D rk->w[swap_w ^ 0] ^ w0; + r->w[swap_w ^ 1] =3D rk->w[swap_w ^ 1] ^ w1; + r->w[swap_w ^ 2] =3D rk->w[swap_w ^ 2] ^ w2; + r->w[swap_w ^ 3] =3D rk->w[swap_w ^ 3] ^ w3; +} + +void aesdec_ISB_ISR_IMC_AK_gen(AESState *r, const AESState *st, + const AESState *rk) +{ + aesdec_ISB_ISR_IMC_AK_swap(r, st, rk, false); +} + +void aesdec_ISB_ISR_IMC_AK_genrev(AESState *r, const AESState *st, + const AESState *rk) +{ + aesdec_ISB_ISR_IMC_AK_swap(r, st, rk, true); +} + /** * Expand the cipher key into the encryption key schedule. */ --=20 2.34.1 From nobody Tue May 14 18:40:19 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1688379250; cv=none; d=zohomail.com; s=zohoarc; b=HkK6in8af/kRMJ0BDrZKc8sN7kGJMQNa7ZcCMrcMJJJRs5qANJIlsNummnfRFyzICiG3GOE9C94ClKmCJ9kFw/0fgbzGu10NSrJcEtEtG4yMd957e5Q7HpA7CX5UluaVcWc8g7Jq5uLunw6LUS5A1Zz/HcSJNHZts0NyvO6wyJM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1688379250; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=/QBtvBQSI1Tt7HA/Hos/l3dVZOAq+hVRSg1lIqyT39k=; b=Il3jZMpq36z8rUXdUEPl3YNp3nlmNl6sVurKZYIfYMomH1XFNXewOzVYjIRpjR3SWNSA1R0uBmQlxfaK4hSSsuYTjlocgpnYkjtM6FAF33Knu9TqeGXoKIAG0OjiQUGoKXNs5mnq/i2sWw6vcSQdFccr798zLen82DBw62BEzTM= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1688379250007892.1811651511356; Mon, 3 Jul 2023 03:14:10 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qGGRu-0003Cf-Ju; Mon, 03 Jul 2023 06:06:26 -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 1qGGRW-0002rh-46 for qemu-devel@nongnu.org; Mon, 03 Jul 2023 06:06:03 -0400 Received: from mail-wm1-x335.google.com ([2a00:1450:4864:20::335]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qGGRG-0005nB-MH for qemu-devel@nongnu.org; Mon, 03 Jul 2023 06:06:00 -0400 Received: by mail-wm1-x335.google.com with SMTP id 5b1f17b1804b1-3fbc12181b6so46877845e9.2 for ; Mon, 03 Jul 2023 03:05:34 -0700 (PDT) Received: from stoup.home (91.232.79.188.dynamic.jazztel.es. [188.79.232.91]) by smtp.gmail.com with ESMTPSA id t5-20020a05600001c500b00313f7b077fesm18446562wrx.59.2023.07.03.03.05.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 03 Jul 2023 03:05:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1688378734; x=1690970734; 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=/QBtvBQSI1Tt7HA/Hos/l3dVZOAq+hVRSg1lIqyT39k=; b=AhmLxzxSb4U5V2xacDX4rGa7xUh+9bH+lkN7yFR9dlOsxxS1YM1kHxK4I3oG/w6G1K 35g9uv79cI5/mBMaD8MpNMWGssZcEW69AxBYw1s5St9HqAHykxL2I9T+qiEM2YUV5CAp 7QjWM2b7QmoQj8k8ke4TO0WFn3aSd0ZOjv7sNoobK+UwN4SmTvXN5Pap8FeIxg048ji5 iXokiEeEZuCXQR6j2RMRbAvSxtPRJPqm0YprxWkSDba1Rfd2Q6OGCs3ajuez6AnUNv+g 1mMJ/L+A2SimQw8TQwl1qi7+Yo5cRjboPpUnAgodCEscpOdbJxYxrYnkF0PxlhCBiAMs ii8w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1688378734; x=1690970734; 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=/QBtvBQSI1Tt7HA/Hos/l3dVZOAq+hVRSg1lIqyT39k=; b=aAuD/nxH4JQt9/4elWMR7IC7LwKKgpPb0NfHJ9Si72T2QFgNuRtPjD10QIxFlDPVwi HnM7zbNQfLEK0Z3182sDIjVtNIE4FYo1nZzcSoCvkZd4iorkbVGu6m5fPL76/mCZBONw dCFP3665UbfiCsqHiH+D4BW0WQiEvtwLfHDniSP2Ihdr2MJNHb2nBzv7YzV0V3MZI70V W3gty9yLS4GQyZ+mSp82+yANa2y3M95ZkCUdF9+JHFmQdLKvNUXdHdu6WVxjjebqrrVD j9VAEpULGhEdVESfEOfUppQ+KnbVBVN7oncpB50W3Kw+DpaCvyJFSwUU7nC8fushsFn9 fKlQ== X-Gm-Message-State: AC+VfDzppbO3WvkCftpQlH0sJVJdIopx1HfCnIDXbGRHTja6xNdonz+g 2E5cb3AINcks2p8CxYb8LfC8smFfPH93BFzDbEhC6g== X-Google-Smtp-Source: ACHHUZ4R0l5oQeev080nVyMo8zYCtsvhaj8YmqzMWrLvcTUkhd67bHfK4kXJtVAjK0kbzAnfoTu+Vw== X-Received: by 2002:a7b:cc87:0:b0:3fb:a917:b769 with SMTP id p7-20020a7bcc87000000b003fba917b769mr8537659wma.21.1688378733988; Mon, 03 Jul 2023 03:05:33 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: qemu-arm@nongnu.org, qemu-riscv@nongnu.org, pbonzini@redhat.com, eduardo@habkost.net, alistair.francis@wdc.com, danielhb413@gmail.com, =?UTF-8?q?Daniel=20P=20=2E=20Berrang=C3=A9?= , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Subject: [PATCH v4 11/37] crypto: Add aesdec_ISB_ISR_AK_IMC Date: Mon, 3 Jul 2023 12:04:54 +0200 Message-Id: <20230703100520.68224-12-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230703100520.68224-1-richard.henderson@linaro.org> References: <20230703100520.68224-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::335; envelope-from=richard.henderson@linaro.org; helo=mail-wm1-x335.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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1688379250776100003 Add a primitive for InvSubBytes + InvShiftRows + AddRoundKey + InvMixColumns. Acked-by: Daniel P. Berrang=C3=A9 Reviewed-by: Philippe Mathieu-Daud=C3=A9 Signed-off-by: Richard Henderson --- host/include/generic/host/crypto/aes-round.h | 3 +++ include/crypto/aes-round.h | 21 ++++++++++++++++++++ crypto/aes.c | 14 +++++++++++++ 3 files changed, 38 insertions(+) diff --git a/host/include/generic/host/crypto/aes-round.h b/host/include/ge= neric/host/crypto/aes-round.h index db8cfe17eb..1b9720f917 100644 --- a/host/include/generic/host/crypto/aes-round.h +++ b/host/include/generic/host/crypto/aes-round.h @@ -23,6 +23,9 @@ void aesdec_IMC_accel(AESState *, const AESState *, bool) void aesdec_ISB_ISR_AK_accel(AESState *, const AESState *, const AESState *, bool) QEMU_ERROR("unsupported accel"); +void aesdec_ISB_ISR_AK_IMC_accel(AESState *, const AESState *, + const AESState *, bool) + QEMU_ERROR("unsupported accel"); void aesdec_ISB_ISR_IMC_AK_accel(AESState *, const AESState *, const AESState *, bool) QEMU_ERROR("unsupported accel"); diff --git a/include/crypto/aes-round.h b/include/crypto/aes-round.h index 9996f1c219..854fb0966a 100644 --- a/include/crypto/aes-round.h +++ b/include/crypto/aes-round.h @@ -119,6 +119,27 @@ static inline void aesdec_ISB_ISR_AK(AESState *r, cons= t AESState *st, } } =20 +/* + * Perform InvSubBytes + InvShiftRows + AddRoundKey + InvMixColumns. + */ + +void aesdec_ISB_ISR_AK_IMC_gen(AESState *ret, const AESState *st, + const AESState *rk); +void aesdec_ISB_ISR_AK_IMC_genrev(AESState *ret, const AESState *st, + const AESState *rk); + +static inline void aesdec_ISB_ISR_AK_IMC(AESState *r, const AESState *st, + const AESState *rk, bool be) +{ + if (HAVE_AES_ACCEL) { + aesdec_ISB_ISR_AK_IMC_accel(r, st, rk, be); + } else if (HOST_BIG_ENDIAN =3D=3D be) { + aesdec_ISB_ISR_AK_IMC_gen(r, st, rk); + } else { + aesdec_ISB_ISR_AK_IMC_genrev(r, st, rk); + } +} + /* * Perform InvSubBytes + InvShiftRows + InvMixColumns + AddRoundKey. */ diff --git a/crypto/aes.c b/crypto/aes.c index c2546ef12e..c765f11c1e 100644 --- a/crypto/aes.c +++ b/crypto/aes.c @@ -1542,6 +1542,20 @@ void aesdec_ISB_ISR_IMC_AK_genrev(AESState *r, const= AESState *st, aesdec_ISB_ISR_IMC_AK_swap(r, st, rk, true); } =20 +void aesdec_ISB_ISR_AK_IMC_gen(AESState *ret, const AESState *st, + const AESState *rk) +{ + aesdec_ISB_ISR_AK_gen(ret, st, rk); + aesdec_IMC_gen(ret, ret); +} + +void aesdec_ISB_ISR_AK_IMC_genrev(AESState *ret, const AESState *st, + const AESState *rk) +{ + aesdec_ISB_ISR_AK_genrev(ret, st, rk); + aesdec_IMC_genrev(ret, ret); +} + /** * Expand the cipher key into the encryption key schedule. */ --=20 2.34.1 From nobody Tue May 14 18:40:19 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1688379161; cv=none; d=zohomail.com; s=zohoarc; b=kub7oc3AjEScS10e6wagXRpA4j/eBarPQAdBcsjADIlOp8NQZYMRi7v/X8kCik+C/ieqO9wKh2earZ4rJhvBZR5Ul4LGtytCM0ZkTvFssXUJGZ/R9zfV+jzGYHvGUOE0u2gW6LMcyXDrRJR7rmQnmI8+Mcw/9T3Uhw74lxYc6uk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1688379161; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=jsF8E0JGJalzWmrX5g2tSojnQQtbBHl3guSmbqu5fKQ=; b=SEbP+TZFYsg6hoo8LTiktMNwhFu89K4izgSxxx2QmyS/7iVC2+QTPuoT9qBn6cmYZrReRxaUXQiJZUwXRZPAuit1zu7LW1Q2P0Y3MQ34VgWlLhtDIWeD+A+aN7X/OXSE8CAQCrgO6hWZrWAhxgKuZGIkshIqi8g/jsUAkgY9N4w= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1688379161508916.9893534907618; Mon, 3 Jul 2023 03:12:41 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qGGRK-0002fi-9P; Mon, 03 Jul 2023 06:05:50 -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 1qGGRF-0002ao-DB for qemu-devel@nongnu.org; Mon, 03 Jul 2023 06:05:45 -0400 Received: from mail-wr1-x430.google.com ([2a00:1450:4864:20::430]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qGGR7-0005nj-63 for qemu-devel@nongnu.org; Mon, 03 Jul 2023 06:05:41 -0400 Received: by mail-wr1-x430.google.com with SMTP id ffacd0b85a97d-3143493728dso1309085f8f.1 for ; Mon, 03 Jul 2023 03:05:35 -0700 (PDT) Received: from stoup.home (91.232.79.188.dynamic.jazztel.es. [188.79.232.91]) by smtp.gmail.com with ESMTPSA id t5-20020a05600001c500b00313f7b077fesm18446562wrx.59.2023.07.03.03.05.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 03 Jul 2023 03:05:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1688378735; x=1690970735; 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=jsF8E0JGJalzWmrX5g2tSojnQQtbBHl3guSmbqu5fKQ=; b=I6VYwR7yVUv0BG7BhJKjhxDgoIMJsO4Bnl6tSTBaKz7RxmoAVl/uwMxxXzB1odxUJY h7+fqJxyDeCNQttgtPZBolW4cLvOHZ3CnlBR1o/0vPvhusDLFoiB5e/cLl4WjHZwjQL6 uGtHZzORlcE2K89l5rXdHwrUFKXuzhgOAEwgK8DJv3metXfmtXa/cHhSv9Tl0r4PcP3w eMAoQxNZnGM/OTaTAxL5pKoIODUowWHuIHh9rtcoCrwAFOqYq1Dn/8k9DGWPNUOC/sKI YctkGmRraQmcfjHmhWXYVN/7jtRTUJwmFxdeEI4k50gvy4Szes5XDVZKSDHtsbPxaX69 eeCA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1688378735; x=1690970735; 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=jsF8E0JGJalzWmrX5g2tSojnQQtbBHl3guSmbqu5fKQ=; b=G+SLWQUVhFyGLJ5HEdFKqeU+tQc7Uqww2jZNdX5WitjG8vA95UOnqbsOoo9TWyG4gT 5VPfj/lTEnMfRa0LWRt8YUvmh3w+I6qtvOoWFRCvfWFXVvUmaq2rceUjcTvHUcOWA3i9 57Tt3nzjnpMWiDmG/KHKEsciJiPkrcMOFMr8z06w47kp6LRdY/kMusO76n64jJnf/l8X btFSQNAGS2W8JjCkXf4WaVTVPOjTtKB3mBf5k468bgXdFk86EiMIlz8KtKYRHO96t2TC gte3fpL5fP47Qn6QcBMFDZmsxOooQBwp7SCaJrpK2x1l9JB7Ha2dgaDM79pA/UDajzCv ZzbA== X-Gm-Message-State: ABy/qLbX5lMMZ1iBgerSu3bWj9/Gu5CTeOGWN8kL1vb56JEE3VJF9q9I TVhs25A+lDdN5dXUBmG9kj/ulreF+Fin/9ML0LDpqQ== X-Google-Smtp-Source: APBJJlEn4TgoPGVfvw+aFCOi88XiwoybpF1x+HnenYTINX92khUN6ZipoWoP6FXQw9qiXOHrA7u/+A== X-Received: by 2002:adf:ed8f:0:b0:313:e953:65d0 with SMTP id c15-20020adfed8f000000b00313e95365d0mr7172505wro.28.1688378734939; Mon, 03 Jul 2023 03:05:34 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: qemu-arm@nongnu.org, qemu-riscv@nongnu.org, pbonzini@redhat.com, eduardo@habkost.net, alistair.francis@wdc.com, danielhb413@gmail.com Subject: [PATCH v4 12/37] host/include/i386: Implement aes-round.h Date: Mon, 3 Jul 2023 12:04:55 +0200 Message-Id: <20230703100520.68224-13-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230703100520.68224-1-richard.henderson@linaro.org> References: <20230703100520.68224-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::430; envelope-from=richard.henderson@linaro.org; helo=mail-wr1-x430.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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1688379163029100004 Content-Type: text/plain; charset="utf-8" Detect AES in cpuinfo; implement the accel hooks. Signed-off-by: Richard Henderson --- host/include/i386/host/cpuinfo.h | 1 + host/include/i386/host/crypto/aes-round.h | 152 ++++++++++++++++++++ host/include/x86_64/host/crypto/aes-round.h | 1 + util/cpuinfo-i386.c | 3 + 4 files changed, 157 insertions(+) create mode 100644 host/include/i386/host/crypto/aes-round.h create mode 100644 host/include/x86_64/host/crypto/aes-round.h diff --git a/host/include/i386/host/cpuinfo.h b/host/include/i386/host/cpui= nfo.h index a6537123cf..073d0a426f 100644 --- a/host/include/i386/host/cpuinfo.h +++ b/host/include/i386/host/cpuinfo.h @@ -26,6 +26,7 @@ #define CPUINFO_AVX512VBMI2 (1u << 15) #define CPUINFO_ATOMIC_VMOVDQA (1u << 16) #define CPUINFO_ATOMIC_VMOVDQU (1u << 17) +#define CPUINFO_AES (1u << 18) =20 /* Initialized with a constructor. */ extern unsigned cpuinfo; diff --git a/host/include/i386/host/crypto/aes-round.h b/host/include/i386/= host/crypto/aes-round.h new file mode 100644 index 0000000000..59a64130f7 --- /dev/null +++ b/host/include/i386/host/crypto/aes-round.h @@ -0,0 +1,152 @@ +/* + * x86 specific aes acceleration. + * SPDX-License-Identifier: GPL-2.0-or-later + */ + +#ifndef X86_HOST_CRYPTO_AES_ROUND_H +#define X86_HOST_CRYPTO_AES_ROUND_H + +#include "host/cpuinfo.h" +#include + +#if defined(__AES__) && defined(__SSSE3__) +# define HAVE_AES_ACCEL true +# define ATTR_AES_ACCEL +#else +# define HAVE_AES_ACCEL likely(cpuinfo & CPUINFO_AES) +# define ATTR_AES_ACCEL __attribute__((target("aes,ssse3"))) +#endif + +static inline __m128i ATTR_AES_ACCEL +aes_accel_bswap(__m128i x) +{ + return _mm_shuffle_epi8(x, _mm_set_epi8(0, 1, 2, 3, 4, 5, 6, 7, 8, + 9, 10, 11, 12, 13, 14, 15)); +} + +static inline void ATTR_AES_ACCEL +aesenc_MC_accel(AESState *ret, const AESState *st, bool be) +{ + __m128i t =3D (__m128i)st->v; + __m128i z =3D _mm_setzero_si128(); + + if (be) { + t =3D aes_accel_bswap(t); + t =3D _mm_aesdeclast_si128(t, z); + t =3D _mm_aesenc_si128(t, z); + t =3D aes_accel_bswap(t); + } else { + t =3D _mm_aesdeclast_si128(t, z); + t =3D _mm_aesenc_si128(t, z); + } + ret->v =3D (AESStateVec)t; +} + +static inline void ATTR_AES_ACCEL +aesenc_SB_SR_AK_accel(AESState *ret, const AESState *st, + const AESState *rk, bool be) +{ + __m128i t =3D (__m128i)st->v; + __m128i k =3D (__m128i)rk->v; + + if (be) { + t =3D aes_accel_bswap(t); + k =3D aes_accel_bswap(k); + t =3D _mm_aesenclast_si128(t, k); + t =3D aes_accel_bswap(t); + } else { + t =3D _mm_aesenclast_si128(t, k); + } + ret->v =3D (AESStateVec)t; +} + +static inline void ATTR_AES_ACCEL +aesenc_SB_SR_MC_AK_accel(AESState *ret, const AESState *st, + const AESState *rk, bool be) +{ + __m128i t =3D (__m128i)st->v; + __m128i k =3D (__m128i)rk->v; + + if (be) { + t =3D aes_accel_bswap(t); + k =3D aes_accel_bswap(k); + t =3D _mm_aesenc_si128(t, k); + t =3D aes_accel_bswap(t); + } else { + t =3D _mm_aesenc_si128(t, k); + } + ret->v =3D (AESStateVec)t; +} + +static inline void ATTR_AES_ACCEL +aesdec_IMC_accel(AESState *ret, const AESState *st, bool be) +{ + __m128i t =3D (__m128i)st->v; + + if (be) { + t =3D aes_accel_bswap(t); + t =3D _mm_aesimc_si128(t); + t =3D aes_accel_bswap(t); + } else { + t =3D _mm_aesimc_si128(t); + } + ret->v =3D (AESStateVec)t; +} + +static inline void ATTR_AES_ACCEL +aesdec_ISB_ISR_AK_accel(AESState *ret, const AESState *st, + const AESState *rk, bool be) +{ + __m128i t =3D (__m128i)st->v; + __m128i k =3D (__m128i)rk->v; + + if (be) { + t =3D aes_accel_bswap(t); + k =3D aes_accel_bswap(k); + t =3D _mm_aesdeclast_si128(t, k); + t =3D aes_accel_bswap(t); + } else { + t =3D _mm_aesdeclast_si128(t, k); + } + ret->v =3D (AESStateVec)t; +} + +static inline void ATTR_AES_ACCEL +aesdec_ISB_ISR_AK_IMC_accel(AESState *ret, const AESState *st, + const AESState *rk, bool be) +{ + __m128i t =3D (__m128i)st->v; + __m128i k =3D (__m128i)rk->v; + + if (be) { + t =3D aes_accel_bswap(t); + k =3D aes_accel_bswap(k); + t =3D _mm_aesdeclast_si128(t, k); + t =3D _mm_aesimc_si128(t); + t =3D aes_accel_bswap(t); + } else { + t =3D _mm_aesdeclast_si128(t, k); + t =3D _mm_aesimc_si128(t); + } + ret->v =3D (AESStateVec)t; +} + +static inline void ATTR_AES_ACCEL +aesdec_ISB_ISR_IMC_AK_accel(AESState *ret, const AESState *st, + const AESState *rk, bool be) +{ + __m128i t =3D (__m128i)st->v; + __m128i k =3D (__m128i)rk->v; + + if (be) { + t =3D aes_accel_bswap(t); + k =3D aes_accel_bswap(k); + t =3D _mm_aesdec_si128(t, k); + t =3D aes_accel_bswap(t); + } else { + t =3D _mm_aesdec_si128(t, k); + } + ret->v =3D (AESStateVec)t; +} + +#endif /* X86_HOST_CRYPTO_AES_ROUND_H */ diff --git a/host/include/x86_64/host/crypto/aes-round.h b/host/include/x86= _64/host/crypto/aes-round.h new file mode 100644 index 0000000000..2773cc9f10 --- /dev/null +++ b/host/include/x86_64/host/crypto/aes-round.h @@ -0,0 +1 @@ +#include "host/include/i386/host/crypto/aes-round.h" diff --git a/util/cpuinfo-i386.c b/util/cpuinfo-i386.c index ab6143d9e7..3a7b7e0ad1 100644 --- a/util/cpuinfo-i386.c +++ b/util/cpuinfo-i386.c @@ -40,6 +40,9 @@ unsigned __attribute__((constructor)) cpuinfo_init(void) info |=3D (c & bit_MOVBE ? CPUINFO_MOVBE : 0); info |=3D (c & bit_POPCNT ? CPUINFO_POPCNT : 0); =20 + /* Our AES support requires PSHUFB as well. */ + info |=3D ((c & bit_AES) && (c & bit_SSSE3) ? CPUINFO_AES : 0); + /* For AVX features, we must check available and usable. */ if ((c & bit_AVX) && (c & bit_OSXSAVE)) { unsigned bv =3D xgetbv_low(0); --=20 2.34.1 From nobody Tue May 14 18:40:19 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1688378853; cv=none; d=zohomail.com; s=zohoarc; b=fLMQEtcEzNXPu2R1iG2eVaWteyECSeolwHaFI3pF9Vaoo8Rhb4TUSodLpB6WutO9gjgO6iHJ0rpFJ1s0k1zv1LSa7y3oVhh9MIiG/Fbd7ObiKFHmnnOWT4rFud6TwBpxY8FjqZfyo2uHhsuRhDdcUjlnJoff3mhHR6kSwDon/eM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1688378853; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=9pAoF0UlpvCp+BiEKxTuLbyLAGeWXzeXWAmpv3OKFQo=; b=U6R8p/3jUbnR72JCHIvqN1Vtztc2j3m3htQElxKwnfrt9K6YLjM1O0kcV48b31bqz5OzFvIPGCmRqtso8yVfIQ4dFAMpMwm3svcFS/4d+mMSzy5J/cnxg5MEDjabiNWmqR3kIzTQuJFjIxoND7ttxE5MNpWeJxgBt3kWRjI4e7Q= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1688378853836842.858563094496; Mon, 3 Jul 2023 03:07:33 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qGGRQ-0002p3-0D; Mon, 03 Jul 2023 06:05:56 -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 1qGGRN-0002kh-7F for qemu-devel@nongnu.org; Mon, 03 Jul 2023 06:05:53 -0400 Received: from mail-wr1-x430.google.com ([2a00:1450:4864:20::430]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qGGRG-0005oM-4G for qemu-devel@nongnu.org; Mon, 03 Jul 2023 06:05:52 -0400 Received: by mail-wr1-x430.google.com with SMTP id ffacd0b85a97d-3142970df44so2403536f8f.3 for ; Mon, 03 Jul 2023 03:05:37 -0700 (PDT) Received: from stoup.home (91.232.79.188.dynamic.jazztel.es. [188.79.232.91]) by smtp.gmail.com with ESMTPSA id t5-20020a05600001c500b00313f7b077fesm18446562wrx.59.2023.07.03.03.05.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 03 Jul 2023 03:05:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1688378736; x=1690970736; 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=9pAoF0UlpvCp+BiEKxTuLbyLAGeWXzeXWAmpv3OKFQo=; b=JaUBn2TY4B4q8jBRk8JVYx6T3uoqhRWAr4/RF32Eh3GyknanGI/bcL5z5Ez9V9eJ7c fhlYuPvQON5YZclUrFKSTvEspt/nnELhSUBxSAz7MrcCMx/PzvLKhMypWrLhhGwOOyMN /niGiDOBYf8EW3T0/Q9OFyMyqkYFmGAA4KoWwGCcOg/+NkAVq1Kipzg4jeQYeeo1RMrh 8Pkmxvy90FOC39AJJJgbAR2WAJ7T9+tDRfoJdvXvL5ZZBW7kgGpRNBPvbYX6A3ceChOX OjAEeGm9MfHV8LiBZQB3xFM7sAo3+iCWEyDQ6oxpDbwwrKaooajK8UnM043Z7CmojZJw PYNA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1688378736; x=1690970736; 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=9pAoF0UlpvCp+BiEKxTuLbyLAGeWXzeXWAmpv3OKFQo=; b=iFPL+IidZQp4avH3prHKtfw+f/UDC7HLOq3c15S5/HtsWAbBzXiVkxRFVWCUVUpe34 fV55Z9Xksbh+RijxLdhfMeGDdZx2t9GOBU/GeOXxhh/GuGE75mW/uBWHiStscYVvS6Ar rNbja9MWgJ+nCYtC8vN+uNealmdeAz6UrDTvSoTl/WMXJZgSYCjg4s7Q86OhRBtUHJGu rg8qCtVdP8KXRi8NY3Xc6oYgJeM5SOGG8H2+Uzt9L1xSh/3UvTCdeREynHco/SL25FAF 5qUFQZtrJE8+LFWrNsds986mSpAJFJnwLpRpj4k8ORPgHAlouSV15i+8Be1Fm2gpkk3i h0GA== X-Gm-Message-State: ABy/qLZnSuvgvXkFe7dHVjJW/bcwrKtSJZnSjikoAvglUnmZGphsAYSM are9HB+c1dOQNW3W2ay/rIgqqGRb+PmQ3wp19o0HoA== X-Google-Smtp-Source: APBJJlHt7v39cjJQNS5sKdPBBHPJAO6x9nBOHAYn98EG2Glfr9RM/mcHsQFRAny2x3Zn1RqVud9JZw== X-Received: by 2002:adf:ee51:0:b0:314:2a9:1071 with SMTP id w17-20020adfee51000000b0031402a91071mr8873926wro.19.1688378735957; Mon, 03 Jul 2023 03:05:35 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: qemu-arm@nongnu.org, qemu-riscv@nongnu.org, pbonzini@redhat.com, eduardo@habkost.net, alistair.francis@wdc.com, danielhb413@gmail.com Subject: [PATCH v4 13/37] host/include/aarch64: Implement aes-round.h Date: Mon, 3 Jul 2023 12:04:56 +0200 Message-Id: <20230703100520.68224-14-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230703100520.68224-1-richard.henderson@linaro.org> References: <20230703100520.68224-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::430; envelope-from=richard.henderson@linaro.org; helo=mail-wr1-x430.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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1688378854621100001 Content-Type: text/plain; charset="utf-8" Detect AES in cpuinfo; implement the accel hooks. Signed-off-by: Richard Henderson --- meson.build | 9 + host/include/aarch64/host/cpuinfo.h | 1 + host/include/aarch64/host/crypto/aes-round.h | 205 +++++++++++++++++++ util/cpuinfo-aarch64.c | 2 + 4 files changed, 217 insertions(+) create mode 100644 host/include/aarch64/host/crypto/aes-round.h diff --git a/meson.build b/meson.build index a9ba0bfab3..029c6c0048 100644 --- a/meson.build +++ b/meson.build @@ -2674,6 +2674,15 @@ config_host_data.set('CONFIG_AVX512BW_OPT', get_opti= on('avx512bw') \ int main(int argc, char *argv[]) { return bar(argv[0]); } '''), error_message: 'AVX512BW not available').allowed()) =20 +# For both AArch64 and AArch32, detect if builtins are available. +config_host_data.set('CONFIG_ARM_AES_BUILTIN', cc.compiles(''' + #include + #ifndef __ARM_FEATURE_AES + __attribute__((target("+crypto"))) + #endif + void foo(uint8x16_t *p) { *p =3D vaesmcq_u8(*p); } + ''')) + have_pvrdma =3D get_option('pvrdma') \ .require(rdma.found(), error_message: 'PVRDMA requires OpenFabrics libra= ries') \ .require(cc.compiles(gnu_source_prefix + ''' diff --git a/host/include/aarch64/host/cpuinfo.h b/host/include/aarch64/hos= t/cpuinfo.h index 82227890b4..05feeb4f43 100644 --- a/host/include/aarch64/host/cpuinfo.h +++ b/host/include/aarch64/host/cpuinfo.h @@ -9,6 +9,7 @@ #define CPUINFO_ALWAYS (1u << 0) /* so cpuinfo is nonzero */ #define CPUINFO_LSE (1u << 1) #define CPUINFO_LSE2 (1u << 2) +#define CPUINFO_AES (1u << 3) =20 /* Initialized with a constructor. */ extern unsigned cpuinfo; diff --git a/host/include/aarch64/host/crypto/aes-round.h b/host/include/aa= rch64/host/crypto/aes-round.h new file mode 100644 index 0000000000..8b5f88d50c --- /dev/null +++ b/host/include/aarch64/host/crypto/aes-round.h @@ -0,0 +1,205 @@ +/* + * AArch64 specific aes acceleration. + * SPDX-License-Identifier: GPL-2.0-or-later + */ + +#ifndef AARCH64_HOST_CRYPTO_AES_ROUND_H +#define AARCH64_HOST_CRYPTO_AES_ROUND_H + +#include "host/cpuinfo.h" +#include + +#ifdef __ARM_FEATURE_AES +# define HAVE_AES_ACCEL true +#else +# define HAVE_AES_ACCEL likely(cpuinfo & CPUINFO_AES) +#endif +#if !defined(__ARM_FEATURE_AES) && defined(CONFIG_ARM_AES_BUILTIN) +# define ATTR_AES_ACCEL __attribute__((target("+crypto"))) +#else +# define ATTR_AES_ACCEL +#endif + +static inline uint8x16_t aes_accel_bswap(uint8x16_t x) +{ + return vqtbl1q_u8(x, (uint8x16_t){ 15, 14, 13, 12, 11, 10, 9, 8, + 7, 6, 5, 4, 3, 2, 1, 0, }); +} + +#ifdef CONFIG_ARM_AES_BUILTIN +# define aes_accel_aesd vaesdq_u8 +# define aes_accel_aese vaeseq_u8 +# define aes_accel_aesmc vaesmcq_u8 +# define aes_accel_aesimc vaesimcq_u8 +# define aes_accel_aesd_imc(S, K) vaesimcq_u8(vaesdq_u8(S, K)) +# define aes_accel_aese_mc(S, K) vaesmcq_u8(vaeseq_u8(S, K)) +#else +static inline uint8x16_t aes_accel_aesd(uint8x16_t d, uint8x16_t k) +{ + asm(".arch_extension aes\n\t" + "aesd %0.16b, %1.16b" : "+w"(d) : "w"(k)); + return d; +} + +static inline uint8x16_t aes_accel_aese(uint8x16_t d, uint8x16_t k) +{ + asm(".arch_extension aes\n\t" + "aese %0.16b, %1.16b" : "+w"(d) : "w"(k)); + return d; +} + +static inline uint8x16_t aes_accel_aesmc(uint8x16_t d) +{ + asm(".arch_extension aes\n\t" + "aesmc %0.16b, %1.16b" : "=3Dw"(d) : "w"(d)); + return d; +} + +static inline uint8x16_t aes_accel_aesimc(uint8x16_t d) +{ + asm(".arch_extension aes\n\t" + "aesimc %0.16b, %1.16b" : "=3Dw"(d) : "w"(d)); + return d; +} + +/* Most CPUs fuse AESD+AESIMC in the execution pipeline. */ +static inline uint8x16_t aes_accel_aesd_imc(uint8x16_t d, uint8x16_t k) +{ + asm(".arch_extension aes\n\t" + "aesd %0.16b, %1.16b\n\t" + "aesimc %0.16b, %0.16b" : "+w"(d) : "w"(k)); + return d; +} + +/* Most CPUs fuse AESE+AESMC in the execution pipeline. */ +static inline uint8x16_t aes_accel_aese_mc(uint8x16_t d, uint8x16_t k) +{ + asm(".arch_extension aes\n\t" + "aese %0.16b, %1.16b\n\t" + "aesmc %0.16b, %0.16b" : "+w"(d) : "w"(k)); + return d; +} +#endif /* CONFIG_ARM_AES_BUILTIN */ + +static inline void ATTR_AES_ACCEL +aesenc_MC_accel(AESState *ret, const AESState *st, bool be) +{ + uint8x16_t t =3D (uint8x16_t)st->v; + + if (be) { + t =3D aes_accel_bswap(t); + t =3D aes_accel_aesmc(t); + t =3D aes_accel_bswap(t); + } else { + t =3D aes_accel_aesmc(t); + } + ret->v =3D (AESStateVec)t; +} + +static inline void ATTR_AES_ACCEL +aesenc_SB_SR_AK_accel(AESState *ret, const AESState *st, + const AESState *rk, bool be) +{ + uint8x16_t t =3D (uint8x16_t)st->v; + uint8x16_t z =3D { }; + + if (be) { + t =3D aes_accel_bswap(t); + t =3D aes_accel_aese(t, z); + t =3D aes_accel_bswap(t); + } else { + t =3D aes_accel_aese(t, z); + } + ret->v =3D (AESStateVec)t ^ rk->v; +} + +static inline void ATTR_AES_ACCEL +aesenc_SB_SR_MC_AK_accel(AESState *ret, const AESState *st, + const AESState *rk, bool be) +{ + uint8x16_t t =3D (uint8x16_t)st->v; + uint8x16_t z =3D { }; + + if (be) { + t =3D aes_accel_bswap(t); + t =3D aes_accel_aese_mc(t, z); + t =3D aes_accel_bswap(t); + } else { + t =3D aes_accel_aese_mc(t, z); + } + ret->v =3D (AESStateVec)t ^ rk->v; +} + +static inline void ATTR_AES_ACCEL +aesdec_IMC_accel(AESState *ret, const AESState *st, bool be) +{ + uint8x16_t t =3D (uint8x16_t)st->v; + + if (be) { + t =3D aes_accel_bswap(t); + t =3D aes_accel_aesimc(t); + t =3D aes_accel_bswap(t); + } else { + t =3D aes_accel_aesimc(t); + } + ret->v =3D (AESStateVec)t; +} + +static inline void ATTR_AES_ACCEL +aesdec_ISB_ISR_AK_accel(AESState *ret, const AESState *st, + const AESState *rk, bool be) +{ + uint8x16_t t =3D (uint8x16_t)st->v; + uint8x16_t z =3D { }; + + if (be) { + t =3D aes_accel_bswap(t); + t =3D aes_accel_aesd(t, z); + t =3D aes_accel_bswap(t); + } else { + t =3D aes_accel_aesd(t, z); + } + ret->v =3D (AESStateVec)t ^ rk->v; +} + +static inline void ATTR_AES_ACCEL +aesdec_ISB_ISR_AK_IMC_accel(AESState *ret, const AESState *st, + const AESState *rk, bool be) +{ + uint8x16_t t =3D (uint8x16_t)st->v; + uint8x16_t k =3D (uint8x16_t)rk->v; + uint8x16_t z =3D { }; + + if (be) { + t =3D aes_accel_bswap(t); + k =3D aes_accel_bswap(k); + t =3D aes_accel_aesd(t, z); + t ^=3D k; + t =3D aes_accel_aesimc(t); + t =3D aes_accel_bswap(t); + } else { + t =3D aes_accel_aesd(t, z); + t ^=3D k; + t =3D aes_accel_aesimc(t); + } + ret->v =3D (AESStateVec)t; +} + +static inline void ATTR_AES_ACCEL +aesdec_ISB_ISR_IMC_AK_accel(AESState *ret, const AESState *st, + const AESState *rk, bool be) +{ + uint8x16_t t =3D (uint8x16_t)st->v; + uint8x16_t z =3D { }; + + if (be) { + t =3D aes_accel_bswap(t); + t =3D aes_accel_aesd_imc(t, z); + t =3D aes_accel_bswap(t); + } else { + t =3D aes_accel_aesd_imc(t, z); + } + ret->v =3D (AESStateVec)t ^ rk->v; +} + +#endif /* AARCH64_HOST_CRYPTO_AES_ROUND_H */ diff --git a/util/cpuinfo-aarch64.c b/util/cpuinfo-aarch64.c index f99acb7884..ababc39550 100644 --- a/util/cpuinfo-aarch64.c +++ b/util/cpuinfo-aarch64.c @@ -56,10 +56,12 @@ unsigned __attribute__((constructor)) cpuinfo_init(void) unsigned long hwcap =3D qemu_getauxval(AT_HWCAP); info |=3D (hwcap & HWCAP_ATOMICS ? CPUINFO_LSE : 0); info |=3D (hwcap & HWCAP_USCAT ? CPUINFO_LSE2 : 0); + info |=3D (hwcap & HWCAP_AES ? CPUINFO_AES: 0); #endif #ifdef CONFIG_DARWIN info |=3D sysctl_for_bool("hw.optional.arm.FEAT_LSE") * CPUINFO_LSE; info |=3D sysctl_for_bool("hw.optional.arm.FEAT_LSE2") * CPUINFO_LSE2; + info |=3D sysctl_for_bool("hw.optional.arm.FEAT_AES") * CPUINFO_AES; #endif =20 cpuinfo =3D info; --=20 2.34.1 From nobody Tue May 14 18:40:19 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1688379214; cv=none; d=zohomail.com; s=zohoarc; b=IVBgYyfbPMT80nbJyoloZ8qfd+E7GBbT956Xh/ELMnqCJV+vy5eaEIdXAmEgil2dQ2g7Do4kwkWBiYG1s07H7Ejo8tE0wYMv8kAw++y3M+xKxSG7Tj267b/wyTxEX5rn4HST/URAJyT6kdrfXmezJmpI5j7MideU5fp4pL1zUuo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1688379214; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=tquFfTdtw0sVSZbN7ZybV+/6BBhwf96oST0EwHIj8d8=; b=DDiRkyOA65g3dhFzfpnyiGI8uUWtaM7Ak/WfS0F7sHtGFgr6lwY5EiJoEeFYy20tB+Rf1L5FLtqR/HY/+N8mSYSvNGZFxToD0N7+/mjnVBLYgtubXwz0D+X3TwisxpV8vf4KgpUCOQdSkugIrS7Lfqy0TVhxvSyUkmL6lxO2aGw= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1688379214609811.7001660780312; Mon, 3 Jul 2023 03:13:34 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qGGRZ-0002wh-6k; Mon, 03 Jul 2023 06:06:05 -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 1qGGRK-0002gB-Tv for qemu-devel@nongnu.org; Mon, 03 Jul 2023 06:05:50 -0400 Received: from mail-wm1-x331.google.com ([2a00:1450:4864:20::331]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qGGRF-0005pA-LO for qemu-devel@nongnu.org; Mon, 03 Jul 2023 06:05:50 -0400 Received: by mail-wm1-x331.google.com with SMTP id 5b1f17b1804b1-3fbc54cab6fso33964315e9.0 for ; Mon, 03 Jul 2023 03:05:38 -0700 (PDT) Received: from stoup.home (91.232.79.188.dynamic.jazztel.es. [188.79.232.91]) by smtp.gmail.com with ESMTPSA id t5-20020a05600001c500b00313f7b077fesm18446562wrx.59.2023.07.03.03.05.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 03 Jul 2023 03:05:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1688378737; x=1690970737; 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=tquFfTdtw0sVSZbN7ZybV+/6BBhwf96oST0EwHIj8d8=; b=owwWZUomaZMItKwgFZNjSF8ClG3c5cEoOgYqiw3UKkmLvZ0ryXEzifBtmKdvbqFIYN +ltnJCaRdCER62HwW3UKbvVBokjCJeUwZZNpdr6jdKhVfzzP/XmOPwFhUZSR+zqNFPvS GiAr0YSl7PNJ3sEMrG7dUQLhSVKaNn8qe6udXaUgiJgc+79/XCGnBXKUJQHN3tI6I6qm TtFvcIj7CelJiHLjD1E4Yac+Sm7DNrJTJk55b08y8K8bysDoYqXKOoUqYhLsTFrizct/ wuMCdCpPvRSPGTLGzw4ea3IBLJjFqbItz8v2R0drDAe9+xGSGbyDo4U7E9zcxAm14/SR H5qw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1688378737; x=1690970737; 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=tquFfTdtw0sVSZbN7ZybV+/6BBhwf96oST0EwHIj8d8=; b=RSV4CKaMckjXrDbrfq8lJOX8L+vCCMkJqfduzXMYAo7EL2XI5Qp+F0BqMSWDDxg5nx OYXpH2AzM94R80W1vppgPuK9ahRe8NB8pMDAiG164TQQvEOFPe0JMIygR7hz3zsXZSs/ w21p7h9V1a1Wz08fEfwkwtGE3FWldB747FRAekIKtz2FUQr+1v2XTX2/d/hGZ6bMPIyN s01deb9acydwa1GNOHgddR0lsJ6Axjp13TNFUWOmB47YgQYB33UYSNPtaxONDbPlQZHr P4IGfEKXDgTbEaAPnPLBRskb0tRBa79qCoBkOW3wSSFM4iTkjVfjfKn9RWi7AeDE0G8f ObmA== X-Gm-Message-State: AC+VfDzYQdQB2gpCQLd8rr10xmYUrL2y8rB6Y85Ncd49d4afwLvQK7DZ I7VvUGc3VfqrFGgpfji9sfEUFbdbg99qPSWQDjHONw== X-Google-Smtp-Source: ACHHUZ7UY11/Bb4h/Tkd+bnFWKQisjj9u3UD73KiCn5+LacTkFFI+2ozaA/Et13bRNLbxdcx7F0Qhg== X-Received: by 2002:a05:600c:2219:b0:3fb:c217:7243 with SMTP id z25-20020a05600c221900b003fbc2177243mr7728393wml.18.1688378736847; Mon, 03 Jul 2023 03:05:36 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: qemu-arm@nongnu.org, qemu-riscv@nongnu.org, pbonzini@redhat.com, eduardo@habkost.net, alistair.francis@wdc.com, danielhb413@gmail.com Subject: [PATCH v4 14/37] host/include/ppc: Implement aes-round.h Date: Mon, 3 Jul 2023 12:04:57 +0200 Message-Id: <20230703100520.68224-15-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230703100520.68224-1-richard.henderson@linaro.org> References: <20230703100520.68224-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::331; envelope-from=richard.henderson@linaro.org; helo=mail-wm1-x331.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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1688379215371100005 Content-Type: text/plain; charset="utf-8" Detect CRYPTO in cpuinfo; implement the accel hooks. Reviewed-by: Daniel Henrique Barboza Signed-off-by: Richard Henderson --- host/include/ppc/host/cpuinfo.h | 1 + host/include/ppc/host/crypto/aes-round.h | 182 +++++++++++++++++++++ host/include/ppc64/host/crypto/aes-round.h | 1 + util/cpuinfo-ppc.c | 8 + 4 files changed, 192 insertions(+) create mode 100644 host/include/ppc/host/crypto/aes-round.h create mode 100644 host/include/ppc64/host/crypto/aes-round.h diff --git a/host/include/ppc/host/cpuinfo.h b/host/include/ppc/host/cpuinf= o.h index df11e8d417..29ee7f9ef8 100644 --- a/host/include/ppc/host/cpuinfo.h +++ b/host/include/ppc/host/cpuinfo.h @@ -16,6 +16,7 @@ #define CPUINFO_ISEL (1u << 5) #define CPUINFO_ALTIVEC (1u << 6) #define CPUINFO_VSX (1u << 7) +#define CPUINFO_CRYPTO (1u << 8) =20 /* Initialized with a constructor. */ extern unsigned cpuinfo; diff --git a/host/include/ppc/host/crypto/aes-round.h b/host/include/ppc/ho= st/crypto/aes-round.h new file mode 100644 index 0000000000..8062d2a537 --- /dev/null +++ b/host/include/ppc/host/crypto/aes-round.h @@ -0,0 +1,182 @@ +/* + * Power v2.07 specific aes acceleration. + * SPDX-License-Identifier: GPL-2.0-or-later + */ + +#ifndef PPC_HOST_CRYPTO_AES_ROUND_H +#define PPC_HOST_CRYPTO_AES_ROUND_H + +#ifdef __ALTIVEC__ +#include "host/cpuinfo.h" + +#ifdef __CRYPTO__ +# define HAVE_AES_ACCEL true +#else +# define HAVE_AES_ACCEL likely(cpuinfo & CPUINFO_CRYPTO) +#endif +#define ATTR_AES_ACCEL + +/* + * While there is , both gcc and clang "aid" with the + * endianness issues in different ways. Just use inline asm instead. + */ + +/* Bytes in memory are host-endian; bytes in register are @be. */ +static inline AESStateVec aes_accel_ld(const AESState *p, bool be) +{ + AESStateVec r; + + if (be) { + asm("lvx %0, 0, %1" : "=3Dv"(r) : "r"(p), "m"(*p)); + } else if (HOST_BIG_ENDIAN) { + AESStateVec rev =3D { + 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, + }; + asm("lvx %0, 0, %1\n\t" + "vperm %0, %0, %0, %2" + : "=3Dv"(r) : "r"(p), "v"(rev), "m"(*p)); + } else { +#ifdef __POWER9_VECTOR__ + asm("lxvb16x %x0, 0, %1" : "=3Dv"(r) : "r"(p), "m"(*p)); +#else + asm("lxvd2x %x0, 0, %1\n\t" + "xxpermdi %x0, %x0, %x0, 2" + : "=3Dv"(r) : "r"(p), "m"(*p)); +#endif + } + return r; +} + +static void aes_accel_st(AESState *p, AESStateVec r, bool be) +{ + if (be) { + asm("stvx %1, 0, %2" : "=3Dm"(*p) : "v"(r), "r"(p)); + } else if (HOST_BIG_ENDIAN) { + AESStateVec rev =3D { + 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, + }; + asm("vperm %1, %1, %1, %2\n\t" + "stvx %1, 0, %3" + : "=3Dm"(*p), "+v"(r) : "v"(rev), "r"(p)); + } else { +#ifdef __POWER9_VECTOR__ + asm("stxvb16x %x1, 0, %2" : "=3Dm"(*p) : "v"(r), "r"(p)); +#else + asm("xxpermdi %x1, %x1, %x1, 2\n\t" + "stxvd2x %x1, 0, %2" + : "=3Dm"(*p), "+v"(r) : "r"(p)); +#endif + } +} + +static inline AESStateVec aes_accel_vcipher(AESStateVec d, AESStateVec k) +{ + asm("vcipher %0, %0, %1" : "+v"(d) : "v"(k)); + return d; +} + +static inline AESStateVec aes_accel_vncipher(AESStateVec d, AESStateVec k) +{ + asm("vncipher %0, %0, %1" : "+v"(d) : "v"(k)); + return d; +} + +static inline AESStateVec aes_accel_vcipherlast(AESStateVec d, AESStateVec= k) +{ + asm("vcipherlast %0, %0, %1" : "+v"(d) : "v"(k)); + return d; +} + +static inline AESStateVec aes_accel_vncipherlast(AESStateVec d, AESStateVe= c k) +{ + asm("vncipherlast %0, %0, %1" : "+v"(d) : "v"(k)); + return d; +} + +static inline void +aesenc_MC_accel(AESState *ret, const AESState *st, bool be) +{ + AESStateVec t, z =3D { }; + + t =3D aes_accel_ld(st, be); + t =3D aes_accel_vncipherlast(t, z); + t =3D aes_accel_vcipher(t, z); + aes_accel_st(ret, t, be); +} + +static inline void +aesenc_SB_SR_AK_accel(AESState *ret, const AESState *st, + const AESState *rk, bool be) +{ + AESStateVec t, k; + + t =3D aes_accel_ld(st, be); + k =3D aes_accel_ld(rk, be); + t =3D aes_accel_vcipherlast(t, k); + aes_accel_st(ret, t, be); +} + +static inline void +aesenc_SB_SR_MC_AK_accel(AESState *ret, const AESState *st, + const AESState *rk, bool be) +{ + AESStateVec t, k; + + t =3D aes_accel_ld(st, be); + k =3D aes_accel_ld(rk, be); + t =3D aes_accel_vcipher(t, k); + aes_accel_st(ret, t, be); +} + +static inline void +aesdec_IMC_accel(AESState *ret, const AESState *st, bool be) +{ + AESStateVec t, z =3D { }; + + t =3D aes_accel_ld(st, be); + t =3D aes_accel_vcipherlast(t, z); + t =3D aes_accel_vncipher(t, z); + aes_accel_st(ret, t, be); +} + +static inline void +aesdec_ISB_ISR_AK_accel(AESState *ret, const AESState *st, + const AESState *rk, bool be) +{ + AESStateVec t, k; + + t =3D aes_accel_ld(st, be); + k =3D aes_accel_ld(rk, be); + t =3D aes_accel_vncipherlast(t, k); + aes_accel_st(ret, t, be); +} + +static inline void +aesdec_ISB_ISR_AK_IMC_accel(AESState *ret, const AESState *st, + const AESState *rk, bool be) +{ + AESStateVec t, k; + + t =3D aes_accel_ld(st, be); + k =3D aes_accel_ld(rk, be); + t =3D aes_accel_vncipher(t, k); + aes_accel_st(ret, t, be); +} + +static inline void +aesdec_ISB_ISR_IMC_AK_accel(AESState *ret, const AESState *st, + const AESState *rk, bool be) +{ + AESStateVec t, k, z =3D { }; + + t =3D aes_accel_ld(st, be); + k =3D aes_accel_ld(rk, be); + t =3D aes_accel_vncipher(t, z); + aes_accel_st(ret, t ^ k, be); +} +#else +/* Without ALTIVEC, we can't even write inline assembly. */ +#include "host/include/generic/host/crypto/aes-round.h" +#endif + +#endif /* PPC_HOST_CRYPTO_AES_ROUND_H */ diff --git a/host/include/ppc64/host/crypto/aes-round.h b/host/include/ppc6= 4/host/crypto/aes-round.h new file mode 100644 index 0000000000..5eeba6dcb7 --- /dev/null +++ b/host/include/ppc64/host/crypto/aes-round.h @@ -0,0 +1 @@ +#include "host/include/ppc/host/crypto/aes-round.h" diff --git a/util/cpuinfo-ppc.c b/util/cpuinfo-ppc.c index d95adc8ccd..7212afa45d 100644 --- a/util/cpuinfo-ppc.c +++ b/util/cpuinfo-ppc.c @@ -48,6 +48,14 @@ unsigned __attribute__((constructor)) cpuinfo_init(void) /* We only care about the portion of VSX that overlaps Altivec. */ if (hwcap & PPC_FEATURE_HAS_VSX) { info |=3D CPUINFO_VSX; + /* + * We use VSX especially for little-endian, but we should + * always have both anyway, since VSX came with Power7 + * and crypto came with Power8. + */ + if (hwcap2 & PPC_FEATURE2_HAS_VEC_CRYPTO) { + info |=3D CPUINFO_CRYPTO; + } } } =20 --=20 2.34.1 From nobody Tue May 14 18:40:19 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1688378812; cv=none; d=zohomail.com; s=zohoarc; b=IlLoSZwmglxWyBpBazhZErw400oZGYjw9AN2S0GZwobHwhhXQQFK2zotz+JySAvVjebuyLyIOnbdNz6ugQLyrl5Upe0BV8Segj3IAvhmkCc9YaCjFsDuVyEn46amrZj2MZn4WizyjZZ3eGybobQd1qYHnJ8HnTcPKdV/b0Ux27I= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1688378812; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=CXOtR+skbBy3g0n+KA4k0jDRJwr6870/fEeTqXEf6Vk=; b=LjghyseTrBOAEPw6f7AxUYICOiSDq8xUGJOeeMx5VVkaHuFiwwKruBIvySfQZeotxIggh0Fj2DnVR+KQQjsKbF16Du8T2+J/h6AOa/dR+iiXQvxmFwMbd6hiXH9B+0Fvk6xyuvFFgmUAhAFr/qdKpOvXFz/I4lZE3BTQqGJBljI= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1688378812446171.23500732590992; Mon, 3 Jul 2023 03:06:52 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qGGRV-0002pt-Qu; Mon, 03 Jul 2023 06:06:01 -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 1qGGRL-0002gb-7k for qemu-devel@nongnu.org; Mon, 03 Jul 2023 06:05:51 -0400 Received: from mail-lf1-x134.google.com ([2a00:1450:4864:20::134]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qGGRF-0005pg-MB for qemu-devel@nongnu.org; Mon, 03 Jul 2023 06:05:50 -0400 Received: by mail-lf1-x134.google.com with SMTP id 2adb3069b0e04-4fba1288bbdso5163452e87.1 for ; Mon, 03 Jul 2023 03:05:39 -0700 (PDT) Received: from stoup.home (91.232.79.188.dynamic.jazztel.es. [188.79.232.91]) by smtp.gmail.com with ESMTPSA id t5-20020a05600001c500b00313f7b077fesm18446562wrx.59.2023.07.03.03.05.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 03 Jul 2023 03:05:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1688378738; x=1690970738; 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=CXOtR+skbBy3g0n+KA4k0jDRJwr6870/fEeTqXEf6Vk=; b=xrl3cKBGhkcU8TYDD3DWfaDWe7wEh8ettvQtJ5XM31Ict/oAX6jqvRW1g8ra+r9OEM VI+LpZ50jjMTXUGKh8xgvxt2kZEd+VoXFmBgBGLVe8gzFv7ZJGEQdQ2jMSYCdOn4//FF 5JU1NqG32fR11IpbUlHZswa/SFOCYCDXdzqhzy7Pq1XztfEIT1AphtsT4+h0+zitj6eU Y80S2QKh9Xrr6HQh6gvj0+Q0HXCTtHXFQqxg3aCYm8y84ab9pUpdDl11kvP6aCSD+RnK ZFK7hjZPWL0uUDOxOISbI9XTw+5dBbmEBT1uFEBu1um3/cuZbctLZrKRBKP4LGla4zpj dJxA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1688378738; x=1690970738; 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=CXOtR+skbBy3g0n+KA4k0jDRJwr6870/fEeTqXEf6Vk=; b=QtiD5gviiNhJQA/Bzb9f78/GDc/vU0WuqT1mkxPoVTFtM4Q1DJhfVCkwn2zwgQr7WK XUCcAlTGnEz+uqZ3TcRH1Qk4EHy4vNmzYkdCVFnhBEjKioF+leVrJQ47OZW2JW6qbH43 5Ic1UvxuCI0Wwmd9/fORtxrE9weVbEp+9CI8MOwu0f8HWNk4A6T+Y47EV1FQ166gnf55 v56BbXhPUnxiXZ7Fub0vji3T3oK4HNdcqosFx6Ec7VDBaSioOBZfwUQ7tQr8/XcNEV97 DBi0XsK36J4OrYBOFF6E+pUSfeOUXWUR2NPPuV33urjPQ+fGFv9Bdbrg47Ti+n4xdsvG rUjw== X-Gm-Message-State: ABy/qLbKCVrW7XLFGARaXmYmrBsgCz7M6f5rEGCe9kaNGXl3tMR5PK73 IL1Lz8R/yqnPEWZZUDITvm+ceZa93kRQB/JNXro2gg== X-Google-Smtp-Source: APBJJlHTWYFg56o5atNgPfJfgSF9w6MaczUFVkzyZXfs0HQ9FuXC2me4SBULnUbo9EAxRREajwmJnQ== X-Received: by 2002:a05:6512:1116:b0:4fb:9d61:db44 with SMTP id l22-20020a056512111600b004fb9d61db44mr8572347lfg.12.1688378737834; Mon, 03 Jul 2023 03:05:37 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: qemu-arm@nongnu.org, qemu-riscv@nongnu.org, pbonzini@redhat.com, eduardo@habkost.net, alistair.francis@wdc.com, danielhb413@gmail.com, =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Subject: [PATCH v4 15/37] target/ppc: Use aesenc_SB_SR_AK Date: Mon, 3 Jul 2023 12:04:58 +0200 Message-Id: <20230703100520.68224-16-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230703100520.68224-1-richard.henderson@linaro.org> References: <20230703100520.68224-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::134; envelope-from=richard.henderson@linaro.org; helo=mail-lf1-x134.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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1688378813029100001 This implements the VCIPHERLAST instruction. Reviewed-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Daniel Henrique Barboza Signed-off-by: Richard Henderson --- target/ppc/int_helper.c | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/target/ppc/int_helper.c b/target/ppc/int_helper.c index d97a7f1f28..34257e9d76 100644 --- a/target/ppc/int_helper.c +++ b/target/ppc/int_helper.c @@ -25,6 +25,7 @@ #include "qemu/log.h" #include "exec/helper-proto.h" #include "crypto/aes.h" +#include "crypto/aes-round.h" #include "fpu/softfloat.h" #include "qapi/error.h" #include "qemu/guest-random.h" @@ -2947,13 +2948,7 @@ void helper_vcipher(ppc_avr_t *r, ppc_avr_t *a, ppc_= avr_t *b) =20 void helper_vcipherlast(ppc_avr_t *r, ppc_avr_t *a, ppc_avr_t *b) { - ppc_avr_t result; - int i; - - VECTOR_FOR_INORDER_I(i, u8) { - result.VsrB(i) =3D b->VsrB(i) ^ (AES_sbox[a->VsrB(AES_shifts[i])]); - } - *r =3D result; + aesenc_SB_SR_AK((AESState *)r, (AESState *)a, (AESState *)b, true); } =20 void helper_vncipher(ppc_avr_t *r, ppc_avr_t *a, ppc_avr_t *b) --=20 2.34.1 From nobody Tue May 14 18:40:19 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1688378972; cv=none; d=zohomail.com; s=zohoarc; b=HySoxgysfY5knEQHZYckep6m9IOFGEl3NypuBbJD7YGMToCJGb80Dg/6RxMXLVTIeNR2cRGQIU4OSGY0mFk4cbMhaaCwjZWOAGIE1HyDCAegGVj4JYkBzQ71UaUPWcrZcyZz5/17EvqMOOj2Z6GcR93sRcVY3Afl8+x0zhkXsTw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1688378972; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=9eRhNGGsvyXPq3UhYSn/b3L2GTywYRMcqzsZGePD5qs=; b=ROrPlapHgFckBsBp2Potq8tFaxY9uwtYlwhYhZq9mOI1jJ05ckU5pSkmUMI7noMWanLlE0IQgA0ngiFiNPVktGUjLnQwWAl5LlZfbWPFg+UkYf8NHyvY+Ai6tFqmsgDkGDcKGVvQfrm+Znoqdnhrmp9H4fCXMugrV1ThcPvrVB0= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1688378972646752.018313885968; Mon, 3 Jul 2023 03:09:32 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qGGRe-000352-Lv; Mon, 03 Jul 2023 06:06:10 -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 1qGGRS-0002qd-Se for qemu-devel@nongnu.org; Mon, 03 Jul 2023 06:06:01 -0400 Received: from mail-wr1-x42f.google.com ([2a00:1450:4864:20::42f]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qGGRG-0005qa-HK for qemu-devel@nongnu.org; Mon, 03 Jul 2023 06:05:58 -0400 Received: by mail-wr1-x42f.google.com with SMTP id ffacd0b85a97d-3141c8a6f30so4372589f8f.1 for ; Mon, 03 Jul 2023 03:05:40 -0700 (PDT) Received: from stoup.home (91.232.79.188.dynamic.jazztel.es. [188.79.232.91]) by smtp.gmail.com with ESMTPSA id t5-20020a05600001c500b00313f7b077fesm18446562wrx.59.2023.07.03.03.05.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 03 Jul 2023 03:05:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1688378739; x=1690970739; 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=9eRhNGGsvyXPq3UhYSn/b3L2GTywYRMcqzsZGePD5qs=; b=VljriHMdSXC8EaXjnTswdR4Z6m54Sss3Ohv9fTzUVY+VL4HkQGU8itXQw+EuDSPerY Tg7RC9e/VmNuAmj1EH7NSNRCRecWfDXK0+JYm5vKANgcmcKXhOy9Xt4zsocJUmOioXhP cDk07FrApzFtGXDbAiFlXxvwY48iy83bq3CTDYD9LfWwHGMBR86JNQ7tQFTfFcxi28c8 AtOE+5D7tlcEY8j8XeT2nSrLO3fHUvFhBd1fPdORTB1tMfbp4XWh0bGA0cep8kH4qLoz jp+aCAHJd+Jz7cVx2Q95fW7f88sFG3vHQU8nV8gpAqRfqrYt4/C6XojgRCYFFtyVaLvr Y3Sw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1688378739; x=1690970739; 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=9eRhNGGsvyXPq3UhYSn/b3L2GTywYRMcqzsZGePD5qs=; b=iIU13xe22LNDn9e7fzRsDABvIG+bj69qTPmH+pY/puEMyLHpM7iP/9EVPDwTTgbU4i ThK1fr+/Xl8Pi7nLQIZqNBAWQwovqqyl46kG2Lg/jSu0XviQQmJkkXSwmOyN1JzDrqIu 1yKS53sjeDRFkt88BzBQyDWDev0/qBKE6QLZN4Rfn1eVxsmiBdoMbgMnWuRU2wZtbJ3j mh8q4lVYLZRTb9p6zV44g0dTCFiyjOW8ab3ax+WmyNjyXJ1L3Ir/wtqvNtzlwk+33o/l UxqqvUX4Bgr2TIwcL8wjEySCBOrlCqAJUuphSy2m97q6aVZMpUNm0BTmwC42m1NuQ7Lp PvbA== X-Gm-Message-State: ABy/qLZ5oqlRMSzAaU/GR2Zz0YYubx7yCHWfjlLogwDvqoWSgZNilHO4 w4hkorX1z9gQ5BBqfUmPJxhUa6X6pwSQj9tUx722Ew== X-Google-Smtp-Source: APBJJlFmmb5FjCgB3YLfeR6I5zEyICzQI0yAhyNz5zsT+34S23jihyhy+tlpORlon3OVeMMOUZETZA== X-Received: by 2002:adf:f504:0:b0:313:ebbf:3696 with SMTP id q4-20020adff504000000b00313ebbf3696mr7337308wro.46.1688378738829; Mon, 03 Jul 2023 03:05:38 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: qemu-arm@nongnu.org, qemu-riscv@nongnu.org, pbonzini@redhat.com, eduardo@habkost.net, alistair.francis@wdc.com, danielhb413@gmail.com, =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Subject: [PATCH v4 16/37] target/ppc: Use aesdec_ISB_ISR_AK Date: Mon, 3 Jul 2023 12:04:59 +0200 Message-Id: <20230703100520.68224-17-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230703100520.68224-1-richard.henderson@linaro.org> References: <20230703100520.68224-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::42f; envelope-from=richard.henderson@linaro.org; helo=mail-wr1-x42f.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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1688378974028100007 This implements the VNCIPHERLAST instruction. Reviewed-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Daniel Henrique Barboza Signed-off-by: Richard Henderson --- target/ppc/int_helper.c | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/target/ppc/int_helper.c b/target/ppc/int_helper.c index 34257e9d76..15f07fca2b 100644 --- a/target/ppc/int_helper.c +++ b/target/ppc/int_helper.c @@ -2973,13 +2973,7 @@ void helper_vncipher(ppc_avr_t *r, ppc_avr_t *a, ppc= _avr_t *b) =20 void helper_vncipherlast(ppc_avr_t *r, ppc_avr_t *a, ppc_avr_t *b) { - ppc_avr_t result; - int i; - - VECTOR_FOR_INORDER_I(i, u8) { - result.VsrB(i) =3D b->VsrB(i) ^ (AES_isbox[a->VsrB(AES_ishifts[i])= ]); - } - *r =3D result; + aesdec_ISB_ISR_AK((AESState *)r, (AESState *)a, (AESState *)b, true); } =20 void helper_vshasigmaw(ppc_avr_t *r, ppc_avr_t *a, uint32_t st_six) --=20 2.34.1 From nobody Tue May 14 18:40:19 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1688379137; cv=none; d=zohomail.com; s=zohoarc; b=Qx9oK7//2w6m4TzKQ0E5bS7k/fonNMHdr369Z3BfyHqexP+yPrz6VVNZd4QqGtQBLbTXtx/EvvR2L8HJKzvXjSj5OLhOW4Sh5DQoGze9kkxq09ZuM+YZWjRx1ozWIlZaSjWYiw1CLxVuTeSWw4Um8h1MYAoBDWlqhe7LPJES51U= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1688379137; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=5yB3KjFB+U9E0IGbPxBILX7NHTWOiWyWbVzWyod1A2Y=; b=KqO92UeV942P8xErXSZOTlHeYyTChFYGDj8YC/ChpBzC4AwJXPfN6YX9dkMB/DGI6Hu6FV9xkxuH2DL62WCD14EaigKLzj6+RkW1F54qO5P2ygZPhNdekjhwo0diyHV73GaQplij6qcavil5mHXpwR5VQMoqC+Z4ZRH0hrr2sGE= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1688379137863822.8597375834418; Mon, 3 Jul 2023 03:12:17 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qGGRM-0002jN-Sx; Mon, 03 Jul 2023 06:05:52 -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 1qGGRI-0002eO-Ni for qemu-devel@nongnu.org; Mon, 03 Jul 2023 06:05:48 -0400 Received: from mail-wr1-x429.google.com ([2a00:1450:4864:20::429]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qGGRF-0005rR-0H for qemu-devel@nongnu.org; Mon, 03 Jul 2023 06:05:48 -0400 Received: by mail-wr1-x429.google.com with SMTP id ffacd0b85a97d-3143b70d6easo206569f8f.2 for ; Mon, 03 Jul 2023 03:05:41 -0700 (PDT) Received: from stoup.home (91.232.79.188.dynamic.jazztel.es. [188.79.232.91]) by smtp.gmail.com with ESMTPSA id t5-20020a05600001c500b00313f7b077fesm18446562wrx.59.2023.07.03.03.05.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 03 Jul 2023 03:05:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1688378741; x=1690970741; 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=5yB3KjFB+U9E0IGbPxBILX7NHTWOiWyWbVzWyod1A2Y=; b=joR4m/ClJeRpoob+t5+QnStkdNFoxeTqfQX2yViVC46KO8kYWovTf89P8V7IYr+Oos EvFwMsu2XhPCpfSYyOyj197LvUN+uyCBja2AyU9fy3uoIrlrnS4KRBC0izuUzOzHYgbm smVoL85LinnLzkiXD+MISmbYxQWwCe6bjaY81jTj2uBWzQXqHnorTvcc7i4CS7qx5iQx OoQ2GqgjtBUrJwRByW8dE1iDFMOBnuZcNz4kaO2RiClgTvzKykzFAEnfgWrJbFR2mg5t 12oVanW9YC6tUBLRtS4MOWkZOPJTlweeCB+/D7QSfC/GHQi/rciO8hVKTc0Nx5POIjV4 JuDQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1688378741; x=1690970741; 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=5yB3KjFB+U9E0IGbPxBILX7NHTWOiWyWbVzWyod1A2Y=; b=i1rjH2EwaqaPcx7e14+6dD9Pe4whslcEBvUxHMVb8/JVnP2v2AAoKNGuzHV4/FYu1p 8t63HE/GdHslYdDMjFdu/AgEA7orlLHKlLIKO84lrd3PuCt5BIpTgE7myz3oz6PfQrbm 88c5u12xuDYt3Vphzo2JWg7UsmlDzIbtakWrASL4ejr6EKgdlrjtm9KrJiKBij5+Rlda yivmTeh+CuUU3xLFiEcbazXxH53r+IA1IgqXe+6RXybwo1Sj8XB1SGKfpCAdgzPQczk8 o4c7BCwvcIpEGNrUDDCAQpBBTYPsSp28AT8reXsk2RH0xWWSjUofBOh3lhhHzFlmfhWm OhLA== X-Gm-Message-State: ABy/qLZxcO4pKq9W4zC0NCEA2BSNysOdlnTyZfKSz8Z8ry1drg4QCaWS 1Y4lNoorpFbt4NTMuivOs3kpyKOjprgbT4wocXTKrg== X-Google-Smtp-Source: APBJJlHffpZ/OpXAg7uvfnKlL79jVR66Kr1p0PZ5UUI3MDUX1zaZmuOHzdNIR1rkyMBOUNq+40mtcg== X-Received: by 2002:adf:fd43:0:b0:313:f5f8:a331 with SMTP id h3-20020adffd43000000b00313f5f8a331mr8284810wrs.34.1688378740035; Mon, 03 Jul 2023 03:05:40 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: qemu-arm@nongnu.org, qemu-riscv@nongnu.org, pbonzini@redhat.com, eduardo@habkost.net, alistair.francis@wdc.com, danielhb413@gmail.com Subject: [PATCH v4 17/37] target/ppc: Use aesenc_SB_SR_MC_AK Date: Mon, 3 Jul 2023 12:05:00 +0200 Message-Id: <20230703100520.68224-18-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230703100520.68224-1-richard.henderson@linaro.org> References: <20230703100520.68224-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::429; envelope-from=richard.henderson@linaro.org; helo=mail-wr1-x429.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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1688379139666100003 Content-Type: text/plain; charset="utf-8" This implements the VCIPHER instruction. Reviewed-by: Daniel Henrique Barboza Signed-off-by: Richard Henderson Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- target/ppc/int_helper.c | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/target/ppc/int_helper.c b/target/ppc/int_helper.c index 15f07fca2b..1e477924b7 100644 --- a/target/ppc/int_helper.c +++ b/target/ppc/int_helper.c @@ -2933,17 +2933,11 @@ void helper_vsbox(ppc_avr_t *r, ppc_avr_t *a) =20 void helper_vcipher(ppc_avr_t *r, ppc_avr_t *a, ppc_avr_t *b) { - ppc_avr_t result; - int i; + AESState *ad =3D (AESState *)r; + AESState *st =3D (AESState *)a; + AESState *rk =3D (AESState *)b; =20 - VECTOR_FOR_INORDER_I(i, u32) { - result.VsrW(i) =3D b->VsrW(i) ^ - (AES_Te0[a->VsrB(AES_shifts[4 * i + 0])] ^ - AES_Te1[a->VsrB(AES_shifts[4 * i + 1])] ^ - AES_Te2[a->VsrB(AES_shifts[4 * i + 2])] ^ - AES_Te3[a->VsrB(AES_shifts[4 * i + 3])]); - } - *r =3D result; + aesenc_SB_SR_MC_AK(ad, st, rk, true); } =20 void helper_vcipherlast(ppc_avr_t *r, ppc_avr_t *a, ppc_avr_t *b) --=20 2.34.1 From nobody Tue May 14 18:40:19 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1688379343; cv=none; d=zohomail.com; s=zohoarc; b=EpkFkREGW4a7XPq9KYy159SLT527vXpJusQb7mZkpkg3JqZn3E58sl2C6zEaQ6MF/Tkp6nq6xbYs8IoFFHI4I6o5i4tPR09doYKfgBBHgMxqfpdTeDzH3N9pAjLRCJ0j/u5T2bgzbg+08UPccW8E2lvvVzzneJkO9DeXiZg1V/M= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1688379343; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=NQsBpcgKVgYp7fXYDQVN06TvKGcdOIek7QQgIG6AozQ=; b=StRwHahTQS52ZgnnicIh5AiZicRtOAzn3oXKuWtHwmRxN0AJMJxf14PjjgvdGokrFPM+Sj2F1LoJNLxNqUEmQsvx0JnhD3gq5UW4PtFwblK0wRXFUcrqgDT/rwxPN0bvmRH4eyrCiYHDlRR7jyXlAc9+NgIRRlCAzTFZs7EpYx8= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1688379343401947.5708781449744; Mon, 3 Jul 2023 03:15:43 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qGGRZ-0002xF-LZ; Mon, 03 Jul 2023 06:06:05 -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 1qGGRO-0002mP-9l for qemu-devel@nongnu.org; Mon, 03 Jul 2023 06:05:54 -0400 Received: from mail-wr1-x432.google.com ([2a00:1450:4864:20::432]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qGGRG-0005rf-84 for qemu-devel@nongnu.org; Mon, 03 Jul 2023 06:05:53 -0400 Received: by mail-wr1-x432.google.com with SMTP id ffacd0b85a97d-3141c8a6f30so4372649f8f.1 for ; Mon, 03 Jul 2023 03:05:43 -0700 (PDT) Received: from stoup.home (91.232.79.188.dynamic.jazztel.es. [188.79.232.91]) by smtp.gmail.com with ESMTPSA id t5-20020a05600001c500b00313f7b077fesm18446562wrx.59.2023.07.03.03.05.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 03 Jul 2023 03:05:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1688378742; x=1690970742; 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=NQsBpcgKVgYp7fXYDQVN06TvKGcdOIek7QQgIG6AozQ=; b=mZ/IrUE6/4Sgc7ls67lO5hlJNFTZGJQuyK7rU1pjq5w4o6lmCQ3ZvRKgdkDTa3x8E2 zm6IPnPCy7j0qoUidc0jppHp2jbFqqLg53fbc6cCyForMLD1L5PIDqSHUtlwvrvd8YTH p3CF1k2n7cAA51rQMEZS69yxqQIUSq0ck8zNOypaImnrozJ1CDylJ+XOhlWh9LLtgrdX NlVvFiRn/U0GzTKneyOGbBnNw4jzr63IrACpyibMdhdCmpwb/NXdKHtGeHBg1KuRQ4D2 KwpXe65bd3x8PL9XHQ+A1Yyi3ioI6cruO19juWirqoUisX9Ub4ADWUWzNIulDxCQFS2O T8bw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1688378742; x=1690970742; 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=NQsBpcgKVgYp7fXYDQVN06TvKGcdOIek7QQgIG6AozQ=; b=V+N/O1iRLAFhRSnTFvXNFvvr3zFJhmfua+dH+pZFeikW1VNsyAZYSP9tYhmMdUKe3c fr5p7tZ/US5o48kbFo4Hlh1uz9tiFi0Gso3Wb0KSWHGzm9CuR200lYqwE0medcV/skI8 cNNok6Wcc18dHcv50VTlbytWjCQvP2GRm2oUdMbqKbHlSDBBeLHOPCFhtHCA7G1Qu+wa zwT3N2j5x66SLmd/UQgS1odaQLA8Na9hSnd/+CKiVWhkWrnbtg7BgefYIA0Y3nuIheJT 6xGGfZnHncn5OuHvHaz52xshXBdCjnp133uC9ZkYDZhGuw9tSBYK/0922omRRxoNlHTi AlHQ== X-Gm-Message-State: ABy/qLadYiWQjE/J9RXpouz6Ey8YvDZ81KndL50V5xyZ1mXM5x6fh1o8 t0J+rCgs+ajQmFEQnUHonXRmSa8i0rfzsobJQ9hBTg== X-Google-Smtp-Source: APBJJlGlYO37mRzpMB7XFRv1JL8DNCTK5e9dO0BjmamwoJjoWBF6pDhE7yy2DpftBSxQOWHFpv6ytQ== X-Received: by 2002:adf:f14a:0:b0:314:96f:bb81 with SMTP id y10-20020adff14a000000b00314096fbb81mr7292123wro.22.1688378742155; Mon, 03 Jul 2023 03:05:42 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: qemu-arm@nongnu.org, qemu-riscv@nongnu.org, pbonzini@redhat.com, eduardo@habkost.net, alistair.francis@wdc.com, danielhb413@gmail.com, =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Subject: [PATCH v4 18/37] target/ppc: Use aesdec_ISB_ISR_AK_IMC Date: Mon, 3 Jul 2023 12:05:01 +0200 Message-Id: <20230703100520.68224-19-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230703100520.68224-1-richard.henderson@linaro.org> References: <20230703100520.68224-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::432; envelope-from=richard.henderson@linaro.org; helo=mail-wr1-x432.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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1688379345297100007 This implements the VNCIPHER instruction. Reviewed-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Daniel Henrique Barboza Signed-off-by: Richard Henderson --- target/ppc/int_helper.c | 19 ++++--------------- 1 file changed, 4 insertions(+), 15 deletions(-) diff --git a/target/ppc/int_helper.c b/target/ppc/int_helper.c index 1e477924b7..834da80fe3 100644 --- a/target/ppc/int_helper.c +++ b/target/ppc/int_helper.c @@ -2947,22 +2947,11 @@ void helper_vcipherlast(ppc_avr_t *r, ppc_avr_t *a,= ppc_avr_t *b) =20 void helper_vncipher(ppc_avr_t *r, ppc_avr_t *a, ppc_avr_t *b) { - /* This differs from what is written in ISA V2.07. The RTL is */ - /* incorrect and will be fixed in V2.07B. */ - int i; - ppc_avr_t tmp; + AESState *ad =3D (AESState *)r; + AESState *st =3D (AESState *)a; + AESState *rk =3D (AESState *)b; =20 - VECTOR_FOR_INORDER_I(i, u8) { - tmp.VsrB(i) =3D b->VsrB(i) ^ AES_isbox[a->VsrB(AES_ishifts[i])]; - } - - VECTOR_FOR_INORDER_I(i, u32) { - r->VsrW(i) =3D - AES_imc[tmp.VsrB(4 * i + 0)][0] ^ - AES_imc[tmp.VsrB(4 * i + 1)][1] ^ - AES_imc[tmp.VsrB(4 * i + 2)][2] ^ - AES_imc[tmp.VsrB(4 * i + 3)][3]; - } + aesdec_ISB_ISR_AK_IMC(ad, st, rk, true); } =20 void helper_vncipherlast(ppc_avr_t *r, ppc_avr_t *a, ppc_avr_t *b) --=20 2.34.1 From nobody Tue May 14 18:40:19 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1688379449; cv=none; d=zohomail.com; s=zohoarc; b=Zhgxhun+XF4EsuG/ibtV1H/TL9gFFZt12AhobtH+GcSvMv/eK8iVYuYZIij0aBg3xgb+XHFZhf0+ZjHOT09TOB1QfdaspzVhmIL9C5+6QzrBcGxaNy2kwWntogj5u/+vILoVKzivV27RhmHh6ESyjxl5Xssf7aLA4oG9LVFQqI0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1688379449; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=fCbxuyj6w2doHmBool/Ak6eLq+V5O+przb+5Ur/gE60=; b=nXfsOeXGYQxQPHuQi9jNt7PiNeRLVl52oijevCROOoqrrF24KeXMpyKpFQEXtiywlH7EiU2nUhywqaqTNLXI0NRHuqUxWHQTYdfomhE4hQ076sRupGOWfvY2BA5HD5ISvHlOirb+iZTk2yWBn/M8c9+45cpPWjHs+e1Lg/koQDI= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1688379449845506.49987853475955; Mon, 3 Jul 2023 03:17:29 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qGGRZ-0002ws-9E; Mon, 03 Jul 2023 06:06:05 -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 1qGGRN-0002k9-2I for qemu-devel@nongnu.org; Mon, 03 Jul 2023 06:05:53 -0400 Received: from mail-wm1-x32c.google.com ([2a00:1450: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 1qGGRG-0005rt-3f for qemu-devel@nongnu.org; Mon, 03 Jul 2023 06:05:52 -0400 Received: by mail-wm1-x32c.google.com with SMTP id 5b1f17b1804b1-3fbc244d307so49220025e9.1 for ; Mon, 03 Jul 2023 03:05:43 -0700 (PDT) Received: from stoup.home (91.232.79.188.dynamic.jazztel.es. [188.79.232.91]) by smtp.gmail.com with ESMTPSA id t5-20020a05600001c500b00313f7b077fesm18446562wrx.59.2023.07.03.03.05.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 03 Jul 2023 03:05:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1688378743; x=1690970743; 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=fCbxuyj6w2doHmBool/Ak6eLq+V5O+przb+5Ur/gE60=; b=Dt/EC/uU7ECskHqfbxVRsmJj/DB5u2mG5aGX6ZEsCxE3kuWl/Fpg10kenXBGS0sBvP wg1EDXvuWX/FgO7xvuOst7WQcYzUDEBq23gGK+4pd11CFF/P0f/SX4155OoY609HfluI /DQ+Oz0HrECWZrKX/D0EbxOf15NKAWXhidKOiEe8VCCYMyKSUmDM5cHInH9VZMnkVJZR znobaGaw9OuD8aY+hgNI8dcmqaN+KBLbx2Tc+0vx60HNwH6OwS+8KCs8udU55yZVxNpe VAjEiYAZ20rwmKOyd0oAh9feZMMqmkUZt4X66RGZrOb6jrVy8Ke1XWeE92W1BsS65Wog D2xA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1688378743; x=1690970743; 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=fCbxuyj6w2doHmBool/Ak6eLq+V5O+przb+5Ur/gE60=; b=QwV5WC325UGlwKN2zoOWp5lCBrbrIHoKdPTC1lBDr3eoIielnYiWbiYBJp9kAWTDtq fQnRgUXX2H9Kven1n0znQ54Uomej8slRG8vWw7Ty6n96WYfkQw/JL8keF1tsmbbWqLO5 1+EdlMEDZQ4+C5wyXfi/Pi8NHnVYeW2qxT6Kz8vLp+/g8NqZP7rZ3NKMOrBfVhUE1Jqr oClCpyuojP3kpGQ5inh/8BwOi4ijNkpECzdBsQePZ9IPLOjQiukqofMA37jIlhnYPhok t2NicGd13GIr/vg2msjmrbPP5A4z2nDddGztUPXGJJzFleS9VRPxDcEbcx4Bk+0ATHVH UIRA== X-Gm-Message-State: AC+VfDzmmDaJ9tWKZ+vWDvazrLSybTjbAEgs6WLNdWXin33lzfPfBqpV sRDVqiO0guYcooPLcDP06KEZ475t3z8nMtFtwIfZJQ== X-Google-Smtp-Source: ACHHUZ5GUFJHOeweeCXtCVa6V4ThFrA2gcoi0NIX9+l4Snpj/FyIaxmCJTz2MInnSTxH/hRKpy/KMQ== X-Received: by 2002:a7b:ce94:0:b0:3fb:a266:3a34 with SMTP id q20-20020a7bce94000000b003fba2663a34mr9438164wmj.12.1688378743037; Mon, 03 Jul 2023 03:05:43 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: qemu-arm@nongnu.org, qemu-riscv@nongnu.org, pbonzini@redhat.com, eduardo@habkost.net, alistair.francis@wdc.com, danielhb413@gmail.com, =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Subject: [PATCH v4 19/37] target/i386: Use aesenc_SB_SR_AK Date: Mon, 3 Jul 2023 12:05:02 +0200 Message-Id: <20230703100520.68224-20-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230703100520.68224-1-richard.henderson@linaro.org> References: <20230703100520.68224-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::32c; envelope-from=richard.henderson@linaro.org; helo=mail-wm1-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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1688379451178100001 This implements the AESENCLAST instruction. Reviewed-by: Philippe Mathieu-Daud=C3=A9 Signed-off-by: Richard Henderson --- target/i386/ops_sse.h | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/target/i386/ops_sse.h b/target/i386/ops_sse.h index fb63af7afa..63fdecbe03 100644 --- a/target/i386/ops_sse.h +++ b/target/i386/ops_sse.h @@ -19,6 +19,7 @@ */ =20 #include "crypto/aes.h" +#include "crypto/aes-round.h" =20 #if SHIFT =3D=3D 0 #define Reg MMXReg @@ -2202,12 +2203,12 @@ void glue(helper_aesenc, SUFFIX)(CPUX86State *env, = Reg *d, Reg *v, Reg *s) =20 void glue(helper_aesenclast, SUFFIX)(CPUX86State *env, Reg *d, Reg *v, Reg= *s) { - int i; - Reg st =3D *v; - Reg rk =3D *s; + for (int i =3D 0; i < SHIFT; i++) { + AESState *ad =3D (AESState *)&d->ZMM_X(i); + AESState *st =3D (AESState *)&v->ZMM_X(i); + AESState *rk =3D (AESState *)&s->ZMM_X(i); =20 - for (i =3D 0; i < 8 << SHIFT; i++) { - d->B(i) =3D rk.B(i) ^ (AES_sbox[st.B(AES_shifts[i & 15] + (i & ~15= ))]); + aesenc_SB_SR_AK(ad, st, rk, false); } } =20 --=20 2.34.1 From nobody Tue May 14 18:40:19 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1688378856; cv=none; d=zohomail.com; s=zohoarc; b=jhzt3mzjDyilPK/oFKvxe5yYe/QLEjMqKCLtCWvNah/wr6Xnq1M93JQ/VO85DXuhgVaBkt+jcjaviSLSbdCLlNzrtqnG7HRMAWEw3Cpuih0ru9d6NL1PFoEfyHTl1T/N6vQEjTuFnLFfeZlBFsv+QRYh9D0qCdfE6/Fc6NnDK34= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1688378856; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=Vdmp9g0LETEOImAoeAZ0vz3CHG5eCYIT92dyMVPeN7s=; b=KmCTF7Ro1RKegbPIr8OtcSv+YSCLeq7ZolOLO2XhlJwSN4CvvfOCPiktZtrpp+dlfUYLf/pd1G0pjwNzitZwQ1s0cbCXm/DdyGqt+UvvpJ5ZrtKFK3zXhfdmu+3yCmV+uspyePy4ZDeD2OM+O9mn7+P5gh0xMeCnac0D0HZnmzc= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1688378856136982.6226286418846; Mon, 3 Jul 2023 03:07:36 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qGGRo-0003BT-Pt; Mon, 03 Jul 2023 06:06:20 -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 1qGGRX-0002uc-Tx for qemu-devel@nongnu.org; Mon, 03 Jul 2023 06:06:03 -0400 Received: from mail-wr1-x432.google.com ([2a00:1450:4864:20::432]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qGGRH-0005sC-E2 for qemu-devel@nongnu.org; Mon, 03 Jul 2023 06:06:03 -0400 Received: by mail-wr1-x432.google.com with SMTP id ffacd0b85a97d-313e09a5b19so3499828f8f.0 for ; Mon, 03 Jul 2023 03:05:44 -0700 (PDT) Received: from stoup.home (91.232.79.188.dynamic.jazztel.es. [188.79.232.91]) by smtp.gmail.com with ESMTPSA id t5-20020a05600001c500b00313f7b077fesm18446562wrx.59.2023.07.03.03.05.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 03 Jul 2023 03:05:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1688378744; x=1690970744; 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=Vdmp9g0LETEOImAoeAZ0vz3CHG5eCYIT92dyMVPeN7s=; b=lIzVhNtoj5F6bRYtVeKVIjArwvK6p7enSfe9GQjPkN+NfKlT1zcL1UvFfCFN+izCFz cWoLsKc3Sz7bUS0s1wGImM+eKWSmqwB/JJDwOpO3oxgqvS+DkN1XjbdYrUQE0ujpdInG 3Uz6YB9EMIcYsPNAUOa4zA+ztXge+Tac9FQVFERyZkpU2E24zaHscJMhd2SB2Py1PTHG N1Nehrc+LK7o7r2DzeYjDY9tkQKh58PFvJejUFXpxOSoZgrktPcqgk3oN6Jga0e1+n/Q z8fAnBu/xVCwsjN/mP4wiFRsjxGsxWaZD3r5oJTjHkLHywdXtAeFzC9EQ73G7kpLEG3K NMVg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1688378744; x=1690970744; 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=Vdmp9g0LETEOImAoeAZ0vz3CHG5eCYIT92dyMVPeN7s=; b=DECnYmBP4WGEQRPTg51qIlCS6qAFmdcIkMu7RJQVACAIH4TwQYS/yT9GSCDvJuFV1U ezo4l6CVEBNuFo1t76NZljHr1Qv6p64h9W8EacUluo0wT/RAPNAKlUdne0eGS5rknRhw mZe87cNP6DXP45uI89QuKAoOKOr6jQ6wvaTXQj1vL7aQK3of8cRoNeD8KhBFognk5Frj c/8qWXg7mJoyHprwcUW5uLM/AbqGOImc0w3kY7YdbvuzuZ1gTdprplkx2+J3ndijGgrR bFbJe6anVOLSuPayb/7F9tzKM1MpK3AVp9JqK6w7TchG2+Gg5vtNkaMiShmavlixirVz EB9g== X-Gm-Message-State: ABy/qLZJnrT3vji/O87Ubp/QoeeXDkLAVx5Jn5Rtu4ZJ57Cxnw29D+7t rOn2qVoA57OIwx3ickXzEfyqfPBZQ4mnZYqoTpR4tw== X-Google-Smtp-Source: APBJJlEse5ck8aUfC8LmxRLx5Z3E2hvsQXNMv5ofp9reBryWphZa+Ky21MEAG5qCXNpXYc/cKrwV2A== X-Received: by 2002:a5d:660b:0:b0:314:c6b:b9a2 with SMTP id n11-20020a5d660b000000b003140c6bb9a2mr9401053wru.13.1688378744098; Mon, 03 Jul 2023 03:05:44 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: qemu-arm@nongnu.org, qemu-riscv@nongnu.org, pbonzini@redhat.com, eduardo@habkost.net, alistair.francis@wdc.com, danielhb413@gmail.com, =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Subject: [PATCH v4 20/37] target/i386: Use aesdec_ISB_ISR_AK Date: Mon, 3 Jul 2023 12:05:03 +0200 Message-Id: <20230703100520.68224-21-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230703100520.68224-1-richard.henderson@linaro.org> References: <20230703100520.68224-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::432; envelope-from=richard.henderson@linaro.org; helo=mail-wr1-x432.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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1688378857353100007 This implements the AESDECLAST instruction. Reviewed-by: Philippe Mathieu-Daud=C3=A9 Signed-off-by: Richard Henderson --- target/i386/ops_sse.h | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/target/i386/ops_sse.h b/target/i386/ops_sse.h index 63fdecbe03..0a37bde595 100644 --- a/target/i386/ops_sse.h +++ b/target/i386/ops_sse.h @@ -2177,12 +2177,12 @@ void glue(helper_aesdec, SUFFIX)(CPUX86State *env, = Reg *d, Reg *v, Reg *s) =20 void glue(helper_aesdeclast, SUFFIX)(CPUX86State *env, Reg *d, Reg *v, Reg= *s) { - int i; - Reg st =3D *v; - Reg rk =3D *s; + for (int i =3D 0; i < SHIFT; i++) { + AESState *ad =3D (AESState *)&d->ZMM_X(i); + AESState *st =3D (AESState *)&v->ZMM_X(i); + AESState *rk =3D (AESState *)&s->ZMM_X(i); =20 - for (i =3D 0; i < 8 << SHIFT; i++) { - d->B(i) =3D rk.B(i) ^ (AES_isbox[st.B(AES_ishifts[i & 15] + (i & ~= 15))]); + aesdec_ISB_ISR_AK(ad, st, rk, false); } } =20 --=20 2.34.1 From nobody Tue May 14 18:40:19 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1688378887; cv=none; d=zohomail.com; s=zohoarc; b=HdGtX9+S+eomk8rGC1gdlv/57ux6dIbL2M5SJHOHqePbJEfni6hWbmsdEcVHEdZmYuu2gcBx6QB8C98PQ5MyUAg+/2WNFjx6OMGPUkYnbB3R22I0+ZbWwCPV/F7h/3v56iqYd3oJVHOCYraRUiPd5veLH2pxqYjfdDhT8S+ILFY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1688378887; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=+lOYUQGr/W2hN41A+MbMW4B7XkhWFliC6iC1qe2q7c8=; b=Q3BP+LjO4cWz8YiSLmcrbHbEOO6wMsGoCv+9UUWLMUJ5Nm3wtuS86+M0hLuu5E72qB53zkPE6lqkeq1JHtvhspWi50Sm5AXBpsPhkMvAMXvEKKb1OPvBzMbIx4M64NOGRLwyDeTtoe5gD1VpZet4r3SkoHIHquUUGskGB/dOcS8= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1688378887002369.49563461299124; Mon, 3 Jul 2023 03:08:07 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qGGRo-0003CH-Uj; Mon, 03 Jul 2023 06:06:24 -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 1qGGRW-0002s0-6D for qemu-devel@nongnu.org; Mon, 03 Jul 2023 06:06:03 -0400 Received: from mail-wr1-x42f.google.com ([2a00:1450:4864:20::42f]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qGGRH-0005sv-64 for qemu-devel@nongnu.org; Mon, 03 Jul 2023 06:06:01 -0400 Received: by mail-wr1-x42f.google.com with SMTP id ffacd0b85a97d-3141fa31c2bso3957675f8f.2 for ; Mon, 03 Jul 2023 03:05:46 -0700 (PDT) Received: from stoup.home (91.232.79.188.dynamic.jazztel.es. [188.79.232.91]) by smtp.gmail.com with ESMTPSA id t5-20020a05600001c500b00313f7b077fesm18446562wrx.59.2023.07.03.03.05.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 03 Jul 2023 03:05:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1688378745; x=1690970745; 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=+lOYUQGr/W2hN41A+MbMW4B7XkhWFliC6iC1qe2q7c8=; b=FKuTLHWnU9cGz6omANfyTbx8zbAbdvn63Os5v9VbhwZhASRSUR2tyIvnBhtIFLYHDm Thf89+6pNW5dlV6I7QNZb4gEpoFGx9eGjUakyzPg2xxzZK2hq7uXH810IO+tS1cs3Zvf Tn7S3sgB3mQgCVEEI9v1wLzVn1KboVaifNSpwOuHKSjQG2378fvcz5nwDk+YA+3JKS+d x0vw0vnhKVZyanEFyHexz+E4upOvJ3W7xpSDOnuJiqj8b9DudL2rwjrML1fuqLCIIJEb MZXziao5U0bSHyWmnUIwlrLbLWSDfXu0tPblAUL7oxnK/2w8jfmDEN4NVW9/XuoY8cK5 Ajmg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1688378745; x=1690970745; 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=+lOYUQGr/W2hN41A+MbMW4B7XkhWFliC6iC1qe2q7c8=; b=HZkCZ5wT0pZzoa4pk80qjcVKTpVD0hrpx8wzab1ulqqEa8K/YHDssGKZ8xgzrJDLSx Fv7eBlmiDC7vaCjhvdA68V05FHgYfsbuMcIFWz+OAmhwUE+8UtQ7weQ3qidE3oBIIK8X iphWc9fHJ9qC9fUmhJ/s1i6JD/IQEhm1cyOb21/N+X/LahiJjHvCr/toOKEci4yrdx2R ziBAqnJRTKJk8JrDKifAxW+baMx++6yn2UBuf+T53j54w82eCG9rr+Yn22tqPPRvweIX W1YMcQ7IfHRcUOSM+7PXtLeb5x8pP9VBDz/fnVMGsPQUpaYSRyA9j5vCUe5C64oUANYv EV2g== X-Gm-Message-State: ABy/qLaw6UrVsgSrV+I2KjiUYiz8Mq0G/dbo01c9rKEChyMSZL0uz7/i eMMvbCeDqsliuTqsmNHmovPtVLapGnvdoCRW716DOg== X-Google-Smtp-Source: APBJJlG7MmNJ+XFAFY7OAEYCvWeKq/k/Oi3Gk1+mNc85Dt9XPLyocoRo4OIBoE9779WgLq/MNVphqQ== X-Received: by 2002:adf:fdc9:0:b0:313:f399:6cea with SMTP id i9-20020adffdc9000000b00313f3996ceamr8276715wrs.4.1688378745288; Mon, 03 Jul 2023 03:05:45 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: qemu-arm@nongnu.org, qemu-riscv@nongnu.org, pbonzini@redhat.com, eduardo@habkost.net, alistair.francis@wdc.com, danielhb413@gmail.com Subject: [PATCH v4 21/37] target/i386: Use aesdec_IMC Date: Mon, 3 Jul 2023 12:05:04 +0200 Message-Id: <20230703100520.68224-22-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230703100520.68224-1-richard.henderson@linaro.org> References: <20230703100520.68224-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::42f; envelope-from=richard.henderson@linaro.org; helo=mail-wr1-x42f.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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1688378888605100003 Content-Type: text/plain; charset="utf-8" This implements the AESIMC instruction. Signed-off-by: Richard Henderson Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- target/i386/ops_sse.h | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/target/i386/ops_sse.h b/target/i386/ops_sse.h index 0a37bde595..893913ebf8 100644 --- a/target/i386/ops_sse.h +++ b/target/i386/ops_sse.h @@ -2215,15 +2215,10 @@ void glue(helper_aesenclast, SUFFIX)(CPUX86State *e= nv, Reg *d, Reg *v, Reg *s) #if SHIFT =3D=3D 1 void glue(helper_aesimc, SUFFIX)(CPUX86State *env, Reg *d, Reg *s) { - int i; - Reg tmp =3D *s; + AESState *ad =3D (AESState *)&d->ZMM_X(0); + AESState *st =3D (AESState *)&s->ZMM_X(0); =20 - for (i =3D 0 ; i < 4 ; i++) { - d->L(i) =3D bswap32(AES_imc[tmp.B(4 * i + 0)][0] ^ - AES_imc[tmp.B(4 * i + 1)][1] ^ - AES_imc[tmp.B(4 * i + 2)][2] ^ - AES_imc[tmp.B(4 * i + 3)][3]); - } + aesdec_IMC(ad, st, false); } =20 void glue(helper_aeskeygenassist, SUFFIX)(CPUX86State *env, Reg *d, Reg *s, --=20 2.34.1 From nobody Tue May 14 18:40:19 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1688379012; cv=none; d=zohomail.com; s=zohoarc; b=V4HsxD6VsV1PwnseCaQpPhT27zVCgLeYWWm/fRBEB2l+shalVZsGPu7CDAFg53ZfcEdmlUoPkyqqlg/5r9rOwDX34z/W1GsmKYAs2ZzrqwrYyiNTKoVKyxSUFX6x116Xpap45ZewbdCxT3RmNTY0EYmP2TMs4BexcEDYk0fWHqA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1688379012; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=+os3nHQ/ZmARewYX8s5fRYkcgS0NtfZNFjYHPGkpaM4=; b=QKvb/76D/zEhycfnuB+iCupoUrWRSngYWrbG3ToIuBpN7XfYxPxvkQqdUlYubkn5ewixEs5Ibwxgd+ii5JfZAqEd/8y69Y83Og6VfIRvYANq4SI9hAqYD2G+qXWAX8sMk9eSTL5o4o8VD4QqqRiCKKbx+EGiWhlu9iaqhG07thQ= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1688379012063986.191040751626; Mon, 3 Jul 2023 03:10:12 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qGGRg-00037y-LX; Mon, 03 Jul 2023 06:06:12 -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 1qGGRZ-0002wy-AK for qemu-devel@nongnu.org; Mon, 03 Jul 2023 06:06:05 -0400 Received: from mail-wm1-x336.google.com ([2a00:1450:4864:20::336]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qGGRH-0005tW-Qd for qemu-devel@nongnu.org; Mon, 03 Jul 2023 06:06:05 -0400 Received: by mail-wm1-x336.google.com with SMTP id 5b1f17b1804b1-3fbd33a57ddso15581135e9.1 for ; Mon, 03 Jul 2023 03:05:47 -0700 (PDT) Received: from stoup.home (91.232.79.188.dynamic.jazztel.es. [188.79.232.91]) by smtp.gmail.com with ESMTPSA id t5-20020a05600001c500b00313f7b077fesm18446562wrx.59.2023.07.03.03.05.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 03 Jul 2023 03:05:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1688378746; x=1690970746; 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=+os3nHQ/ZmARewYX8s5fRYkcgS0NtfZNFjYHPGkpaM4=; b=X5TrsKfAhQX/kK1CsQ/ipdzc+4Nj/S5XX4YJ45qsbLFxdaK9RAoC+QjOOK3flb3hrj MKhWK7LSXOlky1g+ytCR4o9OJdPGZaI8BuoJffTrWhpBojgxmhc+pFA/XZO73EDZ4CRl gWgutKsdYSJP9oUN8QstNcmAfiFS9NMyQM4hghNmU3pNglAQZCJ0T05oe69+S88Zm7hD +jaMZRrOOHl05q91EUSJNv1gfHqdUHrow3MrrOEMD65cvmctQKvckyjIdbqMu7RR3wzp WzlerCFCKLjy9gcmPWFmapv5Sl2toL9nRzREUZkofCQQMgi7+4li0wx+DQKMMWwlZSdp C/ag== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1688378746; x=1690970746; 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=+os3nHQ/ZmARewYX8s5fRYkcgS0NtfZNFjYHPGkpaM4=; b=BQYXPc59vW5ItQJLso+0WPJWI6J0GcblWAMQvg3GCavCpMLcrM1WvtU0/lTqz7UPBB Sqx5KNZSrzthiTrC9jNYOFXtXhqav6ZaiEqZ4qPZfpD4M2fQZKupJEUwlGa6HidnMzCZ 3DfBswfVw0NVkACvwddRkAS/4npRg0Taq8N7sbeTy1EHFRAP7SaTT0Bqq+bSEOv6Crf9 tV/Kf2/K/9UWVrgHbAOUrXrb1v9BmWY64v79jgfgM/G1gljTBtXV6WrNrx6bLAeoTF/6 YaoTBeyRd1TM46dhyr0bW8bBCcfXHVv/LVjW8mLxVNIu83r7TgSwLuB/Gj9i81mNIxE+ RgkQ== X-Gm-Message-State: AC+VfDzR6rcqG2/h8/KQLn3PENMZzRaJWNyESgBQAfOsH25Q+coiDyE5 DysQWT57IbkIonGgArxtJOugjSdDxn8XFx3oX+1OdQ== X-Google-Smtp-Source: ACHHUZ44n7UqB44H291RGVVvCZ8CI95gg/yhq4p5d9KjrwxSOncV6wVCWPmS5qVvFnz/KQMLd+zIBQ== X-Received: by 2002:a05:600c:2253:b0:3fb:a5b3:4f02 with SMTP id a19-20020a05600c225300b003fba5b34f02mr7464716wmm.36.1688378746218; Mon, 03 Jul 2023 03:05:46 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: qemu-arm@nongnu.org, qemu-riscv@nongnu.org, pbonzini@redhat.com, eduardo@habkost.net, alistair.francis@wdc.com, danielhb413@gmail.com Subject: [PATCH v4 22/37] target/i386: Use aesenc_SB_SR_MC_AK Date: Mon, 3 Jul 2023 12:05:05 +0200 Message-Id: <20230703100520.68224-23-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230703100520.68224-1-richard.henderson@linaro.org> References: <20230703100520.68224-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::336; envelope-from=richard.henderson@linaro.org; helo=mail-wm1-x336.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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1688379014674100003 Content-Type: text/plain; charset="utf-8" This implements the AESENC instruction. Signed-off-by: Richard Henderson Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- target/i386/ops_sse.h | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/target/i386/ops_sse.h b/target/i386/ops_sse.h index 893913ebf8..93a4e0cf16 100644 --- a/target/i386/ops_sse.h +++ b/target/i386/ops_sse.h @@ -2188,16 +2188,12 @@ void glue(helper_aesdeclast, SUFFIX)(CPUX86State *e= nv, Reg *d, Reg *v, Reg *s) =20 void glue(helper_aesenc, SUFFIX)(CPUX86State *env, Reg *d, Reg *v, Reg *s) { - int i; - Reg st =3D *v; - Reg rk =3D *s; + for (int i =3D 0; i < SHIFT; i++) { + AESState *ad =3D (AESState *)&d->ZMM_X(i); + AESState *st =3D (AESState *)&v->ZMM_X(i); + AESState *rk =3D (AESState *)&s->ZMM_X(i); =20 - for (i =3D 0 ; i < 2 << SHIFT ; i++) { - int j =3D i & 3; - d->L(i) =3D rk.L(i) ^ bswap32(AES_Te0[st.B(AES_shifts[4 * j + 0])]= ^ - AES_Te1[st.B(AES_shifts[4 * j + 1])] ^ - AES_Te2[st.B(AES_shifts[4 * j + 2])] ^ - AES_Te3[st.B(AES_shifts[4 * j + 3])]); + aesenc_SB_SR_MC_AK(ad, st, rk, false); } } =20 --=20 2.34.1 From nobody Tue May 14 18:40:19 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1688379061; cv=none; d=zohomail.com; s=zohoarc; b=bCNgnSZ+s23ndQXwZ6kdlXHI4N1YSel97jxzAL1xVRIU/cr7EhaIi5ENZ33K62WxeHJkcj5YT1lYRy4kKc+IepSNED1Po7/DRMjXTp2bfBCsNeiuorIlqR48Ljh4TMsAJ4y5NyG6Sh85TLak8KUW5WafTlLabkl7xAAcSm8Bmq0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1688379061; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=5CADGmxGJYg/RjV/FHciOOU7jKKLgdI+xydvPDVf6m0=; b=UO60l1tlsoacWBJURwadzVixIgHK6nqFLuMu9tRSO+3xMhdmOdm8+Z4Ijpg0kwdSR1Xr0Hqb+1ZalhuwBjidz+Y5Fy+/j0OdWa7b59huqtHTMIIEuwHbR6CDKjsd9RZSHkw0BVQ0Ndidnl6uXLKOxZA/dAc+135AEXD+E6nz4R0= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1688379061121885.7444808707033; Mon, 3 Jul 2023 03:11:01 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qGGS3-0003U1-Ey; Mon, 03 Jul 2023 06:06: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 1qGGRa-0002yw-KK for qemu-devel@nongnu.org; Mon, 03 Jul 2023 06:06:06 -0400 Received: from mail-wr1-x433.google.com ([2a00:1450:4864:20::433]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qGGRI-0005u2-J9 for qemu-devel@nongnu.org; Mon, 03 Jul 2023 06:06:06 -0400 Received: by mail-wr1-x433.google.com with SMTP id ffacd0b85a97d-3141c3a7547so4391799f8f.2 for ; Mon, 03 Jul 2023 03:05:48 -0700 (PDT) Received: from stoup.home (91.232.79.188.dynamic.jazztel.es. [188.79.232.91]) by smtp.gmail.com with ESMTPSA id t5-20020a05600001c500b00313f7b077fesm18446562wrx.59.2023.07.03.03.05.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 03 Jul 2023 03:05:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1688378747; x=1690970747; 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=5CADGmxGJYg/RjV/FHciOOU7jKKLgdI+xydvPDVf6m0=; b=VvIsKEyqLpv7mL5+/kHjPzHS0Rkh1Yfwk40Ta0J9qyXijv8RRccLzrNDmvnwJDpOri Qdi+ograIyCToOFco4uxD8loUFju4u+GeNRwMGyc9DbSqqDzg2Wj1kGJ2Xb3rTSztobj 7mOhs5SdqGETydpBiiMX7PsatWJ7JQNbqiSl51/80WwZiDOlojCFnCcYXt/Z/Qk91DcB PxDtj1aHeQMtduLFS5vdVMis/C3e+89hOPvhzmNfyv5sIVvrqxU3GwPefBLfQkXKvl0M d/Zqmppj7qDNLTABY8jvy/bKa26EhKaQ7Cq5MiwXmEF0tZsytUtgGY2uLmOt+ua5bK2/ qenA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1688378747; x=1690970747; 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=5CADGmxGJYg/RjV/FHciOOU7jKKLgdI+xydvPDVf6m0=; b=I4vlh9kPQSPi0stHGAe34iO8nnV1pTdr7xLmEiNEHRyNL+DbQadDhbCKSYHpHXoTbk D8X5RjJJy19Ucql3wBo/2ybdw/k82EqSvzdea5wdbq/SVuOMpFkJAxmVmFQc3LYXtcFT PnkYXhJllbB9gAAdALlhjoxlvKlLIo3VneGliGs1C/UcLWe69sEN8CbS3/+ZIxK1AZ37 07ikCcaUZatgJ4T0DOZnb4bC9BDoKezQbxyK0wSN6/uGlHiDcwySFndOV8c/36evm8K4 WSfQ8dOk2CYkpYpvm9G6fOSEN7lwo/Yp7HWnQlow9l65tFTYrPJFTx0GI7WAOTl2pnDu u8Ig== X-Gm-Message-State: ABy/qLahQOgCz8Eo7WeD4GGnCc87MKIs3FKK02+LDaiDOrkJirCAZBc0 HWnx4AVpET3+dctMmuEd2YqjKGCbN91sAJ0wMzA1xg== X-Google-Smtp-Source: APBJJlEW+zTHqpMUQEHX6cKNuM4MGV5f3qaRE/iUUPOANL6FWwbdiY58DV2VojxAA2clMUsqvo6c7Q== X-Received: by 2002:a5d:63ca:0:b0:314:2594:7b9f with SMTP id c10-20020a5d63ca000000b0031425947b9fmr7327835wrw.11.1688378747179; Mon, 03 Jul 2023 03:05:47 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: qemu-arm@nongnu.org, qemu-riscv@nongnu.org, pbonzini@redhat.com, eduardo@habkost.net, alistair.francis@wdc.com, danielhb413@gmail.com Subject: [PATCH v4 23/37] target/i386: Use aesdec_ISB_ISR_IMC_AK Date: Mon, 3 Jul 2023 12:05:06 +0200 Message-Id: <20230703100520.68224-24-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230703100520.68224-1-richard.henderson@linaro.org> References: <20230703100520.68224-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::433; envelope-from=richard.henderson@linaro.org; helo=mail-wr1-x433.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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1688379062534100001 Content-Type: text/plain; charset="utf-8" This implements the AESDEC instruction. Signed-off-by: Richard Henderson Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- target/i386/ops_sse.h | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/target/i386/ops_sse.h b/target/i386/ops_sse.h index 93a4e0cf16..a0e425733f 100644 --- a/target/i386/ops_sse.h +++ b/target/i386/ops_sse.h @@ -2162,16 +2162,12 @@ void glue(helper_pclmulqdq, SUFFIX)(CPUX86State *en= v, Reg *d, Reg *v, Reg *s, =20 void glue(helper_aesdec, SUFFIX)(CPUX86State *env, Reg *d, Reg *v, Reg *s) { - int i; - Reg st =3D *v; - Reg rk =3D *s; + for (int i =3D 0; i < SHIFT; i++) { + AESState *ad =3D (AESState *)&d->ZMM_X(i); + AESState *st =3D (AESState *)&v->ZMM_X(i); + AESState *rk =3D (AESState *)&s->ZMM_X(i); =20 - for (i =3D 0 ; i < 2 << SHIFT ; i++) { - int j =3D i & 3; - d->L(i) =3D rk.L(i) ^ bswap32(AES_Td0[st.B(AES_ishifts[4 * j + 0])= ] ^ - AES_Td1[st.B(AES_ishifts[4 * j + 1])] ^ - AES_Td2[st.B(AES_ishifts[4 * j + 2])] ^ - AES_Td3[st.B(AES_ishifts[4 * j + 3])]); + aesdec_ISB_ISR_IMC_AK(ad, st, rk, false); } } =20 --=20 2.34.1 From nobody Tue May 14 18:40:19 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1688379343; cv=none; d=zohomail.com; s=zohoarc; b=T8jHKzZshQ5gJ9ZA3EZuR31apXQ92IVKgDN0w2xNLm17kRNVM5JZNPBpOGW5F3yMDVSTrzaxzIsWzUJAayZ76OeRTHhzmSb9HyZ9ln2gq1+PydROug0HnSLbt/+btvLbADOkKtCXZo1GZlo1ktD7t2Hu2v/JB6EMNkD6OESVEY8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1688379343; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=O7ydnBYQ5OsAEU6obJ0/WYba/6nStgh78o+Q1/ZISH0=; b=lUoQfM4P5iE0SR9Dqw31jiTNvEr1sXP7PxEyar/MzNm2Emj7UHdGiLDewS7EWO1H1R+dRndFIrtyfdWv4zDFnxIX8rK3Z6m9CdJbWWdhOUIXFtrhXqmP56KwLRNa53eqvua3OUN86ruLRlKlWecKKzR5joI5k4WzEmr/vDHrvXY= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1688379343916894.390155709021; Mon, 3 Jul 2023 03:15:43 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qGGS4-0003W2-4b; Mon, 03 Jul 2023 06:06:36 -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 1qGGRb-00030o-EG for qemu-devel@nongnu.org; Mon, 03 Jul 2023 06:06:07 -0400 Received: from mail-wm1-x335.google.com ([2a00:1450:4864:20::335]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qGGRJ-0005ue-TN for qemu-devel@nongnu.org; Mon, 03 Jul 2023 06:06:07 -0400 Received: by mail-wm1-x335.google.com with SMTP id 5b1f17b1804b1-3fbc1218262so51762295e9.3 for ; Mon, 03 Jul 2023 03:05:49 -0700 (PDT) Received: from stoup.home (91.232.79.188.dynamic.jazztel.es. [188.79.232.91]) by smtp.gmail.com with ESMTPSA id t5-20020a05600001c500b00313f7b077fesm18446562wrx.59.2023.07.03.03.05.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 03 Jul 2023 03:05:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1688378748; x=1690970748; 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=O7ydnBYQ5OsAEU6obJ0/WYba/6nStgh78o+Q1/ZISH0=; b=yb39+pDhZycA2fHLjHGixpPuf3i7NQRi5KGGR6mtI413gm4anCHy8f9ZHXisz0IPii 2KjUjd44s0x4A6AuIf5379XikQBKVmg7RoI5Qcr2vkGo4WemXCHyVQK9Pyop42tEhONn yilw9XVHDbBVGEHh8s59RP5JGnPJW7bZu9kiVABmDp1YRjDhmt2NRNDa1h0/FvyEUWPD N5rGIg3qavTuBQNRwgl8h5ATTKFr3m2Ff4JEw/pX3Dg0mP9H/TSRyWdCU7gcnOBI1YOL EdIVnyZkcj6FGf4TVRE2Z6jsqQBTD1+4XSEtSx9VwhvlmIkWI9Algy1XAo4orT7QPIwv XyIQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1688378748; x=1690970748; 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=O7ydnBYQ5OsAEU6obJ0/WYba/6nStgh78o+Q1/ZISH0=; b=OQydHxdbtaqPaz7oP4whLhZensiPjYaE+BYsYa4T/M2IQleLWF3LWNq7zW+WuSdq+T f11JZMY2yl3qGqAeqwbe1/7HdmX4wOjnh/HXBkiKs6wuUE4w1lFy4w6jP6Jrh0Jg1ppy 9SSXX5TuoqB2aPQ3yp4v83gL7bc0ycWscrZBa3agBqnyEtwNdrbN5NPRBJqaLqmNj7dY Foh+jWI91qq0rK3OG2a64rFQEZ+0GB2GwpznDeIF4/ByH0MbRDjeCbWDsGQsRfP6N+nq /1S7BLB9Vkaa50U4bTIG9ixhiLi4oPfdcvTfy7oBXSHaMTlEKP1URenP0kk/eHECaJtF Tfog== X-Gm-Message-State: ABy/qLaAkHzaX68ix0Lo076zUy7w91Pms2aAKAaVf+AB1xD3mqGePoZJ OPFOomUUrnVYi18oXiHm+SSOM9oBFEVglFpJecF+sg== X-Google-Smtp-Source: APBJJlHbyE9bMDEcZuPOZcCA+WR8E3jCtZR96Aj7R9bIFv4rw4v/7b6QhYnMzSemz8ZOmCzHsAaL6Q== X-Received: by 2002:adf:f5c5:0:b0:314:3864:d3d0 with SMTP id k5-20020adff5c5000000b003143864d3d0mr1464873wrp.25.1688378748104; Mon, 03 Jul 2023 03:05:48 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: qemu-arm@nongnu.org, qemu-riscv@nongnu.org, pbonzini@redhat.com, eduardo@habkost.net, alistair.francis@wdc.com, danielhb413@gmail.com, =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Subject: [PATCH v4 24/37] target/arm: Demultiplex AESE and AESMC Date: Mon, 3 Jul 2023 12:05:07 +0200 Message-Id: <20230703100520.68224-25-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230703100520.68224-1-richard.henderson@linaro.org> References: <20230703100520.68224-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::335; envelope-from=richard.henderson@linaro.org; helo=mail-wm1-x335.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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1688379344758100005 Split these helpers so that we are not passing 'decrypt' within the simd descriptor. Reviewed-by: Philippe Mathieu-Daud=C3=A9 Signed-off-by: Richard Henderson --- target/arm/helper.h | 2 ++ target/arm/tcg/sve.decode | 4 ++-- target/arm/tcg/crypto_helper.c | 37 +++++++++++++++++++++++---------- target/arm/tcg/translate-a64.c | 13 ++++-------- target/arm/tcg/translate-neon.c | 4 ++-- target/arm/tcg/translate-sve.c | 8 ++++--- 6 files changed, 41 insertions(+), 27 deletions(-) diff --git a/target/arm/helper.h b/target/arm/helper.h index 3335c2b10b..95e32a697a 100644 --- a/target/arm/helper.h +++ b/target/arm/helper.h @@ -552,7 +552,9 @@ DEF_HELPER_FLAGS_2(neon_qzip16, TCG_CALL_NO_RWG, void, = ptr, ptr) DEF_HELPER_FLAGS_2(neon_qzip32, TCG_CALL_NO_RWG, void, ptr, ptr) =20 DEF_HELPER_FLAGS_4(crypto_aese, TCG_CALL_NO_RWG, void, ptr, ptr, ptr, i32) +DEF_HELPER_FLAGS_4(crypto_aesd, TCG_CALL_NO_RWG, void, ptr, ptr, ptr, i32) DEF_HELPER_FLAGS_3(crypto_aesmc, TCG_CALL_NO_RWG, void, ptr, ptr, i32) +DEF_HELPER_FLAGS_3(crypto_aesimc, TCG_CALL_NO_RWG, void, ptr, ptr, i32) =20 DEF_HELPER_FLAGS_4(crypto_sha1su0, TCG_CALL_NO_RWG, void, ptr, ptr, ptr, i= 32) DEF_HELPER_FLAGS_4(crypto_sha1c, TCG_CALL_NO_RWG, void, ptr, ptr, ptr, i32) diff --git a/target/arm/tcg/sve.decode b/target/arm/tcg/sve.decode index 14b3a69c36..04b6fcc0cf 100644 --- a/target/arm/tcg/sve.decode +++ b/target/arm/tcg/sve.decode @@ -1629,8 +1629,8 @@ STNT1_zprz 1110010 .. 10 ..... 001 ... ..... ...= .. \ ### SVE2 Crypto Extensions =20 # SVE2 crypto unary operations -# AESMC and AESIMC -AESMC 01000101 00 10000011100 decrypt:1 00000 rd:5 +AESMC 01000101 00 10000011100 0 00000 rd:5 +AESIMC 01000101 00 10000011100 1 00000 rd:5 =20 # SVE2 crypto destructive binary operations AESE 01000101 00 10001 0 11100 0 ..... ..... @rdn_rm_e0 diff --git a/target/arm/tcg/crypto_helper.c b/target/arm/tcg/crypto_helper.c index 06254939d2..75882d9ea3 100644 --- a/target/arm/tcg/crypto_helper.c +++ b/target/arm/tcg/crypto_helper.c @@ -45,11 +45,9 @@ static void clear_tail_16(void *vd, uint32_t desc) clear_tail(vd, opr_sz, max_sz); } =20 -static void do_crypto_aese(uint64_t *rd, uint64_t *rn, - uint64_t *rm, bool decrypt) +static void do_crypto_aese(uint64_t *rd, uint64_t *rn, uint64_t *rm, + const uint8_t *sbox, const uint8_t *shift) { - static uint8_t const * const sbox[2] =3D { AES_sbox, AES_isbox }; - static uint8_t const * const shift[2] =3D { AES_shifts, AES_ishifts }; union CRYPTO_STATE rk =3D { .l =3D { rm[0], rm[1] } }; union CRYPTO_STATE st =3D { .l =3D { rn[0], rn[1] } }; int i; @@ -60,7 +58,7 @@ static void do_crypto_aese(uint64_t *rd, uint64_t *rn, =20 /* combine ShiftRows operation and sbox substitution */ for (i =3D 0; i < 16; i++) { - CR_ST_BYTE(st, i) =3D sbox[decrypt][CR_ST_BYTE(rk, shift[decrypt][= i])]; + CR_ST_BYTE(st, i) =3D sbox[CR_ST_BYTE(rk, shift[i])]; } =20 rd[0] =3D st.l[0]; @@ -70,18 +68,26 @@ static void do_crypto_aese(uint64_t *rd, uint64_t *rn, void HELPER(crypto_aese)(void *vd, void *vn, void *vm, uint32_t desc) { intptr_t i, opr_sz =3D simd_oprsz(desc); - bool decrypt =3D simd_data(desc); =20 for (i =3D 0; i < opr_sz; i +=3D 16) { - do_crypto_aese(vd + i, vn + i, vm + i, decrypt); + do_crypto_aese(vd + i, vn + i, vm + i, AES_sbox, AES_shifts); } clear_tail(vd, opr_sz, simd_maxsz(desc)); } =20 -static void do_crypto_aesmc(uint64_t *rd, uint64_t *rm, bool decrypt) +void HELPER(crypto_aesd)(void *vd, void *vn, void *vm, uint32_t desc) +{ + intptr_t i, opr_sz =3D simd_oprsz(desc); + + for (i =3D 0; i < opr_sz; i +=3D 16) { + do_crypto_aese(vd + i, vn + i, vm + i, AES_isbox, AES_ishifts); + } + clear_tail(vd, opr_sz, simd_maxsz(desc)); +} + +static void do_crypto_aesmc(uint64_t *rd, uint64_t *rm, const uint32_t *mc) { union CRYPTO_STATE st =3D { .l =3D { rm[0], rm[1] } }; - const uint32_t *mc =3D decrypt ? AES_imc_rot : AES_mc_rot; int i; =20 for (i =3D 0; i < 16; i +=3D 4) { @@ -99,10 +105,19 @@ static void do_crypto_aesmc(uint64_t *rd, uint64_t *rm= , bool decrypt) void HELPER(crypto_aesmc)(void *vd, void *vm, uint32_t desc) { intptr_t i, opr_sz =3D simd_oprsz(desc); - bool decrypt =3D simd_data(desc); =20 for (i =3D 0; i < opr_sz; i +=3D 16) { - do_crypto_aesmc(vd + i, vm + i, decrypt); + do_crypto_aesmc(vd + i, vm + i, AES_mc_rot); + } + clear_tail(vd, opr_sz, simd_maxsz(desc)); +} + +void HELPER(crypto_aesimc)(void *vd, void *vm, uint32_t desc) +{ + intptr_t i, opr_sz =3D simd_oprsz(desc); + + for (i =3D 0; i < opr_sz; i +=3D 16) { + do_crypto_aesmc(vd + i, vm + i, AES_imc_rot); } clear_tail(vd, opr_sz, simd_maxsz(desc)); } diff --git a/target/arm/tcg/translate-a64.c b/target/arm/tcg/translate-a64.c index 3baab6aa60..7d0c8f79a7 100644 --- a/target/arm/tcg/translate-a64.c +++ b/target/arm/tcg/translate-a64.c @@ -13210,7 +13210,6 @@ static void disas_crypto_aes(DisasContext *s, uint3= 2_t insn) int opcode =3D extract32(insn, 12, 5); int rn =3D extract32(insn, 5, 5); int rd =3D extract32(insn, 0, 5); - int decrypt; gen_helper_gvec_2 *genfn2 =3D NULL; gen_helper_gvec_3 *genfn3 =3D NULL; =20 @@ -13221,20 +13220,16 @@ static void disas_crypto_aes(DisasContext *s, uin= t32_t insn) =20 switch (opcode) { case 0x4: /* AESE */ - decrypt =3D 0; genfn3 =3D gen_helper_crypto_aese; break; case 0x6: /* AESMC */ - decrypt =3D 0; genfn2 =3D gen_helper_crypto_aesmc; break; case 0x5: /* AESD */ - decrypt =3D 1; - genfn3 =3D gen_helper_crypto_aese; + genfn3 =3D gen_helper_crypto_aesd; break; case 0x7: /* AESIMC */ - decrypt =3D 1; - genfn2 =3D gen_helper_crypto_aesmc; + genfn2 =3D gen_helper_crypto_aesimc; break; default: unallocated_encoding(s); @@ -13245,9 +13240,9 @@ static void disas_crypto_aes(DisasContext *s, uint3= 2_t insn) return; } if (genfn2) { - gen_gvec_op2_ool(s, true, rd, rn, decrypt, genfn2); + gen_gvec_op2_ool(s, true, rd, rn, 0, genfn2); } else { - gen_gvec_op3_ool(s, true, rd, rd, rn, decrypt, genfn3); + gen_gvec_op3_ool(s, true, rd, rd, rn, 0, genfn3); } } =20 diff --git a/target/arm/tcg/translate-neon.c b/target/arm/tcg/translate-neo= n.c index 03913de047..8de4ceb203 100644 --- a/target/arm/tcg/translate-neon.c +++ b/target/arm/tcg/translate-neon.c @@ -3451,9 +3451,9 @@ static bool trans_VMVN(DisasContext *s, arg_2misc *a) } =20 WRAP_2M_3_OOL_FN(gen_AESE, gen_helper_crypto_aese, 0) -WRAP_2M_3_OOL_FN(gen_AESD, gen_helper_crypto_aese, 1) +WRAP_2M_3_OOL_FN(gen_AESD, gen_helper_crypto_aesd, 0) WRAP_2M_2_OOL_FN(gen_AESMC, gen_helper_crypto_aesmc, 0) -WRAP_2M_2_OOL_FN(gen_AESIMC, gen_helper_crypto_aesmc, 1) +WRAP_2M_2_OOL_FN(gen_AESIMC, gen_helper_crypto_aesimc, 0) WRAP_2M_2_OOL_FN(gen_SHA1H, gen_helper_crypto_sha1h, 0) WRAP_2M_2_OOL_FN(gen_SHA1SU1, gen_helper_crypto_sha1su1, 0) WRAP_2M_2_OOL_FN(gen_SHA256SU0, gen_helper_crypto_sha256su0, 0) diff --git a/target/arm/tcg/translate-sve.c b/target/arm/tcg/translate-sve.c index 225d358922..8350a65f31 100644 --- a/target/arm/tcg/translate-sve.c +++ b/target/arm/tcg/translate-sve.c @@ -7151,12 +7151,14 @@ TRANS_FEAT(USDOT_zzzz, aa64_sve_i8mm, gen_gvec_ool_= arg_zzzz, a->esz =3D=3D 2 ? gen_helper_gvec_usdot_b : NULL, a, 0) =20 TRANS_FEAT_NONSTREAMING(AESMC, aa64_sve2_aes, gen_gvec_ool_zz, - gen_helper_crypto_aesmc, a->rd, a->rd, a->decrypt) + gen_helper_crypto_aesmc, a->rd, a->rd, 0) +TRANS_FEAT_NONSTREAMING(AESIMC, aa64_sve2_aes, gen_gvec_ool_zz, + gen_helper_crypto_aesimc, a->rd, a->rd, 0) =20 TRANS_FEAT_NONSTREAMING(AESE, aa64_sve2_aes, gen_gvec_ool_arg_zzz, - gen_helper_crypto_aese, a, false) + gen_helper_crypto_aese, a, 0) TRANS_FEAT_NONSTREAMING(AESD, aa64_sve2_aes, gen_gvec_ool_arg_zzz, - gen_helper_crypto_aese, a, true) + gen_helper_crypto_aesd, a, 0) =20 TRANS_FEAT_NONSTREAMING(SM4E, aa64_sve2_sm4, gen_gvec_ool_arg_zzz, gen_helper_crypto_sm4e, a, 0) --=20 2.34.1 From nobody Tue May 14 18:40:19 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1688379077; cv=none; d=zohomail.com; s=zohoarc; b=FTPwT0Uh3wb066FdkfSLRQYSN/dZqHv8+YJ68LgwrxwJ/4wSbmjpOKDoD8oeLyn5kANP3BpgKi+odBgdCO5RxMVaBXTzWXaZlwq7TNzVsw+SVQ5dvdBch0QgLDJw0ISFj6ndMmwyEG2s/xUAE5xFCsk3+kUQrRyJV5WWbPgv+b8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1688379077; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=mjZWs2Y+Z9mHPnjXNP6VJFYBwuCl2SNNXRyLlkiAXFM=; b=hZLAxyjlhdi4CP9o3J+npzKZi6mqHpHshr0N6hYcBMER+Ytmm9aH+nN8q3/jfENEy9ZJnM3IYvult9dW4kPkEDtvwjky1IwJpPDCCietoo2bQ//BqQHP4sy5qYBtjj/FOuLIYFK2go/XpEjqGpSwrQ/Giq9YGKxtpLLoXX/kfLQ= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1688379077926370.8667026282968; Mon, 3 Jul 2023 03:11:17 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qGGS5-0003bf-NS; Mon, 03 Jul 2023 06:06:37 -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 1qGGRc-00033I-SX for qemu-devel@nongnu.org; Mon, 03 Jul 2023 06:06:08 -0400 Received: from mail-wr1-x434.google.com ([2a00:1450:4864:20::434]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qGGRK-0005v7-Hs for qemu-devel@nongnu.org; Mon, 03 Jul 2023 06:06:08 -0400 Received: by mail-wr1-x434.google.com with SMTP id ffacd0b85a97d-3143b88faebso153096f8f.3 for ; Mon, 03 Jul 2023 03:05:50 -0700 (PDT) Received: from stoup.home (91.232.79.188.dynamic.jazztel.es. [188.79.232.91]) by smtp.gmail.com with ESMTPSA id t5-20020a05600001c500b00313f7b077fesm18446562wrx.59.2023.07.03.03.05.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 03 Jul 2023 03:05:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1688378749; x=1690970749; 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=mjZWs2Y+Z9mHPnjXNP6VJFYBwuCl2SNNXRyLlkiAXFM=; b=EhHpdifngm5xRIl5rDfI4Fa8GsjtJ9BDXqwUtHz1uaNJbqAM1GPTChzTyjWSVKpoAy xx6vCx6/8M3I+EmUCqhDJmH1wci0Np90jVjpzociSeoX8bmeE1kGu6VuSfBeV7EETC6E V6j7wv5lhTSaBsoCk9GG7KZf5UDUSq/8XO93hg99lYDtm/56xURudUdwa7BiRT1yBrvT 2qNFZg7CkMQY908PBwn8B2DnYRFHAvoOcgtU0d6gVngf6AId3Hhpz73HSuSH8R4Y2vLP MlL4jPc1zFVbqTXd6Dx3U4Nm9fjP85yaTBLmzTGwFkkQY87cn8qLJHVds4K9i68l5pDL rPWQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1688378749; x=1690970749; 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=mjZWs2Y+Z9mHPnjXNP6VJFYBwuCl2SNNXRyLlkiAXFM=; b=CrAn8Dx4heOYIKEsRX68aJdOtMik5mJjECSg3HRLQ0UdTTiP3DdZd7GD9HkQyyoR/Z 5Kznc8lpsTpqOy/DLBlEHjxZEJ6FiV9kEsnhmEXwSqv1TOLYUmn8OVd4t5SgvDGWN1WD FuIeQVmtXnuqV3SrKXIVJqh5PHs2Ufex9E3IYErj+PGvuBWwkbLnsQAKR7XQbfpGef8Z LZ4VVq3ao/C3mDHjT3BWxpkZWEONlopCIZ4aW0/87hKCVODokceFnLkOgpflwWHPY9TQ i88lFLAHHJ7bkprdf4GE6/asJI3hHmRfLAWoJF3+esasvYAisjfIW7NuUU6zVXTrzGfC XeSQ== X-Gm-Message-State: ABy/qLbRdo4bWoHGirCmTX/XyME1rMBfn3TYYTJhRO2oV/Zr7umjMWlV W2yYyfEUjcPpyyuottOizozrKFJAdYvQ4glpOC14LA== X-Google-Smtp-Source: APBJJlEtGMclBgAnZsu482t+L8NtcRGHo/yF0M0Z7WHu896twwVVgcR03cvQVzPQY90hm/9zkULYcg== X-Received: by 2002:a5d:6190:0:b0:314:c2a:31c5 with SMTP id j16-20020a5d6190000000b003140c2a31c5mr9265936wru.19.1688378748960; Mon, 03 Jul 2023 03:05:48 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: qemu-arm@nongnu.org, qemu-riscv@nongnu.org, pbonzini@redhat.com, eduardo@habkost.net, alistair.francis@wdc.com, danielhb413@gmail.com Subject: [PATCH v4 25/37] target/arm: Use aesenc_SB_SR_AK Date: Mon, 3 Jul 2023 12:05:08 +0200 Message-Id: <20230703100520.68224-26-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230703100520.68224-1-richard.henderson@linaro.org> References: <20230703100520.68224-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::434; envelope-from=richard.henderson@linaro.org; helo=mail-wr1-x434.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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1688379080049100007 Content-Type: text/plain; charset="utf-8" This implements the AESE instruction. Signed-off-by: Richard Henderson Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- target/arm/tcg/crypto_helper.c | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/target/arm/tcg/crypto_helper.c b/target/arm/tcg/crypto_helper.c index 75882d9ea3..00f3b21507 100644 --- a/target/arm/tcg/crypto_helper.c +++ b/target/arm/tcg/crypto_helper.c @@ -15,6 +15,7 @@ #include "exec/helper-proto.h" #include "tcg/tcg-gvec-desc.h" #include "crypto/aes.h" +#include "crypto/aes-round.h" #include "crypto/sm4.h" #include "vec_internal.h" =20 @@ -45,6 +46,8 @@ static void clear_tail_16(void *vd, uint32_t desc) clear_tail(vd, opr_sz, max_sz); } =20 +static const AESState aes_zero =3D { }; + static void do_crypto_aese(uint64_t *rd, uint64_t *rn, uint64_t *rm, const uint8_t *sbox, const uint8_t *shift) { @@ -70,7 +73,26 @@ void HELPER(crypto_aese)(void *vd, void *vn, void *vm, u= int32_t desc) intptr_t i, opr_sz =3D simd_oprsz(desc); =20 for (i =3D 0; i < opr_sz; i +=3D 16) { - do_crypto_aese(vd + i, vn + i, vm + i, AES_sbox, AES_shifts); + AESState *ad =3D (AESState *)(vd + i); + AESState *st =3D (AESState *)(vn + i); + AESState *rk =3D (AESState *)(vm + i); + AESState t; + + /* + * Our uint64_t are in the wrong order for big-endian. + * The Arm AddRoundKey comes first, while the API AddRoundKey + * comes last: perform the xor here, and provide zero to API. + */ + if (HOST_BIG_ENDIAN) { + t.d[0] =3D st->d[1] ^ rk->d[1]; + t.d[1] =3D st->d[0] ^ rk->d[0]; + aesenc_SB_SR_AK(&t, &t, &aes_zero, false); + ad->d[0] =3D t.d[1]; + ad->d[1] =3D t.d[0]; + } else { + t.v =3D st->v ^ rk->v; + aesenc_SB_SR_AK(ad, &t, &aes_zero, false); + } } clear_tail(vd, opr_sz, simd_maxsz(desc)); } --=20 2.34.1 From nobody Tue May 14 18:40:19 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1688378985; cv=none; d=zohomail.com; s=zohoarc; b=eop92EZwweggYfDpB3XuMj9YxcOypvnI6TiP/FYfQTXo09QnMH1J9HGvrpNGD+1zLasqyRzb9YPPHsxX/vVkBCNEQf+srS03H4izS4Fjhj3ZmVZNZ/rtKRkOBpi4Rd6ZfRLKzHDulKE5g0AStRu0IQoHAfCcTMn1YKGGmaAObVM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1688378985; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=UEsv77WByzgBc2oRedydI0QuEnu20ntgk1P70X2mStE=; b=dGxM+pHGZ+fLiGn9UM6+BlsfC0V+vD+q1VbIkpjmif7BjRoTvdGrub5Nuh/9IFV6xbQd6DRkjxx+KEgv1LHCwu9GG0IKlLr1QMhxzthwsAW48LHIHgQ6I2hzcxUiYVbUGPd1MH2BFhcbmdCYNZKPh7vhn+tUQDfQE6m2D/f0aYk= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1688378985454910.2233220025406; Mon, 3 Jul 2023 03:09:45 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qGGRi-00039m-JM; Mon, 03 Jul 2023 06:06:14 -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 1qGGRc-00033M-U8 for qemu-devel@nongnu.org; Mon, 03 Jul 2023 06:06:08 -0400 Received: from mail-wr1-x42e.google.com ([2a00:1450:4864:20::42e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qGGRL-0005vf-Cj for qemu-devel@nongnu.org; Mon, 03 Jul 2023 06:06:08 -0400 Received: by mail-wr1-x42e.google.com with SMTP id ffacd0b85a97d-3112f5ab0b1so4700798f8f.0 for ; Mon, 03 Jul 2023 03:05:50 -0700 (PDT) Received: from stoup.home (91.232.79.188.dynamic.jazztel.es. [188.79.232.91]) by smtp.gmail.com with ESMTPSA id t5-20020a05600001c500b00313f7b077fesm18446562wrx.59.2023.07.03.03.05.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 03 Jul 2023 03:05:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1688378750; x=1690970750; 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=uHiYfhKwnw1I57OcVIqitUWlypy7M1mJKy2Gi3bSQEDUl1aZsd5hUSfUazumXVLdgt GxOM3oU+yuEaOnay7X26f8fIa1Gckle9bn8FbdU8p1uwSb3bnKxO/rWVpQl29J15bXwy Wvs3pJ0ecXo9C8Qhci1ECN98iFuoBfALN+SmpN2Y7hAUj/lQm6mixz46+ohjWA43KrlO GELj/WyLv+IQ22rvqs6UhO1pcHZTCg6G9SuWSBeVD1rmdysI+eZkfbqlc8Uf0tM8nY6h JwMeYC4y8FuXC/wO6rG/ajeyioI703PZIRQ7pXN5G53zaD6ffNWd75TZoCzqZKA3TiPL FjuQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1688378750; x=1690970750; 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=bkYxBYyv1lUtc6Zad9S7buTIhbDaRIHK/65rh8SRAgLCxsHT4lYTo+7EOvw6ObFtcN ek16nukioTQkZlbG3PShZoSvrztEulCCQNi4MWCIUdoHSMFYcN8r1lpQrQBeaLnxCDN/ uakivEeHYfMM3ysK7lhI/M5QUBX/bwm5yTk6qdWTwG3IW9RQ/LnehcdYwyIhykjWvzRs fH8wAjbya8Bn8fgUolyuypFBqGKZdli93NoRikcu+gJBmNmpy8Tynob8QujsKJoU9ZcZ HNzLjp8Ydv+p3WTzPGvfIXA56tyioG9TFLxUZY/zs6LuFTCYVoEC8wbgEbHPY7QDX3aj bJSQ== X-Gm-Message-State: ABy/qLYNxf9lRlVnSIoQdGmPcefGSHcCH782psguH8gRc3j6bQS/onBI hHqDNgnBGNnHDmmLxL221paxjKmGFPY31B89+diTPA== X-Google-Smtp-Source: APBJJlHoOhbvt0onrFM6tbP+ySa5ZsNwjXCHli/C7yoaHHJcCnRTwx+GRrNqSEk+F89WZuKcuPfkEQ== X-Received: by 2002:a5d:4a09:0:b0:30e:3f54:f8c9 with SMTP id m9-20020a5d4a09000000b0030e3f54f8c9mr7207560wrq.10.1688378749888; Mon, 03 Jul 2023 03:05:49 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: qemu-arm@nongnu.org, qemu-riscv@nongnu.org, pbonzini@redhat.com, eduardo@habkost.net, alistair.francis@wdc.com, danielhb413@gmail.com Subject: [PATCH v4 26/37] target/arm: Use aesdec_ISB_ISR_AK Date: Mon, 3 Jul 2023 12:05:09 +0200 Message-Id: <20230703100520.68224-27-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230703100520.68224-1-richard.henderson@linaro.org> References: <20230703100520.68224-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::42e; envelope-from=richard.henderson@linaro.org; helo=mail-wr1-x42e.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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1688378985750100001 Content-Type: text/plain; charset="utf-8" This implements the AESD instruction. Signed-off-by: Richard Henderson Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- 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) =20 static const AESState aes_zero =3D { }; =20 -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 =3D { .l =3D { rm[0], rm[1] } }; - union CRYPTO_STATE st =3D { .l =3D { rn[0], rn[1] } }; - int i; - - /* xor state vector with round key */ - rk.l[0] ^=3D st.l[0]; - rk.l[1] ^=3D st.l[1]; - - /* combine ShiftRows operation and sbox substitution */ - for (i =3D 0; i < 16; i++) { - CR_ST_BYTE(st, i) =3D sbox[CR_ST_BYTE(rk, shift[i])]; - } - - rd[0] =3D st.l[0]; - rd[1] =3D st.l[1]; -} - void HELPER(crypto_aese)(void *vd, void *vn, void *vm, uint32_t desc) { intptr_t i, opr_sz =3D 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 =3D simd_oprsz(desc); =20 for (i =3D 0; i < opr_sz; i +=3D 16) { - do_crypto_aese(vd + i, vn + i, vm + i, AES_isbox, AES_ishifts); + AESState *ad =3D (AESState *)(vd + i); + AESState *st =3D (AESState *)(vn + i); + AESState *rk =3D (AESState *)(vm + i); + AESState t; + + /* Our uint64_t are in the wrong order for big-endian. */ + if (HOST_BIG_ENDIAN) { + t.d[0] =3D st->d[1] ^ rk->d[1]; + t.d[1] =3D st->d[0] ^ rk->d[0]; + aesdec_ISB_ISR_AK(&t, &t, &aes_zero, false); + ad->d[0] =3D t.d[1]; + ad->d[1] =3D t.d[0]; + } else { + t.v =3D st->v ^ rk->v; + aesdec_ISB_ISR_AK(ad, &t, &aes_zero, false); + } } clear_tail(vd, opr_sz, simd_maxsz(desc)); } --=20 2.34.1 From nobody Tue May 14 18:40:19 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1688379200; cv=none; d=zohomail.com; s=zohoarc; b=Nl4/ksejuOwbq/zBKPBtaEbmmjRXt8sACbc8BbGhGT4ObepDM4/l4CHjxv2UKuJUzoqMlN3QReODZ7cQ0Mh/zIYhMaAnsYftiu/Ropu0IqQYh867mtQHFa8071KeA0mobx+ViYjL/2P9egZkgfwhRbssIFRqEgbUPSkNa73cf1s= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1688379200; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=N6iXZSXnCLQtjnIuP74mgzpVObleAywaFeG7GQpsIEc=; b=fkGplVAFwHaUbB+TkEMj+zTFgtCeh+GiLX9v3mVcj2TJp4YSPisNQM/BigL1XPta3PVs7ViKYdD1t5h7427QOHqchdefz8DFLpDG5dLt5gVcDUt+m5beMOtlP8MaU4obGMG53kWUH8w1JXQ+YkGFZz3pHxlhr0of3XE5Y6S+e6E= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1688379200110653.6812245287756; Mon, 3 Jul 2023 03:13:20 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qGGS8-0003hW-If; Mon, 03 Jul 2023 06:06:40 -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 1qGGRe-00034t-DU for qemu-devel@nongnu.org; Mon, 03 Jul 2023 06:06:10 -0400 Received: from mail-wm1-x335.google.com ([2a00:1450:4864:20::335]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qGGRM-0005wG-7T for qemu-devel@nongnu.org; Mon, 03 Jul 2023 06:06:09 -0400 Received: by mail-wm1-x335.google.com with SMTP id 5b1f17b1804b1-3fbc5d5746cso44951315e9.2 for ; Mon, 03 Jul 2023 03:05:51 -0700 (PDT) Received: from stoup.home (91.232.79.188.dynamic.jazztel.es. [188.79.232.91]) by smtp.gmail.com with ESMTPSA id t5-20020a05600001c500b00313f7b077fesm18446562wrx.59.2023.07.03.03.05.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 03 Jul 2023 03:05:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1688378751; x=1690970751; 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=N6iXZSXnCLQtjnIuP74mgzpVObleAywaFeG7GQpsIEc=; b=WrN0qQr3Zazx9yoN4Z03RfwC8zsb6Om4LlRmCiUNYRXRhl5jZVZKZ3JIrnC/T4urTQ vkNvC+e9ABN235eaKHc59puOUWw4aKeO/putW+S7dLwSSprhscMMqRzQSaLHbqVgn7gt CFv9oFXR+tgJlmECc2DE5m91X1UDjIDPyHbYl34oNbrP2P6RVQMIbdT6RfHj8Xf0h+GA W14ebU/WX1rQBNH05jMQyY62mV/pLu0splzrhBVVohNvqDk1sO/YD7oexSBDE5jdy98p A/86qmQ2Fo86Xmh/R31jFhvoPjxuAfQrjxiuWSRAILIkYLZXW3tEENiP85OiB/CNiJ8k 0HRg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1688378751; x=1690970751; 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=N6iXZSXnCLQtjnIuP74mgzpVObleAywaFeG7GQpsIEc=; b=XBZ2jXfWDU63/Fk3QBF1AoKovDLKuD3jI3I+rhZw1HHciSPUGVM8tsNIhr78Ei6zkK 2MgyxolC8gs97DqrSek+/5VqomelQklWeJYP5Qk5jJe0q5SibOdlhCjW6DOadSXxWOGB qLIZ4EAEI24JCA0kN9Z1GJkHVpqW2iOe+40OvixNRzymEpDZPxvplWL5VQge7oDjpHZW vSq/h09Gfb0GSb8MH9ZsZ96yvBWixHE4MtHZE5bAngPTo7k9ZHRWH7B+u/CDmZ5E+g9D QbDuf1hlcGsfhkNNkj7ESLijGu4BWDQD/Dh6h7qz9qWdV/ZNwa7od3znG/CDEiu0hEcA VUaw== X-Gm-Message-State: AC+VfDyHoUzUuIINe1pZZ6LIZIwB6kdLb5+7wnco5jSWL7tZO4Txe4P1 VuL9HWoyQOjGyAxSexQrx4CMlDqXKmWXJE8ROsmwmg== X-Google-Smtp-Source: ACHHUZ5/Gu5OuuZ7NCGsTPg0xIEEWGcPIJ/24FEtNCWC8fK4PXdtWEZZwVz2aEUO5MpKTIjHdlzwow== X-Received: by 2002:a05:600c:294a:b0:3fb:b3aa:1c8a with SMTP id n10-20020a05600c294a00b003fbb3aa1c8amr9444893wmd.16.1688378750851; Mon, 03 Jul 2023 03:05:50 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: qemu-arm@nongnu.org, qemu-riscv@nongnu.org, pbonzini@redhat.com, eduardo@habkost.net, alistair.francis@wdc.com, danielhb413@gmail.com Subject: [PATCH v4 27/37] target/arm: Use aesenc_MC Date: Mon, 3 Jul 2023 12:05:10 +0200 Message-Id: <20230703100520.68224-28-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230703100520.68224-1-richard.henderson@linaro.org> References: <20230703100520.68224-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::335; envelope-from=richard.henderson@linaro.org; helo=mail-wm1-x335.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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1688379200681100001 Content-Type: text/plain; charset="utf-8" This implements the AESMC instruction. Signed-off-by: Richard Henderson Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- target/arm/tcg/crypto_helper.c | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/target/arm/tcg/crypto_helper.c b/target/arm/tcg/crypto_helper.c index d2cb74e7fc..1952aaac58 100644 --- a/target/arm/tcg/crypto_helper.c +++ b/target/arm/tcg/crypto_helper.c @@ -124,7 +124,20 @@ void HELPER(crypto_aesmc)(void *vd, void *vm, uint32_t= desc) intptr_t i, opr_sz =3D simd_oprsz(desc); =20 for (i =3D 0; i < opr_sz; i +=3D 16) { - do_crypto_aesmc(vd + i, vm + i, AES_mc_rot); + AESState *ad =3D (AESState *)(vd + i); + AESState *st =3D (AESState *)(vm + i); + AESState t; + + /* Our uint64_t are in the wrong order for big-endian. */ + if (HOST_BIG_ENDIAN) { + t.d[0] =3D st->d[1]; + t.d[1] =3D st->d[0]; + aesenc_MC(&t, &t, false); + ad->d[0] =3D t.d[1]; + ad->d[1] =3D t.d[0]; + } else { + aesenc_MC(ad, st, false); + } } clear_tail(vd, opr_sz, simd_maxsz(desc)); } --=20 2.34.1 From nobody Tue May 14 18:40:19 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1688379086; cv=none; d=zohomail.com; s=zohoarc; b=EYOikS0Y/ClszP+Ynjq6aTvpjHLhQWclNOybJMGD/tq5N+ZaeiMCfhh/OPRcRdBrYTgwYv9V63k7WkQUUrpd7aH0KzuYUre/+dfdthmnbai47hUnw200cHOPYRKTjHt+QrWRM/IQHKqgw6uPvOqo593NCIZ6IALyvesvBCwOJlc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1688379086; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=F8c22mTwcbWMs129JigZzKtfDDKQP2XGxgtoSuBUoiE=; b=ZFGEen14qfo941E7r3dJj8radtdHo+iVu3IPZ5pkDZ1mIKlULx+figld8eDjVhVZKtvAb9RpKel0ImsWStVudiLpi//Znbv5mX0UCHn+M9FPJyzmfpb3uHx0eDoSJ90u072vtqOePiK28iK7KtjO3e1/q0cnmfkbyh/LKtqqxRk= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1688379086382266.09390564445437; Mon, 3 Jul 2023 03:11:26 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qGGSD-0003k2-Vw; Mon, 03 Jul 2023 06:06:46 -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 1qGGRe-000358-MP for qemu-devel@nongnu.org; Mon, 03 Jul 2023 06:06:10 -0400 Received: from mail-wr1-x42f.google.com ([2a00:1450:4864:20::42f]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qGGRN-0005wl-7u for qemu-devel@nongnu.org; Mon, 03 Jul 2023 06:06:10 -0400 Received: by mail-wr1-x42f.google.com with SMTP id ffacd0b85a97d-312824aa384so4702882f8f.1 for ; Mon, 03 Jul 2023 03:05:52 -0700 (PDT) Received: from stoup.home (91.232.79.188.dynamic.jazztel.es. [188.79.232.91]) by smtp.gmail.com with ESMTPSA id t5-20020a05600001c500b00313f7b077fesm18446562wrx.59.2023.07.03.03.05.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 03 Jul 2023 03:05:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1688378752; x=1690970752; 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=F8c22mTwcbWMs129JigZzKtfDDKQP2XGxgtoSuBUoiE=; b=KwPKwXtHiSwM+qNiiC3T1qjUtOewzs46RoKAckypIPKVGgw15pHZcBdZ2LGdyiAXNr bii5d1k+heY0WYib0YxJKw18eKcUF3VPf/reMz70l1ytQDiU/KfdEpG93rDFJhLfRsNb fNkPTDDalV2AsugccbUhG5VjdcbpNbJFU8hJC4yrX7jOvPHEK2GFFdXquNfegBRqy8is ICH9vhCsEVop31QBMq9ZplVWfdvR0bHvyDf0GLeG+084Hei3UzFcVTJ5ltQWhFd8XsVJ 6LiXXBIPtfyfcBB7rI+/KFiuMEOoMz5oxc+nzJvRDiZugZFMNDVNX2/b82nv/grHmNd6 XA+A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1688378752; x=1690970752; 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=F8c22mTwcbWMs129JigZzKtfDDKQP2XGxgtoSuBUoiE=; b=MjJdAh2e90MczhIMBr3bYqDEUy4Qygn44F3WTz+hXhpPzXQESB0v87t0IZTCQQRUiG qfT9rKnxh+OT4Dij3UOWX+zWvBAIPAnZVjhvoNviPEswGKM2EVIEzf56sy90A7NDjFSx A1DhqwFDmmUsfZVKT+0e5mF9aEOsAP/3YR07jY+U8S+a/opc/pvJTUuMAMvoAMGjQex7 uGgyIBLH3aO/GkYKD5sq8Pz9rN7vrLFfsEP+SJ0JlkZwEAI7w8zv0iINvzUbp+wWg/2b k2zpc0yCQhuHQLYofyyLFbJwyPo/Zm0lp5Ci7jfcVPfHCYoLgJLefafYbSwM90m3KrKQ 35DA== X-Gm-Message-State: ABy/qLbFRJJ59Jpcvji8InFnZ5osKQlqK7cYM0cQcbqxZSmSF6DeUyHs hyUMpY+BFOir77ECa3M/1F3hDDSnzyKWnBtxwuSJyQ== X-Google-Smtp-Source: APBJJlHE20l3UCxNvIHA4svgDJuCF6thqTuAEkxV/x7MWYyAou6RlNbmvC4wv1eTbHLdxObaERm/1A== X-Received: by 2002:adf:fcc5:0:b0:314:1ba7:fb29 with SMTP id f5-20020adffcc5000000b003141ba7fb29mr7766310wrs.1.1688378751832; Mon, 03 Jul 2023 03:05:51 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: qemu-arm@nongnu.org, qemu-riscv@nongnu.org, pbonzini@redhat.com, eduardo@habkost.net, alistair.francis@wdc.com, danielhb413@gmail.com Subject: [PATCH v4 28/37] target/arm: Use aesdec_IMC Date: Mon, 3 Jul 2023 12:05:11 +0200 Message-Id: <20230703100520.68224-29-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230703100520.68224-1-richard.henderson@linaro.org> References: <20230703100520.68224-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::42f; envelope-from=richard.henderson@linaro.org; helo=mail-wr1-x42f.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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1688379087469100003 Content-Type: text/plain; charset="utf-8" This implements the AESIMC instruction. We have converted everything to crypto/aes-round.h; crypto/aes.h is no longer needed. Signed-off-by: Richard Henderson Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- target/arm/tcg/crypto_helper.c | 33 ++++++++++++++------------------- 1 file changed, 14 insertions(+), 19 deletions(-) diff --git a/target/arm/tcg/crypto_helper.c b/target/arm/tcg/crypto_helper.c index 1952aaac58..fdd70abbfd 100644 --- a/target/arm/tcg/crypto_helper.c +++ b/target/arm/tcg/crypto_helper.c @@ -14,7 +14,6 @@ #include "cpu.h" #include "exec/helper-proto.h" #include "tcg/tcg-gvec-desc.h" -#include "crypto/aes.h" #include "crypto/aes-round.h" #include "crypto/sm4.h" #include "vec_internal.h" @@ -102,23 +101,6 @@ void HELPER(crypto_aesd)(void *vd, void *vn, void *vm,= uint32_t desc) clear_tail(vd, opr_sz, simd_maxsz(desc)); } =20 -static void do_crypto_aesmc(uint64_t *rd, uint64_t *rm, const uint32_t *mc) -{ - union CRYPTO_STATE st =3D { .l =3D { rm[0], rm[1] } }; - int i; - - for (i =3D 0; i < 16; i +=3D 4) { - CR_ST_WORD(st, i >> 2) =3D - mc[CR_ST_BYTE(st, i)] ^ - rol32(mc[CR_ST_BYTE(st, i + 1)], 8) ^ - rol32(mc[CR_ST_BYTE(st, i + 2)], 16) ^ - rol32(mc[CR_ST_BYTE(st, i + 3)], 24); - } - - rd[0] =3D st.l[0]; - rd[1] =3D st.l[1]; -} - void HELPER(crypto_aesmc)(void *vd, void *vm, uint32_t desc) { intptr_t i, opr_sz =3D simd_oprsz(desc); @@ -147,7 +129,20 @@ void HELPER(crypto_aesimc)(void *vd, void *vm, uint32_= t desc) intptr_t i, opr_sz =3D simd_oprsz(desc); =20 for (i =3D 0; i < opr_sz; i +=3D 16) { - do_crypto_aesmc(vd + i, vm + i, AES_imc_rot); + AESState *ad =3D (AESState *)(vd + i); + AESState *st =3D (AESState *)(vm + i); + AESState t; + + /* Our uint64_t are in the wrong order for big-endian. */ + if (HOST_BIG_ENDIAN) { + t.d[0] =3D st->d[1]; + t.d[1] =3D st->d[0]; + aesdec_IMC(&t, &t, false); + ad->d[0] =3D t.d[1]; + ad->d[1] =3D t.d[0]; + } else { + aesdec_IMC(ad, st, false); + } } clear_tail(vd, opr_sz, simd_maxsz(desc)); } --=20 2.34.1 From nobody Tue May 14 18:40:19 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1688379275; cv=none; d=zohomail.com; s=zohoarc; b=iEK426O4ZRwLi1eEPZ3RfzoPz+LPPEgmLArGa5ZAOTxXrLsS2lvGrfUxsJIk/qsDAvpjwQcsPQgWDLXVJ1zjbhThlDbwQL4BFTROdmo3E2PtH2gL+i036obvuy/DxlP6mXt1G9boCS63GOmnkoVQCxJpesjs/BsImVSwDXBLxew= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1688379275; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=pqEpHLv387miC8e5l2/HE3hMgLmxzv9wY41InkeK+gI=; b=Jf/9kueEZWk9XNJXbgkE2OA86CSQbuLd1HkBxbcxX/FOFSB5kdfWfFIXH2lIK3d+s9M4Dh8vMK1iO6zyXw34mAAg6+7UYMh2FHym9aXjYhaPOnvkY45StjW58Gd0B1JiLgWZztWxscD2tCFcLW8zukL6seFnpO3wO/lzX+rWxMI= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 16883792751351016.2216369134828; Mon, 3 Jul 2023 03:14:35 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qGGS8-0003gE-4V; Mon, 03 Jul 2023 06:06:40 -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 1qGGRf-00036I-IM for qemu-devel@nongnu.org; Mon, 03 Jul 2023 06:06:11 -0400 Received: from mail-wm1-x329.google.com ([2a00:1450:4864:20::329]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qGGRO-0005xM-3K for qemu-devel@nongnu.org; Mon, 03 Jul 2023 06:06:11 -0400 Received: by mail-wm1-x329.google.com with SMTP id 5b1f17b1804b1-3fbc5d5746cso44951675e9.2 for ; Mon, 03 Jul 2023 03:05:53 -0700 (PDT) Received: from stoup.home (91.232.79.188.dynamic.jazztel.es. [188.79.232.91]) by smtp.gmail.com with ESMTPSA id t5-20020a05600001c500b00313f7b077fesm18446562wrx.59.2023.07.03.03.05.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 03 Jul 2023 03:05:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1688378752; x=1690970752; 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=pqEpHLv387miC8e5l2/HE3hMgLmxzv9wY41InkeK+gI=; b=eRaO08ZrDSuzrYp5BuQ8239RqbroaXpv62TZftzya4xyfWZ/pv3a/OfQIK1aCcwJZ3 yCXfLyGJm9p2USDzqFkHExVZ7/j9Ei6Vj4hUxLFughLgCj8kVtVn+uv+onAPbhGcQfMH XA3dJnemVe1rFO+5/pEaBcgGbWBWIh+ax1qvLhr7t0W/Gi6Z8x867zxMVwy3UPbL/2Ce LglqD9dgoDoTH2IKrzDvQ+Lrm868YEIN3Fiqh+Urgml1XnUphGlEqtSs1aj8THRHduu8 akt7plmLkGEAW2sDV/odopa6KIDyZIUYuJGnlYDxmbtOGjD9ufsWRFt0J1ByD7lnQ+lU bpgg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1688378752; x=1690970752; 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=pqEpHLv387miC8e5l2/HE3hMgLmxzv9wY41InkeK+gI=; b=LMQA/SUKTe+UWflHB8Z5EkqrVwaqMrQUykUY9M+WYkvfu3gG8FelJgAVmxgCPWYnWt G/0cQAu5uu15fThIwrlhcapXIrwdcG/1XHRN0RRFjoXbHDZ2uvmoq7mQQNmRIdZWEAfz X3ikBSwR3X5cIkJRfM8nWZ1i/YhYIMJdPwf5S5YoLb6N702ypbtCLv2Z9bKUJv1fcdXG JB5efvfr2RdUF+KsGzxxd03EZ0aVMXVra5zTEqfzzWSjUJ97R9HqXLyT8h/gUx03HZba D3xaNKNu2e3tCGnodP5PKVZeWpp4AIC+neofFhoMf1CYJT4HEBzApobQDcvD7w8/fgu7 7dBA== X-Gm-Message-State: AC+VfDxTlxLOeWxWfPURhKOwIQhxEU/s1d219d2FcapejTwNG3SEyh47 bsObQsHTs9nwETYwg9kfLb6xlFbYXP56m21f82fKyw== X-Google-Smtp-Source: ACHHUZ54TQr3KHjx3kUgsMExtgYRezoDG4hOV35YxOFbMzO8obAmcBz06m3y4qk2YbX4WPodFu5Phg== X-Received: by 2002:a7b:cb4d:0:b0:3f9:b17a:cb61 with SMTP id v13-20020a7bcb4d000000b003f9b17acb61mr9585654wmj.13.1688378752763; Mon, 03 Jul 2023 03:05:52 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: qemu-arm@nongnu.org, qemu-riscv@nongnu.org, pbonzini@redhat.com, eduardo@habkost.net, alistair.francis@wdc.com, danielhb413@gmail.com Subject: [PATCH v4 29/37] target/riscv: Use aesenc_SB_SR_AK Date: Mon, 3 Jul 2023 12:05:12 +0200 Message-Id: <20230703100520.68224-30-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230703100520.68224-1-richard.henderson@linaro.org> References: <20230703100520.68224-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::329; envelope-from=richard.henderson@linaro.org; helo=mail-wm1-x329.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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1688379278247100001 Content-Type: text/plain; charset="utf-8" This implements the AES64ES instruction. Signed-off-by: Richard Henderson Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- target/riscv/crypto_helper.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/target/riscv/crypto_helper.c b/target/riscv/crypto_helper.c index 2ef30281b1..b072fed3e2 100644 --- a/target/riscv/crypto_helper.c +++ b/target/riscv/crypto_helper.c @@ -22,6 +22,7 @@ #include "exec/exec-all.h" #include "exec/helper-proto.h" #include "crypto/aes.h" +#include "crypto/aes-round.h" #include "crypto/sm4.h" =20 #define AES_XTIME(a) \ @@ -136,6 +137,8 @@ target_ulong HELPER(aes32dsi)(target_ulong rs1, target_= ulong rs2, AES_INVMIXBYTE(COL, 1, 2, 3, 0) << 8 | \ AES_INVMIXBYTE(COL, 0, 1, 2, 3) << 0) =20 +static const AESState aes_zero =3D { }; + static inline target_ulong aes64_operation(target_ulong rs1, target_ulong = rs2, bool enc, bool mix) { @@ -200,7 +203,12 @@ target_ulong HELPER(aes64esm)(target_ulong rs1, target= _ulong rs2) =20 target_ulong HELPER(aes64es)(target_ulong rs1, target_ulong rs2) { - return aes64_operation(rs1, rs2, true, false); + AESState t; + + t.d[HOST_BIG_ENDIAN] =3D rs1; + t.d[!HOST_BIG_ENDIAN] =3D rs2; + aesenc_SB_SR_AK(&t, &t, &aes_zero, false); + return t.d[HOST_BIG_ENDIAN]; } =20 target_ulong HELPER(aes64ds)(target_ulong rs1, target_ulong rs2) --=20 2.34.1 From nobody Tue May 14 18:40:19 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1688379254; cv=none; d=zohomail.com; s=zohoarc; b=nJ2SKm+ss5kxD7Oi+J3bCBnzIukMIPeVO3jDWAdRZuad0GPR5qpFOj1qo+7oUnU/EfcsdB8koTXZUaqDhPpMPYMRKrTsb+gvbsXnL1HA+16VE55KmBXeo1w0HKTGzHVuC+T8sFEZr9pdbakjqZTn5Z1w62xi8YTPnhQPMUnwUt8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1688379254; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=QRqjQC8v/J/3z0IiE+GLS9BAOlnmnUcZezvum6TPI3k=; b=WlfmjZBLL1jXE0d3gYo2IQKmek9jyKqXO4sAPlpEfHoX93CxfT40EES795mX65LTo2Hy74Qkqf9K6krRwi3IqY/QYSgpFscVTk5TpJLDZG4TMYSYX5C16na3tV7gIR1v5vl2TfZ7UiPDLhSLGXM+quraDqhe6y5RojAjkmbsTtg= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1688379254217333.5447638103984; Mon, 3 Jul 2023 03:14:14 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qGGS8-0003gw-D9; Mon, 03 Jul 2023 06:06:40 -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 1qGGRg-00037c-4b for qemu-devel@nongnu.org; Mon, 03 Jul 2023 06:06:12 -0400 Received: from mail-wr1-x42c.google.com ([2a00:1450:4864:20::42c]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qGGRP-0005xv-47 for qemu-devel@nongnu.org; Mon, 03 Jul 2023 06:06:11 -0400 Received: by mail-wr1-x42c.google.com with SMTP id ffacd0b85a97d-3141140f51bso5747773f8f.1 for ; Mon, 03 Jul 2023 03:05:54 -0700 (PDT) Received: from stoup.home (91.232.79.188.dynamic.jazztel.es. [188.79.232.91]) by smtp.gmail.com with ESMTPSA id t5-20020a05600001c500b00313f7b077fesm18446562wrx.59.2023.07.03.03.05.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 03 Jul 2023 03:05:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1688378753; x=1690970753; 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=QRqjQC8v/J/3z0IiE+GLS9BAOlnmnUcZezvum6TPI3k=; b=CyHtq4SuWKPtI0enq0XMRv9MmHffCsVArxB+WqMcFwOePyiyBKr7+ngSf1TchOnl7X LAqaN0+c+/DRVoHb/6FWoHCUqhtI3erVZ1zldHnSwOtPJogJOPn5n/SvLV02nvYRQAup eqk3dr/aeKoIAZ24Fc17rnpqo4Fm7LdzbbPTVaVobK4ChNXqmfe8mv5z2PSZdQPGGnrs mnnOIodGxXKI0z4TkWpUBARUaAN+osWtHDhiVZblyUDzRyWWzZBzizm1q6leYKPtXV/4 RuUv+bV0wvN93xyfNrL7D3vRlQg6UjO4dAQViMJA/6+vDLith9OlnljFy3HrvZOJ5d6c 38Nw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1688378753; x=1690970753; 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=QRqjQC8v/J/3z0IiE+GLS9BAOlnmnUcZezvum6TPI3k=; b=EgNgO9ozIF0XC3/mPl38BsLpG9PhjDcUGtCmJvPUmk7S54ShdsNIluXdmQLlIiHq6K +axBYEUJMST8h2m+LzkVq0wokWHeUB1QlZ45rHJIW0SY2NeHCfBZH9SVvRc55F3bnpzE vyTGnWp4J4INhbC0b9Qn4tDayF/KnjoSPVS8WKPcPcWCPE9E8ltqMzwN6zT9sJSpQwEX 8lIPluylbGPqleu6RdCjYUWgnm5lGGZQblAIiVUjRdg9ubQKY/ndTl8XUsXAx3pAdTWx nsiB6MNLZK7Iw7zca2PleKal1hsgXfy6Di3/YBdjs+Co7itUa+lgQxKM4dHt1DwKqIgY vkLQ== X-Gm-Message-State: ABy/qLYzZrmx5zjrl4OIVHveQrLvYbjOPR8SpmMzc5QNYScN6RRhd68i uU/OEvP5Fu2LbX8kaV41wgz9qko6Kue4q1rLB7+Fsg== X-Google-Smtp-Source: APBJJlE7vUUpB9o9nv2Mz2UGo5rcPzTxUgRtjdi6gFx85Q3YHWJyCBQfkHMqCLvPTk/GPLphZlrbng== X-Received: by 2002:a5d:54c1:0:b0:314:3b78:da77 with SMTP id x1-20020a5d54c1000000b003143b78da77mr430121wrv.29.1688378753715; Mon, 03 Jul 2023 03:05:53 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: qemu-arm@nongnu.org, qemu-riscv@nongnu.org, pbonzini@redhat.com, eduardo@habkost.net, alistair.francis@wdc.com, danielhb413@gmail.com Subject: [PATCH v4 30/37] target/riscv: Use aesdec_ISB_ISR_AK Date: Mon, 3 Jul 2023 12:05:13 +0200 Message-Id: <20230703100520.68224-31-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230703100520.68224-1-richard.henderson@linaro.org> References: <20230703100520.68224-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::42c; envelope-from=richard.henderson@linaro.org; helo=mail-wr1-x42c.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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1688379254856100001 Content-Type: text/plain; charset="utf-8" This implements the AES64DS instruction. Signed-off-by: Richard Henderson Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- target/riscv/crypto_helper.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/target/riscv/crypto_helper.c b/target/riscv/crypto_helper.c index b072fed3e2..e61f7fe1e5 100644 --- a/target/riscv/crypto_helper.c +++ b/target/riscv/crypto_helper.c @@ -213,7 +213,12 @@ target_ulong HELPER(aes64es)(target_ulong rs1, target_= ulong rs2) =20 target_ulong HELPER(aes64ds)(target_ulong rs1, target_ulong rs2) { - return aes64_operation(rs1, rs2, false, false); + AESState t; + + t.d[HOST_BIG_ENDIAN] =3D rs1; + t.d[!HOST_BIG_ENDIAN] =3D rs2; + aesdec_ISB_ISR_AK(&t, &t, &aes_zero, false); + return t.d[HOST_BIG_ENDIAN]; } =20 target_ulong HELPER(aes64dsm)(target_ulong rs1, target_ulong rs2) --=20 2.34.1 From nobody Tue May 14 18:40:19 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1688379075; cv=none; d=zohomail.com; s=zohoarc; b=oEybIYr4Qi0qFzoNLuAgRY7pWANtYEsx6nc+X/p6qwXkxpEurNUorP2i/3vntExmZpY3uOY6HOrmcTko7XmPZFgAfzFr1hnGycfFedEXSwS1J+sOBiEeDzUt+hnrfpE1bvoXdQv17rKoQ6/2cXILP/np5xm9HOU5lKNJf5BBu9Q= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1688379075; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=4pOjdTU6VTsEkj/YPCvRrXcIKg2xairdxfu8316FBss=; b=I26BYym1eXrFt824pZXdukRDjaxLF3OhpecFTE8mj5HaSQmS0ZP5+1tgdG+w6yXVvB3G9txDZWRZK9BUR4Db/9gqqd4ntcimWh/wO0/rG37PQDbcYeKox03UGLLOPwAn9dp4016ZXI8rbZVSHfI6rL4V2FpYsOh2SbNNKwiJ0C4= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1688379075778833.660490012548; Mon, 3 Jul 2023 03:11:15 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qGGSD-0003jm-T2; Mon, 03 Jul 2023 06:06:45 -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 1qGGRh-00038I-1b for qemu-devel@nongnu.org; Mon, 03 Jul 2023 06:06:13 -0400 Received: from mail-wr1-x431.google.com ([2a00:1450:4864:20::431]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qGGRQ-0005yQ-3U for qemu-devel@nongnu.org; Mon, 03 Jul 2023 06:06:12 -0400 Received: by mail-wr1-x431.google.com with SMTP id ffacd0b85a97d-314319c0d3eso1682809f8f.0 for ; Mon, 03 Jul 2023 03:05:55 -0700 (PDT) Received: from stoup.home (91.232.79.188.dynamic.jazztel.es. [188.79.232.91]) by smtp.gmail.com with ESMTPSA id t5-20020a05600001c500b00313f7b077fesm18446562wrx.59.2023.07.03.03.05.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 03 Jul 2023 03:05:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1688378754; x=1690970754; 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=rI/m2BJO7QZr34SY2mUpl0eW4eEQE5b4/CL+OIifeNDRskpqLmaZ7rcMwPvdL2oJEH 1dDEI31s4astHoq7h0lej5E0Uc4Kjd76+nctHh5zio0v+yBKJCzUApvnT/t4HzNVCmqj p/fSyHjdPRiMEVx/ZeJ8byu9Kv5IfZvkfQwRH5bwaH0PPbUnzd79uaAqgpAVz1FJFr+3 ngDIhN53WLXMZOTbITVUdYMtAC4NltnNPVmfjYnF2oD4CtN9H5nz6JF0BBE4c2jJaATU dGOFI+d4chfoYLduou/hj+tpota/dryegtsKf7pm4j8JgWaNDCmt1ewWgpOYx+hFLlNd kDfA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1688378754; x=1690970754; 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=WVuQ13wv2KdiB2a1EbiTJt+WVV67WFLh34Rqv4QnAnSMRU3t1L9cBjDdl8jNzOo9h+ Jkqy9ZH5e9k4T5fxUbOKJZiSWdPEOqnRdtpCF2LCfQcNOImMP/hJaTArCSwnv27ts0kR /E3y8yRXLin3FH88BujaYACehZRj6Gc4T+qXqvYLJD4vrqF0IeTDxP44oFOS2A7c/xu2 kkfFPa0FKZnS10xkxySVqjnJ7Csg6pR8uAwDpz7rN0nvUlsXVPbjnpi62k4If7EsSNMJ BLCrg8Z2/P7ViRYc1YnohBrqMjEYKIZKZW7cIK5ayRw2OawpIcSaj4hP8vDdaEPHctxe w32A== X-Gm-Message-State: ABy/qLZFRZvnrYztyd5vWoSj3S9TLr1jFL93NQO+ZXt7gSeH8dONOG2S xvlLBLSlOBbApN4qXF1gzxDsA3Zdjt3odDXBklURnQ== X-Google-Smtp-Source: APBJJlFRzqSzn52DDoIzuDGd+yB5+kRaHXhEBr4LPPUUe7vqoorQkMM376kLQMSwcF+0G2xUhAoPVQ== X-Received: by 2002:adf:f20d:0:b0:313:f429:f6e9 with SMTP id p13-20020adff20d000000b00313f429f6e9mr7672124wro.60.1688378754667; Mon, 03 Jul 2023 03:05:54 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: qemu-arm@nongnu.org, qemu-riscv@nongnu.org, pbonzini@redhat.com, eduardo@habkost.net, alistair.francis@wdc.com, danielhb413@gmail.com Subject: [PATCH v4 31/37] target/riscv: Use aesdec_IMC Date: Mon, 3 Jul 2023 12:05:14 +0200 Message-Id: <20230703100520.68224-32-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230703100520.68224-1-richard.henderson@linaro.org> References: <20230703100520.68224-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::431; envelope-from=richard.henderson@linaro.org; helo=mail-wr1-x431.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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1688379077494100003 Content-Type: text/plain; charset="utf-8" This implements the AES64IM instruction. Signed-off-by: Richard Henderson Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- 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, targ= et_ulong rnum) =20 target_ulong HELPER(aes64im)(target_ulong rs1) { - uint64_t RS1 =3D rs1; - uint32_t col_0 =3D RS1 & 0xFFFFFFFF; - uint32_t col_1 =3D RS1 >> 32; - target_ulong result; + AESState t; =20 - col_0 =3D AES_INVMIXCOLUMN(col_0); - col_1 =3D AES_INVMIXCOLUMN(col_1); - - result =3D ((uint64_t)col_1 << 32) | col_0; - - return result; + t.d[HOST_BIG_ENDIAN] =3D rs1; + t.d[!HOST_BIG_ENDIAN] =3D 0; + aesdec_IMC(&t, &t, false); + return t.d[HOST_BIG_ENDIAN]; } =20 target_ulong HELPER(sm4ed)(target_ulong rs1, target_ulong rs2, --=20 2.34.1 From nobody Tue May 14 18:40:19 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1688378946; cv=none; d=zohomail.com; s=zohoarc; b=DG0olXRWSnuFyaR8EJFmOc24o9diYvtJMT+bfEjhruTQOKHd4l/jpoHCEp3AJ63etVRxp/QTkzHkiyrJEQVwc27n+rt3N9C/IZ9kqge51cKCtujh9uCwELjSr+L2gABsdYsQ9JYTDlbMB/85A/YGv4Uq1T4hGgSLLVbHhgV6+aA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1688378946; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=D0I8unuNO+OjgsLA/5Ao4N4ndudI6wjx6PBNe+Du5WM=; b=kWM+VpNDkaubmeNRJjleqi2SPuTfAUiI4lZnRpy2KcwBjyqJJXAoQe1CUX+3KfSX+RV1+Efv0vFET+pmlW30W0kmfRsZLHRPi8bpCm8uPI4EVX5LSJgPAeC06Q/qZbSq3pKXyoAM1BEih3uC0U0rT8wtQIMw848wtXhmOjT+34c= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1688378946571149.2278394881962; Mon, 3 Jul 2023 03:09:06 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qGGSG-0003np-3w; Mon, 03 Jul 2023 06:06:48 -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 1qGGRh-00038s-Cx for qemu-devel@nongnu.org; Mon, 03 Jul 2023 06:06:13 -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 1qGGRQ-0005z1-VO for qemu-devel@nongnu.org; Mon, 03 Jul 2023 06:06:13 -0400 Received: by mail-wm1-x32e.google.com with SMTP id 5b1f17b1804b1-3fbc59de0e2so39707455e9.3 for ; Mon, 03 Jul 2023 03:05:56 -0700 (PDT) Received: from stoup.home (91.232.79.188.dynamic.jazztel.es. [188.79.232.91]) by smtp.gmail.com with ESMTPSA id t5-20020a05600001c500b00313f7b077fesm18446562wrx.59.2023.07.03.03.05.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 03 Jul 2023 03:05:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1688378755; x=1690970755; 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=D0I8unuNO+OjgsLA/5Ao4N4ndudI6wjx6PBNe+Du5WM=; b=sSkSvHAzE6szy2s/YZKLXOrmV/DNOM/hfJliwDO20+aCK5yfPlQuvJIK4Ny/+DSezF lGthRG6DVgO6RJDs1l6J6D/txgyszoFL7D/IRwPP9GZiNg9vb2+/B5vLNbG0ci2Rqk/u CoSAlCGp8IwCzYiMp6CI6CsNm9wBojnqcFq0rPtrs1AstbZYBp/8ZK/W+g+7J9weBxUz UZ6wM4yre1SkNLH+gJVD/jlEKHqS3iLWQKEyEXbe4PhtIAVuQ4gcHLb2AhsA7Zuu4fcB gUX1A2XvacoPC5FHFKQnpS2+chQysOE2lofnOAzOzkQ8D6nBnxmKgNzzkZX/rCeUCWAQ BtvQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1688378755; x=1690970755; 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=D0I8unuNO+OjgsLA/5Ao4N4ndudI6wjx6PBNe+Du5WM=; b=c53fKrD1dPgh1iHqm071WV4noin9+lAEmBzvfTpuYENsE71kpWlCQIQf8ukQQ7of9E j28+FjRxxzV5q2JEthkduBM7OZEVLCzt0OQGJHZnybgqctmkDyuc4me8hMsv4KFJ7o1W SiWMUkE5hWQHgkdMAB/pS2X/M4kqzFikVKvXQPtAZquVRzBXbPyzdFNgCf9nvAoHYKm0 Aag9YvwsIqhnRRMBUh0BZu5Dm6fMaGnV8liWW+IFvXqMmQ20cGLJyBky41PkvO2gEgXp hpZfOztfRU7RiA/zuRKCDqDIbIRSLat/HB7yiTxlwdt0uIJUjuVRpzjZAKpIKEcNDf3H JXEA== X-Gm-Message-State: ABy/qLbqAyglBo5M1ykhqQGVA4CfXD5WJaXjJy8mfjNoglpTowp4YPYb ZNvnVZdiwD0Lq666t91PLMT7MvRVdVt9d1hJmUBcOQ== X-Google-Smtp-Source: APBJJlE6r93sX1n9KRDNNAOWMCpOMNGHnRdTwDH/XU8rPqNGSaSYCxjebVbwiQw6r/ni3VsEZq0ITA== X-Received: by 2002:a1c:7207:0:b0:3fb:d1db:545c with SMTP id n7-20020a1c7207000000b003fbd1db545cmr4893277wmc.21.1688378755590; Mon, 03 Jul 2023 03:05:55 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: qemu-arm@nongnu.org, qemu-riscv@nongnu.org, pbonzini@redhat.com, eduardo@habkost.net, alistair.francis@wdc.com, danielhb413@gmail.com Subject: [PATCH v4 32/37] target/riscv: Use aesenc_SB_SR_MC_AK Date: Mon, 3 Jul 2023 12:05:15 +0200 Message-Id: <20230703100520.68224-33-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230703100520.68224-1-richard.henderson@linaro.org> References: <20230703100520.68224-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; 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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1688378948049100001 Content-Type: text/plain; charset="utf-8" This implements the AES64ESM instruction. Signed-off-by: Richard Henderson Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- target/riscv/crypto_helper.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/target/riscv/crypto_helper.c b/target/riscv/crypto_helper.c index 505166ce5a..c036fe8632 100644 --- a/target/riscv/crypto_helper.c +++ b/target/riscv/crypto_helper.c @@ -198,7 +198,12 @@ static inline target_ulong aes64_operation(target_ulon= g rs1, target_ulong rs2, =20 target_ulong HELPER(aes64esm)(target_ulong rs1, target_ulong rs2) { - return aes64_operation(rs1, rs2, true, true); + AESState t; + + t.d[HOST_BIG_ENDIAN] =3D rs1; + t.d[!HOST_BIG_ENDIAN] =3D rs2; + aesenc_SB_SR_MC_AK(&t, &t, &aes_zero, false); + return t.d[HOST_BIG_ENDIAN]; } =20 target_ulong HELPER(aes64es)(target_ulong rs1, target_ulong rs2) --=20 2.34.1 From nobody Tue May 14 18:40:19 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1688379174; cv=none; d=zohomail.com; s=zohoarc; b=DT+xG9UBZs8cSNRWXOi9c+UbknZ2FjnFV6mOaP1/gX65nSPa3nI7tuSQzwkTThMR48OGS+X7eZkMPJsaA9jLNKO75Xvic93HmS5bVGSTjYmJQ+co3iNnNGALj0aBYBEQ1W92IWIQVQVOCjewZTYatN1JbB9jK7oDweVfwomZKQc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1688379174; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=M7z3XVBK0XuXSTZ82FoV8jlvhCwFhDqWNnV/JcekGnU=; b=L2rRWzhJ8XCDyKk6NwWsubRTzAfhfnFZMGd0F8UpOWVb/0kUSZXwVXKJ9XCTqb7LL0L4SHf5HYUz/WBjxRV8qcrG5q07Ed8Hha4KgSHYgzAhOhoZ+XR+TWSMOh9NbMgSyQq0ZNXMpikqBxhEhASw0RJFSbnbAu6hfIXyk8n3uBA= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 16883791743714.691138740002771; Mon, 3 Jul 2023 03:12:54 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qGGSI-0003qG-TI; Mon, 03 Jul 2023 06:06:50 -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 1qGGRi-0003A7-KI for qemu-devel@nongnu.org; Mon, 03 Jul 2023 06:06:14 -0400 Received: from mail-wr1-x429.google.com ([2a00:1450:4864:20::429]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qGGRR-0005zX-Uz for qemu-devel@nongnu.org; Mon, 03 Jul 2023 06:06:14 -0400 Received: by mail-wr1-x429.google.com with SMTP id ffacd0b85a97d-31438512cafso679180f8f.2 for ; Mon, 03 Jul 2023 03:05:57 -0700 (PDT) Received: from stoup.home (91.232.79.188.dynamic.jazztel.es. [188.79.232.91]) by smtp.gmail.com with ESMTPSA id t5-20020a05600001c500b00313f7b077fesm18446562wrx.59.2023.07.03.03.05.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 03 Jul 2023 03:05:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1688378756; x=1690970756; 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=M7z3XVBK0XuXSTZ82FoV8jlvhCwFhDqWNnV/JcekGnU=; b=l0Qy+jWm45AnLdewkPB0cFKRIdircgIUmUBoJQpaiJ5xwLCGdGKgevHToJMojzXEZg ShOPjO8ZN1bzCD4TCCG+1NWwVFFHq9gjXXXZxIIuEhSMs/smZXQ2S0OyeR+nMJ8qkGI6 ETzM6mvAKkrWt5oUJ8W/RKo/AGsEb6fl8ugnAFDeF1KE/uPKBr/elGz6GDoXPBw38Ukd LW3PzzrNmUNp+XtT4rXqoaq6vvjx6V00Wp2+rsyyZP1ad8yESsgotvtfgYPigpACaeiO SguWVSXpkFMOllusg6lItR6bjgGhqdJmfEChZ/XZ3VCUpNlp0AGyXQGROCf8bq0s4tp1 olFQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1688378756; x=1690970756; 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=M7z3XVBK0XuXSTZ82FoV8jlvhCwFhDqWNnV/JcekGnU=; b=acWbHXtviDF31LXqPJXUnC1OJcR+y5cbTuu+QdNxdGKSk/+K5JoV9xJLTciHEIh6tV BMDQ8++HXY1v4GdL0WRhSJO2iBMhNes52fmlDZ66aUBGluREtZ1mNdBDs018ByoxS5Pu h6KS+7ifwp5YAiVtyxy04IKIudKZsaPgNkyTNsLYE+Viz+6ltc+dNxzB/mYe8wHS8TQi YhTiT+XZcNlPWeCrrXvM7VSAON3oIQx0sK+TM80QSKoF2P/xwLc0j0wcIEE6LasfIAgf esnoAeC6/RFvMXOcGEoyNjURGp/mHoaZn5hp3yfSsFjp/tsWhInKSgDOGnrF28blYfu1 nw8g== X-Gm-Message-State: ABy/qLZyR9kXLmFJ5FYd3a8UT/9EquZq5CZB1oKCsBnuz7hNN2tqK00g V7Lr6XypAlSkYLE+dYY89j6NmypryDOAqqm4H/YdlA== X-Google-Smtp-Source: APBJJlGL383d9dDuDCX+oXUy+p6OgBasIevM8BL5+s6QlufvBswzoZO+58j5iDahrK/UK1jOsG43qg== X-Received: by 2002:a5d:68c2:0:b0:314:336e:d4d8 with SMTP id p2-20020a5d68c2000000b00314336ed4d8mr3408480wrw.8.1688378756583; Mon, 03 Jul 2023 03:05:56 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: qemu-arm@nongnu.org, qemu-riscv@nongnu.org, pbonzini@redhat.com, eduardo@habkost.net, alistair.francis@wdc.com, danielhb413@gmail.com Subject: [PATCH v4 33/37] target/riscv: Use aesdec_ISB_ISR_IMC_AK Date: Mon, 3 Jul 2023 12:05:16 +0200 Message-Id: <20230703100520.68224-34-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230703100520.68224-1-richard.henderson@linaro.org> References: <20230703100520.68224-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::429; envelope-from=richard.henderson@linaro.org; helo=mail-wr1-x429.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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1688379176482100001 Content-Type: text/plain; charset="utf-8" This implements the AES64DSM instruction. This was the last use of aes64_operation and its support macros, so remove them all. Signed-off-by: Richard Henderson Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- target/riscv/crypto_helper.c | 101 ++++------------------------------- 1 file changed, 10 insertions(+), 91 deletions(-) diff --git a/target/riscv/crypto_helper.c b/target/riscv/crypto_helper.c index c036fe8632..99d85a6188 100644 --- a/target/riscv/crypto_helper.c +++ b/target/riscv/crypto_helper.c @@ -104,98 +104,8 @@ target_ulong HELPER(aes32dsi)(target_ulong rs1, target= _ulong rs2, return aes32_operation(shamt, rs1, rs2, false, false); } =20 -#define BY(X, I) ((X >> (8 * I)) & 0xFF) - -#define AES_SHIFROWS_LO(RS1, RS2) ( \ - (((RS1 >> 24) & 0xFF) << 56) | (((RS2 >> 48) & 0xFF) << 48) | \ - (((RS2 >> 8) & 0xFF) << 40) | (((RS1 >> 32) & 0xFF) << 32) | \ - (((RS2 >> 56) & 0xFF) << 24) | (((RS2 >> 16) & 0xFF) << 16) | \ - (((RS1 >> 40) & 0xFF) << 8) | (((RS1 >> 0) & 0xFF) << 0)) - -#define AES_INVSHIFROWS_LO(RS1, RS2) ( \ - (((RS2 >> 24) & 0xFF) << 56) | (((RS2 >> 48) & 0xFF) << 48) | \ - (((RS1 >> 8) & 0xFF) << 40) | (((RS1 >> 32) & 0xFF) << 32) | \ - (((RS1 >> 56) & 0xFF) << 24) | (((RS2 >> 16) & 0xFF) << 16) | \ - (((RS2 >> 40) & 0xFF) << 8) | (((RS1 >> 0) & 0xFF) << 0)) - -#define AES_MIXBYTE(COL, B0, B1, B2, B3) ( \ - BY(COL, B3) ^ BY(COL, B2) ^ AES_GFMUL(BY(COL, B1), 3) ^ \ - AES_GFMUL(BY(COL, B0), 2)) - -#define AES_MIXCOLUMN(COL) ( \ - AES_MIXBYTE(COL, 3, 0, 1, 2) << 24 | \ - AES_MIXBYTE(COL, 2, 3, 0, 1) << 16 | \ - AES_MIXBYTE(COL, 1, 2, 3, 0) << 8 | AES_MIXBYTE(COL, 0, 1, 2, 3) << 0) - -#define AES_INVMIXBYTE(COL, B0, B1, B2, B3) ( \ - AES_GFMUL(BY(COL, B3), 0x9) ^ AES_GFMUL(BY(COL, B2), 0xd) ^ \ - AES_GFMUL(BY(COL, B1), 0xb) ^ AES_GFMUL(BY(COL, B0), 0xe)) - -#define AES_INVMIXCOLUMN(COL) ( \ - AES_INVMIXBYTE(COL, 3, 0, 1, 2) << 24 | \ - AES_INVMIXBYTE(COL, 2, 3, 0, 1) << 16 | \ - AES_INVMIXBYTE(COL, 1, 2, 3, 0) << 8 | \ - AES_INVMIXBYTE(COL, 0, 1, 2, 3) << 0) - static const AESState aes_zero =3D { }; =20 -static inline target_ulong aes64_operation(target_ulong rs1, target_ulong = rs2, - bool enc, bool mix) -{ - uint64_t RS1 =3D rs1; - uint64_t RS2 =3D rs2; - uint64_t result; - uint64_t temp; - uint32_t col_0; - uint32_t col_1; - - if (enc) { - temp =3D AES_SHIFROWS_LO(RS1, RS2); - temp =3D (((uint64_t)AES_sbox[(temp >> 0) & 0xFF] << 0) | - ((uint64_t)AES_sbox[(temp >> 8) & 0xFF] << 8) | - ((uint64_t)AES_sbox[(temp >> 16) & 0xFF] << 16) | - ((uint64_t)AES_sbox[(temp >> 24) & 0xFF] << 24) | - ((uint64_t)AES_sbox[(temp >> 32) & 0xFF] << 32) | - ((uint64_t)AES_sbox[(temp >> 40) & 0xFF] << 40) | - ((uint64_t)AES_sbox[(temp >> 48) & 0xFF] << 48) | - ((uint64_t)AES_sbox[(temp >> 56) & 0xFF] << 56)); - if (mix) { - col_0 =3D temp & 0xFFFFFFFF; - col_1 =3D temp >> 32; - - col_0 =3D AES_MIXCOLUMN(col_0); - col_1 =3D AES_MIXCOLUMN(col_1); - - result =3D ((uint64_t)col_1 << 32) | col_0; - } else { - result =3D temp; - } - } else { - temp =3D AES_INVSHIFROWS_LO(RS1, RS2); - temp =3D (((uint64_t)AES_isbox[(temp >> 0) & 0xFF] << 0) | - ((uint64_t)AES_isbox[(temp >> 8) & 0xFF] << 8) | - ((uint64_t)AES_isbox[(temp >> 16) & 0xFF] << 16) | - ((uint64_t)AES_isbox[(temp >> 24) & 0xFF] << 24) | - ((uint64_t)AES_isbox[(temp >> 32) & 0xFF] << 32) | - ((uint64_t)AES_isbox[(temp >> 40) & 0xFF] << 40) | - ((uint64_t)AES_isbox[(temp >> 48) & 0xFF] << 48) | - ((uint64_t)AES_isbox[(temp >> 56) & 0xFF] << 56)); - if (mix) { - col_0 =3D temp & 0xFFFFFFFF; - col_1 =3D temp >> 32; - - col_0 =3D AES_INVMIXCOLUMN(col_0); - col_1 =3D AES_INVMIXCOLUMN(col_1); - - result =3D ((uint64_t)col_1 << 32) | col_0; - } else { - result =3D temp; - } - } - - return result; -} - target_ulong HELPER(aes64esm)(target_ulong rs1, target_ulong rs2) { AESState t; @@ -228,7 +138,16 @@ target_ulong HELPER(aes64ds)(target_ulong rs1, target_= ulong rs2) =20 target_ulong HELPER(aes64dsm)(target_ulong rs1, target_ulong rs2) { - return aes64_operation(rs1, rs2, false, true); + AESState t, z =3D { }; + + /* + * This instruction does not include a round key, + * so supply a zero to our primitive. + */ + t.d[HOST_BIG_ENDIAN] =3D rs1; + t.d[!HOST_BIG_ENDIAN] =3D rs2; + aesdec_ISB_ISR_IMC_AK(&t, &t, &z, false); + return t.d[HOST_BIG_ENDIAN]; } =20 target_ulong HELPER(aes64ks2)(target_ulong rs1, target_ulong rs2) --=20 2.34.1 From nobody Tue May 14 18:40:19 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1688379033; cv=none; d=zohomail.com; s=zohoarc; b=NwkJ4BaqiqMqbm2QpXjCdwU4MmlLl0UlrTiiXqFjR38uj8limPicGIOTIBw5ZH2RlLak8RkeQ2l/sSOGx/LH6p4jO9STjcccgZ9rOPHHKyGcHmwOacoITULP4QSvZFRtg17T375ZIpNoV5qU67faM+P9r51CW/UKMW9Bt/Ba4x4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1688379033; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=LO6Chl8aQYLOaHq+kw102b8WCIYofNouZUqxF+V9shk=; b=VwuQALXIbZyaLs7xY/7O7zx1TA8jfZY+mMHW8abCxL3yk8d39arGe/EoSpCKwe+7agkKsJ7Jrj0w7B8B/T0k3aYKbnIVKyix0S8L/hmLLDmOhR/4fKCwm0yhlz7Y/trt7LM6q2GAHjJXVSVKxABpGIEwtjTcGVF/ZT6LzUTEkUo= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1688379033380600.4144019623258; Mon, 3 Jul 2023 03:10:33 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qGGSk-0005OR-KD; Mon, 03 Jul 2023 06:07:18 -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 1qGGRp-0003Cl-8o for qemu-devel@nongnu.org; Mon, 03 Jul 2023 06:06:24 -0400 Received: from mail-wm1-x32c.google.com ([2a00:1450: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 1qGGRU-0005zw-6j for qemu-devel@nongnu.org; Mon, 03 Jul 2023 06:06:15 -0400 Received: by mail-wm1-x32c.google.com with SMTP id 5b1f17b1804b1-3fbc54caad5so35868595e9.2 for ; Mon, 03 Jul 2023 03:05:58 -0700 (PDT) Received: from stoup.home (91.232.79.188.dynamic.jazztel.es. [188.79.232.91]) by smtp.gmail.com with ESMTPSA id t5-20020a05600001c500b00313f7b077fesm18446562wrx.59.2023.07.03.03.05.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 03 Jul 2023 03:05:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1688378757; x=1690970757; 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=LO6Chl8aQYLOaHq+kw102b8WCIYofNouZUqxF+V9shk=; b=Wfoj7yBvoE2rJiaUip7aBTpzIk5X8EPJzvFr5SdfrtuOrbdaeKRFsVVP3QF6HhXIyB Qu1xnx8xtXPVvKAF2KQ3Iy+iOkv/q6mP4EmBKk5mJfaf5mgdfGexmNYusfCnl6r/dCSR 8JAp7gR6lxrfuJnwstFCnbe8F4Utnrj+O5M26Y/2Enh2r9V89BO8ThgockIqvf9Sfy02 tp+sOJMcG5EwJHhaVU7lDKOWpymMwxrj/rD+iHHRW4OgiCWc6jCTRq9ZyI4fegHAH2sl 1LF9mBIvD7TaN9MbuieG/oTH2PcjlaMKC0DL3usNsZ2p5Au93viQYW9FpAl/0kzaBEum p4Jg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1688378757; x=1690970757; 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=LO6Chl8aQYLOaHq+kw102b8WCIYofNouZUqxF+V9shk=; b=MVzjKC1a/CsuEcxjKyP42uwliF/cLzDYR8ZWJRrpX1IZOczSGb/n3okyhvMF1vpF9Q ek5Dm4ur4VSh+DC7J8GDtNhliCL7OfNcUnRRXVQeElIMRe2DkaDRSe0EEGMgVlCzZ+80 dIpmMi/teObOTBXbuvCpCK+1hiShmGS7tM8/uosZrKOLasD+cVjLFanv8EjQD/MRFFos x1l60hzWyrHupi74+O60gKUVmPZJvKxDwLJE818i5mIhBYfJf4SloXrRnhKM3DIwsd/M s/mjGYo5wfaLY/toKrBVLwz0U/yBpmNiBGhFwHf4EXKroGACEngerXfK/Hsk3yuFIWuF KNjA== X-Gm-Message-State: AC+VfDzVMC6OCKYy/GWBhe2H5GW0i0kwTaKUwYYh9ezU+QuyhLoikT9r ssu+DfMU10ay5xtshcIm1gAGUbwOqNILYS4kCBICkA== X-Google-Smtp-Source: ACHHUZ5DLiGqROsPlg5CaaKoUVLHiEOqYbSPc0Q8fauPGnMxlfLK/nH9WXTPVG+3qAMqtOmUOyLcTw== X-Received: by 2002:a05:600c:22da:b0:3fb:31b:d516 with SMTP id 26-20020a05600c22da00b003fb031bd516mr7612148wmg.29.1688378757576; Mon, 03 Jul 2023 03:05:57 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: qemu-arm@nongnu.org, qemu-riscv@nongnu.org, pbonzini@redhat.com, eduardo@habkost.net, alistair.francis@wdc.com, danielhb413@gmail.com, =?UTF-8?q?Daniel=20P=20=2E=20Berrang=C3=A9?= , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Subject: [PATCH v4 34/37] crypto: Remove AES_shifts, AES_ishifts Date: Mon, 3 Jul 2023 12:05:17 +0200 Message-Id: <20230703100520.68224-35-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230703100520.68224-1-richard.henderson@linaro.org> References: <20230703100520.68224-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::32c; envelope-from=richard.henderson@linaro.org; helo=mail-wm1-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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1688379033905100001 These arrays are no longer used, replaced by AES_SH_*, AES_ISH_*. Acked-by: Daniel P. Berrang=C3=A9 Reviewed-by: Philippe Mathieu-Daud=C3=A9 Signed-off-by: Richard Henderson --- include/crypto/aes.h | 4 ---- crypto/aes.c | 14 -------------- 2 files changed, 18 deletions(-) diff --git a/include/crypto/aes.h b/include/crypto/aes.h index 24b073d569..aa8b54065d 100644 --- a/include/crypto/aes.h +++ b/include/crypto/aes.h @@ -30,10 +30,6 @@ void AES_decrypt(const unsigned char *in, unsigned char = *out, extern const uint8_t AES_sbox[256]; extern const uint8_t AES_isbox[256]; =20 -/* AES ShiftRows and InvShiftRows */ -extern const uint8_t AES_shifts[16]; -extern const uint8_t AES_ishifts[16]; - /* AES MixColumns, for use with rot32. */ extern const uint32_t AES_mc_rot[256]; =20 diff --git a/crypto/aes.c b/crypto/aes.c index c765f11c1e..00e16d3f92 100644 --- a/crypto/aes.c +++ b/crypto/aes.c @@ -114,23 +114,9 @@ const uint8_t AES_isbox[256] =3D { /* AES ShiftRows, for complete unrolling. */ #define AES_SH(X) (((X) * 5) & 15) =20 -const uint8_t AES_shifts[16] =3D { - AES_SH(0x0), AES_SH(0x1), AES_SH(0x2), AES_SH(0x3), - AES_SH(0x4), AES_SH(0x5), AES_SH(0x6), AES_SH(0x7), - AES_SH(0x8), AES_SH(0x9), AES_SH(0xA), AES_SH(0xB), - AES_SH(0xC), AES_SH(0xD), AES_SH(0xE), AES_SH(0xF), -}; - /* AES InvShiftRows, for complete unrolling. */ #define AES_ISH(X) (((X) * 13) & 15) =20 -const uint8_t AES_ishifts[16] =3D { - AES_ISH(0x0), AES_ISH(0x1), AES_ISH(0x2), AES_ISH(0x3), - AES_ISH(0x4), AES_ISH(0x5), AES_ISH(0x6), AES_ISH(0x7), - AES_ISH(0x8), AES_ISH(0x9), AES_ISH(0xA), AES_ISH(0xB), - AES_ISH(0xC), AES_ISH(0xD), AES_ISH(0xE), AES_ISH(0xF), -}; - /* * MixColumns lookup table, for use with rot32. */ --=20 2.34.1 From nobody Tue May 14 18:40:19 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1688379123; cv=none; d=zohomail.com; s=zohoarc; b=at0CwZWM9AInSvh0PalWMcsuYYvO/hSS5kdBer5JmR9/KV6ainuLCF/8br2wkdPz1i9LxuatvckpYDMTazFtCB4Z66lHLwj+46mIAHYM0PBYU8yD7UbK5a/owkwuFlyJkKvF7e83D0L/S5rok87sMPEqUK940Cw03Y8+Kw0Wja0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1688379123; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=KoRRyATrWAHPOTZCqqegjuftHV3UOSCP+hcOlJjHRIM=; b=aK5EhKqpDit8FJf8vWCuTH25rTr2Uty92agGE8l4lbwfbY3LQobfscOZBMXvKEeiqlCWYIhVMhUwXW8oezdf88DYzRWonP5XGWFKG1P2vim1lADqhRarzimul0CasJx2A9MkzqDrGi4I/S5MZjw5VSuGHDc+l6p7kN8+NaO4Q04= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1688379123854873.1981020501682; Mon, 3 Jul 2023 03:12:03 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qGGSz-0006KV-Md; Mon, 03 Jul 2023 06:07:33 -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 1qGGRp-0003Co-Ad for qemu-devel@nongnu.org; Mon, 03 Jul 2023 06:06:24 -0400 Received: from mail-wr1-x429.google.com ([2a00:1450:4864:20::429]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qGGRU-00060S-6i for qemu-devel@nongnu.org; Mon, 03 Jul 2023 06:06:15 -0400 Received: by mail-wr1-x429.google.com with SMTP id ffacd0b85a97d-3143b72c5ffso189891f8f.3 for ; Mon, 03 Jul 2023 03:05:59 -0700 (PDT) Received: from stoup.home (91.232.79.188.dynamic.jazztel.es. [188.79.232.91]) by smtp.gmail.com with ESMTPSA id t5-20020a05600001c500b00313f7b077fesm18446562wrx.59.2023.07.03.03.05.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 03 Jul 2023 03:05:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1688378758; x=1690970758; 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=KoRRyATrWAHPOTZCqqegjuftHV3UOSCP+hcOlJjHRIM=; b=IRI3MCkGlPttop81BvrXMKjRpBkCq7p7sMHGhx2SVdnGXkr18SLBdKfnzA6hxrk2E3 bVwbz+4AU2wtMMXaOakkSOWeqah3rhkUavpn5GKjh8bLrrmSTeQJvDFFFPL6xbqkVMCG 3U/iPBNpawMunoX7SLu0kEqOPKFMG3tYvo4LBO+sPOrbHiYu4Ju8MeJxb/jWipb2hH7D xUb1aOYuaomj2aSf3x1CPAXsqZLo0z7bLM9V4JpHDrUZ9mBUv9EPRLthPoYUsJR0ax1T +5tn4Q22AwLSQabuWTzuyudwXBTA49SWx4pXDQiF0QiAG+fWp+rhtz6B5giIJKYRPMA0 94iQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1688378758; x=1690970758; 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=KoRRyATrWAHPOTZCqqegjuftHV3UOSCP+hcOlJjHRIM=; b=ITVOoibWvqIE+Wrtpc76sVrsNuvoQ3DkdlapKd2lni8TtF8GN1KTEngWCQLZalOFEi 4QMYtkKHcnCrKE0c07ujVsYe4lfc3N0vT1y/FV3ntgeJH9ffNTQz4pdlgLb9Hy36kwo1 WtzOz2qLJxQE+CQh+9lqC0/iohbPd6ylCc2akY9budiDl5QFqgFxIZ3t8QA51JhGEakU iq8rbfi0xXo1LVGxpSKgVEC98oIKZ+EcC6Fm8JJt+7McOQpWc5xEoxlEdMxxdUPOU6+O mBTVM0qfXZIYIrwORQyUnygScxdobLYynaAE341kur+LFZMIt2ocjLiZ8pvuLyWYra6j O9Yg== X-Gm-Message-State: ABy/qLY9yt/vFLexrjXNYXt0IwWSfN7MswC37bkUz3+X8irBamAq94hd LWfUDsTk41yItZT2auwNhgvKyPjbLDtwpcOq/ZaXkg== X-Google-Smtp-Source: APBJJlFXsU1szV2jGD2KQ3XF8y4KVaoM8NFXX1wckF4DSx/aaivb0TbORufaxy+MqwVLc4pGtXYb1w== X-Received: by 2002:a05:6000:14e:b0:313:ecee:5517 with SMTP id r14-20020a056000014e00b00313ecee5517mr12333265wrx.40.1688378758535; Mon, 03 Jul 2023 03:05:58 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: qemu-arm@nongnu.org, qemu-riscv@nongnu.org, pbonzini@redhat.com, eduardo@habkost.net, alistair.francis@wdc.com, danielhb413@gmail.com, =?UTF-8?q?Daniel=20P=20=2E=20Berrang=C3=A9?= , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Subject: [PATCH v4 35/37] crypto: Implement aesdec_IMC with AES_imc_rot Date: Mon, 3 Jul 2023 12:05:18 +0200 Message-Id: <20230703100520.68224-36-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230703100520.68224-1-richard.henderson@linaro.org> References: <20230703100520.68224-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::429; envelope-from=richard.henderson@linaro.org; helo=mail-wr1-x429.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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1688379125626100007 This method uses one uint32_t * 256 table instead of 4, which means its data cache overhead is less. Acked-by: Daniel P. Berrang=C3=A9 Reviewed-by: Philippe Mathieu-Daud=C3=A9 Signed-off-by: Richard Henderson --- crypto/aes.c | 42 +++++++++++++++++++++--------------------- 1 file changed, 21 insertions(+), 21 deletions(-) diff --git a/crypto/aes.c b/crypto/aes.c index 00e16d3f92..d93883eb18 100644 --- a/crypto/aes.c +++ b/crypto/aes.c @@ -1377,39 +1377,39 @@ aesdec_IMC_swap(AESState *r, const AESState *st, bo= ol swap) bool be =3D HOST_BIG_ENDIAN ^ swap; uint32_t t; =20 - /* Note that AES_imc is encoded for big-endian. */ - t =3D (AES_imc[st->b[swap_b ^ 0x0]][0] ^ - AES_imc[st->b[swap_b ^ 0x1]][1] ^ - AES_imc[st->b[swap_b ^ 0x2]][2] ^ - AES_imc[st->b[swap_b ^ 0x3]][3]); - if (!be) { + /* Note that AES_imc_rot is encoded for little-endian. */ + t =3D ( AES_imc_rot[st->b[swap_b ^ 0x0]] ^ + rol32(AES_imc_rot[st->b[swap_b ^ 0x1]], 8) ^ + rol32(AES_imc_rot[st->b[swap_b ^ 0x2]], 16) ^ + rol32(AES_imc_rot[st->b[swap_b ^ 0x3]], 24)); + if (be) { t =3D bswap32(t); } r->w[swap_w ^ 0] =3D t; =20 - t =3D (AES_imc[st->b[swap_b ^ 0x4]][0] ^ - AES_imc[st->b[swap_b ^ 0x5]][1] ^ - AES_imc[st->b[swap_b ^ 0x6]][2] ^ - AES_imc[st->b[swap_b ^ 0x7]][3]); - if (!be) { + t =3D ( AES_imc_rot[st->b[swap_b ^ 0x4]] ^ + rol32(AES_imc_rot[st->b[swap_b ^ 0x5]], 8) ^ + rol32(AES_imc_rot[st->b[swap_b ^ 0x6]], 16) ^ + rol32(AES_imc_rot[st->b[swap_b ^ 0x7]], 24)); + if (be) { t =3D bswap32(t); } r->w[swap_w ^ 1] =3D t; =20 - t =3D (AES_imc[st->b[swap_b ^ 0x8]][0] ^ - AES_imc[st->b[swap_b ^ 0x9]][1] ^ - AES_imc[st->b[swap_b ^ 0xA]][2] ^ - AES_imc[st->b[swap_b ^ 0xB]][3]); - if (!be) { + t =3D ( AES_imc_rot[st->b[swap_b ^ 0x8]] ^ + rol32(AES_imc_rot[st->b[swap_b ^ 0x9]], 8) ^ + rol32(AES_imc_rot[st->b[swap_b ^ 0xA]], 16) ^ + rol32(AES_imc_rot[st->b[swap_b ^ 0xB]], 24)); + if (be) { t =3D bswap32(t); } r->w[swap_w ^ 2] =3D t; =20 - t =3D (AES_imc[st->b[swap_b ^ 0xC]][0] ^ - AES_imc[st->b[swap_b ^ 0xD]][1] ^ - AES_imc[st->b[swap_b ^ 0xE]][2] ^ - AES_imc[st->b[swap_b ^ 0xF]][3]); - if (!be) { + t =3D ( AES_imc_rot[st->b[swap_b ^ 0xC]] ^ + rol32(AES_imc_rot[st->b[swap_b ^ 0xD]], 8) ^ + rol32(AES_imc_rot[st->b[swap_b ^ 0xE]], 16) ^ + rol32(AES_imc_rot[st->b[swap_b ^ 0xF]], 24)); + if (be) { t =3D bswap32(t); } r->w[swap_w ^ 3] =3D t; --=20 2.34.1 From nobody Tue May 14 18:40:19 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1688379439; cv=none; d=zohomail.com; s=zohoarc; b=ng2OuR+dpSF6XdIO+tKsnnKRYCHFaa5LbOpMNetO4GBd3V/3ShDR7oodbC1Dz1oHjv3nJdwGesDwyLUh5ppFbk2YtXTCdmTefUY36dsfd+wZS7tKg46Z5TF+jxdjqZmjZ6mRjV6J9nDCxhi64EQ2uEHkDDrsJ9IKJAMd6Yviq/U= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1688379439; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=QDJWgUvS8Zs4L2lTferPtp1fyLNTd5LXy05o4rblG4c=; b=hcnaFBzj6xMBvWILPPI5TshjYBVoHsMjSBI8zfjAmAZPSB0GE5EMUB84hATtrunpKX/CalouZg9NkmPMZwjonLMMwPvs9v7xDoNQYqPzqI21u64EiE2DzsMOoG5vXFhOyTkbeSpN4RV2bTilNB5NSS9semay9ao1w4P/GnT5z40= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1688379439165497.75894676895916; Mon, 3 Jul 2023 03:17:19 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qGGU4-0008Lv-3b; Mon, 03 Jul 2023 06:08:40 -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 1qGGRp-0003Cu-CO for qemu-devel@nongnu.org; Mon, 03 Jul 2023 06:06:24 -0400 Received: from mail-wm1-x32f.google.com ([2a00:1450:4864:20::32f]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qGGRV-00060w-C7 for qemu-devel@nongnu.org; Mon, 03 Jul 2023 06:06:18 -0400 Received: by mail-wm1-x32f.google.com with SMTP id 5b1f17b1804b1-3fbc77e769cso36411645e9.0 for ; Mon, 03 Jul 2023 03:06:00 -0700 (PDT) Received: from stoup.home (91.232.79.188.dynamic.jazztel.es. [188.79.232.91]) by smtp.gmail.com with ESMTPSA id t5-20020a05600001c500b00313f7b077fesm18446562wrx.59.2023.07.03.03.05.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 03 Jul 2023 03:05:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1688378759; x=1690970759; 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=QDJWgUvS8Zs4L2lTferPtp1fyLNTd5LXy05o4rblG4c=; b=bssAy58A8lGqjV7RJpcJtq4ImBjiPip+4bn6ymQr3F+2zzrewbP9zjLcSk3i/wAYLs ArndEaYpPfpo8ML/7b7rg94IxmppsYBqmeJP5yoFGXtunrP6xtqnLDY4iOin6wEidxcF vvpmw5SHPCQiUkRZoCSee/xdMpzzFoLmRIqDicSg7DeUtHqVu9LwLPwtZOa/nzS4NlyZ 70wG6v0cpB0FFxIeOitcCIpLM7kr6zGtUf6L2nYkog0xgqo3GHE0USjOepDB1ErFbIvg obu68aFqOGeRPltsorHLGO1HWwHB+apVn18MKukoxIsMYmPeNmthegoCSZcTB5b1v6Gw oYWw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1688378759; x=1690970759; 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=QDJWgUvS8Zs4L2lTferPtp1fyLNTd5LXy05o4rblG4c=; b=OtKHne0CvCmwGZ+OIC4PehmwIY5+8hGPmWdqMWz1VO/vPi8c/te9GrjcQD3ZwrB4he 5l23S4NkeVeYvjC7uTe1SkoPAmxhZe/VQoYH7o8bSHqNTJ2mU2MCx8WVyFFT258olLmk Y5T2uTvSz9W9w4fh7F0LScGcOz3HdYKjrRv8ZDT2gP4g8Hn6p1EE6EhSThhFxpyLoQ07 RjGimbeP/0qdrSkA/mMxdofUreHO6DKb//tojkNy8UWOX8At6j8PnlwULV+g8qdDxwPz lfLHT/09c3AF6EWzKPM9RRbN8nL3Gp3q3pNAKl5D7zfxGqkDsDU/uLJ1jXNKZWuJD1Eg VXGg== X-Gm-Message-State: AC+VfDwS2K83e8Nz9lKRY7ElptB9ULEaIDFrtVIT9Cj8k+XKRouvV/jK cXUL/ho/WXf68uDq2OYcTabSDWT23fiu/y7CAgiotQ== X-Google-Smtp-Source: ACHHUZ6uN55lB1eImY4X7zW9ipQ+9Q/3nhKgahvODh40qFQhs7BQwj6V58yzo/IYHn3gX0AjehD02w== X-Received: by 2002:a1c:f314:0:b0:3fb:adc0:609b with SMTP id q20-20020a1cf314000000b003fbadc0609bmr8679505wmq.13.1688378759563; Mon, 03 Jul 2023 03:05:59 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: qemu-arm@nongnu.org, qemu-riscv@nongnu.org, pbonzini@redhat.com, eduardo@habkost.net, alistair.francis@wdc.com, danielhb413@gmail.com, =?UTF-8?q?Daniel=20P=20=2E=20Berrang=C3=A9?= , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Subject: [PATCH v4 36/37] crypto: Remove AES_imc Date: Mon, 3 Jul 2023 12:05:19 +0200 Message-Id: <20230703100520.68224-37-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230703100520.68224-1-richard.henderson@linaro.org> References: <20230703100520.68224-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::32f; envelope-from=richard.henderson@linaro.org; helo=mail-wm1-x32f.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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1688379441190100003 This array is no longer used. Acked-by: Daniel P. Berrang=C3=A9 Reviewed-by: Philippe Mathieu-Daud=C3=A9 Signed-off-by: Richard Henderson --- include/crypto/aes.h | 7 -- crypto/aes.c | 264 ------------------------------------------- 2 files changed, 271 deletions(-) diff --git a/include/crypto/aes.h b/include/crypto/aes.h index aa8b54065d..99209f51b9 100644 --- a/include/crypto/aes.h +++ b/include/crypto/aes.h @@ -36,13 +36,6 @@ extern const uint32_t AES_mc_rot[256]; /* AES InvMixColumns, for use with rot32. */ extern const uint32_t AES_imc_rot[256]; =20 -/* AES InvMixColumns */ -/* AES_imc[x][0] =3D [x].[0e, 09, 0d, 0b]; */ -/* AES_imc[x][1] =3D [x].[0b, 0e, 09, 0d]; */ -/* AES_imc[x][2] =3D [x].[0d, 0b, 0e, 09]; */ -/* AES_imc[x][3] =3D [x].[09, 0d, 0b, 0e]; */ -extern const uint32_t AES_imc[256][4]; - /* AES_Te0[x] =3D S [x].[02, 01, 01, 03]; AES_Te1[x] =3D S [x].[03, 02, 01, 01]; diff --git a/crypto/aes.c b/crypto/aes.c index d93883eb18..685efbd583 100644 --- a/crypto/aes.c +++ b/crypto/aes.c @@ -257,270 +257,6 @@ const uint32_t AES_imc_rot[256] =3D { 0xbe805d9f, 0xb58d5491, 0xa89a4f83, 0xa397468d, }; =20 -/* AES_imc[x][0] =3D [x].[0e, 09, 0d, 0b]; */ -/* AES_imc[x][1] =3D [x].[0b, 0e, 09, 0d]; */ -/* AES_imc[x][2] =3D [x].[0d, 0b, 0e, 09]; */ -/* AES_imc[x][3] =3D [x].[09, 0d, 0b, 0e]; */ -const uint32_t AES_imc[256][4] =3D { - { 0x00000000, 0x00000000, 0x00000000, 0x00000000, }, /* x=3D00 */ - { 0x0E090D0B, 0x0B0E090D, 0x0D0B0E09, 0x090D0B0E, }, /* x=3D01 */ - { 0x1C121A16, 0x161C121A, 0x1A161C12, 0x121A161C, }, /* x=3D02 */ - { 0x121B171D, 0x1D121B17, 0x171D121B, 0x1B171D12, }, /* x=3D03 */ - { 0x3824342C, 0x2C382434, 0x342C3824, 0x24342C38, }, /* x=3D04 */ - { 0x362D3927, 0x27362D39, 0x3927362D, 0x2D392736, }, /* x=3D05 */ - { 0x24362E3A, 0x3A24362E, 0x2E3A2436, 0x362E3A24, }, /* x=3D06 */ - { 0x2A3F2331, 0x312A3F23, 0x23312A3F, 0x3F23312A, }, /* x=3D07 */ - { 0x70486858, 0x58704868, 0x68587048, 0x48685870, }, /* x=3D08 */ - { 0x7E416553, 0x537E4165, 0x65537E41, 0x4165537E, }, /* x=3D09 */ - { 0x6C5A724E, 0x4E6C5A72, 0x724E6C5A, 0x5A724E6C, }, /* x=3D0A */ - { 0x62537F45, 0x4562537F, 0x7F456253, 0x537F4562, }, /* x=3D0B */ - { 0x486C5C74, 0x74486C5C, 0x5C74486C, 0x6C5C7448, }, /* x=3D0C */ - { 0x4665517F, 0x7F466551, 0x517F4665, 0x65517F46, }, /* x=3D0D */ - { 0x547E4662, 0x62547E46, 0x4662547E, 0x7E466254, }, /* x=3D0E */ - { 0x5A774B69, 0x695A774B, 0x4B695A77, 0x774B695A, }, /* x=3D0F */ - { 0xE090D0B0, 0xB0E090D0, 0xD0B0E090, 0x90D0B0E0, }, /* x=3D10 */ - { 0xEE99DDBB, 0xBBEE99DD, 0xDDBBEE99, 0x99DDBBEE, }, /* x=3D11 */ - { 0xFC82CAA6, 0xA6FC82CA, 0xCAA6FC82, 0x82CAA6FC, }, /* x=3D12 */ - { 0xF28BC7AD, 0xADF28BC7, 0xC7ADF28B, 0x8BC7ADF2, }, /* x=3D13 */ - { 0xD8B4E49C, 0x9CD8B4E4, 0xE49CD8B4, 0xB4E49CD8, }, /* x=3D14 */ - { 0xD6BDE997, 0x97D6BDE9, 0xE997D6BD, 0xBDE997D6, }, /* x=3D15 */ - { 0xC4A6FE8A, 0x8AC4A6FE, 0xFE8AC4A6, 0xA6FE8AC4, }, /* x=3D16 */ - { 0xCAAFF381, 0x81CAAFF3, 0xF381CAAF, 0xAFF381CA, }, /* x=3D17 */ - { 0x90D8B8E8, 0xE890D8B8, 0xB8E890D8, 0xD8B8E890, }, /* x=3D18 */ - { 0x9ED1B5E3, 0xE39ED1B5, 0xB5E39ED1, 0xD1B5E39E, }, /* x=3D19 */ - { 0x8CCAA2FE, 0xFE8CCAA2, 0xA2FE8CCA, 0xCAA2FE8C, }, /* x=3D1A */ - { 0x82C3AFF5, 0xF582C3AF, 0xAFF582C3, 0xC3AFF582, }, /* x=3D1B */ - { 0xA8FC8CC4, 0xC4A8FC8C, 0x8CC4A8FC, 0xFC8CC4A8, }, /* x=3D1C */ - { 0xA6F581CF, 0xCFA6F581, 0x81CFA6F5, 0xF581CFA6, }, /* x=3D1D */ - { 0xB4EE96D2, 0xD2B4EE96, 0x96D2B4EE, 0xEE96D2B4, }, /* x=3D1E */ - { 0xBAE79BD9, 0xD9BAE79B, 0x9BD9BAE7, 0xE79BD9BA, }, /* x=3D1F */ - { 0xDB3BBB7B, 0x7BDB3BBB, 0xBB7BDB3B, 0x3BBB7BDB, }, /* x=3D20 */ - { 0xD532B670, 0x70D532B6, 0xB670D532, 0x32B670D5, }, /* x=3D21 */ - { 0xC729A16D, 0x6DC729A1, 0xA16DC729, 0x29A16DC7, }, /* x=3D22 */ - { 0xC920AC66, 0x66C920AC, 0xAC66C920, 0x20AC66C9, }, /* x=3D23 */ - { 0xE31F8F57, 0x57E31F8F, 0x8F57E31F, 0x1F8F57E3, }, /* x=3D24 */ - { 0xED16825C, 0x5CED1682, 0x825CED16, 0x16825CED, }, /* x=3D25 */ - { 0xFF0D9541, 0x41FF0D95, 0x9541FF0D, 0x0D9541FF, }, /* x=3D26 */ - { 0xF104984A, 0x4AF10498, 0x984AF104, 0x04984AF1, }, /* x=3D27 */ - { 0xAB73D323, 0x23AB73D3, 0xD323AB73, 0x73D323AB, }, /* x=3D28 */ - { 0xA57ADE28, 0x28A57ADE, 0xDE28A57A, 0x7ADE28A5, }, /* x=3D29 */ - { 0xB761C935, 0x35B761C9, 0xC935B761, 0x61C935B7, }, /* x=3D2A */ - { 0xB968C43E, 0x3EB968C4, 0xC43EB968, 0x68C43EB9, }, /* x=3D2B */ - { 0x9357E70F, 0x0F9357E7, 0xE70F9357, 0x57E70F93, }, /* x=3D2C */ - { 0x9D5EEA04, 0x049D5EEA, 0xEA049D5E, 0x5EEA049D, }, /* x=3D2D */ - { 0x8F45FD19, 0x198F45FD, 0xFD198F45, 0x45FD198F, }, /* x=3D2E */ - { 0x814CF012, 0x12814CF0, 0xF012814C, 0x4CF01281, }, /* x=3D2F */ - { 0x3BAB6BCB, 0xCB3BAB6B, 0x6BCB3BAB, 0xAB6BCB3B, }, /* x=3D30 */ - { 0x35A266C0, 0xC035A266, 0x66C035A2, 0xA266C035, }, /* x=3D31 */ - { 0x27B971DD, 0xDD27B971, 0x71DD27B9, 0xB971DD27, }, /* x=3D32 */ - { 0x29B07CD6, 0xD629B07C, 0x7CD629B0, 0xB07CD629, }, /* x=3D33 */ - { 0x038F5FE7, 0xE7038F5F, 0x5FE7038F, 0x8F5FE703, }, /* x=3D34 */ - { 0x0D8652EC, 0xEC0D8652, 0x52EC0D86, 0x8652EC0D, }, /* x=3D35 */ - { 0x1F9D45F1, 0xF11F9D45, 0x45F11F9D, 0x9D45F11F, }, /* x=3D36 */ - { 0x119448FA, 0xFA119448, 0x48FA1194, 0x9448FA11, }, /* x=3D37 */ - { 0x4BE30393, 0x934BE303, 0x03934BE3, 0xE303934B, }, /* x=3D38 */ - { 0x45EA0E98, 0x9845EA0E, 0x0E9845EA, 0xEA0E9845, }, /* x=3D39 */ - { 0x57F11985, 0x8557F119, 0x198557F1, 0xF1198557, }, /* x=3D3A */ - { 0x59F8148E, 0x8E59F814, 0x148E59F8, 0xF8148E59, }, /* x=3D3B */ - { 0x73C737BF, 0xBF73C737, 0x37BF73C7, 0xC737BF73, }, /* x=3D3C */ - { 0x7DCE3AB4, 0xB47DCE3A, 0x3AB47DCE, 0xCE3AB47D, }, /* x=3D3D */ - { 0x6FD52DA9, 0xA96FD52D, 0x2DA96FD5, 0xD52DA96F, }, /* x=3D3E */ - { 0x61DC20A2, 0xA261DC20, 0x20A261DC, 0xDC20A261, }, /* x=3D3F */ - { 0xAD766DF6, 0xF6AD766D, 0x6DF6AD76, 0x766DF6AD, }, /* x=3D40 */ - { 0xA37F60FD, 0xFDA37F60, 0x60FDA37F, 0x7F60FDA3, }, /* x=3D41 */ - { 0xB16477E0, 0xE0B16477, 0x77E0B164, 0x6477E0B1, }, /* x=3D42 */ - { 0xBF6D7AEB, 0xEBBF6D7A, 0x7AEBBF6D, 0x6D7AEBBF, }, /* x=3D43 */ - { 0x955259DA, 0xDA955259, 0x59DA9552, 0x5259DA95, }, /* x=3D44 */ - { 0x9B5B54D1, 0xD19B5B54, 0x54D19B5B, 0x5B54D19B, }, /* x=3D45 */ - { 0x894043CC, 0xCC894043, 0x43CC8940, 0x4043CC89, }, /* x=3D46 */ - { 0x87494EC7, 0xC787494E, 0x4EC78749, 0x494EC787, }, /* x=3D47 */ - { 0xDD3E05AE, 0xAEDD3E05, 0x05AEDD3E, 0x3E05AEDD, }, /* x=3D48 */ - { 0xD33708A5, 0xA5D33708, 0x08A5D337, 0x3708A5D3, }, /* x=3D49 */ - { 0xC12C1FB8, 0xB8C12C1F, 0x1FB8C12C, 0x2C1FB8C1, }, /* x=3D4A */ - { 0xCF2512B3, 0xB3CF2512, 0x12B3CF25, 0x2512B3CF, }, /* x=3D4B */ - { 0xE51A3182, 0x82E51A31, 0x3182E51A, 0x1A3182E5, }, /* x=3D4C */ - { 0xEB133C89, 0x89EB133C, 0x3C89EB13, 0x133C89EB, }, /* x=3D4D */ - { 0xF9082B94, 0x94F9082B, 0x2B94F908, 0x082B94F9, }, /* x=3D4E */ - { 0xF701269F, 0x9FF70126, 0x269FF701, 0x01269FF7, }, /* x=3D4F */ - { 0x4DE6BD46, 0x464DE6BD, 0xBD464DE6, 0xE6BD464D, }, /* x=3D50 */ - { 0x43EFB04D, 0x4D43EFB0, 0xB04D43EF, 0xEFB04D43, }, /* x=3D51 */ - { 0x51F4A750, 0x5051F4A7, 0xA75051F4, 0xF4A75051, }, /* x=3D52 */ - { 0x5FFDAA5B, 0x5B5FFDAA, 0xAA5B5FFD, 0xFDAA5B5F, }, /* x=3D53 */ - { 0x75C2896A, 0x6A75C289, 0x896A75C2, 0xC2896A75, }, /* x=3D54 */ - { 0x7BCB8461, 0x617BCB84, 0x84617BCB, 0xCB84617B, }, /* x=3D55 */ - { 0x69D0937C, 0x7C69D093, 0x937C69D0, 0xD0937C69, }, /* x=3D56 */ - { 0x67D99E77, 0x7767D99E, 0x9E7767D9, 0xD99E7767, }, /* x=3D57 */ - { 0x3DAED51E, 0x1E3DAED5, 0xD51E3DAE, 0xAED51E3D, }, /* x=3D58 */ - { 0x33A7D815, 0x1533A7D8, 0xD81533A7, 0xA7D81533, }, /* x=3D59 */ - { 0x21BCCF08, 0x0821BCCF, 0xCF0821BC, 0xBCCF0821, }, /* x=3D5A */ - { 0x2FB5C203, 0x032FB5C2, 0xC2032FB5, 0xB5C2032F, }, /* x=3D5B */ - { 0x058AE132, 0x32058AE1, 0xE132058A, 0x8AE13205, }, /* x=3D5C */ - { 0x0B83EC39, 0x390B83EC, 0xEC390B83, 0x83EC390B, }, /* x=3D5D */ - { 0x1998FB24, 0x241998FB, 0xFB241998, 0x98FB2419, }, /* x=3D5E */ - { 0x1791F62F, 0x2F1791F6, 0xF62F1791, 0x91F62F17, }, /* x=3D5F */ - { 0x764DD68D, 0x8D764DD6, 0xD68D764D, 0x4DD68D76, }, /* x=3D60 */ - { 0x7844DB86, 0x867844DB, 0xDB867844, 0x44DB8678, }, /* x=3D61 */ - { 0x6A5FCC9B, 0x9B6A5FCC, 0xCC9B6A5F, 0x5FCC9B6A, }, /* x=3D62 */ - { 0x6456C190, 0x906456C1, 0xC1906456, 0x56C19064, }, /* x=3D63 */ - { 0x4E69E2A1, 0xA14E69E2, 0xE2A14E69, 0x69E2A14E, }, /* x=3D64 */ - { 0x4060EFAA, 0xAA4060EF, 0xEFAA4060, 0x60EFAA40, }, /* x=3D65 */ - { 0x527BF8B7, 0xB7527BF8, 0xF8B7527B, 0x7BF8B752, }, /* x=3D66 */ - { 0x5C72F5BC, 0xBC5C72F5, 0xF5BC5C72, 0x72F5BC5C, }, /* x=3D67 */ - { 0x0605BED5, 0xD50605BE, 0xBED50605, 0x05BED506, }, /* x=3D68 */ - { 0x080CB3DE, 0xDE080CB3, 0xB3DE080C, 0x0CB3DE08, }, /* x=3D69 */ - { 0x1A17A4C3, 0xC31A17A4, 0xA4C31A17, 0x17A4C31A, }, /* x=3D6A */ - { 0x141EA9C8, 0xC8141EA9, 0xA9C8141E, 0x1EA9C814, }, /* x=3D6B */ - { 0x3E218AF9, 0xF93E218A, 0x8AF93E21, 0x218AF93E, }, /* x=3D6C */ - { 0x302887F2, 0xF2302887, 0x87F23028, 0x2887F230, }, /* x=3D6D */ - { 0x223390EF, 0xEF223390, 0x90EF2233, 0x3390EF22, }, /* x=3D6E */ - { 0x2C3A9DE4, 0xE42C3A9D, 0x9DE42C3A, 0x3A9DE42C, }, /* x=3D6F */ - { 0x96DD063D, 0x3D96DD06, 0x063D96DD, 0xDD063D96, }, /* x=3D70 */ - { 0x98D40B36, 0x3698D40B, 0x0B3698D4, 0xD40B3698, }, /* x=3D71 */ - { 0x8ACF1C2B, 0x2B8ACF1C, 0x1C2B8ACF, 0xCF1C2B8A, }, /* x=3D72 */ - { 0x84C61120, 0x2084C611, 0x112084C6, 0xC6112084, }, /* x=3D73 */ - { 0xAEF93211, 0x11AEF932, 0x3211AEF9, 0xF93211AE, }, /* x=3D74 */ - { 0xA0F03F1A, 0x1AA0F03F, 0x3F1AA0F0, 0xF03F1AA0, }, /* x=3D75 */ - { 0xB2EB2807, 0x07B2EB28, 0x2807B2EB, 0xEB2807B2, }, /* x=3D76 */ - { 0xBCE2250C, 0x0CBCE225, 0x250CBCE2, 0xE2250CBC, }, /* x=3D77 */ - { 0xE6956E65, 0x65E6956E, 0x6E65E695, 0x956E65E6, }, /* x=3D78 */ - { 0xE89C636E, 0x6EE89C63, 0x636EE89C, 0x9C636EE8, }, /* x=3D79 */ - { 0xFA877473, 0x73FA8774, 0x7473FA87, 0x877473FA, }, /* x=3D7A */ - { 0xF48E7978, 0x78F48E79, 0x7978F48E, 0x8E7978F4, }, /* x=3D7B */ - { 0xDEB15A49, 0x49DEB15A, 0x5A49DEB1, 0xB15A49DE, }, /* x=3D7C */ - { 0xD0B85742, 0x42D0B857, 0x5742D0B8, 0xB85742D0, }, /* x=3D7D */ - { 0xC2A3405F, 0x5FC2A340, 0x405FC2A3, 0xA3405FC2, }, /* x=3D7E */ - { 0xCCAA4D54, 0x54CCAA4D, 0x4D54CCAA, 0xAA4D54CC, }, /* x=3D7F */ - { 0x41ECDAF7, 0xF741ECDA, 0xDAF741EC, 0xECDAF741, }, /* x=3D80 */ - { 0x4FE5D7FC, 0xFC4FE5D7, 0xD7FC4FE5, 0xE5D7FC4F, }, /* x=3D81 */ - { 0x5DFEC0E1, 0xE15DFEC0, 0xC0E15DFE, 0xFEC0E15D, }, /* x=3D82 */ - { 0x53F7CDEA, 0xEA53F7CD, 0xCDEA53F7, 0xF7CDEA53, }, /* x=3D83 */ - { 0x79C8EEDB, 0xDB79C8EE, 0xEEDB79C8, 0xC8EEDB79, }, /* x=3D84 */ - { 0x77C1E3D0, 0xD077C1E3, 0xE3D077C1, 0xC1E3D077, }, /* x=3D85 */ - { 0x65DAF4CD, 0xCD65DAF4, 0xF4CD65DA, 0xDAF4CD65, }, /* x=3D86 */ - { 0x6BD3F9C6, 0xC66BD3F9, 0xF9C66BD3, 0xD3F9C66B, }, /* x=3D87 */ - { 0x31A4B2AF, 0xAF31A4B2, 0xB2AF31A4, 0xA4B2AF31, }, /* x=3D88 */ - { 0x3FADBFA4, 0xA43FADBF, 0xBFA43FAD, 0xADBFA43F, }, /* x=3D89 */ - { 0x2DB6A8B9, 0xB92DB6A8, 0xA8B92DB6, 0xB6A8B92D, }, /* x=3D8A */ - { 0x23BFA5B2, 0xB223BFA5, 0xA5B223BF, 0xBFA5B223, }, /* x=3D8B */ - { 0x09808683, 0x83098086, 0x86830980, 0x80868309, }, /* x=3D8C */ - { 0x07898B88, 0x8807898B, 0x8B880789, 0x898B8807, }, /* x=3D8D */ - { 0x15929C95, 0x9515929C, 0x9C951592, 0x929C9515, }, /* x=3D8E */ - { 0x1B9B919E, 0x9E1B9B91, 0x919E1B9B, 0x9B919E1B, }, /* x=3D8F */ - { 0xA17C0A47, 0x47A17C0A, 0x0A47A17C, 0x7C0A47A1, }, /* x=3D90 */ - { 0xAF75074C, 0x4CAF7507, 0x074CAF75, 0x75074CAF, }, /* x=3D91 */ - { 0xBD6E1051, 0x51BD6E10, 0x1051BD6E, 0x6E1051BD, }, /* x=3D92 */ - { 0xB3671D5A, 0x5AB3671D, 0x1D5AB367, 0x671D5AB3, }, /* x=3D93 */ - { 0x99583E6B, 0x6B99583E, 0x3E6B9958, 0x583E6B99, }, /* x=3D94 */ - { 0x97513360, 0x60975133, 0x33609751, 0x51336097, }, /* x=3D95 */ - { 0x854A247D, 0x7D854A24, 0x247D854A, 0x4A247D85, }, /* x=3D96 */ - { 0x8B432976, 0x768B4329, 0x29768B43, 0x4329768B, }, /* x=3D97 */ - { 0xD134621F, 0x1FD13462, 0x621FD134, 0x34621FD1, }, /* x=3D98 */ - { 0xDF3D6F14, 0x14DF3D6F, 0x6F14DF3D, 0x3D6F14DF, }, /* x=3D99 */ - { 0xCD267809, 0x09CD2678, 0x7809CD26, 0x267809CD, }, /* x=3D9A */ - { 0xC32F7502, 0x02C32F75, 0x7502C32F, 0x2F7502C3, }, /* x=3D9B */ - { 0xE9105633, 0x33E91056, 0x5633E910, 0x105633E9, }, /* x=3D9C */ - { 0xE7195B38, 0x38E7195B, 0x5B38E719, 0x195B38E7, }, /* x=3D9D */ - { 0xF5024C25, 0x25F5024C, 0x4C25F502, 0x024C25F5, }, /* x=3D9E */ - { 0xFB0B412E, 0x2EFB0B41, 0x412EFB0B, 0x0B412EFB, }, /* x=3D9F */ - { 0x9AD7618C, 0x8C9AD761, 0x618C9AD7, 0xD7618C9A, }, /* x=3DA0 */ - { 0x94DE6C87, 0x8794DE6C, 0x6C8794DE, 0xDE6C8794, }, /* x=3DA1 */ - { 0x86C57B9A, 0x9A86C57B, 0x7B9A86C5, 0xC57B9A86, }, /* x=3DA2 */ - { 0x88CC7691, 0x9188CC76, 0x769188CC, 0xCC769188, }, /* x=3DA3 */ - { 0xA2F355A0, 0xA0A2F355, 0x55A0A2F3, 0xF355A0A2, }, /* x=3DA4 */ - { 0xACFA58AB, 0xABACFA58, 0x58ABACFA, 0xFA58ABAC, }, /* x=3DA5 */ - { 0xBEE14FB6, 0xB6BEE14F, 0x4FB6BEE1, 0xE14FB6BE, }, /* x=3DA6 */ - { 0xB0E842BD, 0xBDB0E842, 0x42BDB0E8, 0xE842BDB0, }, /* x=3DA7 */ - { 0xEA9F09D4, 0xD4EA9F09, 0x09D4EA9F, 0x9F09D4EA, }, /* x=3DA8 */ - { 0xE49604DF, 0xDFE49604, 0x04DFE496, 0x9604DFE4, }, /* x=3DA9 */ - { 0xF68D13C2, 0xC2F68D13, 0x13C2F68D, 0x8D13C2F6, }, /* x=3DAA */ - { 0xF8841EC9, 0xC9F8841E, 0x1EC9F884, 0x841EC9F8, }, /* x=3DAB */ - { 0xD2BB3DF8, 0xF8D2BB3D, 0x3DF8D2BB, 0xBB3DF8D2, }, /* x=3DAC */ - { 0xDCB230F3, 0xF3DCB230, 0x30F3DCB2, 0xB230F3DC, }, /* x=3DAD */ - { 0xCEA927EE, 0xEECEA927, 0x27EECEA9, 0xA927EECE, }, /* x=3DAE */ - { 0xC0A02AE5, 0xE5C0A02A, 0x2AE5C0A0, 0xA02AE5C0, }, /* x=3DAF */ - { 0x7A47B13C, 0x3C7A47B1, 0xB13C7A47, 0x47B13C7A, }, /* x=3DB0 */ - { 0x744EBC37, 0x37744EBC, 0xBC37744E, 0x4EBC3774, }, /* x=3DB1 */ - { 0x6655AB2A, 0x2A6655AB, 0xAB2A6655, 0x55AB2A66, }, /* x=3DB2 */ - { 0x685CA621, 0x21685CA6, 0xA621685C, 0x5CA62168, }, /* x=3DB3 */ - { 0x42638510, 0x10426385, 0x85104263, 0x63851042, }, /* x=3DB4 */ - { 0x4C6A881B, 0x1B4C6A88, 0x881B4C6A, 0x6A881B4C, }, /* x=3DB5 */ - { 0x5E719F06, 0x065E719F, 0x9F065E71, 0x719F065E, }, /* x=3DB6 */ - { 0x5078920D, 0x0D507892, 0x920D5078, 0x78920D50, }, /* x=3DB7 */ - { 0x0A0FD964, 0x640A0FD9, 0xD9640A0F, 0x0FD9640A, }, /* x=3DB8 */ - { 0x0406D46F, 0x6F0406D4, 0xD46F0406, 0x06D46F04, }, /* x=3DB9 */ - { 0x161DC372, 0x72161DC3, 0xC372161D, 0x1DC37216, }, /* x=3DBA */ - { 0x1814CE79, 0x791814CE, 0xCE791814, 0x14CE7918, }, /* x=3DBB */ - { 0x322BED48, 0x48322BED, 0xED48322B, 0x2BED4832, }, /* x=3DBC */ - { 0x3C22E043, 0x433C22E0, 0xE0433C22, 0x22E0433C, }, /* x=3DBD */ - { 0x2E39F75E, 0x5E2E39F7, 0xF75E2E39, 0x39F75E2E, }, /* x=3DBE */ - { 0x2030FA55, 0x552030FA, 0xFA552030, 0x30FA5520, }, /* x=3DBF */ - { 0xEC9AB701, 0x01EC9AB7, 0xB701EC9A, 0x9AB701EC, }, /* x=3DC0 */ - { 0xE293BA0A, 0x0AE293BA, 0xBA0AE293, 0x93BA0AE2, }, /* x=3DC1 */ - { 0xF088AD17, 0x17F088AD, 0xAD17F088, 0x88AD17F0, }, /* x=3DC2 */ - { 0xFE81A01C, 0x1CFE81A0, 0xA01CFE81, 0x81A01CFE, }, /* x=3DC3 */ - { 0xD4BE832D, 0x2DD4BE83, 0x832DD4BE, 0xBE832DD4, }, /* x=3DC4 */ - { 0xDAB78E26, 0x26DAB78E, 0x8E26DAB7, 0xB78E26DA, }, /* x=3DC5 */ - { 0xC8AC993B, 0x3BC8AC99, 0x993BC8AC, 0xAC993BC8, }, /* x=3DC6 */ - { 0xC6A59430, 0x30C6A594, 0x9430C6A5, 0xA59430C6, }, /* x=3DC7 */ - { 0x9CD2DF59, 0x599CD2DF, 0xDF599CD2, 0xD2DF599C, }, /* x=3DC8 */ - { 0x92DBD252, 0x5292DBD2, 0xD25292DB, 0xDBD25292, }, /* x=3DC9 */ - { 0x80C0C54F, 0x4F80C0C5, 0xC54F80C0, 0xC0C54F80, }, /* x=3DCA */ - { 0x8EC9C844, 0x448EC9C8, 0xC8448EC9, 0xC9C8448E, }, /* x=3DCB */ - { 0xA4F6EB75, 0x75A4F6EB, 0xEB75A4F6, 0xF6EB75A4, }, /* x=3DCC */ - { 0xAAFFE67E, 0x7EAAFFE6, 0xE67EAAFF, 0xFFE67EAA, }, /* x=3DCD */ - { 0xB8E4F163, 0x63B8E4F1, 0xF163B8E4, 0xE4F163B8, }, /* x=3DCE */ - { 0xB6EDFC68, 0x68B6EDFC, 0xFC68B6ED, 0xEDFC68B6, }, /* x=3DCF */ - { 0x0C0A67B1, 0xB10C0A67, 0x67B10C0A, 0x0A67B10C, }, /* x=3DD0 */ - { 0x02036ABA, 0xBA02036A, 0x6ABA0203, 0x036ABA02, }, /* x=3DD1 */ - { 0x10187DA7, 0xA710187D, 0x7DA71018, 0x187DA710, }, /* x=3DD2 */ - { 0x1E1170AC, 0xAC1E1170, 0x70AC1E11, 0x1170AC1E, }, /* x=3DD3 */ - { 0x342E539D, 0x9D342E53, 0x539D342E, 0x2E539D34, }, /* x=3DD4 */ - { 0x3A275E96, 0x963A275E, 0x5E963A27, 0x275E963A, }, /* x=3DD5 */ - { 0x283C498B, 0x8B283C49, 0x498B283C, 0x3C498B28, }, /* x=3DD6 */ - { 0x26354480, 0x80263544, 0x44802635, 0x35448026, }, /* x=3DD7 */ - { 0x7C420FE9, 0xE97C420F, 0x0FE97C42, 0x420FE97C, }, /* x=3DD8 */ - { 0x724B02E2, 0xE2724B02, 0x02E2724B, 0x4B02E272, }, /* x=3DD9 */ - { 0x605015FF, 0xFF605015, 0x15FF6050, 0x5015FF60, }, /* x=3DDA */ - { 0x6E5918F4, 0xF46E5918, 0x18F46E59, 0x5918F46E, }, /* x=3DDB */ - { 0x44663BC5, 0xC544663B, 0x3BC54466, 0x663BC544, }, /* x=3DDC */ - { 0x4A6F36CE, 0xCE4A6F36, 0x36CE4A6F, 0x6F36CE4A, }, /* x=3DDD */ - { 0x587421D3, 0xD3587421, 0x21D35874, 0x7421D358, }, /* x=3DDE */ - { 0x567D2CD8, 0xD8567D2C, 0x2CD8567D, 0x7D2CD856, }, /* x=3DDF */ - { 0x37A10C7A, 0x7A37A10C, 0x0C7A37A1, 0xA10C7A37, }, /* x=3DE0 */ - { 0x39A80171, 0x7139A801, 0x017139A8, 0xA8017139, }, /* x=3DE1 */ - { 0x2BB3166C, 0x6C2BB316, 0x166C2BB3, 0xB3166C2B, }, /* x=3DE2 */ - { 0x25BA1B67, 0x6725BA1B, 0x1B6725BA, 0xBA1B6725, }, /* x=3DE3 */ - { 0x0F853856, 0x560F8538, 0x38560F85, 0x8538560F, }, /* x=3DE4 */ - { 0x018C355D, 0x5D018C35, 0x355D018C, 0x8C355D01, }, /* x=3DE5 */ - { 0x13972240, 0x40139722, 0x22401397, 0x97224013, }, /* x=3DE6 */ - { 0x1D9E2F4B, 0x4B1D9E2F, 0x2F4B1D9E, 0x9E2F4B1D, }, /* x=3DE7 */ - { 0x47E96422, 0x2247E964, 0x642247E9, 0xE9642247, }, /* x=3DE8 */ - { 0x49E06929, 0x2949E069, 0x692949E0, 0xE0692949, }, /* x=3DE9 */ - { 0x5BFB7E34, 0x345BFB7E, 0x7E345BFB, 0xFB7E345B, }, /* x=3DEA */ - { 0x55F2733F, 0x3F55F273, 0x733F55F2, 0xF2733F55, }, /* x=3DEB */ - { 0x7FCD500E, 0x0E7FCD50, 0x500E7FCD, 0xCD500E7F, }, /* x=3DEC */ - { 0x71C45D05, 0x0571C45D, 0x5D0571C4, 0xC45D0571, }, /* x=3DED */ - { 0x63DF4A18, 0x1863DF4A, 0x4A1863DF, 0xDF4A1863, }, /* x=3DEE */ - { 0x6DD64713, 0x136DD647, 0x47136DD6, 0xD647136D, }, /* x=3DEF */ - { 0xD731DCCA, 0xCAD731DC, 0xDCCAD731, 0x31DCCAD7, }, /* x=3DF0 */ - { 0xD938D1C1, 0xC1D938D1, 0xD1C1D938, 0x38D1C1D9, }, /* x=3DF1 */ - { 0xCB23C6DC, 0xDCCB23C6, 0xC6DCCB23, 0x23C6DCCB, }, /* x=3DF2 */ - { 0xC52ACBD7, 0xD7C52ACB, 0xCBD7C52A, 0x2ACBD7C5, }, /* x=3DF3 */ - { 0xEF15E8E6, 0xE6EF15E8, 0xE8E6EF15, 0x15E8E6EF, }, /* x=3DF4 */ - { 0xE11CE5ED, 0xEDE11CE5, 0xE5EDE11C, 0x1CE5EDE1, }, /* x=3DF5 */ - { 0xF307F2F0, 0xF0F307F2, 0xF2F0F307, 0x07F2F0F3, }, /* x=3DF6 */ - { 0xFD0EFFFB, 0xFBFD0EFF, 0xFFFBFD0E, 0x0EFFFBFD, }, /* x=3DF7 */ - { 0xA779B492, 0x92A779B4, 0xB492A779, 0x79B492A7, }, /* x=3DF8 */ - { 0xA970B999, 0x99A970B9, 0xB999A970, 0x70B999A9, }, /* x=3DF9 */ - { 0xBB6BAE84, 0x84BB6BAE, 0xAE84BB6B, 0x6BAE84BB, }, /* x=3DFA */ - { 0xB562A38F, 0x8FB562A3, 0xA38FB562, 0x62A38FB5, }, /* x=3DFB */ - { 0x9F5D80BE, 0xBE9F5D80, 0x80BE9F5D, 0x5D80BE9F, }, /* x=3DFC */ - { 0x91548DB5, 0xB591548D, 0x8DB59154, 0x548DB591, }, /* x=3DFD */ - { 0x834F9AA8, 0xA8834F9A, 0x9AA8834F, 0x4F9AA883, }, /* x=3DFE */ - { 0x8D4697A3, 0xA38D4697, 0x97A38D46, 0x4697A38D, }, /* x=3DFF */ -}; - - =20 /* AES_Te0[x] =3D S [x].[02, 01, 01, 03]; --=20 2.34.1 From nobody Tue May 14 18:40:19 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1688379114; cv=none; d=zohomail.com; s=zohoarc; b=i9e+7oANgGGW4BHbkwh8QEWuKEHs/MMyYBL2YIG4HjAYuBBfjjsfJMp8tRiOrmfRWfDCVp0hvXXEaIjZ9HWnYNOXYoDMnjBES33GsIFUePlbwT1IFdUnQkPKKYVHBwxHWwtXrw3337S6CgG558EUjTX/QQm7+Pv58Phv1lm0F7c= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1688379114; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=1F2YVr3IWQtmqpjJeR+MoFqCj9awn2sZVMTfzE1Dbtk=; b=kUPKifrOUG8Km/52VySOIgaa17odQayDN5F4uZfUuArELVSA9KtDfCztqBQS7VTKRgOkakRLmA3MoLVWkKfpxdbaczAo838NQpmMGjIkm5SwGEv6GP/i8w3rO4Q6sHjLONiI1Z9AFDo3WWIjBoqxlgMxgbTXY0C0Qxq0qNzB2L8= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 168837911491650.93258654168778; Mon, 3 Jul 2023 03:11:54 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qGGSY-0004L0-K3; Mon, 03 Jul 2023 06:07:06 -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 1qGGRp-0003Cn-A9 for qemu-devel@nongnu.org; Mon, 03 Jul 2023 06:06:24 -0400 Received: from mail-wr1-x42c.google.com ([2a00:1450:4864:20::42c]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qGGRX-00061h-2N for qemu-devel@nongnu.org; Mon, 03 Jul 2023 06:06:19 -0400 Received: by mail-wr1-x42c.google.com with SMTP id ffacd0b85a97d-313f61890fbso4703589f8f.3 for ; Mon, 03 Jul 2023 03:06:01 -0700 (PDT) Received: from stoup.home (91.232.79.188.dynamic.jazztel.es. [188.79.232.91]) by smtp.gmail.com with ESMTPSA id t5-20020a05600001c500b00313f7b077fesm18446562wrx.59.2023.07.03.03.05.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 03 Jul 2023 03:06:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1688378761; x=1690970761; 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=1F2YVr3IWQtmqpjJeR+MoFqCj9awn2sZVMTfzE1Dbtk=; b=QoD9a6Dzn0NYGriFaOR/LWOONhuhrExsniOfuKgpMiFjXddDF6Eile9w/vR55X8jC2 5pvwFy97RwqqOOwmvdfWcIEpIG+uHZsqcL2woHpE1aKuo2grAtKYxSi965WCEcr1ux7R h25VxkRZJDugys5OXqh/g1l9urofZI29ZwCsyoVyv5YlPWxY55J+0eWP5DaCEk8MIUgV /kc4Y8zdG869Wps7J7314pg8Z89SnZRiV5Ox6fIM0DriMX4V2mDE6wosNeJPUjQaeJ9w Vhrm/3xY/ZmF28mZK02BSZXDd/y6GsJwBCQ3/F42k0FkSNJuBn4gnW6JZIq5xco2+H5K q10w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1688378761; x=1690970761; 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=1F2YVr3IWQtmqpjJeR+MoFqCj9awn2sZVMTfzE1Dbtk=; b=gFh7DPr8qEPacsadkUdxXAQQ/n/YQY0nkYYvLhbx66oMlzziGS+TQ7DM9J+UE84gWc jb0aRF5hmkfB+HiEt7eYlAGzFG5EKn5T7H5Oc7KApHSVsyiLpsghL604DQ1IeMdVA6Wi 8fh6lIQIpQpW3HJ3nX4WucfT97bi8Ydy6OIzdWmRu+qkoJwJwe3OO/tDfuSVQt0kBt5U wwzooi+H+S6EHPbmny7N5ZuPMbheytfvOkPQzeHzOb26A9nHzAqg7mygAGwopa0mxKdD mDvUsiJsDbBHyPrgiwbT4MNG997pogrjgoAe99qw+Bs4TlGyIbAAzkrMQ0izby0duNSa 9d9A== X-Gm-Message-State: ABy/qLa0JhPQWgYS5tuEgcr17PLzE+7eSq6pvExdtZvZD3azK78RE1LX jTdFbCrqpsa/MqWGFsrtIQAUPu2NCHTy3tadlkQXCg== X-Google-Smtp-Source: APBJJlHee7hGakMrOLMy+Uo2aE8/VDwZduspvz6G3rnX8p3f0xk1n3a8q4DH+Se6AqpJ0NAwoYMIdA== X-Received: by 2002:adf:fa49:0:b0:314:212f:360b with SMTP id y9-20020adffa49000000b00314212f360bmr6528005wrr.17.1688378760778; Mon, 03 Jul 2023 03:06:00 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: qemu-arm@nongnu.org, qemu-riscv@nongnu.org, pbonzini@redhat.com, eduardo@habkost.net, alistair.francis@wdc.com, danielhb413@gmail.com, =?UTF-8?q?Daniel=20P=20=2E=20Berrang=C3=A9?= , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Subject: [PATCH v4 37/37] crypto: Unexport AES_*_rot, AES_TeN, AES_TdN Date: Mon, 3 Jul 2023 12:05:20 +0200 Message-Id: <20230703100520.68224-38-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230703100520.68224-1-richard.henderson@linaro.org> References: <20230703100520.68224-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::42c; envelope-from=richard.henderson@linaro.org; helo=mail-wr1-x42c.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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1688379116342100001 These arrays are no longer used outside of aes.c. Acked-by: Daniel P. Berrang=C3=A9 Reviewed-by: Philippe Mathieu-Daud=C3=A9 Signed-off-by: Richard Henderson --- include/crypto/aes.h | 25 ------------------------- crypto/aes.c | 33 +++++++++++++++++++++------------ 2 files changed, 21 insertions(+), 37 deletions(-) diff --git a/include/crypto/aes.h b/include/crypto/aes.h index 99209f51b9..709d4d226b 100644 --- a/include/crypto/aes.h +++ b/include/crypto/aes.h @@ -30,29 +30,4 @@ void AES_decrypt(const unsigned char *in, unsigned char = *out, extern const uint8_t AES_sbox[256]; extern const uint8_t AES_isbox[256]; =20 -/* AES MixColumns, for use with rot32. */ -extern const uint32_t AES_mc_rot[256]; - -/* AES InvMixColumns, for use with rot32. */ -extern const uint32_t AES_imc_rot[256]; - -/* -AES_Te0[x] =3D S [x].[02, 01, 01, 03]; -AES_Te1[x] =3D S [x].[03, 02, 01, 01]; -AES_Te2[x] =3D S [x].[01, 03, 02, 01]; -AES_Te3[x] =3D S [x].[01, 01, 03, 02]; -AES_Te4[x] =3D S [x].[01, 01, 01, 01]; - -AES_Td0[x] =3D Si[x].[0e, 09, 0d, 0b]; -AES_Td1[x] =3D Si[x].[0b, 0e, 09, 0d]; -AES_Td2[x] =3D Si[x].[0d, 0b, 0e, 09]; -AES_Td3[x] =3D Si[x].[09, 0d, 0b, 0e]; -AES_Td4[x] =3D Si[x].[01, 01, 01, 01]; -*/ - -extern const uint32_t AES_Te0[256], AES_Te1[256], AES_Te2[256], - AES_Te3[256], AES_Te4[256]; -extern const uint32_t AES_Td0[256], AES_Td1[256], AES_Td2[256], - AES_Td3[256], AES_Td4[256]; - #endif diff --git a/crypto/aes.c b/crypto/aes.c index 685efbd583..836d7d5c0b 100644 --- a/crypto/aes.c +++ b/crypto/aes.c @@ -120,7 +120,7 @@ const uint8_t AES_isbox[256] =3D { /* * MixColumns lookup table, for use with rot32. */ -const uint32_t AES_mc_rot[256] =3D { +static const uint32_t AES_mc_rot[256] =3D { 0x00000000, 0x03010102, 0x06020204, 0x05030306, 0x0c040408, 0x0f05050a, 0x0a06060c, 0x0907070e, 0x18080810, 0x1b090912, 0x1e0a0a14, 0x1d0b0b16, @@ -190,7 +190,7 @@ const uint32_t AES_mc_rot[256] =3D { /* * Inverse MixColumns lookup table, for use with rot32. */ -const uint32_t AES_imc_rot[256] =3D { +static const uint32_t AES_imc_rot[256] =3D { 0x00000000, 0x0b0d090e, 0x161a121c, 0x1d171b12, 0x2c342438, 0x27392d36, 0x3a2e3624, 0x31233f2a, 0x58684870, 0x5365417e, 0x4e725a6c, 0x457f5362, @@ -272,7 +272,7 @@ AES_Td3[x] =3D Si[x].[09, 0d, 0b, 0e]; AES_Td4[x] =3D Si[x].[01, 01, 01, 01]; */ =20 -const uint32_t AES_Te0[256] =3D { +static const uint32_t AES_Te0[256] =3D { 0xc66363a5U, 0xf87c7c84U, 0xee777799U, 0xf67b7b8dU, 0xfff2f20dU, 0xd66b6bbdU, 0xde6f6fb1U, 0x91c5c554U, 0x60303050U, 0x02010103U, 0xce6767a9U, 0x562b2b7dU, @@ -338,7 +338,8 @@ const uint32_t AES_Te0[256] =3D { 0x824141c3U, 0x299999b0U, 0x5a2d2d77U, 0x1e0f0f11U, 0x7bb0b0cbU, 0xa85454fcU, 0x6dbbbbd6U, 0x2c16163aU, }; -const uint32_t AES_Te1[256] =3D { + +static const uint32_t AES_Te1[256] =3D { 0xa5c66363U, 0x84f87c7cU, 0x99ee7777U, 0x8df67b7bU, 0x0dfff2f2U, 0xbdd66b6bU, 0xb1de6f6fU, 0x5491c5c5U, 0x50603030U, 0x03020101U, 0xa9ce6767U, 0x7d562b2bU, @@ -404,7 +405,8 @@ const uint32_t AES_Te1[256] =3D { 0xc3824141U, 0xb0299999U, 0x775a2d2dU, 0x111e0f0fU, 0xcb7bb0b0U, 0xfca85454U, 0xd66dbbbbU, 0x3a2c1616U, }; -const uint32_t AES_Te2[256] =3D { + +static const uint32_t AES_Te2[256] =3D { 0x63a5c663U, 0x7c84f87cU, 0x7799ee77U, 0x7b8df67bU, 0xf20dfff2U, 0x6bbdd66bU, 0x6fb1de6fU, 0xc55491c5U, 0x30506030U, 0x01030201U, 0x67a9ce67U, 0x2b7d562bU, @@ -470,8 +472,8 @@ const uint32_t AES_Te2[256] =3D { 0x41c38241U, 0x99b02999U, 0x2d775a2dU, 0x0f111e0fU, 0xb0cb7bb0U, 0x54fca854U, 0xbbd66dbbU, 0x163a2c16U, }; -const uint32_t AES_Te3[256] =3D { =20 +static const uint32_t AES_Te3[256] =3D { 0x6363a5c6U, 0x7c7c84f8U, 0x777799eeU, 0x7b7b8df6U, 0xf2f20dffU, 0x6b6bbdd6U, 0x6f6fb1deU, 0xc5c55491U, 0x30305060U, 0x01010302U, 0x6767a9ceU, 0x2b2b7d56U, @@ -537,7 +539,8 @@ const uint32_t AES_Te3[256] =3D { 0x4141c382U, 0x9999b029U, 0x2d2d775aU, 0x0f0f111eU, 0xb0b0cb7bU, 0x5454fca8U, 0xbbbbd66dU, 0x16163a2cU, }; -const uint32_t AES_Te4[256] =3D { + +static const uint32_t AES_Te4[256] =3D { 0x63636363U, 0x7c7c7c7cU, 0x77777777U, 0x7b7b7b7bU, 0xf2f2f2f2U, 0x6b6b6b6bU, 0x6f6f6f6fU, 0xc5c5c5c5U, 0x30303030U, 0x01010101U, 0x67676767U, 0x2b2b2b2bU, @@ -603,7 +606,8 @@ const uint32_t AES_Te4[256] =3D { 0x41414141U, 0x99999999U, 0x2d2d2d2dU, 0x0f0f0f0fU, 0xb0b0b0b0U, 0x54545454U, 0xbbbbbbbbU, 0x16161616U, }; -const uint32_t AES_Td0[256] =3D { + +static const uint32_t AES_Td0[256] =3D { 0x51f4a750U, 0x7e416553U, 0x1a17a4c3U, 0x3a275e96U, 0x3bab6bcbU, 0x1f9d45f1U, 0xacfa58abU, 0x4be30393U, 0x2030fa55U, 0xad766df6U, 0x88cc7691U, 0xf5024c25U, @@ -669,7 +673,8 @@ const uint32_t AES_Td0[256] =3D { 0x39a80171U, 0x080cb3deU, 0xd8b4e49cU, 0x6456c190U, 0x7bcb8461U, 0xd532b670U, 0x486c5c74U, 0xd0b85742U, }; -const uint32_t AES_Td1[256] =3D { + +static const uint32_t AES_Td1[256] =3D { 0x5051f4a7U, 0x537e4165U, 0xc31a17a4U, 0x963a275eU, 0xcb3bab6bU, 0xf11f9d45U, 0xabacfa58U, 0x934be303U, 0x552030faU, 0xf6ad766dU, 0x9188cc76U, 0x25f5024cU, @@ -735,7 +740,8 @@ const uint32_t AES_Td1[256] =3D { 0x7139a801U, 0xde080cb3U, 0x9cd8b4e4U, 0x906456c1U, 0x617bcb84U, 0x70d532b6U, 0x74486c5cU, 0x42d0b857U, }; -const uint32_t AES_Td2[256] =3D { + +static const uint32_t AES_Td2[256] =3D { 0xa75051f4U, 0x65537e41U, 0xa4c31a17U, 0x5e963a27U, 0x6bcb3babU, 0x45f11f9dU, 0x58abacfaU, 0x03934be3U, 0xfa552030U, 0x6df6ad76U, 0x769188ccU, 0x4c25f502U, @@ -802,7 +808,8 @@ const uint32_t AES_Td2[256] =3D { 0x017139a8U, 0xb3de080cU, 0xe49cd8b4U, 0xc1906456U, 0x84617bcbU, 0xb670d532U, 0x5c74486cU, 0x5742d0b8U, }; -const uint32_t AES_Td3[256] =3D { + +static const uint32_t AES_Td3[256] =3D { 0xf4a75051U, 0x4165537eU, 0x17a4c31aU, 0x275e963aU, 0xab6bcb3bU, 0x9d45f11fU, 0xfa58abacU, 0xe303934bU, 0x30fa5520U, 0x766df6adU, 0xcc769188U, 0x024c25f5U, @@ -868,7 +875,8 @@ const uint32_t AES_Td3[256] =3D { 0xa8017139U, 0x0cb3de08U, 0xb4e49cd8U, 0x56c19064U, 0xcb84617bU, 0x32b670d5U, 0x6c5c7448U, 0xb85742d0U, }; -const uint32_t AES_Td4[256] =3D { + +static const uint32_t AES_Td4[256] =3D { 0x52525252U, 0x09090909U, 0x6a6a6a6aU, 0xd5d5d5d5U, 0x30303030U, 0x36363636U, 0xa5a5a5a5U, 0x38383838U, 0xbfbfbfbfU, 0x40404040U, 0xa3a3a3a3U, 0x9e9e9e9eU, @@ -934,6 +942,7 @@ const uint32_t AES_Td4[256] =3D { 0xe1e1e1e1U, 0x69696969U, 0x14141414U, 0x63636363U, 0x55555555U, 0x21212121U, 0x0c0c0c0cU, 0x7d7d7d7dU, }; + static const u32 rcon[] =3D { 0x01000000, 0x02000000, 0x04000000, 0x08000000, 0x10000000, 0x20000000, 0x40000000, 0x80000000, --=20 2.34.1