Received: by 2002:a05:6359:c8b:b0:c7:702f:21d4 with SMTP id go11csp3983259rwb; Sun, 9 Oct 2022 15:16:21 -0700 (PDT) X-Google-Smtp-Source: AMsMyM7MOL4q55NMHPAwkHooBKTfmLdMIaW/Qvi/E6VEALZJhSSBe7zcfss6pOI1iIUqV7N+bfXQ X-Received: by 2002:a17:907:2e19:b0:78d:3ade:a546 with SMTP id ig25-20020a1709072e1900b0078d3adea546mr11899011ejc.564.1665353781378; Sun, 09 Oct 2022 15:16:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1665353781; cv=none; d=google.com; s=arc-20160816; b=v0++kfZjCPjCuYAxdbv3CLDNPMhmrl5lrRdGRQZiy53iVkHX66/5DM3UyobFV5RBmh QjOc3+/5sNAa896isg71dDF2PyXCJks8cnqZpVgkgmc21ZZBqcM6GHeduUlqzZoQdOiT fflYijXGx+TKYH349PSYvGIs3cvRnnITd/9a/bq2RmsdU8R1Frwnwe+v4m8G4zVu1TEx wCQky+Ylu4uhIzPzdORHYVskwRsmUtvct+2PZBz4J7mlNR4cXxLgBvDCDj9VQY4PU470 6osJgqgWMK/npOSGFJS5eF+4uTKtm/iD2lsxKIEV7JCv6qnb7waBXntaO7DqmRY+2jPg clvQ== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=srna4Sr+Pg4Z+QZaPAmMHxutexXuQK+Be7sKBmRqIYA=; b=a+YtwQ+YtUUHboPnazl5lNbAS9adcDaqpyKWC3MS/UgTCeOM8iebblVv4FYJzYnyG1 4xJN6NfFh4vKqJUVyuAYMBlb/RMdEjfzds2m380wld2By42Meeemub7N1u1vmG/CqMKn 3KAqWOZQZRXBPsI5Cp01PsTJQkJqeYw7QP00zQiKOImAGYuxk2TTxcpPQbF7tNjRE001 8O+9gTmPOCrV52T1YZXJei1m2TVKwjiNL3EV/oTpMBnYP07wkkpA5+1/BRB0MEUqzWGh C+os1whMrSo2iQaIgKE5jK9TJPiu8tFwWDlFMu2UH9E71NrVsPv3HH15AaenhSeA+oNF mlow== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=Nycm77E3; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id sg38-20020a170907a42600b007788260dfdbsi8103790ejc.862.2022.10.09.15.15.54; Sun, 09 Oct 2022 15:16:21 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=Nycm77E3; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231161AbiJIWKn (ORCPT + 99 others); Sun, 9 Oct 2022 18:10:43 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42060 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231142AbiJIWJ0 (ORCPT ); Sun, 9 Oct 2022 18:09:26 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EB5AE27FFA; Sun, 9 Oct 2022 15:08:55 -0700 (PDT) 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 6507FB80DD7; Sun, 9 Oct 2022 22:08:48 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id DF87EC433D7; Sun, 9 Oct 2022 22:08:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1665353327; bh=/LmuOibYq4SSvlEYG9tQkbKyOyx/DdrdHV6RwtqcukY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Nycm77E36xDLKRLiIjEDBqPw1O22Z/tb4iZZ0F+5jvHyEYuYwoKmnoX2HbHMOPCUc II6TVrIGDSsVKHG2p7FlWthZWuGqH9rDEC016rpXO8XRPFIOpNPoZQkGvf2Oh9OAu0 h7lSgkFPqHnBwQRB2UEZjoT/3bR7HfLjlFxlYKlmM51tMT7uVbyfH4gGcK4vI4Ix+K yOaJuYJ+oMO4pLB0r01zyFA9GSgLfD2S6AielDwKisK/gmAJGsxaUMde/u5ho8qTDF NsOQcB+7MydyI8D7QLcugT0g//7LQS37L+Ih6jO18yMoGOO1sWMAfxOdzSc0tBUfVS VzedjSRXDL+ZQ== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Jane Chu , Borislav Petkov , Dan Williams , Ingo Molnar , Sasha Levin , bp@alien8.de, tglx@linutronix.de, mingo@redhat.com, dave.hansen@linux.intel.com, x86@kernel.org, linux-edac@vger.kernel.org Subject: [PATCH AUTOSEL 6.0 19/77] x86/mce: Retrieve poison range from hardware Date: Sun, 9 Oct 2022 18:06:56 -0400 Message-Id: <20221009220754.1214186-19-sashal@kernel.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20221009220754.1214186-1-sashal@kernel.org> References: <20221009220754.1214186-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Jane Chu [ Upstream commit f9781bb18ed828e7b83b7bac4a4ad7cd497ee7d7 ] When memory poison consumption machine checks fire, MCE notifier handlers like nfit_handle_mce() record the impacted physical address range which is reported by the hardware in the MCi_MISC MSR. The error information includes data about blast radius, i.e. how many cachelines did the hardware determine are impacted. A recent change 7917f9cdb503 ("acpi/nfit: rely on mce->misc to determine poison granularity") updated nfit_handle_mce() to stop hard coding the blast radius value of 1 cacheline, and instead rely on the blast radius reported in 'struct mce' which can be up to 4K (64 cachelines). It turns out that apei_mce_report_mem_error() had a similar problem in that it hard coded a blast radius of 4K rather than reading the blast radius from the error information. Fix apei_mce_report_mem_error() to convey the proper poison granularity. Signed-off-by: Jane Chu Signed-off-by: Borislav Petkov Reviewed-by: Dan Williams Reviewed-by: Ingo Molnar Link: https://lore.kernel.org/r/7ed50fd8-521e-cade-77b1-738b8bfb8502@oracle.com Link: https://lore.kernel.org/r/20220826233851.1319100-1-jane.chu@oracle.com Signed-off-by: Sasha Levin --- arch/x86/kernel/cpu/mce/apei.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/arch/x86/kernel/cpu/mce/apei.c b/arch/x86/kernel/cpu/mce/apei.c index 717192915f28..8ed341714686 100644 --- a/arch/x86/kernel/cpu/mce/apei.c +++ b/arch/x86/kernel/cpu/mce/apei.c @@ -29,15 +29,26 @@ void apei_mce_report_mem_error(int severity, struct cper_sec_mem_err *mem_err) { struct mce m; + int lsb; if (!(mem_err->validation_bits & CPER_MEM_VALID_PA)) return; + /* + * Even if the ->validation_bits are set for address mask, + * to be extra safe, check and reject an error radius '0', + * and fall back to the default page size. + */ + if (mem_err->validation_bits & CPER_MEM_VALID_PA_MASK) + lsb = find_first_bit((void *)&mem_err->physical_addr_mask, PAGE_SHIFT); + else + lsb = PAGE_SHIFT; + mce_setup(&m); m.bank = -1; /* Fake a memory read error with unknown channel */ m.status = MCI_STATUS_VAL | MCI_STATUS_EN | MCI_STATUS_ADDRV | MCI_STATUS_MISCV | 0x9f; - m.misc = (MCI_MISC_ADDR_PHYS << 6) | PAGE_SHIFT; + m.misc = (MCI_MISC_ADDR_PHYS << 6) | lsb; if (severity >= GHES_SEV_RECOVERABLE) m.status |= MCI_STATUS_UC; -- 2.35.1