Received: by 2002:a05:6a10:af89:0:0:0:0 with SMTP id iu9csp3579560pxb; Mon, 24 Jan 2022 12:42:10 -0800 (PST) X-Google-Smtp-Source: ABdhPJwhkDHn9+0GfI4CSB+51Z0fYDizR/wvr8zYugNj/XlXonHk2rfck1gBZ+bXwYyodbvOmyjG X-Received: by 2002:a63:2cd2:: with SMTP id s201mr12939182pgs.53.1643056929913; Mon, 24 Jan 2022 12:42:09 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1643056929; cv=none; d=google.com; s=arc-20160816; b=jQJ4hUggFE6YbQE8g6A7KDFT62/ssCBopv72r3WdQKlAKcX1nGmHBSoBlxvXv2sJXx Uh7EPBAHTWpgZwSjn6cPrhW9EcNw7Qe3Vnd0k2KB7tIJLcVygGABeDuMIfUSVhu0eVSx UUQfJ6ExbM4eISh+dVKILgw9sPRnAx/P1bBBpsktiPlq4d+yhj8gkO+v2fL5tczg0/Bi hOH2r5eMcb1K5XQtDPW0I9V6ZbBXyfVNOiN8HAGBLl+NGhBKcTbWihMMm9CXL3jJDXbb 6U8UH5ecV3lm2zPHJh6sofzL90240FFGuLwF/09jO4CLOw4IJbuFylF1HY74O8ytk/xg 0fIQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=CIxqcb/uJXLnDxKR1t57DTT1fkEh5sYmLzfU1bgw52w=; b=ty9mtzJjcGTph+OLMW2+0A3/GCYqb8MySMy17HUemq0mH3b57UgrB209YamCWNL0NO /OhORWscgfr3yz64mnqLe8fit00UKOYCoJh3DQp6VheUCSbmxjmq/MsdZl8Z74YfDXU+ jFv/rSZHPo5ySYZ/GbnQcul6ZelUaP89QS3Bx0rwpO2WR3CCoq9irj1q3GZ8il7DjOCe sHuJw7MCJiTRue908a0AbqXMO070r+neekQgrL6O+7XzQIySnq/EKgbmlXdMfQPLiydF p+5QB66qxSv+y0C3oCSTgZy6ZGoKeSHxb70HbkoHQTfGkSnT0uASrZaa8NAi1a2cxTMv 0Eyg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="ylTvvB/W"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id z6si12959964pfb.209.2022.01.24.12.41.54; Mon, 24 Jan 2022 12:42:09 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="ylTvvB/W"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1358751AbiAXTzo (ORCPT + 99 others); Mon, 24 Jan 2022 14:55:44 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54224 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1348952AbiAXTk7 (ORCPT ); Mon, 24 Jan 2022 14:40:59 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 91AC0C07A968; Mon, 24 Jan 2022 11:19:43 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 30F3C612F3; Mon, 24 Jan 2022 19:19:43 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 0A596C340E5; Mon, 24 Jan 2022 19:19:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1643051982; bh=vPTjVddl5DKb6MbfQQ7t/DzPJ0dMH0IYt5/qolz2wgk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ylTvvB/WdWBBFrQmbF5JU8R69IlzDBi3QAFD1oYZoEOwXmCQXKOqI+1BxsZHNU56r 7gpCwWVSnvfq9WlI+MA1U9WRdpf1YX7FwKhyQ3RWo/+s6C5C7fJpnOJOsj5mXAM3u7 Zia/WEtWOMYEvg4kwcxIGiSYBRiXR6fUdhgSdbt4= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Borislav Petkov , Sasha Levin Subject: [PATCH 4.19 142/239] x86/mce: Mark mce_panic() noinstr Date: Mon, 24 Jan 2022 19:43:00 +0100 Message-Id: <20220124183947.617320258@linuxfoundation.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220124183943.102762895@linuxfoundation.org> References: <20220124183943.102762895@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Borislav Petkov [ Upstream commit 3c7ce80a818fa7950be123cac80cd078e5ac1013 ] And allow instrumentation inside it because it does calls to other facilities which will not be tagged noinstr. Fixes vmlinux.o: warning: objtool: do_machine_check()+0xc73: call to mce_panic() leaves .noinstr.text section Signed-off-by: Borislav Petkov Link: https://lore.kernel.org/r/20211208111343.8130-8-bp@alien8.de Signed-off-by: Sasha Levin --- arch/x86/kernel/cpu/mcheck/mce.c | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/arch/x86/kernel/cpu/mcheck/mce.c b/arch/x86/kernel/cpu/mcheck/mce.c index 2a13468f87739..56c4456434a82 100644 --- a/arch/x86/kernel/cpu/mcheck/mce.c +++ b/arch/x86/kernel/cpu/mcheck/mce.c @@ -295,11 +295,17 @@ static void wait_for_panic(void) panic("Panicing machine check CPU died"); } -static void mce_panic(const char *msg, struct mce *final, char *exp) +static noinstr void mce_panic(const char *msg, struct mce *final, char *exp) { - int apei_err = 0; struct llist_node *pending; struct mce_evt_llist *l; + int apei_err = 0; + + /* + * Allow instrumentation around external facilities usage. Not that it + * matters a whole lot since the machine is going to panic anyway. + */ + instrumentation_begin(); if (!fake_panic) { /* @@ -314,7 +320,7 @@ static void mce_panic(const char *msg, struct mce *final, char *exp) } else { /* Don't log too much for fake panic */ if (atomic_inc_return(&mce_fake_panicked) > 1) - return; + goto out; } pending = mce_gen_pool_prepare_records(); /* First print corrected ones that are still unlogged */ @@ -352,6 +358,9 @@ static void mce_panic(const char *msg, struct mce *final, char *exp) panic(msg); } else pr_emerg(HW_ERR "Fake kernel panic: %s\n", msg); + +out: + instrumentation_end(); } /* Support code for software error injection */ -- 2.34.1