public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Peter Zijlstra <peterz@infradead.org>
To: x86@kernel.org
Cc: linux-kernel@vger.kernel.org, peterz@infradead.org,
	rdunlap@infradead.org, jpoimboe@redhat.com, sfr@canb.auug.org.au,
	tony.luck@intel.com
Subject: [RFC][PATCH 6/6] x86/mce: Dont use noinstr for now
Date: Wed, 06 Jan 2021 15:36:25 +0100	[thread overview]
Message-ID: <20210106144017.779081583@infradead.org> (raw)
In-Reply-To: 20210106143619.479313782@infradead.org

We call do_machine_check() from a 'safe' context, instrumentation
should be possible. However, due to the nature of the beast, MCE is
fragile and we really rather would not want to hit additional code.

Currently this is done by marking do_machine_check() as noinstr,
however there's at least one objtool warning because of that:

  vmlinux.o: warning: objtool: do_machine_check()+0x650: call to queue_task_work() leaves .noinstr.text section

trying to fix that leads down a rabbit-hole. A _lot_ of code would end
up having to be marked noinstr outside of the MCE code. While
possible, doing so is undesired because it would hide it from
instrumentation for all other users.

Instead of using noinstr, kill instrumentation for all of mce/. This
switches MCE over to a best-effort but non-validated mode. Doing
better will require a significant investment of time and effort.

The obvious problem with tracing the MCE is that the tracer will
trigger a further MCE and we DIE an instant death.

Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
---
 arch/x86/kernel/cpu/mce/Makefile |    7 +++++++
 arch/x86/kernel/cpu/mce/core.c   |    6 +-----
 2 files changed, 8 insertions(+), 5 deletions(-)

--- a/arch/x86/kernel/cpu/mce/Makefile
+++ b/arch/x86/kernel/cpu/mce/Makefile
@@ -1,4 +1,11 @@
 # SPDX-License-Identifier: GPL-2.0
+
+# No instrumentation for MCE code
+KASAN_SANITIZE := n
+UBSAN_SANITIZE := n
+KCOV_INSTRUMENT := n
+ccflags-remove-$(CONFIG_FUNCTION_TRACER) += $(CC_FLAGS_FTRACE)
+
 obj-y				=  core.o severity.o genpool.o
 
 obj-$(CONFIG_X86_ANCIENT_MCE)	+= winchip.o p5.o
--- a/arch/x86/kernel/cpu/mce/core.c
+++ b/arch/x86/kernel/cpu/mce/core.c
@@ -1299,7 +1299,7 @@ static void queue_task_work(struct mce *
  * backing the user stack, tracing that reads the user stack will cause
  * potentially infinite recursion.
  */
-noinstr void do_machine_check(struct pt_regs *regs)
+void do_machine_check(struct pt_regs *regs)
 {
 	DECLARE_BITMAP(valid_banks, MAX_NR_BANKS);
 	DECLARE_BITMAP(toclear, MAX_NR_BANKS);
@@ -1987,10 +1987,6 @@ static __always_inline void exc_machine_
 		return;
 
 	irq_state = irqentry_nmi_enter(regs);
-	/*
-	 * The call targets are marked noinstr, but objtool can't figure
-	 * that out because it's an indirect call. Annotate it.
-	 */
 	instrumentation_begin();
 
 	machine_check_vector(regs);



  parent reply	other threads:[~2021-01-06 14:50 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-01-06 14:36 [PATCH 0/6] x86 noinstr fixes Peter Zijlstra
2021-01-06 14:36 ` [PATCH 1/6] x86/entry: Fix noinstr fail Peter Zijlstra
2021-01-12 20:12   ` [tip: x86/urgent] " tip-bot2 for Peter Zijlstra
2021-01-06 14:36 ` [PATCH 2/6] x86/sev: Fix nonistr violation Peter Zijlstra
2021-01-06 17:59   ` Randy Dunlap
2021-01-07  9:36     ` Peter Zijlstra
2021-01-07 10:18       ` [PATCH 7/6] x86: __always_inline __{rd,wr}msr() Peter Zijlstra
2021-01-07 10:31         ` David Laight
2021-01-07 16:49         ` Randy Dunlap
2021-01-12 20:12   ` [tip: x86/urgent] x86/sev: Fix nonistr violation tip-bot2 for Peter Zijlstra
2021-01-06 14:36 ` [PATCH 3/6] locking/lockdep: Cure noinstr fail Peter Zijlstra
2021-01-12 20:12   ` [tip: x86/urgent] " tip-bot2 for Peter Zijlstra
2021-01-06 14:36 ` [PATCH 4/6] locking/lockdep: Avoid noinstr warning for DEBUG_LOCKDEP Peter Zijlstra
2021-01-12 20:12   ` [tip: x86/urgent] " tip-bot2 for Peter Zijlstra
2021-01-06 14:36 ` [PATCH 5/6] x86/mce: Remove explicit/superfluous tracing Peter Zijlstra
2021-01-12 20:12   ` [tip: x86/urgent] " tip-bot2 for Peter Zijlstra
2021-01-06 14:36 ` Peter Zijlstra [this message]
2021-01-06 14:57   ` [RFC][PATCH 6/6] x86/mce: Dont use noinstr for now Boris Petkov
2021-01-07 10:06     ` Borislav Petkov
2021-01-07 12:58       ` Peter Zijlstra
2021-01-07 13:13         ` Borislav Petkov

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=20210106144017.779081583@infradead.org \
    --to=peterz@infradead.org \
    --cc=jpoimboe@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=rdunlap@infradead.org \
    --cc=sfr@canb.auug.org.au \
    --cc=tony.luck@intel.com \
    --cc=x86@kernel.org \
    /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