Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp8116328imu; Tue, 4 Dec 2018 03:16:53 -0800 (PST) X-Google-Smtp-Source: AFSGD/UG57JlVD3alnjuq/GQfITB34vLXIJDE+PRAgdEi3J1lJqOEeAihnh+YSajtLnSvZALQJKe X-Received: by 2002:a63:314c:: with SMTP id x73mr16699683pgx.323.1543922212750; Tue, 04 Dec 2018 03:16:52 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1543922212; cv=none; d=google.com; s=arc-20160816; b=qEZaTFGsUfCPg1y5RQR1Z80wqubNA6y1wDNLWXBjBn343i6Ns2BVwQsz/aGINsyTLk zMEY5NmAC0xjEVHHCbPnFOqECTbkDMtPnQ5x2cJZyWjzokPVV7D+j9xFt0/lp7YM7Kzv +qq5UI/gEb3htxl1PVwTxAmbT0eT93QEe3r41FLvEKRhAnHFihW1QSTgiXAVaRlQ0Y61 FVGhZTrjxnPCY7Q6vDAJ7mGMu9/+13RKcknysBYKfOxyH2WJLhQyTCNUCaEMmDUI6euD sqKd2JRe4klRWHZvU6andVpc2Vtld32+2UJ8SdIejOMXKkk1XCBygTHPO05bTrc+nPK1 2iFA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=TStavIzlHmfurYISRUmV20efJH6DK5vvhbRfxmRysXw=; b=d23z90lvxxi/SRHy6h7HkwcP8F6P3VO3o2EzaF0DDjx+UhgtftLiKwKv2DCkaLSwiq QH9bygZykcRdLswOLPUwma38N2o0QYksHIlzKCiFDXVKVjaCr0/2gH9SM7YXxScBd6f0 /4LQKnG+wXZ3JFp/o8I+jvd6DBbY3UGLg5PSxKWL9vVvCj5yAaTm1sNJFpDtlmNGRM+o okPFADtg/YNB3S5WloPG11bLKNFxA0NIW5/E9HMQXkWLTrfwf8oViv/UWpPn08vmlDa7 yLaMyg/zhT6x1Fb4R6659v4qo0JWcPZ3RM71LFSkcARhDRAnAXJJhI5JcqJlWgP4wHPF Wdew== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b="wJZ/4SHC"; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id a3si14512276pga.297.2018.12.04.03.16.36; Tue, 04 Dec 2018 03:16:52 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b="wJZ/4SHC"; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728015AbeLDLQF (ORCPT + 99 others); Tue, 4 Dec 2018 06:16:05 -0500 Received: from mail.kernel.org ([198.145.29.99]:54250 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728249AbeLDLGF (ORCPT ); Tue, 4 Dec 2018 06:06:05 -0500 Received: from localhost (5356596B.cm-6-7b.dynamic.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 8F258214DB; Tue, 4 Dec 2018 11:06:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1543921564; bh=sCdxcCH0NNxYIDe1J8Vc6DJ8BurYL3ek+Z99gj2ssPc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=wJZ/4SHCBns7koehn1SH5gDtbs5JY25e26yUIV4YQbqNnpe/sa78V3eKR6d3/qhd/ WKtuZvOMmbkrGCiSAaRPshYmd0groyuLVBeiZy20LLtP0JrmncxYZSTqlXR+9AfmXX QHTJNy66x9FIErCNQn1Pd+ixHRKFj6jwo71pM71w= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, =?UTF-8?q?Rafa=C5=82=20Mi=C5=82ecki?= , John Clemens , Borislav Petkov , John Clemens , Aravind Gopalakrishnan , linux-edac@vger.kernel.org, Tony Luck , x86@kernel.org, Yazen Ghannam Subject: [PATCH 4.14 120/146] x86/MCE/AMD: Fix the thresholding machinery initialization order Date: Tue, 4 Dec 2018 11:50:06 +0100 Message-Id: <20181204103731.659254879@linuxfoundation.org> X-Mailer: git-send-email 2.19.2 In-Reply-To: <20181204103726.750894136@linuxfoundation.org> References: <20181204103726.750894136@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review X-Patchwork-Hint: ignore MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.14-stable review patch. If anyone has any objections, please let me know. ------------------ From: Borislav Petkov commit 60c8144afc287ef09ce8c1230c6aa972659ba1bb upstream. Currently, the code sets up the thresholding interrupt vector and only then goes about initializing the thresholding banks. Which is wrong, because an early thresholding interrupt would cause a NULL pointer dereference when accessing those banks and prevent the machine from booting. Therefore, set the thresholding interrupt vector only *after* having initialized the banks successfully. Fixes: 18807ddb7f88 ("x86/mce/AMD: Reset Threshold Limit after logging error") Reported-by: Rafał Miłecki Reported-by: John Clemens Signed-off-by: Borislav Petkov Tested-by: Rafał Miłecki Tested-by: John Clemens Cc: Aravind Gopalakrishnan Cc: linux-edac@vger.kernel.org Cc: stable@vger.kernel.org Cc: Tony Luck Cc: x86@kernel.org Cc: Yazen Ghannam Link: https://lkml.kernel.org/r/20181127101700.2964-1-zajec5@gmail.com Link: https://bugzilla.kernel.org/show_bug.cgi?id=201291 Signed-off-by: Greg Kroah-Hartman --- arch/x86/kernel/cpu/mcheck/mce_amd.c | 19 ++++++------------- 1 file changed, 6 insertions(+), 13 deletions(-) --- a/arch/x86/kernel/cpu/mcheck/mce_amd.c +++ b/arch/x86/kernel/cpu/mcheck/mce_amd.c @@ -56,7 +56,7 @@ /* Threshold LVT offset is at MSR0xC0000410[15:12] */ #define SMCA_THR_LVT_OFF 0xF000 -static bool thresholding_en; +static bool thresholding_irq_en; static const char * const th_names[] = { "load_store", @@ -533,9 +533,8 @@ prepare_threshold_block(unsigned int ban set_offset: offset = setup_APIC_mce_threshold(offset, new); - - if ((offset == new) && (mce_threshold_vector != amd_threshold_interrupt)) - mce_threshold_vector = amd_threshold_interrupt; + if (offset == new) + thresholding_irq_en = true; done: mce_threshold_block_init(&b, offset); @@ -1356,9 +1355,6 @@ int mce_threshold_remove_device(unsigned { unsigned int bank; - if (!thresholding_en) - return 0; - for (bank = 0; bank < mca_cfg.banks; ++bank) { if (!(per_cpu(bank_map, cpu) & (1 << bank))) continue; @@ -1376,9 +1372,6 @@ int mce_threshold_create_device(unsigned struct threshold_bank **bp; int err = 0; - if (!thresholding_en) - return 0; - bp = per_cpu(threshold_banks, cpu); if (bp) return 0; @@ -1407,9 +1400,6 @@ static __init int threshold_init_device( { unsigned lcpu = 0; - if (mce_threshold_vector == amd_threshold_interrupt) - thresholding_en = true; - /* to hit CPUs online before the notifier is up */ for_each_online_cpu(lcpu) { int err = mce_threshold_create_device(lcpu); @@ -1418,6 +1408,9 @@ static __init int threshold_init_device( return err; } + if (thresholding_irq_en) + mce_threshold_vector = amd_threshold_interrupt; + return 0; } /*