linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/9] x86/entry fixes
@ 2020-06-03 11:40 Peter Zijlstra
  2020-06-03 11:40 ` [PATCH 1/9] x86/entry: Fix irq_exit() Peter Zijlstra
                   ` (9 more replies)
  0 siblings, 10 replies; 52+ messages in thread
From: Peter Zijlstra @ 2020-06-03 11:40 UTC (permalink / raw)
  To: tglx
  Cc: x86, elver, paulmck, kasan-dev, linux-kernel, peterz, will,
	dvyukov, glider, andreyknvl

The first patch is a fix for x86/entry, I'm quicky runing out of brown paper bags again :/

The rest goes on top of these:

  https://lkml.kernel.org/r/20200602173103.931412766@infradead.org
  https://lkml.kernel.org/r/20200602184409.22142-1-elver@google.com

patches from myself and Marco that enable *SAN builds. So far GCC-KASAN seen to
behave quite well, I've yet to try UBSAN.


^ permalink raw reply	[flat|nested] 52+ messages in thread
* [tip: x86/entry] x86/entry, cpumask: Provide non-instrumented variant of cpu_is_offline()
@ 2020-06-15 22:31 tip-bot2 for Peter Zijlstra
  0 siblings, 0 replies; 52+ messages in thread
From: tip-bot2 for Peter Zijlstra @ 2020-06-15 22:31 UTC (permalink / raw)
  To: linux-tip-commits; +Cc: Peter Zijlstra (Intel), x86, LKML

The following commit has been merged into the x86/entry branch of tip:

Commit-ID:     14d3b376b6c3f66d62559d457d32edf565472163
Gitweb:        https://git.kernel.org/tip/14d3b376b6c3f66d62559d457d32edf565472163
Author:        Peter Zijlstra <peterz@infradead.org>
AuthorDate:    Wed, 03 Jun 2020 13:32:48 +02:00
Committer:     Peter Zijlstra <peterz@infradead.org>
CommitterDate: Mon, 15 Jun 2020 14:10:09 +02:00

x86/entry, cpumask: Provide non-instrumented variant of cpu_is_offline()

vmlinux.o: warning: objtool: exc_nmi()+0x12: call to cpumask_test_cpu.constprop.0() leaves .noinstr.text section
vmlinux.o: warning: objtool: mce_check_crashing_cpu()+0x12: call to cpumask_test_cpu.constprop.0()leaves .noinstr.text section

  cpumask_test_cpu()
    test_bit()
      instrument_atomic_read()
      arch_test_bit()

Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
---
 arch/x86/include/asm/cpumask.h | 18 ++++++++++++++++++
 arch/x86/kernel/cpu/mce/core.c |  2 +-
 arch/x86/kernel/nmi.c          |  2 +-
 3 files changed, 20 insertions(+), 2 deletions(-)

diff --git a/arch/x86/include/asm/cpumask.h b/arch/x86/include/asm/cpumask.h
index 6722ffc..3afa990 100644
--- a/arch/x86/include/asm/cpumask.h
+++ b/arch/x86/include/asm/cpumask.h
@@ -11,5 +11,23 @@ extern cpumask_var_t cpu_sibling_setup_mask;
 
 extern void setup_cpu_local_masks(void);
 
+/*
+ * NMI and MCE exceptions need cpu_is_offline() _really_ early,
+ * provide an arch_ special for them to avoid instrumentation.
+ */
+#if NR_CPUS > 1
+static __always_inline bool arch_cpu_online(int cpu)
+{
+	return arch_test_bit(cpu, cpumask_bits(cpu_online_mask));
+}
+#else
+static __always_inline bool arch_cpu_online(int cpu)
+{
+	return cpu == 0;
+}
+#endif
+
+#define arch_cpu_is_offline(cpu)	unlikely(!arch_cpu_online(cpu))
+
 #endif /* __ASSEMBLY__ */
 #endif /* _ASM_X86_CPUMASK_H */
