Re: [PATCH 3/4] x86/mce: Get rid of msr_ops

From: Luck, Tony
Date: Mon Sep 20 2021 - 00:58:44 EST


On Fri, Sep 17, 2021 at 12:53:54PM +0200, Borislav Petkov wrote:
> + switch (reg) {
> + case MCA_CTL:
> + return mce_flags.smca ? MSR_AMD64_SMCA_MCx_CTL(bank)
> + : MSR_IA32_MCx_CTL(bank);
>
> -static inline u32 smca_ctl_reg(int bank)
> -{
> - return MSR_AMD64_SMCA_MCx_CTL(bank);
> -}
> + case MCA_STATUS:
> + return mce_flags.smca ? MSR_AMD64_SMCA_MCx_STATUS(bank)
> + : MSR_IA32_MCx_STATUS(bank);
>
> -static inline u32 smca_status_reg(int bank)
> -{
> - return MSR_AMD64_SMCA_MCx_STATUS(bank);
> -}
> + case MCA_ADDR:
> + return mce_flags.smca ? MSR_AMD64_SMCA_MCx_ADDR(bank)
> + : MSR_IA32_MCx_ADDR(bank);
>
> -static inline u32 smca_addr_reg(int bank)
> -{
> - return MSR_AMD64_SMCA_MCx_ADDR(bank);
> -}
> + case MCA_MISC:
> + return mce_flags.smca ? MSR_AMD64_SMCA_MCx_MISC(bank)
> + : MSR_IA32_MCx_MISC(bank);
> + default: break;
> + }

I think this would be easier on the eyeballs with
a couple of helper functions:

if (mce_flags.smca)
return smca_msr_number(bank, reg);
else
return msr_number(bank, reg);

with the switch (reg) in each of those helper functions.

-Tony