Skip to content

Commit 793aa4b

Browse files
yghannambp3tk0v
authored andcommitted
x86/mce: Use mce_prep_record() helpers for apei_smca_report_x86_error()
Current AMD systems can report MCA errors using the ACPI Boot Error Record Table (BERT). The BERT entries for MCA errors will be an x86 Common Platform Error Record (CPER) with an MSR register context that matches the MCAX/SMCA register space. However, the BERT will not necessarily be processed on the CPU that reported the MCA errors. Therefore, the correct CPU number needs to be determined and the information saved in struct mce. Use the newly defined mce_prep_record_*() helpers to get the correct data. Also, add an explicit check to verify that a valid CPU number was found from the APIC ID search. Signed-off-by: Yazen Ghannam <[email protected]> Signed-off-by: Borislav Petkov (AMD) <[email protected]> Reviewed-by: Nikolay Borisov <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Borislav Petkov (AMD) <[email protected]>
1 parent f9bbb8a commit 793aa4b

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

arch/x86/kernel/cpu/mce/apei.c

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ EXPORT_SYMBOL_GPL(apei_mce_report_mem_error);
6666
int apei_smca_report_x86_error(struct cper_ia_proc_ctx *ctx_info, u64 lapic_id)
6767
{
6868
const u64 *i_mce = ((const u64 *) (ctx_info + 1));
69+
bool apicid_found = false;
6970
unsigned int cpu;
7071
struct mce m;
7172

@@ -97,20 +98,19 @@ int apei_smca_report_x86_error(struct cper_ia_proc_ctx *ctx_info, u64 lapic_id)
9798
if (ctx_info->reg_arr_size < 48)
9899
return -EINVAL;
99100

100-
mce_prep_record(&m);
101-
102-
m.extcpu = -1;
103-
m.socketid = -1;
104-
105101
for_each_possible_cpu(cpu) {
106102
if (cpu_data(cpu).topo.initial_apicid == lapic_id) {
107-
m.extcpu = cpu;
108-
m.socketid = cpu_data(m.extcpu).topo.pkg_id;
103+
apicid_found = true;
109104
break;
110105
}
111106
}
112107

113-
m.apicid = lapic_id;
108+
if (!apicid_found)
109+
return -EINVAL;
110+
111+
mce_prep_record_common(&m);
112+
mce_prep_record_per_cpu(cpu, &m);
113+
114114
m.bank = (ctx_info->msr_addr >> 4) & 0xFF;
115115
m.status = *i_mce;
116116
m.addr = *(i_mce + 1);

0 commit comments

Comments
 (0)