diff --git a/arch/x86/kernel/cpu/mce/core.c b/arch/x86/kernel/cpu/mce/core.c
index ce9120c..fbe89a9 100644
--- a/arch/x86/kernel/cpu/mce/core.c
+++ b/arch/x86/kernel/cpu/mce/core.c
@@ -1083,7 +1083,7 @@ static noinstr bool mce_check_crashing_cpu(void)
 {
 	unsigned int cpu = smp_processor_id();
 
-	if (cpu_is_offline(cpu) ||
+	if (arch_cpu_is_offline(cpu) ||
 	    (crashing_cpu != -1 && crashing_cpu != cpu)) {
 		u64 mcgstatus;
 
diff --git a/arch/x86/kernel/nmi.c b/arch/x86/kernel/nmi.c
index 2de365f..d7c5e44 100644
--- a/arch/x86/kernel/nmi.c
+++ b/arch/x86/kernel/nmi.c
@@ -478,7 +478,7 @@ static DEFINE_PER_CPU(unsigned long, nmi_dr7);
 
 DEFINE_IDTENTRY_RAW(exc_nmi)
 {
-	if (IS_ENABLED(CONFIG_SMP) && cpu_is_offline(smp_processor_id()))
+	if (IS_ENABLED(CONFIG_SMP) && arch_cpu_is_offline(smp_processor_id()))
 		return;
 
 	if (this_cpu_read(nmi_state) != NMI_NOT_RUNNING) {

^ permalink raw reply related	[flat|nested] 52+ messages in thread

end of thread, other threads:[~2020-06-24 13:03 UTC | newest]

Thread overview: 52+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-06-03 11:40 [PATCH 0/9] x86/entry fixes Peter Zijlstra
2020-06-03 11:40 ` [PATCH 1/9] x86/entry: Fix irq_exit() Peter Zijlstra
2020-06-03 11:40 ` [PATCH 2/9] rcu: Fixup noinstr warnings Peter Zijlstra
2020-06-03 16:46   ` Paul E. McKenney
2020-06-03 17:13     ` Peter Zijlstra
2020-06-04  3:34       ` Paul E. McKenney
2020-06-04  6:02         ` Marco Elver
2020-06-04 14:14           ` Paul E. McKenney
2020-06-04  8:05         ` Peter Zijlstra
2020-06-04 14:17           ` Paul E. McKenney
2020-06-15 15:30     ` Peter Zijlstra
2020-06-15 15:52       ` Paul E. McKenney
2020-06-15 16:06         ` Peter Zijlstra
2020-06-15 15:49   ` Peter Zijlstra
2020-06-15 15:55     ` Peter Zijlstra
2020-06-15 16:24       ` Peter Zijlstra
2020-06-15 17:14         ` Paul E. McKenney
2020-06-15 18:33           ` Peter Zijlstra
2020-06-15 18:59             ` Paul E. McKenney
2020-06-15 20:00           ` Paul E. McKenney
2020-06-19 22:15           ` Paul E. McKenney
2020-06-23 20:46             ` Peter Zijlstra
2020-06-23 21:44               ` Paul E. McKenney
2020-06-24  7:52                 ` Peter Zijlstra
2020-06-24 13:03                   ` Paul E. McKenney
2020-06-03 11:40 ` [PATCH 3/9] x86/entry: __always_inline debugreg for noinstr Peter Zijlstra
2020-06-03 17:50   ` [tip: x86/entry] " tip-bot2 for Peter Zijlstra
2020-06-03 11:40 ` [PATCH 4/9] x86/entry: __always_inline irqflags " Peter Zijlstra
2020-06-03 17:50   ` [tip: x86/entry] " tip-bot2 for Peter Zijlstra
2020-06-03 11:40 ` [PATCH 5/9] x86/entry: __always_inline arch_atomic_* " Peter Zijlstra
2020-06-03 17:50   ` [tip: x86/entry] " tip-bot2 for Peter Zijlstra
2020-06-03 11:40 ` [PATCH 6/9] x86/entry: Re-order #DB handler to avoid *SAN instrumentation Peter Zijlstra
2020-06-03 17:50   ` [tip: x86/entry] " tip-bot2 for Peter Zijlstra
2020-06-03 11:40 ` [PATCH 7/9] lockdep: __always_inline more for noinstr Peter Zijlstra
2020-06-03 17:50   ` [tip: x86/entry] " tip-bot2 for Peter Zijlstra
2020-06-03 11:40 ` [PATCH 8/9] x86/entry: __always_inline CR2 " Peter Zijlstra
2020-06-03 17:50   ` [tip: x86/entry] " tip-bot2 for Peter Zijlstra
2020-06-03 11:40 ` [PATCH 9/9] x86/entry, cpumask: Provide non-instrumented variant of cpu_is_offline() Peter Zijlstra
2020-06-03 17:50   ` [tip: x86/entry] " tip-bot2 for Peter Zijlstra
2020-06-03 12:00 ` [PATCH 0/9] x86/entry fixes Peter Zijlstra
2020-06-03 12:08   ` Peter Zijlstra
2020-06-03 12:08     ` Marco Elver
2020-06-03 12:18       ` Peter Zijlstra
2020-06-03 13:32         ` Marco Elver
2020-06-03 14:47           ` Marco Elver
2020-06-03 16:07             ` Peter Zijlstra
2020-06-03 17:26               ` Marco Elver
2020-06-03 18:16               ` Peter Zijlstra
2020-06-03 19:10                 ` Marco Elver
2020-06-04  6:00                   ` Marco Elver
2020-06-04  9:52                     ` Marco Elver
2020-06-15 22:31 [tip: x86/entry] x86/entry, cpumask: Provide non-instrumented variant of cpu_is_offline() tip-bot2 for Peter Zijlstra

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).