From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-17.0 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4F5CAC4361B for ; Thu, 10 Dec 2020 18:13:28 +0000 (UTC) Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id EBD3D23D57 for ; Thu, 10 Dec 2020 18:13:27 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org EBD3D23D57 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:MIME-Version:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:References:In-Reply-To:Message-Id:Date:Subject:To: From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=jjKb1k9fdvT6v8aAooZKbZAEUvl3qmEXBOyFiXTttTk=; b=Z+KlnRtN9jzh3qhXxil7O7C4mK 6XW2FpIMN6e3ZrgNfAph9czYVvk0V+O55aj/Uo9n98ReTINehycQkIeYcekiSU9r4SEnhtfopb6k4 suaw5M9ZVErX9QKaMJ1LxQCxVcirHYp7b6jQEnOojVPZjKGW6JlQp4e1gK5LfAUu6eSKize5TVlEY sUl0dmKfjP3ZmPaElKPTOn5DBCz3YLoxk2t3i9esCr5TKgEXj1VU9i1ZPWeqm8FvVVhxWlz9dFgdl qM19X9sEycFjeiO8Z9QnS1C7QD3a+ZZQ/lQfE8mquKtWEr0vIueMzentyZqGJRL9oXDh5MxdvPJAT mgJY8Dvw==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1knQQF-0008GU-Uw; Thu, 10 Dec 2020 18:12:11 +0000 Received: from mail.kernel.org ([198.145.29.99]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1knQQC-0008Fc-7f for linux-arm-kernel@lists.infradead.org; Thu, 10 Dec 2020 18:12:08 +0000 From: Ard Biesheuvel Authentication-Results: mail.kernel.org; dkim=permerror (bad message/signature format) To: linux-crypto@vger.kernel.org Subject: [RFC PATCH 1/3] ARM: vfp: allow kernel mode NEON in softirq context Date: Thu, 10 Dec 2020 19:11:56 +0100 Message-Id: <20201210181158.28960-2-ardb@kernel.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20201210181158.28960-1-ardb@kernel.org> References: <20201210181158.28960-1-ardb@kernel.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20201210_131208_370442_FF2B17EF X-CRM114-Status: GOOD ( 15.51 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Herbert Xu , Ben Greear , Ard Biesheuvel , linux-arm-kernel@lists.infradead.org, Eric Biggers MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Allow kernel mode NEON to be used in softirq context as well as process context. To avoid nested use of the NEON, which would require the kernel mode process context NEON state to be preserved while the NEON is used in softirq context, turn off softirq processing when enabling kernel mode NEON. Signed-off-by: Ard Biesheuvel --- arch/arm/include/asm/simd.h | 12 ++++++++++++ arch/arm/vfp/vfpmodule.c | 11 +++++++---- 2 files changed, 19 insertions(+), 4 deletions(-) diff --git a/arch/arm/include/asm/simd.h b/arch/arm/include/asm/simd.h new file mode 100644 index 000000000000..0f44f0d9df4a --- /dev/null +++ b/arch/arm/include/asm/simd.h @@ -0,0 +1,12 @@ +/* SPDX-License-Identifier: GPL-2.0 */ + +#include + +/* + * may_use_simd - whether it is allowable at this time to issue SIMD + * instructions or access the SIMD register file + */ +static __must_check inline bool may_use_simd(void) +{ + return !in_irq() && !irqs_disabled() && !in_nmi(); +} diff --git a/arch/arm/vfp/vfpmodule.c b/arch/arm/vfp/vfpmodule.c index c3b6451c18bd..849703571ffa 100644 --- a/arch/arm/vfp/vfpmodule.c +++ b/arch/arm/vfp/vfpmodule.c @@ -21,6 +21,7 @@ #include #include +#include #include #include #include @@ -719,12 +720,13 @@ void kernel_neon_begin(void) u32 fpexc; /* - * Kernel mode NEON is only allowed outside of interrupt context - * with preemption disabled. This will make sure that the kernel - * mode NEON register contents never need to be preserved. + * Kernel mode NEON is only allowed outside of hard interrupt context + * with preemption and softirq processing disabled. This ensures that + * the kernel mode NEON register contents never need to be preserved. */ - BUG_ON(in_interrupt()); + BUG_ON(!may_use_simd()); cpu = get_cpu(); + local_bh_disable(); fpexc = fmrx(FPEXC) | FPEXC_EN; fmxr(FPEXC, fpexc); @@ -747,6 +749,7 @@ void kernel_neon_end(void) { /* Disable the NEON/VFP unit. */ fmxr(FPEXC, fmrx(FPEXC) & ~FPEXC_EN); + local_bh_enable(); put_cpu(); } EXPORT_SYMBOL(kernel_neon_end); -- 2.17.1 _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel