linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Tom Zanussi <zanussi@kernel.org>
To: linux-kernel@vger.kernel.org, linux-rt-users@vger.kernel.org
Cc: rostedt@goodmis.org, tglx@linutronix.de, C.Emde@osadl.org,
	jkacur@redhat.com, bigeasy@linutronix.de,
	daniel.wagner@siemens.com, julia@ni.com, amartin@nvidia.com
Subject: [PATCH 01/13] arm64: fpsimd: use preemp_disable in addition to local_bh_disable()
Date: Mon,  8 Apr 2019 14:14:03 -0500	[thread overview]
Message-ID: <b639e14b57a08f3a8931e44ed26101867414b4be.1554737688.git.tom.zanussi@linux.intel.com> (raw)
In-Reply-To: <cover.1554737688.git.tom.zanussi@linux.intel.com>
In-Reply-To: <cover.1554737688.git.tom.zanussi@linux.intel.com>

4.14.109-rt58-rc1 stable review patch.
If anyone has any objections, please let me know.

------------------

From: Sebastian Andrzej Siewior <bigeasy@linutronix.de>

[ Upstream commit 3afdfe419c33c1655d0763e070350aad44416594 ]

In v4.16-RT I noticed a number of warnings from task_fpsimd_load(). The
code disables BH and expects that it is not preemptible. On -RT the
task remains preemptible but remains the same CPU. This may corrupt the
content of the SIMD registers if the task is preempted during
saving/restoring those registers.

Add preempt_disable()/enable() to enfore the required semantic on -RT.

Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
[tom.zanussi@linux.intel.com: ignored sve-related changes]
Signed-off-by: Tom Zanussi <tom.zanussi@linux.intel.com>

 Conflicts:
	arch/arm64/kernel/fpsimd.c
---
 arch/arm64/kernel/fpsimd.c | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/arch/arm64/kernel/fpsimd.c b/arch/arm64/kernel/fpsimd.c
index 5d547deb6996..049641a458f3 100644
--- a/arch/arm64/kernel/fpsimd.c
+++ b/arch/arm64/kernel/fpsimd.c
@@ -172,6 +172,7 @@ void fpsimd_flush_thread(void)
 	if (!system_supports_fpsimd())
 		return;
 
+	preempt_disable();
 	local_bh_disable();
 
 	memset(&current->thread.fpsimd_state, 0, sizeof(struct fpsimd_state));
@@ -179,6 +180,7 @@ void fpsimd_flush_thread(void)
 	set_thread_flag(TIF_FOREIGN_FPSTATE);
 
 	local_bh_enable();
+	preempt_enable();
 }
 
 /*
@@ -190,12 +192,14 @@ void fpsimd_preserve_current_state(void)
 	if (!system_supports_fpsimd())
 		return;
 
+	preempt_disable();
 	local_bh_disable();
 
 	if (!test_thread_flag(TIF_FOREIGN_FPSTATE))
 		fpsimd_save_state(&current->thread.fpsimd_state);
 
 	local_bh_enable();
+	preempt_enable();
 }
 
 /*
@@ -208,6 +212,7 @@ void fpsimd_restore_current_state(void)
 	if (!system_supports_fpsimd())
 		return;
 
+	preempt_disable();
 	local_bh_disable();
 
 	if (test_and_clear_thread_flag(TIF_FOREIGN_FPSTATE)) {
@@ -219,6 +224,7 @@ void fpsimd_restore_current_state(void)
 	}
 
 	local_bh_enable();
+	preempt_enable();
 }
 
 /*
@@ -231,6 +237,7 @@ void fpsimd_update_current_state(struct fpsimd_state *state)
 	if (!system_supports_fpsimd())
 		return;
 
+	preempt_disable();
 	local_bh_disable();
 
 	fpsimd_load_state(state);
@@ -242,6 +249,7 @@ void fpsimd_update_current_state(struct fpsimd_state *state)
 	}
 
 	local_bh_enable();
+	preempt_enable();
 }
 
 /*
@@ -281,6 +289,7 @@ void kernel_neon_begin(void)
 
 	BUG_ON(!may_use_simd());
 
+	preempt_disable();
 	local_bh_disable();
 
 	__this_cpu_write(kernel_neon_busy, true);
@@ -295,6 +304,7 @@ void kernel_neon_begin(void)
 	preempt_disable();
 
 	local_bh_enable();
+	preempt_enable();
 }
 EXPORT_SYMBOL(kernel_neon_begin);
 
-- 
2.14.1


  reply	other threads:[~2019-04-08 19:14 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-04-08 19:14 [PATCH 00/13] Linux 4.14.109-rt58-rc1 Tom Zanussi
2019-04-08 19:14 ` Tom Zanussi [this message]
2019-04-08 19:14 ` [PATCH 02/13] sched/fair: Robustify CFS-bandwidth timer locking Tom Zanussi
2019-04-08 19:14 ` [PATCH 03/13] sched/fair: Make the hrtimers non-hard again Tom Zanussi
2019-04-08 19:14 ` [PATCH 04/13] locking/rt-mutex: Flush block plug on __down_read() Tom Zanussi
2019-04-08 19:14 ` [PATCH 05/13] rtmutex/rwlock: preserve state like a sleeping lock Tom Zanussi
2019-04-08 19:14 ` [PATCH 06/13] softirq: Avoid "local_softirq_pending" messages if ksoftirqd is blocked Tom Zanussi
2019-04-08 19:14 ` [PATCH 07/13] softirq: Avoid "local_softirq_pending" messages if task is in cpu_chill() Tom Zanussi
2019-04-08 19:14 ` [PATCH 08/13] hrtimer: Don't lose state " Tom Zanussi
2019-04-08 19:14 ` [PATCH 09/13] x86: lazy-preempt: properly check against preempt-mask Tom Zanussi
2019-04-08 19:14 ` [PATCH 10/13] hrtimer: cpu_chill(): save task state in ->saved_state() Tom Zanussi
2019-04-08 19:14 ` [PATCH 11/13] tty/sysrq: Convert show_lock to raw_spinlock_t Tom Zanussi
2019-04-08 19:14 ` [PATCH 12/13] powerpc/pseries/iommu: Use a locallock instead local_irq_save() Tom Zanussi
2019-04-08 19:14 ` [PATCH 13/13] Linux 4.14.109-rt58 Tom Zanussi

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=b639e14b57a08f3a8931e44ed26101867414b4be.1554737688.git.tom.zanussi@linux.intel.com \
    --to=zanussi@kernel.org \
    --cc=C.Emde@osadl.org \
    --cc=amartin@nvidia.com \
    --cc=bigeasy@linutronix.de \
    --cc=daniel.wagner@siemens.com \
    --cc=jkacur@redhat.com \
    --cc=julia@ni.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-rt-users@vger.kernel.org \
    --cc=rostedt@goodmis.org \
    --cc=tglx@linutronix.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).