Received: by 2002:a05:6a10:af89:0:0:0:0 with SMTP id iu9csp3707997pxb; Mon, 24 Jan 2022 15:58:55 -0800 (PST) X-Google-Smtp-Source: ABdhPJwom8DdswbHXpt5PC400dVZPRFtLLbKExLee7dPlUBcKRpox5eoaJC2bYgHFklUubyyGCf/ X-Received: by 2002:a63:114:: with SMTP id 20mr6515354pgb.524.1643068735355; Mon, 24 Jan 2022 15:58:55 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1643068735; cv=none; d=google.com; s=arc-20160816; b=Z3HnkHgdXyHWL/9LhRh02qz5c/dYzhOE0U6kExLWmMcP359J3makilHufLP6Sxq/87 X352ybRBxjhNl14AYPH7C8cVidAbzkKihOxQtgfOIayCugnoxXqtFVsgl4MVllB+gvrL mV38IRbKpi/YOmFMLSwzpHPdgsuI/GxfV19CMJConPK20abA0YEdt/M4aiSy5v0H9qvc kW4gXc74L4ANrCXzKEY4KW5+C6xNbmzApCBUuawBdsWtqod/RKWbrJPS982+yumtdj7Q XH8B2uM+CN/7Bzz6/mUHfa360ot7/pz5Of0sTQ7fSboMgRZH3v0+6afN6x9/sIeVjdsE EUqg== 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=xxRC84IzXl31ihpSmSfd7TuNn1YwIgfBw4oygKaLNJg=; b=Rt1ueF9cwyxUu9THVBkG146HAKEtaFFOEyrIv0g07+qtMv1vg5gVGL2AvbAxKgWrz3 hkdZjR2gtoxMpKz7ZxaK2SfTutj6VrNKO5LqPi+ZliZJmmQwc3vXgWUuK62wqjouz7lR pqXb99Jm7IKdd+q5IlhXTWk0BsDmKMwz4QoYqL7kT8Zzitr175XRsak8KAtekrF8xQHh VjufOjA+hpYtX4b+MzXQUIn86tITu0M49SBmYEgg8YrfqtfVMfW/GwV+qZIPWOala4f2 dPqJf6IpMt4QuDZVA8oxW1Mum7iIC9efV60pzok922phbOmxkQbWmjsDnbAzHJ2+RBnw tFKA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=hX9abKQj; 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 nn10si728920pjb.96.2022.01.24.15.58.43; Mon, 24 Jan 2022 15:58:55 -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=hX9abKQj; 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 S2367408AbiAXXzX (ORCPT + 99 others); Mon, 24 Jan 2022 18:55:23 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50114 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1846523AbiAXXQP (ORCPT ); Mon, 24 Jan 2022 18:16:15 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 55D61C0617B1; Mon, 24 Jan 2022 13:25:21 -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 ams.source.kernel.org (Postfix) with ESMTPS id 12649B81243; Mon, 24 Jan 2022 21:25:20 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 3A177C340E4; Mon, 24 Jan 2022 21:25:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1643059518; bh=76k952JqIoqnSJrdx/YN9ePOzNmgl602GkwnJ/y28TY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=hX9abKQjqWcHi2yiscz10ufTLNOZl0NqPvd5BUL+xzD5g//faInXFfcp+4SVHzRj4 QGBhOac1SxLGb5bA/J3vcW3LVq2nve+ZTeobm/flfTg/eqy5HZYR1E2jHnQIKAWTEg HmGi4sSZbBpTTa0lvZ3R1KlgMuMpa/FOCX/n0fqA= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Borislav Petkov , Sasha Levin Subject: [PATCH 5.16 0642/1039] x86/mce: Mark mce_panic() noinstr Date: Mon, 24 Jan 2022 19:40:31 +0100 Message-Id: <20220124184146.936639036@linuxfoundation.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220124184125.121143506@linuxfoundation.org> References: <20220124184125.121143506@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/mce/core.c | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/arch/x86/kernel/cpu/mce/core.c b/arch/x86/kernel/cpu/mce/core.c index 70ec5685906b2..9a52ec55e0555 100644 --- a/arch/x86/kernel/cpu/mce/core.c +++ b/arch/x86/kernel/cpu/mce/core.c @@ -267,11 +267,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) { /* @@ -286,7 +292,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 */ @@ -324,6 +330,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