Received: by 2002:a05:7412:251c:b0:e2:908c:2ebd with SMTP id w28csp1201633rda; Mon, 23 Oct 2023 05:56:17 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHHTW78ViPOd1CjNXK2ZK8ZW13sffIU07c7ejeqtkdr6V0cuZ+sc5+yfyu2ND+irlYemit+ X-Received: by 2002:a05:6359:6d8d:b0:168:dcd8:ca1f with SMTP id tg13-20020a0563596d8d00b00168dcd8ca1fmr2417002rwb.18.1698065776840; Mon, 23 Oct 2023 05:56:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1698065776; cv=none; d=google.com; s=arc-20160816; b=xV1xjgKLJY+z0AapJFIDFZnMPvjtvahIVgvnwcVk/lrR5T6hvngRLOy/vv3zSsmRwT tJ2GuRd047rL1MTww1lfyHoWFNhlDumbO9a8OY8XeaQq12SbNPZO7XDTuBouS2ubUzTc +iQBsgwzB0bNdtRnMW6f/o5JWMJXW733bRrDAQR2b22uRxKfCil+2mi0MtAvVMRp8xk0 FYDQhYvIFofbI7I35RRYY94ewRFNxZNnI5k7j3Ittd4EANhUGZY9bVoaKALNvmfHI8u6 Op1vcSrD3IFoJNVUnrXAOnuNxV8O/spKp3xA4a86sC9H7zYlaXDOQuwWVN/45UK1QDaq KyyA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:robot-unsubscribe :robot-id:message-id:mime-version:references:in-reply-to:cc:subject :to:reply-to:sender:from:dkim-signature:dkim-signature:date; bh=YZEg4B8ZXuhFQLOdRKI34p1p/QHIZWG+7pUU2/5EiMU=; fh=hiTKwefEd832GltDW4MJ/Xzb4c4y2e/FuH05c8YgukA=; b=jrrD0RntKDG9kdV15OY/nqfyCKDS+dCbxOhTgpw9q+JKbZqRJOZMRYeyOzAaScL1jP 39vkWvVbJCdhxwCXfcXAnRn9tE+Og0qvClDPgUwpgGxNL689EPUILBaLkftjoMuEOynv /WgfQPLQIKD4gYgkOw8hLeOS5mif8EUUXfcZA0xIBW76f1DKiktXdROm9VPzlbumT5p4 ATvkWcaHN6mNtSr2MKxoEtDEvAO9LkyOr+BkMMeyg5SHCFsUYrTzgO2ucxVqwcfp+xg3 LRC9G3c+w0cSWCyUadf7aSHxynFSXCOgeHIvbYd6Q6+Y3zySc0Po8l7XEUTN56BJGU9A fWdQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=HEjVNzW1; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e header.b=mSfJDKZK; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Return-Path: Received: from howler.vger.email (howler.vger.email. [2620:137:e000::3:4]) by mx.google.com with ESMTPS id 18-20020a630f52000000b00578d0d070f4si6309732pgp.844.2023.10.23.05.56.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 23 Oct 2023 05:56:16 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 as permitted sender) client-ip=2620:137:e000::3:4; Authentication-Results: mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=HEjVNzW1; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e header.b=mSfJDKZK; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by howler.vger.email (Postfix) with ESMTP id D5AF6805B2CE; Mon, 23 Oct 2023 05:56:13 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at howler.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230071AbjJWM4E (ORCPT + 99 others); Mon, 23 Oct 2023 08:56:04 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52834 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230108AbjJWM4C (ORCPT ); Mon, 23 Oct 2023 08:56:02 -0400 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B8BA4D7C; Mon, 23 Oct 2023 05:55:57 -0700 (PDT) Date: Mon, 23 Oct 2023 12:55:54 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1698065755; h=from:from:sender:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=YZEg4B8ZXuhFQLOdRKI34p1p/QHIZWG+7pUU2/5EiMU=; b=HEjVNzW1zV1rgMga3FSLpp2/ZGqS7LRTfJgrdmPLx5E7oddsN74CCITdiZeWH3DyR56/UN RMOusumsYXqMqUD3lDcbxLqRhfwmcpQIVurrXMuGuPVU5AmsjRlCU8czlSjmD1scncoVDw rrdV9z3xL1fnY3HOtISDf7rKG7Ylx6DEqf0L0jIYRDq7u1DLKy7VE9aaOu8TzoZWuG/n7V Kl6+8N3gK0Cbkn0JvVunA0WDVSI7Kq4bZ2paHN28Thubt9c1fzVRlmS/0u1DuC7rWuaoJ3 ejYzqCbyNpXmmWmPDQB8z9/Bb16eJ86zN3muUvEjzOBips8Hlz98q0qe9ynEeA== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1698065755; h=from:from:sender:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=YZEg4B8ZXuhFQLOdRKI34p1p/QHIZWG+7pUU2/5EiMU=; b=mSfJDKZKNoiuvWp2LvWNTUxV57wKGl9eFLT9W5nwzXsPYLqjxy/NJBU3wjWU/xWBVGtI/w 1aExUxCUvVYclVCg== From: "tip-bot2 for Zhiquan Li" Sender: tip-bot2@linutronix.de Reply-to: linux-kernel@vger.kernel.org To: linux-tip-commits@vger.kernel.org Subject: [tip: ras/core] x86/mce: Mark fatal MCE's page as poison to avoid panic in the kdump kernel Cc: Youquan Song , Zhiquan Li , "Borislav Petkov (AMD)" , Naoya Horiguchi , x86@kernel.org, linux-kernel@vger.kernel.org In-Reply-To: <20231014051754.3759099-1-zhiquan1.li@intel.com> References: <20231014051754.3759099-1-zhiquan1.li@intel.com> MIME-Version: 1.0 Message-ID: <169806575453.3135.14265994538914502918.tip-bot2@tip-bot2> Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-0.8 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on howler.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (howler.vger.email [0.0.0.0]); Mon, 23 Oct 2023 05:56:14 -0700 (PDT) The following commit has been merged into the ras/core branch of tip: Commit-ID: 1d11b153d23b5fd131d4ea125ff23c9e8ebc98ab Gitweb: https://git.kernel.org/tip/1d11b153d23b5fd131d4ea125ff23c9e8ebc98ab Author: Zhiquan Li AuthorDate: Mon, 23 Oct 2023 12:22:37 +08:00 Committer: Borislav Petkov (AMD) CommitterDate: Mon, 23 Oct 2023 14:53:13 +02:00 x86/mce: Mark fatal MCE's page as poison to avoid panic in the kdump kernel Memory errors don't happen very often, especially fatal ones. However, in large-scale scenarios such as data centers, that probability increases with the amount of machines present. When a fatal machine check happens, mce_panic() is called based on the severity grading of that error. The page containing the error is not marked as poison. However, when kexec is enabled, tools like makedumpfile understand when pages are marked as poison and do not touch them so as not to cause a fatal machine check exception again while dumping the previous kernel's memory. Therefore, mark the page containing the error as poisoned so that the kexec'ed kernel can avoid accessing the page. [ bp: Rewrite commit message and comment. ] Co-developed-by: Youquan Song Signed-off-by: Youquan Song Signed-off-by: Zhiquan Li Signed-off-by: Borislav Petkov (AMD) Reviewed-by: Naoya Horiguchi Link: https://lore.kernel.org/r/20231014051754.3759099-1-zhiquan1.li@intel.com --- arch/x86/kernel/cpu/mce/core.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/arch/x86/kernel/cpu/mce/core.c b/arch/x86/kernel/cpu/mce/core.c index 0214d42..a25e692 100644 --- a/arch/x86/kernel/cpu/mce/core.c +++ b/arch/x86/kernel/cpu/mce/core.c @@ -44,6 +44,7 @@ #include #include #include +#include #include #include @@ -233,6 +234,7 @@ static noinstr void mce_panic(const char *msg, struct mce *final, char *exp) struct llist_node *pending; struct mce_evt_llist *l; int apei_err = 0; + struct page *p; /* * Allow instrumentation around external facilities usage. Not that it @@ -286,6 +288,18 @@ static noinstr void mce_panic(const char *msg, struct mce *final, char *exp) if (!fake_panic) { if (panic_timeout == 0) panic_timeout = mca_cfg.panic_timeout; + + /* + * Kdump skips the poisoned page in order to avoid + * touching the error bits again. Poison the page even + * if the error is fatal and the machine is about to + * panic. + */ + if (kexec_crash_loaded()) { + p = pfn_to_online_page(final->addr >> PAGE_SHIFT); + if (final && (final->status & MCI_STATUS_ADDRV) && p) + SetPageHWPoison(p); + } panic(msg); } else pr_emerg(HW_ERR "Fake kernel panic: %s\n", msg);