Re: [PATCH v5 2/2] x86/mce: Add support for Extended Physical Address MCA changes

Yazen Ghannam
2022-04-13T14:11:02Z

On Wed, Apr 13, 2022 at 12:21:41PM +0200, Borislav Petkov wrote:
> On Tue, Apr 12, 2022 at 10:40:38AM -0500, Smita Koralahalli wrote:
> > diff --git a/arch/x86/kernel/cpu/mce/amd.c b/arch/x86/kernel/cpu/mce/amd.c
> > index f809eacac523..4f2744324d9b 100644
> > --- a/arch/x86/kernel/cpu/mce/amd.c
> > +++ b/arch/x86/kernel/cpu/mce/amd.c
> > @@ -722,6 +722,17 @@ bool amd_mce_is_memory_error(struct mce *m)
> > return m->bank == 4 && xec == 0x8;
> > }
> >
> > +void smca_feature_init(void)
> > +{
> > + unsigned int bank;
> > + u64 mca_cfg;
> > +
> > + for (bank = 0; bank < this_cpu_read(mce_num_banks); ++bank) {
> > + rdmsrl(MSR_AMD64_SMCA_MCx_CONFIG(bank), mca_cfg);
> > + this_cpu_ptr(mce_banks_array)[bank].lsb_in_status = !!(mca_cfg & BIT(8));
> > + }
> > +}
>
> We have smca_configure() for SMCA banks init and there it even reads
> MCx_CONFIG.
>
> Do you guys not see this?
>
> Or integrating new stuff into the existing code doesn't really matter -
> just bolt it on wherever it works?!
>

This function gets called from __mcheck_cpu_init_early() so that the info is
available before the MCA banks are polled in __mcheck_cpu_init_generic().

Maybe we can avoid some confusion by renaming this new function? It doesn't do
any feature initialization, so maybe smca_feature_detect_early() would be
better? The goal is to get just enough info that's needed before the bulk of
generic and vendor MCA initiliazation happens.

Or do you recommend unifying this with smca_configure()?

Thanks,
Yazen