From patchwork Wed Jun 28 08:05:13 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sebastian Andrzej Siewior X-Patchwork-Id: 13295328 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 366A9EB64DA for ; Wed, 28 Jun 2023 08:06:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=soR7ESgMuuFw2vCg0clif28yAKpbVYazlRhzjC/LicI=; b=UG7R49XrZt6gle CisLPnoIF4FrwqAo6W9KPcsA6P2YSFovVR42QUG3SYuq+RZxGPL1vYxwlar9rNM8Xjp8N/SqQ51cv 8nt9vrK+6ffiOOqSBzsbTvDkrg1HNtSsZOL9yr7F7CjhZ3B9st8fkVuKbqBtHYnzMriYv8VIGAkkC RidlNT3Cy0mQulPw9CcaE5VlGsaEch951FW3NcQYlrLpCGpXiTvOKLd5s295TLuEV0Gvi/2NZd5co qX0VZdelgy+Im13dCim7l2aCWlcJ4/6ztV+pEhVaUpZl+aP8mLG0c2G0JmewTJylDZWmPhmFZAztV jYqT2kDwtTClv4QmYZkA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qEQBI-00F7Yt-23; Wed, 28 Jun 2023 08:05:40 +0000 Received: from galois.linutronix.de ([193.142.43.55]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1qEQBF-00F7XJ-2n for linux-arm-kernel@lists.infradead.org; Wed, 28 Jun 2023 08:05:39 +0000 From: Sebastian Andrzej Siewior DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1687939532; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=qfXLkJc4J7D887ljO74gBwu9WWMz7jLm1uwGGp6XxxQ=; b=VIjKInJpg4yDYRV2sa5ApZHoCufaEZK1Puz1Xn4Z1vuwHLjhexIEBEE+fxqWBAmZqpRuzo oafhFUikbOUsloj8BIKw+1yQeFwd0ZMyvAza3zEEIXRKs3yV6N01a5KPGRjB+IRusgHEu/ fjwEKc1/4D5h1/KSCOu2KH2N88yeEjUQiJ1lSitCQjhWhWFQG8TR4jammSDTkR/Jt0Mofy 5YrnrCdNXzuW6TKO83OlSXMLHPlFBQXCPbgrLLn22V/hd95oEVPFe7U9jheA8boZGLIoXc KkQA1B7VtBSCGZy8Dcl3kLHJjptfTqB0oNUNhmXF//6t4R1HRxQTZZWV+aSUBg== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1687939532; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=qfXLkJc4J7D887ljO74gBwu9WWMz7jLm1uwGGp6XxxQ=; b=mHmWz9nPtsW72DO18HVcVZNHFvAcIiZ4ecke80dQuLS3n74+lilx5eXG4JuxD5ak9qF/Y6 NhYQSVdo+D7t5ABw== To: linux-arm-kernel@lists.infradead.org Cc: Russell King , Ard Biesheuvel , Thomas Gleixner , Sebastian Andrzej Siewior Subject: [PATCH v2 1/4] ARM: vfp: Provide vfp_lock() for VFP locking. Date: Wed, 28 Jun 2023 10:05:13 +0200 Message-Id: <20230628080516.798032-2-bigeasy@linutronix.de> In-Reply-To: <20230628080516.798032-1-bigeasy@linutronix.de> References: <20230628080516.798032-1-bigeasy@linutronix.de> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230628_010538_052423_D644AC7E X-CRM114-Status: GOOD ( 14.08 ) 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 kernel_neon_begin() uses local_bh_disable() to ensure exclusive access to the VFP unit. This is broken on PREEMPT_RT because a BH disabled section remains preemptible on PREEMPT_RT. Introduce vfp_lock() which uses local_bh_disable() and preempt_disable() on PREEMPT_RT. Since softirqs are processed always in thread context, disabling preemption is enough to ensure that the current context won't get interrupted by something that is using the VFP. Use it in kernel_neon_begin(). Signed-off-by: Sebastian Andrzej Siewior --- arch/arm/vfp/vfpmodule.c | 32 ++++++++++++++++++++++++++++++-- 1 file changed, 30 insertions(+), 2 deletions(-) diff --git a/arch/arm/vfp/vfpmodule.c b/arch/arm/vfp/vfpmodule.c index 58a9442add24b..0a21e13095809 100644 --- a/arch/arm/vfp/vfpmodule.c +++ b/arch/arm/vfp/vfpmodule.c @@ -54,6 +54,34 @@ extern unsigned int VFP_arch_feroceon __alias(VFP_arch); */ union vfp_state *vfp_current_hw_state[NR_CPUS]; +/* + * Claim ownership of the VFP unit. + * + * The caller may change VFP registers until vfp_unlock() is called. + * + * local_bh_disable() is used to disable preemption and to disable VFP + * processing in softirq context. On PREEMPT_RT kernels local_bh_disable() is + * not sufficient because it only serializes soft interrupt related sections + * via a local lock, but stays preemptible. Disabling preemption is the right + * choice here as bottom half processing is always in thread context on RT + * kernels so it implicitly prevents bottom half processing as well. + */ +static void vfp_lock(void) +{ + if (!IS_ENABLED(CONFIG_PREEMPT_RT)) + local_bh_disable(); + else + preempt_disable(); +} + +static void vfp_unlock(void) +{ + if (!IS_ENABLED(CONFIG_PREEMPT_RT)) + local_bh_enable(); + else + preempt_enable(); +} + /* * Is 'thread's most up to date state stored in this CPUs hardware? * Must be called from non-preemptible context. @@ -818,7 +846,7 @@ void kernel_neon_begin(void) unsigned int cpu; u32 fpexc; - local_bh_disable(); + vfp_lock(); /* * Kernel mode NEON is only allowed outside of hardirq context with @@ -849,7 +877,7 @@ void kernel_neon_end(void) { /* Disable the NEON/VFP unit. */ fmxr(FPEXC, fmrx(FPEXC) & ~FPEXC_EN); - local_bh_enable(); + vfp_unlock(); } EXPORT_SYMBOL(kernel_neon_end); From patchwork Wed Jun 28 08:05:14 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sebastian Andrzej Siewior X-Patchwork-Id: 13295329 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 8A765EB64DC for ; Wed, 28 Jun 2023 08:06:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=77mrozfZ/VBlmPNGV/e+ckZJXb81CHWksy3ZfK4jZY4=; b=CpdocYXHA6GncG ZqS8Y5NECDXL4SvmLTCtw33Ryh8VtCobzUbuvzuL3slWOTBat24jw6XT578M5RLWeYIeeUDA1J/6m hxm1eG4VPe+Dx3KaDokqO3Bf8ISBv5TA5qi3zgXVN/P5C7RUqx0/1Coe6W2o5kvjlwtIZPMqUfj19 RcXh18G58FcJIypXbR9MwpknEi/n3ZYWESBC7K59Hl+HsJmTUiXNOOa0W8em8AXwlIH7YpFdvcvOe 6TjWeBf0Uprc5jmDmYae4mIJjZw32hsk6nkP5xR8ChB6jwOk2wiy3DPHUwmhGnPbY40XzvP9CAGWX LvdCgqRdyTFq4/IKPRpQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qEQBI-00F7Yf-0N; Wed, 28 Jun 2023 08:05:40 +0000 Received: from galois.linutronix.de ([193.142.43.55]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1qEQBF-00F7XK-2n for linux-arm-kernel@lists.infradead.org; Wed, 28 Jun 2023 08:05:39 +0000 From: Sebastian Andrzej Siewior DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1687939533; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=HrA5rCi04S6iMZETdNVv7bbSACeaTlVUJZyjM+9n7RM=; b=Bxl4gLvlIZmB0oNBCX9SkSzneNyNiifzdmDNERngEpg2cOhagROErwASoVc2ylaHfO7XCV cgV7drKpSA7qgmoJEVxQ6+I0ex+TEP2jKgwhsuMFeEOTVUHSH+LvmI6eIQcdT0MyySFLto j3LfO4cRcp9LGziertxf3OX0XTfM2+ZLdTD5Y1xOiKbtmk/hjG/5QDSOihTqK2dvGSlg76 xjUqJUHR3g+JdY+a8liqXel/0WydvwvKclbA0TVdNRpp/B4udFchv7vGobDeox1Dv609pH 4s9QvTIjDWrd4Q4vFZE+nkTqF26qt9cmJZiJPDQZ44NV8iPUzy9xRAg4VTuFLA== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1687939533; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=HrA5rCi04S6iMZETdNVv7bbSACeaTlVUJZyjM+9n7RM=; b=meOtisLKBh/RR9OaSBb3CcAD0Oiy0VnuZ5Vd1ytoMuzUdCHdz2JAxKKJsokviie7LiaMDC WMOUkw9XUV2/gXAg== To: linux-arm-kernel@lists.infradead.org Cc: Russell King , Ard Biesheuvel , Thomas Gleixner , Sebastian Andrzej Siewior Subject: [PATCH v2 2/4] ARM: vfp: Use vfp_lock() in vfp_sync_hwstate(). Date: Wed, 28 Jun 2023 10:05:14 +0200 Message-Id: <20230628080516.798032-3-bigeasy@linutronix.de> In-Reply-To: <20230628080516.798032-1-bigeasy@linutronix.de> References: <20230628080516.798032-1-bigeasy@linutronix.de> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230628_010538_052269_E3208A59 X-CRM114-Status: GOOD ( 12.48 ) 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 vfp_sync_hwstate() uses preempt_disable() followed by local_bh_disable() to ensure that it won't get interrupted while checking the VFP state. This harms PREEMPT_RT because softirq handling can get preempted and local_bh_disable() synchronizes the related section with a sleeping lock which does not work with disabled preemption. Use the vfp_lock() to synchronize the access. Signed-off-by: Sebastian Andrzej Siewior --- arch/arm/vfp/vfpmodule.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/arch/arm/vfp/vfpmodule.c b/arch/arm/vfp/vfpmodule.c index 0a21e13095809..524aec81134ba 100644 --- a/arch/arm/vfp/vfpmodule.c +++ b/arch/arm/vfp/vfpmodule.c @@ -539,11 +539,9 @@ static inline void vfp_pm_init(void) { } */ void vfp_sync_hwstate(struct thread_info *thread) { - unsigned int cpu = get_cpu(); + vfp_lock(); - local_bh_disable(); - - if (vfp_state_in_hw(cpu, thread)) { + if (vfp_state_in_hw(raw_smp_processor_id(), thread)) { u32 fpexc = fmrx(FPEXC); /* @@ -554,8 +552,7 @@ void vfp_sync_hwstate(struct thread_info *thread) fmxr(FPEXC, fpexc); } - local_bh_enable(); - put_cpu(); + vfp_unlock(); } /* Ensure that the thread reloads the hardware VFP state on the next use. */ From patchwork Wed Jun 28 08:05:15 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sebastian Andrzej Siewior X-Patchwork-Id: 13295331 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 71053EB64DA for ; Wed, 28 Jun 2023 08:06:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=KBx4vln1Zx2+m6wmDxqsC6vkdKfwjTRBp/F0zqjOe3s=; b=Fq43K3dFcG6nxf 0EGKnKD5+xF0vG8nMgBMIDkbZyeyGMxtE+8hF7rjFjcbY97ouvVQrgja9PawDqeFiSslKdXtzj9gk bgxLutYPnjE0/ST04yPx44qC7eYvOPmugN3nKb/RaJfzLGDdHiw/wQld26Dn2NDZ2UiEofw1lS2QA 7ChOV/V7z6TiyF8F+cTikC2dS/lOG9fV5u9Vi+MgoJVH2fQxZITRHIWavhM9tEj7QlMgAM4brO+mx bnn6ubBjZ4cDoiTV2rr8XcddEFoveLr3SLkjRDi3ntX5ATxD0ORQANeYKhtDcwnrcESSlj+jmANkg yL0PgdMD5EN7dfWagfyg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qEQBY-00F7ay-2D; Wed, 28 Jun 2023 08:05:56 +0000 Received: from galois.linutronix.de ([2a0a:51c0:0:12e:550::1]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1qEQBG-00F7XL-1t for linux-arm-kernel@lists.infradead.org; Wed, 28 Jun 2023 08:05:40 +0000 From: Sebastian Andrzej Siewior DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1687939533; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=BcJGY1eymCInEWmIxxrDiwHtGGU+rmcWb/xiv15li7U=; b=2MPTk4IxfeCUbiQL46csR4g4DNbcDgIQhH1Ak8gupuivZ9WMcaSUeCRJhrMROaKQSL7smO TUfTPIzdw+DXXRv4yG88qPcEyi8kG74jj2J2BWqFnkVpuMV2UxXY15q0L3tn3mb8ZD5bG5 osZQX/3A7pUQJwp95RqbQYaLxy4HENzw1iGxyMkQTMpLIEG7zMqxZnoPu5XAUZymBD3h0L 1Q7j5dQZy9huD16VbbtRL1y9aJwZWdV0zZiJrCRY1pITP7bN3LG0WIuaUh0MErb8Tg+ZBa /Ps4H30EhJyo7jxh1bpWdZteHYlcTx9gU/LfrfY/tBcmQunRugcN+B6JbEkObw== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1687939533; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=BcJGY1eymCInEWmIxxrDiwHtGGU+rmcWb/xiv15li7U=; b=ytfkwPcnWdJuXzegrCdgDWSM8c5biIxpS7orqyynCk/Q9sbJg6iZihuIzDrGoq/WlRanX1 15FtxNRPojTdsyBA== To: linux-arm-kernel@lists.infradead.org Cc: Russell King , Ard Biesheuvel , Thomas Gleixner , Sebastian Andrzej Siewior Subject: [PATCH v2 3/4] ARM: vfp: Use vfp_lock() in vfp_support_entry(). Date: Wed, 28 Jun 2023 10:05:15 +0200 Message-Id: <20230628080516.798032-4-bigeasy@linutronix.de> In-Reply-To: <20230628080516.798032-1-bigeasy@linutronix.de> References: <20230628080516.798032-1-bigeasy@linutronix.de> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230628_010538_764144_1A999326 X-CRM114-Status: GOOD ( 10.37 ) 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 vfp_entry() is invoked from exception handler and is fully preemptible. It uses local_bh_disable() to remain uninterrupted while checking the VFP state. This is not working on PREEMPT_RT because local_bh_disable() synchronizes the relevant section but the context remains fully preemptible. Use vfp_lock() for uninterrupted access. Signed-off-by: Sebastian Andrzej Siewior --- arch/arm/vfp/vfpmodule.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/arch/arm/vfp/vfpmodule.c b/arch/arm/vfp/vfpmodule.c index 524aec81134ba..17e1c200a2305 100644 --- a/arch/arm/vfp/vfpmodule.c +++ b/arch/arm/vfp/vfpmodule.c @@ -707,7 +707,7 @@ static int vfp_support_entry(struct pt_regs *regs, u32 trigger) if (!user_mode(regs)) return vfp_kmode_exception(regs, trigger); - local_bh_disable(); + vfp_lock(); fpexc = fmrx(FPEXC); /* @@ -786,7 +786,7 @@ static int vfp_support_entry(struct pt_regs *regs, u32 trigger) if (!(fpscr & FPSCR_IXE)) { if (!(fpscr & FPSCR_LENGTH_MASK)) { pr_debug("not VFP\n"); - local_bh_enable(); + vfp_unlock(); return -ENOEXEC; } fpexc |= FPEXC_DEX; @@ -796,7 +796,7 @@ bounce: regs->ARM_pc += 4; VFP_bounce(trigger, fpexc, regs); } - local_bh_enable(); + vfp_unlock(); return 0; } From patchwork Wed Jun 28 08:05:16 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sebastian Andrzej Siewior X-Patchwork-Id: 13295332 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 D74A3C0015E for ; Wed, 28 Jun 2023 08:06:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=vvSZZK/A4lI3I+d4gnJR1JTdm4+JAJrqMJsJkqt27+4=; b=lma2npch1xWGOz NY4oiij0IyhThvqF//tVqIGmkfMgrSSPyvrpeWOEXgepBY9FhbAY9GC0x6Zc/+61SXu3pArG83sma CExp27tvElj0H9U5A7RNDia8zRtHmfOPZM4L17j7nyFEQkGBkvLBM9FvEn3nsjK5dK4Pina5z1jpk K4H35FwJSNWZSnM6VHwtSkm9+QAApQ4VoR40wSvfOvu00XNPYdLa6h7pKxeogrc1poihi0ovar0Z+ f8u1v3kH/1kckas0MPvKrPFuOsnE7T2rKk06GNoBuDdfyLnp//bniqrxsGJRrDTpQ73o9U7x1899O d9h/uId/GyRkXegK8zpw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qEQBZ-00F7bG-0X; Wed, 28 Jun 2023 08:05:57 +0000 Received: from galois.linutronix.de ([193.142.43.55]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1qEQBF-00F7XM-2n for linux-arm-kernel@lists.infradead.org; Wed, 28 Jun 2023 08:05:40 +0000 From: Sebastian Andrzej Siewior DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1687939533; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=u2a1LrAhU0Fx4WtW0GtzSx/eppjRqDS3VkyuSTGqhM0=; b=bDkQQbFjotjcp6Gpx/9kvURXkp6kqcok+2jCQYWiWSAVrrVlJXeP1V5WvNy/IiE7GD5hdE eKe7dX+60gj6RVmCokOdgnCAAEU9wnvujYwTQyrPKJKOl/BAcqme4+JQoaCCnZr/CKQ9XX jwdVDvqCN1mrxV4fl/gmAFWyiYvig5+kUAVvAz+HZodCYhVQVKqIYUcLmDaCZM2yje3gaB nQX/BZUQPgbZpIEEqDagtCRq5Sz0M1Y7HukuZjbcvgbCehaxYT+bTNZxxeaIR55TVMq8Gl A4yIPxna8THzQfx+I25+5pVdR3ObYsZ1gEqzAtsAbOe7xa8t5bPoxGXXN6MEDg== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1687939533; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=u2a1LrAhU0Fx4WtW0GtzSx/eppjRqDS3VkyuSTGqhM0=; b=HFAZhW0+Cud59S1Lk9M4XjVyATB1EXTl475mIdiQsqeBo+Hp36b1eXPDBldubbP4yqRzGr DjlltZ0fbab9XIAw== To: linux-arm-kernel@lists.infradead.org Cc: Russell King , Ard Biesheuvel , Thomas Gleixner , Sebastian Andrzej Siewior Subject: [PATCH v2 4/4] ARM: vfp: Move sending signals outside of vfp_lock()ed section. Date: Wed, 28 Jun 2023 10:05:16 +0200 Message-Id: <20230628080516.798032-5-bigeasy@linutronix.de> In-Reply-To: <20230628080516.798032-1-bigeasy@linutronix.de> References: <20230628080516.798032-1-bigeasy@linutronix.de> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230628_010538_195578_1C7F6689 X-CRM114-Status: GOOD ( 14.36 ) 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 VFP_bounce() is invoked from within vfp_support_entry() and may send a signal. Sending a signal uses spinlock_t which becomes a sleeping lock on PREEMPT_RT and must not be acquired within a preempt-disabled section. Move the vfp_raise_sigfpe() block outside of the vfp_lock() section. Signed-off-by: Sebastian Andrzej Siewior --- arch/arm/vfp/vfpmodule.c | 29 ++++++++++++++++++----------- 1 file changed, 18 insertions(+), 11 deletions(-) diff --git a/arch/arm/vfp/vfpmodule.c b/arch/arm/vfp/vfpmodule.c index 17e1c200a2305..67d7042bc3d5c 100644 --- a/arch/arm/vfp/vfpmodule.c +++ b/arch/arm/vfp/vfpmodule.c @@ -267,7 +267,7 @@ static void vfp_panic(char *reason, u32 inst) /* * Process bitmask of exception conditions. */ -static void vfp_raise_exceptions(u32 exceptions, u32 inst, u32 fpscr, struct pt_regs *regs) +static int vfp_raise_exceptions(u32 exceptions, u32 inst, u32 fpscr) { int si_code = 0; @@ -275,8 +275,7 @@ static void vfp_raise_exceptions(u32 exceptions, u32 inst, u32 fpscr, struct pt_ if (exceptions == VFP_EXCEPTION_ERROR) { vfp_panic("unhandled bounce", inst); - vfp_raise_sigfpe(FPE_FLTINV, regs); - return; + return FPE_FLTINV; } /* @@ -304,8 +303,7 @@ static void vfp_raise_exceptions(u32 exceptions, u32 inst, u32 fpscr, struct pt_ RAISE(FPSCR_OFC, FPSCR_OFE, FPE_FLTOVF); RAISE(FPSCR_IOC, FPSCR_IOE, FPE_FLTINV); - if (si_code) - vfp_raise_sigfpe(si_code, regs); + return si_code; } /* @@ -351,6 +349,8 @@ static u32 vfp_emulate_instruction(u32 inst, u32 fpscr, struct pt_regs *regs) static void VFP_bounce(u32 trigger, u32 fpexc, struct pt_regs *regs) { u32 fpscr, orig_fpscr, fpsid, exceptions; + int si_code2 = 0; + int si_code = 0; pr_debug("VFP: bounce: trigger %08x fpexc %08x\n", trigger, fpexc); @@ -396,8 +396,8 @@ static void VFP_bounce(u32 trigger, u32 fpexc, struct pt_regs *regs) * unallocated VFP instruction but with FPSCR.IXE set and not * on VFP subarch 1. */ - vfp_raise_exceptions(VFP_EXCEPTION_ERROR, trigger, fpscr, regs); - return; + si_code = vfp_raise_exceptions(VFP_EXCEPTION_ERROR, trigger, fpscr); + goto exit; } /* @@ -421,14 +421,14 @@ static void VFP_bounce(u32 trigger, u32 fpexc, struct pt_regs *regs) */ exceptions = vfp_emulate_instruction(trigger, fpscr, regs); if (exceptions) - vfp_raise_exceptions(exceptions, trigger, orig_fpscr, regs); + si_code2 = vfp_raise_exceptions(exceptions, trigger, orig_fpscr); /* * If there isn't a second FP instruction, exit now. Note that * the FPEXC.FP2V bit is valid only if FPEXC.EX is 1. */ if ((fpexc & (FPEXC_EX | FPEXC_FP2V)) != (FPEXC_EX | FPEXC_FP2V)) - return; + goto exit; /* * The barrier() here prevents fpinst2 being read @@ -440,7 +440,13 @@ static void VFP_bounce(u32 trigger, u32 fpexc, struct pt_regs *regs) emulate: exceptions = vfp_emulate_instruction(trigger, orig_fpscr, regs); if (exceptions) - vfp_raise_exceptions(exceptions, trigger, orig_fpscr, regs); + si_code = vfp_raise_exceptions(exceptions, trigger, orig_fpscr); +exit: + vfp_unlock(); + if (si_code2) + vfp_raise_sigfpe(si_code2, regs); + if (si_code) + vfp_raise_sigfpe(si_code, regs); } static void vfp_enable(void *unused) @@ -772,6 +778,7 @@ static int vfp_support_entry(struct pt_regs *regs, u32 trigger) * replay the instruction that trapped. */ fmxr(FPEXC, fpexc); + vfp_unlock(); } else { /* Check for synchronous or asynchronous exceptions */ if (!(fpexc & (FPEXC_EX | FPEXC_DEX))) { @@ -793,10 +800,10 @@ static int vfp_support_entry(struct pt_regs *regs, u32 trigger) } } bounce: regs->ARM_pc += 4; + /* VFP_bounce() will invoke vfp_unlock() */ VFP_bounce(trigger, fpexc, regs); } - vfp_unlock(); return 0; }