Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp8128961imu; Tue, 4 Dec 2018 03:30:47 -0800 (PST) X-Google-Smtp-Source: AFSGD/W5Mu0OnDNi8i7Dq5uUBT++2JX/3ITlJKLuNagaQC6cIt5R3Ade1WJIt1MObsiIrFtX4+Gv X-Received: by 2002:a62:cf84:: with SMTP id b126mr19481429pfg.98.1543923047048; Tue, 04 Dec 2018 03:30:47 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1543923046; cv=none; d=google.com; s=arc-20160816; b=ShZBBNfiKahIbwTlfgTz+diryaeYrJ768s2CATl1JOywuijPlkSkCyi2lbFj2mncsc iQNyvXXYGCVBacqLRPf4R7RK3werX8vPWlPjiE72NWTk8UbSxI51x3EvM0Pekg1ojlLZ 6edXqLmdm/p+FitC+vVu1z4Auy5yKzc/Lm/Le1Mm0nf+VuR3H1QBZw94nw2Rm0RksCtX lJipmccp0CDbHKq0uOXaafQMmr1JtNFi9S1Trsp+Ikhf0MtimcaAXlT+UzqzD3eIHwsI Jg6VFrJr1amyJOb0nPI96O1Ct8DWJOKJa8cMlmCt0b+neKREbiGTVd4Mxb35x+/23pHX rBcA== 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=Zh0ltxsf9wlVbh/xznluNHLn/vLev2hVY/bbYp4IUBM=; b=nM3wN1Bf8ygbYH4sdP6Bn373FTlHVH/GSNERkbEAiWEE3P8a1i7i9CJ6VdOpb/zIMf uBAL/xc+EKr5V/25Wf7vYgeYIX8M13eO8bTkLZGtciHtqPUa7LXJIf6XuITJJMW6IS4J WRoOm/hVDq7kK0XWkyTnp1FNFhR4s4BFlF+Ac4D5eV/mPAulT94eCci7ypReVwJVVBmL 0uW5isiSvHdlS7DfLOpufXFmsjR5eLe4MqIBni38X/zQOB95YBqglii/a3OpMXtZN3gv IsOPWJfgDfDE92Vo57dMWB467OdbYZECuX+RMdtxE5xt2+41g82+QRNOYa9OKghS2pyT KIUw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=nzcjniMC; 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 z6si15702813pln.66.2018.12.04.03.30.31; Tue, 04 Dec 2018 03:30:46 -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=nzcjniMC; 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 S1726954AbeLDK61 (ORCPT + 99 others); Tue, 4 Dec 2018 05:58:27 -0500 Received: from mail.kernel.org ([198.145.29.99]:42800 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726944AbeLDK6Z (ORCPT ); Tue, 4 Dec 2018 05:58:25 -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 4930F214DE; Tue, 4 Dec 2018 10:58:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1543921104; bh=6ydHGgUWknbFDSEdyAj1VlBCto798R62PRFTkjmn/gg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=nzcjniMCQBU+VlLois4mKc3ayUpM4vgfK8YCwCyyLa9NlJ5NuK2C7lkfrsLA2Lj0D cJae/+XUV0Kf6wSmVuZTlZGHmDRq7irNeZU93+e+XST0dMcZm6hkF5CMwqXiCZ2m8M h/T+9mQZd+VR/YL5jYowIMfZiOuHXWiPV/NeKxTs= 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.19 083/139] x86/MCE/AMD: Fix the thresholding machinery initialization order Date: Tue, 4 Dec 2018 11:49:24 +0100 Message-Id: <20181204103653.672596104@linuxfoundation.org> X-Mailer: git-send-email 2.19.2 In-Reply-To: <20181204103649.950154335@linuxfoundation.org> References: <20181204103649.950154335@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.19-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", @@ -534,9 +534,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); @@ -1357,9 +1356,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; @@ -1377,9 +1373,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; @@ -1408,9 +1401,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); @@ -1419,6 +1409,9 @@ static __init int threshold_init_device( return err; } + if (thresholding_irq_en) + mce_threshold_vector = amd_threshold_interrupt; + return 0; } /*