Re: [PATCH] x86/mce: Schedule mce_setup() on correct CPU for CPER decoding

From: Yazen Ghannam
Date: Thu Jun 15 2023 - 13:40:03 EST


On 6/15/2023 1:02 PM, Yazen Ghannam wrote:
On 6/15/2023 12:20 PM, Borislav Petkov wrote:
On Thu, Jun 15, 2023 at 11:34:21AM -0400, Yazen Ghannam wrote:
We can solve the NMI issue if it ever comes up in the future. Unless there's
an obvious change to avoid this now. Any suggestions?

Yes, solve it right from the get-go. "It cannot happen now" is not good
enough. It should not be even technically possible.


Okay, understood.

Just report what's logged into BERT - nothing more. Whoever needs the
remaining info, can dump it from the machine.


Will do.


How about these changes? I can split this into separate preemption and PPIN patches.

The PPIN isn't coming directly from BERT. But it seems we can use the per_cpu value which is set up during CPU init.

Thanks,
Yazen

diff --git a/arch/x86/kernel/cpu/mce/apei.c b/arch/x86/kernel/cpu/mce/apei.c
index 8ed341714686..db16dc3c7b03 100644
--- a/arch/x86/kernel/cpu/mce/apei.c
+++ b/arch/x86/kernel/cpu/mce/apei.c
@@ -97,15 +97,19 @@ int apei_smca_report_x86_error(struct cper_ia_proc_ctx *ctx_info, u64 lapic_id)
if (ctx_info->reg_arr_size < 48)
return -EINVAL;

+ get_cpu();
mce_setup(&m);
+ put_cpu();

m.extcpu = -1;
m.socketid = -1;
+ m.ppin = 0;

for_each_possible_cpu(cpu) {
if (cpu_data(cpu).initial_apicid == lapic_id) {
m.extcpu = cpu;
m.socketid = cpu_data(m.extcpu).phys_proc_id;
+ m.ppin = cpu_data(m.extcpu).ppin;
break;
}
}