Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp9405963pxu; Mon, 28 Dec 2020 15:26:12 -0800 (PST) X-Google-Smtp-Source: ABdhPJzqfeShRUwkAuCXrUEEhiB61pvu4YjaUxE5Fvy609vzj5mkAB61bOCirtopSfxtK7uJS/gN X-Received: by 2002:a50:ac86:: with SMTP id x6mr44026581edc.197.1609197972094; Mon, 28 Dec 2020 15:26:12 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1609197972; cv=none; d=google.com; s=arc-20160816; b=irCUCMldMBXZG4jK8BEw/hqaB8O3f1TX+ORfzNK6DSwRqRkTCdqkPna2+/nSZLRzq6 8nnaWQNKvNOMw0hL7rX+5UCxaW1uTuUMwQxXhPMFUFqUGdLl4weE0clQ/eAJv/dVoCmv 7du8j5QvKra3nxgyA9F9nq65aFZKGE1rpw4gskPePtl8Wq8ehUgp58xib+5SVE3l2rO1 J2gqrMHHNcNism7UGSVErZoVkjRIRUk1jM7q9x1YNqGkr8zwnKz002LggpxcHay7AsIe wt5qdThFk77hGv49awOxqK64TkZuEpdEYNuXytwt/aaE07OJmuHoBiEnG34a7g/pIO2p yJtw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=zplXJUVpoCQZcqRPIJQM1t/ULjAiMexmEl8Igc/GpoM=; b=Y4Hfdu9pNV1tGR4J4AIAdVTmi1UEnKpabqUWRHGAUX1C81NPf+izO+YSy46GPWjrQV QfmC9MAmuCqErq/ITQ/Dnpx+tFGIULVhpS4mg/5cSc8/qA1IRtrmIVUg6VO3hX2negyn 9ELJ5Ye3wCVcZ8fQ/oM20hHfOGgo9sFC6kfyoq4wMi20CKV6EH5Y9etm/bai8bOmJ56n ceYsT3pA7cIKUF9BYzKIM6MxKHNN7TexA9x03BURJVDfffFazAL9SBLZkSsjOu16QBBM mTyXNJ7du3yoItplGPf89Gn3ODYahhg8qZ7Rc5tzn8QzibEAgcyO/PU2ATWBmjxt0Cg+ Q4WQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=IvjR8XZh; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id by16si18878541ejb.105.2020.12.28.15.25.49; Mon, 28 Dec 2020 15:26:12 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=IvjR8XZh; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2502944AbgL1OXx (ORCPT + 99 others); Mon, 28 Dec 2020 09:23:53 -0500 Received: from mail.kernel.org ([198.145.29.99]:59278 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2439224AbgL1OXW (ORCPT ); Mon, 28 Dec 2020 09:23:22 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id B0E14229C5; Mon, 28 Dec 2020 14:22:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1609165361; bh=TWf9/haxjXMGxCoZSiwcAasoXVdfqAYS/IuwVtlsvMQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=IvjR8XZhRuMqhUbdk7JV2J+03CSGYoaOAZE3JClik7PFvy8MhhxtvYHfjwrqfRajw BP36Y+wGLZqIfpi5eKFBYSGGEZT3JfTZH8CJLO0/fZcX6al1EMK/NYjinu3LrMfYQu 9cvyAmOA6rOypdsdcfJZnDLFrJUBJgMKA9y0ltZk= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, "kernelci.org bot" , Ard Biesheuvel , Russell King , Sasha Levin Subject: [PATCH 5.10 503/717] ARM: 9044/1: vfp: use undef hook for VFP support detection Date: Mon, 28 Dec 2020 13:48:21 +0100 Message-Id: <20201228125045.056652350@linuxfoundation.org> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201228125020.963311703@linuxfoundation.org> References: <20201228125020.963311703@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Ard Biesheuvel [ Upstream commit 3cce9d44321e460e7c88cdec4e4537a6e9ad7c0d ] Commit f77ac2e378be9dd6 ("ARM: 9030/1: entry: omit FP emulation for UND exceptions taken in kernel mode") failed to take into account that there is in fact a case where we relied on this code path: during boot, the VFP detection code issues a read of FPSID, which will trigger an undef exception on cores that lack VFP support. So let's reinstate this logic using an undef hook which is registered only for the duration of the initcall to vpf_init(), and which sets VFP_arch to a non-zero value - as before - if no VFP support is present. Fixes: f77ac2e378be9dd6 ("ARM: 9030/1: entry: omit FP emulation for UND ...") Reported-by: "kernelci.org bot" Signed-off-by: Ard Biesheuvel Signed-off-by: Russell King Signed-off-by: Sasha Levin --- arch/arm/vfp/entry.S | 17 ----------------- arch/arm/vfp/vfpmodule.c | 25 ++++++++++++++++++++----- 2 files changed, 20 insertions(+), 22 deletions(-) diff --git a/arch/arm/vfp/entry.S b/arch/arm/vfp/entry.S index 0186cf9da890b..27b0a1f27fbdf 100644 --- a/arch/arm/vfp/entry.S +++ b/arch/arm/vfp/entry.S @@ -37,20 +37,3 @@ ENDPROC(vfp_null_entry) .align 2 .LCvfp: .word vfp_vector - -@ This code is called if the VFP does not exist. It needs to flag the -@ failure to the VFP initialisation code. - - __INIT -ENTRY(vfp_testing_entry) - dec_preempt_count_ti r10, r4 - ldr r0, VFP_arch_address - str r0, [r0] @ set to non-zero value - ret r9 @ we have handled the fault -ENDPROC(vfp_testing_entry) - - .align 2 -VFP_arch_address: - .word VFP_arch - - __FINIT diff --git a/arch/arm/vfp/vfpmodule.c b/arch/arm/vfp/vfpmodule.c index c3b6451c18bda..2cb355c1b5b71 100644 --- a/arch/arm/vfp/vfpmodule.c +++ b/arch/arm/vfp/vfpmodule.c @@ -32,7 +32,6 @@ /* * Our undef handlers (in entry.S) */ -asmlinkage void vfp_testing_entry(void); asmlinkage void vfp_support_entry(void); asmlinkage void vfp_null_entry(void); @@ -43,7 +42,7 @@ asmlinkage void (*vfp_vector)(void) = vfp_null_entry; * Used in startup: set to non-zero if VFP checks fail * After startup, holds VFP architecture */ -unsigned int VFP_arch; +static unsigned int __initdata VFP_arch; /* * The pointer to the vfpstate structure of the thread which currently @@ -437,7 +436,7 @@ static void vfp_enable(void *unused) * present on all CPUs within a SMP complex. Needs to be called prior to * vfp_init(). */ -void vfp_disable(void) +void __init vfp_disable(void) { if (VFP_arch) { pr_debug("%s: should be called prior to vfp_init\n", __func__); @@ -707,7 +706,7 @@ static int __init vfp_kmode_exception_hook_init(void) register_undef_hook(&vfp_kmode_exception_hook[i]); return 0; } -core_initcall(vfp_kmode_exception_hook_init); +subsys_initcall(vfp_kmode_exception_hook_init); /* * Kernel-side NEON support functions @@ -753,6 +752,21 @@ EXPORT_SYMBOL(kernel_neon_end); #endif /* CONFIG_KERNEL_MODE_NEON */ +static int __init vfp_detect(struct pt_regs *regs, unsigned int instr) +{ + VFP_arch = UINT_MAX; /* mark as not present */ + regs->ARM_pc += 4; + return 0; +} + +static struct undef_hook vfp_detect_hook __initdata = { + .instr_mask = 0x0c000e00, + .instr_val = 0x0c000a00, + .cpsr_mask = MODE_MASK, + .cpsr_val = SVC_MODE, + .fn = vfp_detect, +}; + /* * VFP support code initialisation. */ @@ -773,10 +787,11 @@ static int __init vfp_init(void) * The handler is already setup to just log calls, so * we just need to read the VFPSID register. */ - vfp_vector = vfp_testing_entry; + register_undef_hook(&vfp_detect_hook); barrier(); vfpsid = fmrx(FPSID); barrier(); + unregister_undef_hook(&vfp_detect_hook); vfp_vector = vfp_null_entry; pr_info("VFP support v0.3: "); -- 2.27.0