Received: by 2002:a05:6358:700f:b0:131:369:b2a3 with SMTP id 15csp3259577rwo; Fri, 4 Aug 2023 01:51:13 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEK8+MLdjft8ioZ/UWbmUTGKdT1i0x6WrFzupqvAgI7Z7o43HviBR3ippvY0zXaAZyBL6K2 X-Received: by 2002:a17:907:2cea:b0:994:1844:c7d1 with SMTP id hz10-20020a1709072cea00b009941844c7d1mr829806ejc.13.1691139072274; Fri, 04 Aug 2023 01:51:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1691139072; cv=none; d=google.com; s=arc-20160816; b=dLM7mJxIcS70GMemJO1IiS169+FB4ioMwHmEdZjUqLLcYoJCMa7EwjfuDSmuMWGH3s izvmqYusMYiSZtweyplJPGfUd80KW8ZFA72cJLaTOW2rPGnq6/M5EuoA2yNcqNvirPDJ e8BSrIddpjlIa1zaD2gwR1qHa0iIjeumopnehk35aN5e4Zps89uxeudoCu5P3O/8tbZc LJvV2GJIlv5JUcqaekXUdglRQBfWRv+94PGAueDRCPLNtSxNokccw5tAlbLyT60F75ru O+LoEJVOi+7khkVt0mERvv78YZ69uQQXcx9BaWyN6q5W7kyexRQvhNpHsrBU7Dp+pJ8e r7dg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=vUAT3BOTvNkXAYmzka8IMzbGwQ7ta/a4iqxSWKYQ63A=; fh=50j3cwNxl6aRnHSY5NqWpvHMC39abtiiCzGc9tsS17E=; b=czB0Of9jnuJryduVgaVCRd5takb0EO++AJYc6CguuxjQH5HdY6UXDQdXS1Ci8w7xfe RdQUvh92KPd+3uKZL9duUKYiobh5GapV0rT9wAlGZZX8ObtTAWYC2v7EgPfAwCpcJxfv 27Tv28Clgv/D8Wg/EDMHurc+/TXqRUuS1j/K2Mc1iPQa+Z5qzE1cS8XNzJSTFFCkk/Kn +M3ze0Y/D8ol8T4MHzUUuDkc8hjqCmC+e3mLcl/0OglYMDbR/6mM5O1WQzjfQ600kLfk NyOGczPvXX5X8QQEAokrOqNNfhmmTn8ANMz/7k4IA36v7RZAdBKFwSqbLHV8swZ0oX1M BD8Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=FVn33WJg; spf=pass (google.com: domain of linux-crypto-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-crypto-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id bk6-20020a170906b0c600b0099c05358e73si385713ejb.688.2023.08.04.01.50.46; Fri, 04 Aug 2023 01:51:12 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-crypto-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=FVn33WJg; spf=pass (google.com: domain of linux-crypto-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-crypto-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230023AbjHDIbq (ORCPT + 99 others); Fri, 4 Aug 2023 04:31:46 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35604 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233444AbjHDIbh (ORCPT ); Fri, 4 Aug 2023 04:31:37 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8BF19101 for ; Fri, 4 Aug 2023 01:31:36 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 1782361F64 for ; Fri, 4 Aug 2023 08:31:36 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 73D7AC433C9 for ; Fri, 4 Aug 2023 08:31:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1691137895; bh=PMg5/i5K6XzQCEgkCjUpkRAzmh6AZZ34kkvt76wThO8=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=FVn33WJgCOhX/L/aX9CJo9m9KHr7oGPIwOtTaIpJW8jvpEcfdsY5eVpiqB5YO+aDZ nvP1uETCAOpaN/LJcmwHO7kNJcK2blZ1vvtuZ3S+zXS9RSdY8seY6FzLLCAaiAefkk 654XZRJan4tiO8dnOw3unchH4AMv8o9RXHGLbmkG59t0f0/sWtHTreSzpneWDCDRwr RoXiY6TZcTQrAz87KJK668zhFFap36DB/I+fkX74Dbdq8aPMEhwnnjWVLVxBUOSyhq N6V0xj1J8ocj5QHDtWtydrnH1MDx772cV3RP/CwM5VFWSyobY4wV79Gi4OGPtUs6dH IRHR7xbZXvvIQ== Received: by mail-lf1-f46.google.com with SMTP id 2adb3069b0e04-4fe389d6f19so3064605e87.3 for ; Fri, 04 Aug 2023 01:31:35 -0700 (PDT) X-Gm-Message-State: AOJu0Yy1k7rGfnOwYLEBlj/3QHaMJcDBBTdz/FoMkE0xmpU2jhRrk1Tn /KPJ0YMkynd5ICPaKXZu2OMA5xk/mLCfj7WfcW0= X-Received: by 2002:a05:6512:1cd:b0:4fb:8f79:631 with SMTP id f13-20020a05651201cd00b004fb8f790631mr690035lfp.46.1691137893509; Fri, 04 Aug 2023 01:31:33 -0700 (PDT) MIME-Version: 1.0 References: <20230726172958.1215472-1-ardb@kernel.org> In-Reply-To: From: Ard Biesheuvel Date: Fri, 4 Aug 2023 10:31:22 +0200 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH] crypto: riscv/aes - Implement scalar Zkn version for RV32 To: Herbert Xu Cc: linux-crypto@vger.kernel.org, ebiggers@kernel.org, linux-riscv@lists.infradead.org, Paul Walmsley , Palmer Dabbelt , Albert Ou , =?UTF-8?Q?Christoph_M=C3=BCllner?= , Heiko Stuebner Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org On Fri, 4 Aug 2023 at 10:21, Herbert Xu wrote= : > > On Wed, Jul 26, 2023 at 07:29:58PM +0200, Ard Biesheuvel wrote: > > The generic AES implementation we rely on if no architecture specific > > one is available relies on lookup tables that are relatively large with > > respect to the typical L1 D-cache size, which not only affects > > performance, it may also result in timing variances that correlate with > > the encryption keys. > > > > So we tend to avoid the generic code if we can, usually by using a > > driver that makes use of special AES instructions which supplant most o= f > > the logic of the table based implementation the AES algorithm. > > > > The Zkn RISC-V extension provides another interesting take on this: it > > defines instructions operating on scalar registers that implement the > > table lookups without relying on tables in memory. Those tables carry > > 32-bit quantities, making them a natural fit for a 32-bit architecture. > > And given the use of scalars, we don't have to rely in in-kernel SIMD, > > which is a bonus. > > > > So let's use the instructions to implement the core AES cipher for RV32= . > > > > Cc: Paul Walmsley > > Cc: Palmer Dabbelt > > Cc: Albert Ou > > Cc: Christoph M=C3=BCllner > > Cc: Heiko Stuebner > > Signed-off-by: Ard Biesheuvel > > --- > > arch/riscv/crypto/Kconfig | 12 ++ > > arch/riscv/crypto/Makefile | 3 + > > arch/riscv/crypto/aes-riscv32-glue.c | 75 ++++++++++++ > > arch/riscv/crypto/aes-riscv32-zkned.S | 119 ++++++++++++++++++++ > > 4 files changed, 209 insertions(+) > > Hi Ard: > > Any chance you could postpone this til after I've finished removing > crypto_cipher? > That's fine with me. Do you have an ETA on that? Need any help? I have implemented the scalar 64-bit counterpart as well in the mean time