From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 34A07C433E6 for ; Wed, 6 Jan 2021 14:50:06 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id EAEF92311D for ; Wed, 6 Jan 2021 14:50:05 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726919AbhAFOtv (ORCPT ); Wed, 6 Jan 2021 09:49:51 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60160 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726578AbhAFOtt (ORCPT ); Wed, 6 Jan 2021 09:49:49 -0500 Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1A1F9C061357 for ; Wed, 6 Jan 2021 06:49:09 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=Content-Type:MIME-Version:References: Subject:Cc:To:From:Date:Message-ID:Sender:Reply-To:Content-Transfer-Encoding: Content-ID:Content-Description:In-Reply-To; bh=LvhqLjzhDb+9q4vjYXmSZl5pgFD1dILWN5ao2jB2EEc=; b=gGUClaRFQCQfVUfPGMSMXWNKbH eKg19pnE6gZMHsxIj90MiaO1Rzj/27tWVwFrMvPOkKsnzAvRqT9W3Rya4PMclBY1Yl5TWibQjQQtb qadNF8Fa6rpd/WBdD5/H4OgjQ4C8oOWF2Zl5w7xG5ZWgTqUvhXaB+WLhV4JCVjfBMiXGreNCNmqTu WpCr0qoBVOmK0SIilncIA9h1OqjROVgTqlzLsfapRmUqD9Q0wKiJBSSb4nUtiqOsucC/BPl6GRaFM e2YGezuFTlxqFXSHkB8JJAgm+tCDwYmIqp7dAsXt2NrEcgNwLxotYQDrVlsOUBrlPNonZK+HuT+0Z M223hylw==; Received: from j217100.upc-j.chello.nl ([24.132.217.100] helo=noisy.programming.kicks-ass.net) by casper.infradead.org with esmtpsa (Exim 4.94 #2 (Red Hat Linux)) id 1kxA3J-002QUb-2z; Wed, 06 Jan 2021 14:45:34 +0000 Received: from hirez.programming.kicks-ass.net (hirez.programming.kicks-ass.net [192.168.1.225]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by noisy.programming.kicks-ass.net (Postfix) with ESMTPS id 28887307967; Wed, 6 Jan 2021 15:44:42 +0100 (CET) Received: by hirez.programming.kicks-ass.net (Postfix, from userid 0) id B18CE202A3CED; Wed, 6 Jan 2021 15:44:42 +0100 (CET) Message-ID: <20210106144017.779081583@infradead.org> User-Agent: quilt/0.66 Date: Wed, 06 Jan 2021 15:36:25 +0100 From: Peter Zijlstra 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 References: <20210106143619.479313782@infradead.org> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.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) --- 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);