]> git.proxmox.com Git - pve-kernel.git/blame - patches/kernel/0006-x86-MCE-AMD-Allow-Reserved-types-to-be-overwritten-i.patch
rebase patches on top of Ubuntu-5.3.0-29.31
[pve-kernel.git] / patches / kernel / 0006-x86-MCE-AMD-Allow-Reserved-types-to-be-overwritten-i.patch
CommitLineData
9538cc28
SR
1From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
2From: Yazen Ghannam <yazen.ghannam@amd.com>
3Date: Thu, 21 Nov 2019 08:15:08 -0600
4Subject: [PATCH] x86/MCE/AMD: Allow Reserved types to be overwritten in
5 smca_banks[]
6
7Each logical CPU in Scalable MCA systems controls a unique set of MCA
8banks in the system. These banks are not shared between CPUs. The bank
9types and ordering will be the same across CPUs on currently available
10systems.
11
12However, some CPUs may see a bank as Reserved/Read-as-Zero (RAZ) while
13other CPUs do not. In this case, the bank seen as Reserved on one CPU is
14assumed to be the same type as the bank seen as a known type on another
15CPU.
16
17In general, this occurs when the hardware represented by the MCA bank
18is disabled, e.g. disabled memory controllers on certain models, etc.
19The MCA bank is disabled in the hardware, so there is no possibility of
20getting an MCA/MCE from it even if it is assumed to have a known type.
21
22For example:
23
24Full system:
25 Bank | Type seen on CPU0 | Type seen on CPU1
26 ------------------------------------------------
27 0 | LS | LS
28 1 | UMC | UMC
29 2 | CS | CS
30
31System with hardware disabled:
32 Bank | Type seen on CPU0 | Type seen on CPU1
33 ------------------------------------------------
34 0 | LS | LS
35 1 | UMC | RAZ
36 2 | CS | CS
37
38For this reason, there is a single, global struct smca_banks[] that is
39initialized at boot time. This array is initialized on each CPU as it
40comes online. However, the array will not be updated if an entry already
41exists.
42
43This works as expected when the first CPU (usually CPU0) has all
44possible MCA banks enabled. But if the first CPU has a subset, then it
45will save a "Reserved" type in smca_banks[]. Successive CPUs will then
46not be able to update smca_banks[] even if they encounter a known bank
47type.
48
49This may result in unexpected behavior. Depending on the system
50configuration, a user may observe issues enumerating the MCA
51thresholding sysfs interface. The issues may be as trivial as sysfs
52entries not being available, or as severe as system hangs.
53
54For example:
55
56 Bank | Type seen on CPU0 | Type seen on CPU1
57 ------------------------------------------------
58 0 | LS | LS
59 1 | RAZ | UMC
60 2 | CS | CS
61
62Extend the smca_banks[] entry check to return if the entry is a
63non-reserved type. Otherwise, continue so that CPUs that encounter a
64known bank type can update smca_banks[].
65
66Fixes: 68627a697c19 ("x86/mce/AMD, EDAC/mce_amd: Enumerate Reserved SMCA bank type")
67Signed-off-by: Yazen Ghannam <yazen.ghannam@amd.com>
68Signed-off-by: Borislav Petkov <bp@suse.de>
69---
70 arch/x86/kernel/cpu/mce/amd.c | 2 +-
71 1 file changed, 1 insertion(+), 1 deletion(-)
72
73diff --git a/arch/x86/kernel/cpu/mce/amd.c b/arch/x86/kernel/cpu/mce/amd.c
74index 6ea7fdc82f3c..08e09c8c269f 100644
75--- a/arch/x86/kernel/cpu/mce/amd.c
76+++ b/arch/x86/kernel/cpu/mce/amd.c
77@@ -266,7 +266,7 @@ static void smca_configure(unsigned int bank, unsigned int cpu)
78 smca_set_misc_banks_map(bank, cpu);
79
80 /* Return early if this bank was already initialized. */
81- if (smca_banks[bank].hwid)
82+ if (smca_banks[bank].hwid && smca_banks[bank].hwid->hwid_mcatype != 0)
83 return;
84
85 if (rdmsr_safe_on_cpu(cpu, MSR_AMD64_SMCA_MCx_IPID(bank), &low, &high)) {