From patchwork Wed Oct 19 08:32:57 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 5453 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4ac7:0:0:0:0:0 with SMTP id y7csp329626wrs; Wed, 19 Oct 2022 06:33:15 -0700 (PDT) X-Google-Smtp-Source: AMsMyM6CnYdIuQw15wEbp7VPqQTt6dQ6axHY+7xrJp+L3Fhi3cVGQCGDgMq8+jhtdw0VYkEwspuW X-Received: by 2002:a17:90b:17c7:b0:20d:7862:778e with SMTP id me7-20020a17090b17c700b0020d7862778emr9683571pjb.91.1666186395090; Wed, 19 Oct 2022 06:33:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666186395; cv=none; d=google.com; s=arc-20160816; b=K2I4hInCyW0crMo1jmgAPb4fRe0BbtCLqYan5mDhnIMB1F/M2YmVa9IM4uySGRyP5K ibnHVNqU6lUlcEkzODYNVTsUwxewc+md+sss92AqRGWmBqp1IG928ZXV0zf1G4BZSqLp bf+W86TLXQiov7xJeerFizUCgARTFoCblL5voOACXyUCLoVGr7ApG1YnaOEW8w/fuMHS r1wt4pGKt8K5pdgDBeMCa76Ch1UPcyfyaefO7wG85Ekj/S5iY3GsXY+t1u/KsIwf68Bo +fKEcvX5r3o5Xt9Q+1YacxDxTHhmdEp6RNANuDATKONrW5416OvnQ49h6mk8Cwlb5p6t iwqw== 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=srna4Sr+Pg4Z+QZaPAmMHxutexXuQK+Be7sKBmRqIYA=; b=GoQQOJUZvW9/qXMFi/zhv3PlC7O8OXOnbWRzhFIcziaxBicfe+uVIh+cRseM45FsAG VhR+eUXx7U3MjwV7WgEyg2VM1NWMgSKpxVTrNaQ9KGREwAgHbJDSlovLn+t/OjoFoI2d SdaG2XNucOUG74BCv81EM4HtLTQIVvLAlwroNUTlKzpbxqUBpJLqVdPK82LiNnFff/CY 0IMA3gLb5BmxVr44rZ+sw78hfY2BBrN7B6RvIUFYzAj0Z+trzdZCNv6HQQZdImcwUI3t 5NNfYe+wTJrcymIqycEe8eupFuYhDAmwtVLWmD2SmoosQViFOPehai9CoDXlvGhyRm+S OgSw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=rB0537pB; 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=linuxfoundation.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id c3-20020a170902b68300b001782ecb617dsi17459480pls.412.2022.10.19.06.33.00; Wed, 19 Oct 2022 06:33:15 -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=@linuxfoundation.org header.s=korg header.b=rB0537pB; 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=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232361AbiJSNUo (ORCPT + 99 others); Wed, 19 Oct 2022 09:20:44 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55720 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231622AbiJSNUK (ORCPT ); Wed, 19 Oct 2022 09:20:10 -0400 Received: from sin.source.kernel.org (sin.source.kernel.org [IPv6:2604:1380:40e1:4800::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B96331DD899; Wed, 19 Oct 2022 06:05:42 -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 sin.source.kernel.org (Postfix) with ESMTPS id 1407DCE2194; Wed, 19 Oct 2022 09:08:50 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 12502C433D7; Wed, 19 Oct 2022 09:08:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1666170528; bh=/LmuOibYq4SSvlEYG9tQkbKyOyx/DdrdHV6RwtqcukY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=rB0537pB9N1dC7LasLnpDzK39952jc4GcxHfRUj9SdxE/Z58io3bXlz+2i1ZtvoFT 15oOoOm2/5bQ6MWMhjWt+pLeQuCuLFAT7yQ/5MkLkFg5fCQ885w4i3RNecRNPNliBR 9YG4dLHiU6NbeC+LbUEU9MnoSE1Iw3WjzNq7Diqk= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Jane Chu , Borislav Petkov , Dan Williams , Ingo Molnar , Sasha Levin Subject: [PATCH 6.0 690/862] x86/mce: Retrieve poison range from hardware Date: Wed, 19 Oct 2022 10:32:57 +0200 Message-Id: <20221019083320.470023711@linuxfoundation.org> X-Mailer: git-send-email 2.38.0 In-Reply-To: <20221019083249.951566199@linuxfoundation.org> References: <20221019083249.951566199@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 X-Spam-Status: No, score=-7.4 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1747123065099589091?= X-GMAIL-MSGID: =?utf-8?q?1747123065099589091?= 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;