Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp13338675ybl; Sun, 29 Dec 2019 09:37:18 -0800 (PST) X-Google-Smtp-Source: APXvYqxMXqsCckQ8D2XXHB5UUu2SP91T4qFtblySur7QP1lgBNh8YYRJretu5z5qv/opMN/v7R6N X-Received: by 2002:a9d:6a41:: with SMTP id h1mr36266354otn.279.1577641038682; Sun, 29 Dec 2019 09:37:18 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1577641038; cv=none; d=google.com; s=arc-20160816; b=guMJYC6c9eIaUYbc6rVwiWUwRd4Li5SaN4gSY7J/gpddyBwraaOZPWZAulKmHc2RLA V59Hwmit3ATK42scn22AmtyZE3o5PGUXTpCVOf4uNZHrpnPLJRInAFcIqIxCDmORDDj4 BSikeINhtpjlnECjEuE6eP71asRlUVoBYF/kq0rt/jJngVXX17TyrKxMK87xaTXxwsfc 6GZTMdUqEUgI8kPJv0kUMB93jK+ycS1gy+aifmazMc5fXI8ZKsXfJQ8guBCtBuXc/BnD BZX9VHGLlRl4cgq4E2xn644KOpeCVAvno2ytQ5WIOQKabBDLQlQOJYqb2GW96aeqE+8L hfqw== 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=dSm72V16kpzfi3VPWl4eXj+MLXV7DdYUKIwQjMHUhvk=; b=a/HZ8xPBVlwSEzk4/aVOVN/iW+IuoMVObxf0A9dGrB3tHl+yr3SMy1b8U4QGJYdMqi KJaakDJS1URWJGrdhu0y0O7pnLza4gms4FN/UDvNq/JUW6vD59PoofhreOnjyKf77Acu vw417f70+bDloHgMjqM1T3AxPVjg+vSP8IYNZyje1ywDCO3+fM8LMKdQYuDd1t7TCK0g YVsFVxR9q++lS2joTTTfnzDKEdQmH6eKo0RYWe+loBgakXeP2baabyIniFXevElbw4bb U7jS0yxPi/qY5KyMBRHPGZs+VI8mINpZhTTYS2WFkrg6/pPRk+hLM3OtvqK8A4tgq4DP tDAA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=Qj3pNeuM; 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 i8si21963408otp.254.2019.12.29.09.37.08; Sun, 29 Dec 2019 09:37:18 -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=Qj3pNeuM; 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 S1729716AbfL2RgK (ORCPT + 99 others); Sun, 29 Dec 2019 12:36:10 -0500 Received: from mail.kernel.org ([198.145.29.99]:41080 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729971AbfL2RgG (ORCPT ); Sun, 29 Dec 2019 12:36:06 -0500 Received: from localhost (83-86-89-107.cable.dynamic.v4.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 18F0921744; Sun, 29 Dec 2019 17:36:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1577640965; bh=BactduNqTs4sPIgTbO6UqdHepaukg3SW1+IJ6I1vWKM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Qj3pNeuMqsppso/9lKODlLfIHsqzT6PgP+F4Pknw1disK08QysVYxXbKbkZjt+izG PbiAtZmXg+athzn4oB/r1WHPUJhiQpOa3gdXFXcrap1mFXtey0v9ft0f1Iof/pcBUX rmQ05duZ+n0E8gNPG7Nu3/f1bzopRaqT5HV/4wMs= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Yazen Ghannam , Borislav Petkov , "H. Peter Anvin" , Ingo Molnar , linux-edac , Thomas Gleixner , Tony Luck , x86-ml Subject: [PATCH 4.19 210/219] x86/MCE/AMD: Allow Reserved types to be overwritten in smca_banks[] Date: Sun, 29 Dec 2019 18:20:12 +0100 Message-Id: <20191229162541.818222862@linuxfoundation.org> X-Mailer: git-send-email 2.24.1 In-Reply-To: <20191229162508.458551679@linuxfoundation.org> References: <20191229162508.458551679@linuxfoundation.org> User-Agent: quilt/0.66 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 From: Yazen Ghannam commit 966af20929ac24360ba3fac5533eb2ab003747da upstream. Each logical CPU in Scalable MCA systems controls a unique set of MCA banks in the system. These banks are not shared between CPUs. The bank types and ordering will be the same across CPUs on currently available systems. However, some CPUs may see a bank as Reserved/Read-as-Zero (RAZ) while other CPUs do not. In this case, the bank seen as Reserved on one CPU is assumed to be the same type as the bank seen as a known type on another CPU. In general, this occurs when the hardware represented by the MCA bank is disabled, e.g. disabled memory controllers on certain models, etc. The MCA bank is disabled in the hardware, so there is no possibility of getting an MCA/MCE from it even if it is assumed to have a known type. For example: Full system: Bank | Type seen on CPU0 | Type seen on CPU1 ------------------------------------------------ 0 | LS | LS 1 | UMC | UMC 2 | CS | CS System with hardware disabled: Bank | Type seen on CPU0 | Type seen on CPU1 ------------------------------------------------ 0 | LS | LS 1 | UMC | RAZ 2 | CS | CS For this reason, there is a single, global struct smca_banks[] that is initialized at boot time. This array is initialized on each CPU as it comes online. However, the array will not be updated if an entry already exists. This works as expected when the first CPU (usually CPU0) has all possible MCA banks enabled. But if the first CPU has a subset, then it will save a "Reserved" type in smca_banks[]. Successive CPUs will then not be able to update smca_banks[] even if they encounter a known bank type. This may result in unexpected behavior. Depending on the system configuration, a user may observe issues enumerating the MCA thresholding sysfs interface. The issues may be as trivial as sysfs entries not being available, or as severe as system hangs. For example: Bank | Type seen on CPU0 | Type seen on CPU1 ------------------------------------------------ 0 | LS | LS 1 | RAZ | UMC 2 | CS | CS Extend the smca_banks[] entry check to return if the entry is a non-reserved type. Otherwise, continue so that CPUs that encounter a known bank type can update smca_banks[]. Fixes: 68627a697c19 ("x86/mce/AMD, EDAC/mce_amd: Enumerate Reserved SMCA bank type") Signed-off-by: Yazen Ghannam Signed-off-by: Borislav Petkov Cc: "H. Peter Anvin" Cc: Ingo Molnar Cc: linux-edac Cc: Cc: Thomas Gleixner Cc: Tony Luck Cc: x86-ml Link: https://lkml.kernel.org/r/20191121141508.141273-1-Yazen.Ghannam@amd.com Signed-off-by: Greg Kroah-Hartman --- arch/x86/kernel/cpu/mcheck/mce_amd.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) --- a/arch/x86/kernel/cpu/mcheck/mce_amd.c +++ b/arch/x86/kernel/cpu/mcheck/mce_amd.c @@ -228,7 +228,7 @@ static void smca_configure(unsigned int } /* Return early if this bank was already initialized. */ - if (smca_banks[bank].hwid) + if (smca_banks[bank].hwid && smca_banks[bank].hwid->hwid_mcatype != 0) return; if (rdmsr_safe(MSR_AMD64_SMCA_MCx_IPID(bank), &low, &high)) {