From patchwork Fri Oct 18 23:53:43 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Biggers X-Patchwork-Id: 13842519 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id EF7B3D3E194 for ; Fri, 18 Oct 2024 23:55:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Transfer-Encoding: MIME-Version:Message-ID:Date:Subject:Cc:To:From:Reply-To:Content-Type: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References:List-Owner; bh=IPgsGgF4KthPNpQVjC0jXZl44mxLyz9le+Wu8qeudTM=; b=vRC0LRX/tm13X2pNy190b0+bOs NfspO8wjLqpjnVq8Pj9o7CZrbwe5UxihXbZR5iyHzjadt0XrcuZbJNMV9ZH4GBpw+srqT2CfcmEQu 5pRGHFTuaxq4+Q7i1w7mfZyxBqCiPFwrmSKt257iuWCO/BtFR7hztS5KQAfSzq24k5snqJ3MDLAKf BsECo+aV76d5oYuQrN2KKNAYvlsZlig0Z4ENfR/45oYOYb2vnutKu7KdygEM4yhf37pq70T13mrmU Qkr8MvErPETjiw5Lbf1ErzxhrqMxlgZwuxPVl/j+SJdFcf1CdtWDYbfuB2L/dQPnNpPR4LlFRd7su mhg/njYA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1t1wod-00000002Ibc-3gCA; Fri, 18 Oct 2024 23:55:31 +0000 Received: from dfw.source.kernel.org ([2604:1380:4641:c500::1]) by bombadil.infradead.org with esmtps (Exim 4.98 #2 (Red Hat Linux)) id 1t1wnA-00000002INj-3Hrn for linux-arm-kernel@lists.infradead.org; Fri, 18 Oct 2024 23:54:02 +0000 Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by dfw.source.kernel.org (Postfix) with ESMTP id 6949B5C0FA4 for ; Fri, 18 Oct 2024 23:53:55 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 5CFF2C4CEC3; Fri, 18 Oct 2024 23:53:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1729295639; bh=elOLD3WjAMYZQazXg2MfqiGC4poV1qZ75XpOhxfqRvA=; h=From:To:Cc:Subject:Date:From; b=GzNaUc0L/q0xETsXLZ74DJ6nsirKY5DimiizEpYR2NSXyNScxb+gWNQwYRacL5Ae7 H2/7fJ8zYuVkb8iNbQKn14NAZErF6Vv+TW64OIb6/B2wOYoBoTtBMVuiSjMrqpb8JY ctVtERDBelfWiuQzCoxYD8KaPHUEj0Y0qfLvmoAws2hQiSmoJmEwsRfby9dia3kyxW g3dG1fb8Jlaq5haWsxiLLcrWWTErCE4YWqEANREv4u9uU1M8gjhcf9fba879ibZQgE jPxgvBbKHT6zG4GrxkODT6ZFR1x649NJyvcbWI9eCURzQO1qdXMr6FF7g5KMKuFZdl QMXVwTRg+8UhQ== From: Eric Biggers To: linux-crypto@vger.kernel.org Cc: Ard Biesheuvel , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH] crypto - move crypto_simd_disabled_for_test to lib Date: Fri, 18 Oct 2024 16:53:43 -0700 Message-ID: <20241018235343.425758-1-ebiggers@kernel.org> X-Mailer: git-send-email 2.47.0 MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20241018_165400_933632_3D0DCCFA X-CRM114-Status: GOOD ( 15.38 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org From: Eric Biggers Move crypto_simd_disabled_for_test to lib/ so that crypto_simd_usable() can be used by library code. This was discussed previously (https://lore.kernel.org/linux-crypto/20220716062920.210381-4-ebiggers@kernel.org/) but was not done because there was no use case yet. However, this is now needed for the arm64 CRC32 library code. Tested with: export ARCH=arm64 CROSS_COMPILE=aarch64-linux-gnu- echo CONFIG_CRC32=y > .config echo CONFIG_MODULES=y >> .config echo CONFIG_CRYPTO=m >> .config echo CONFIG_DEBUG_KERNEL=y >> .config echo CONFIG_CRYPTO_MANAGER_DISABLE_TESTS=n >> .config echo CONFIG_CRYPTO_MANAGER_EXTRA_TESTS=y >> .config make olddefconfig make -j$(nproc) Signed-off-by: Eric Biggers Acked-by: Ard Biesheuvel --- crypto/algapi.c | 6 ------ lib/crypto/Makefile | 2 ++ lib/crypto/simd.c | 11 +++++++++++ 3 files changed, 13 insertions(+), 6 deletions(-) create mode 100644 lib/crypto/simd.c base-commit: 5c20772738e1d1d7bec41664eb9d61497e53c10e diff --git a/crypto/algapi.c b/crypto/algapi.c index 74e2261c184ca..429a832f90fe0 100644 --- a/crypto/algapi.c +++ b/crypto/algapi.c @@ -4,11 +4,10 @@ * * Copyright (c) 2006 Herbert Xu */ #include -#include #include #include #include #include #include @@ -21,15 +20,10 @@ #include "internal.h" static LIST_HEAD(crypto_template_list); -#ifdef CONFIG_CRYPTO_MANAGER_EXTRA_TESTS -DEFINE_PER_CPU(bool, crypto_simd_disabled_for_test); -EXPORT_PER_CPU_SYMBOL_GPL(crypto_simd_disabled_for_test); -#endif - static inline void crypto_check_module_sig(struct module *mod) { if (fips_enabled && mod && !module_sig_ok(mod)) panic("Module %s signature verification failed in FIPS mode\n", module_name(mod)); diff --git a/lib/crypto/Makefile b/lib/crypto/Makefile index 969baab8c805f..01fac1cd05a19 100644 --- a/lib/crypto/Makefile +++ b/lib/crypto/Makefile @@ -56,5 +56,7 @@ libblake2s-y += blake2s-selftest.o libchacha20poly1305-y += chacha20poly1305-selftest.o libcurve25519-y += curve25519-selftest.o endif obj-$(CONFIG_MPILIB) += mpi/ + +obj-$(CONFIG_CRYPTO_MANAGER_EXTRA_TESTS) += simd.o diff --git a/lib/crypto/simd.c b/lib/crypto/simd.c new file mode 100644 index 0000000000000..9c36cb3bb49c4 --- /dev/null +++ b/lib/crypto/simd.c @@ -0,0 +1,11 @@ +// SPDX-License-Identifier: GPL-2.0-or-later +/* + * SIMD testing utility functions + * + * Copyright 2024 Google LLC + */ + +#include + +DEFINE_PER_CPU(bool, crypto_simd_disabled_for_test); +EXPORT_PER_CPU_SYMBOL_GPL(crypto_simd_disabled_for_test);