Re: [PATCH 3/4] x86/mce: Get rid of msr_ops
From: Luck, Tony
Date: Wed Sep 22 2021 - 09:23:35 EST
Looks nice. I don’t think you need those “break;” after each “return …;”
Sent from my iPhone
> On Sep 22, 2021, at 05:18, Borislav Petkov <bp@xxxxxxxxx> wrote:
>
> On Mon, Sep 20, 2021 at 10:32:11AM +0200, Borislav Petkov wrote:
>> but please don't make me add more helper functions. Those MSR defines
>> already have "SMCA" and "IA32" in their names so that should be a good
>> enough differentiation, I'd say.
>
> I just had a better idea - it is compact but regular and one can see at
> a quick glance which block is for which set of MSRs:
>
> u32 mca_msr_reg(int bank, enum mca_msr reg)
> {
> if (mce_flags.smca) {
> switch (reg) {
> case MCA_CTL: return MSR_AMD64_SMCA_MCx_CTL(bank); break;
> case MCA_ADDR: return MSR_AMD64_SMCA_MCx_ADDR(bank); break;
> case MCA_MISC: return MSR_AMD64_SMCA_MCx_MISC(bank); break;
> case MCA_STATUS: return MSR_AMD64_SMCA_MCx_STATUS(bank); break;
> default: goto out; break;
> }
> }
>
> switch (reg) {
> case MCA_CTL: return MSR_IA32_MCx_CTL(bank); break;
> case MCA_ADDR: return MSR_IA32_MCx_ADDR(bank); break;
> case MCA_MISC: return MSR_IA32_MCx_MISC(bank); break;
> case MCA_STATUS: return MSR_IA32_MCx_STATUS(bank); break;
> default: goto out; break;
> }
>
> out:
> WARN_ON_ONCE(1);
> return 0;
> }
>
> --
> Regards/Gruss,
> Boris.
>
> https://people.kernel.org/tglx/notes-about-netiquette