lkml.org 
[lkml]   [2021]   [Sep]   [22]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH 3/4] x86/mce: Get rid of msr_ops
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

\
 
 \ /
  Last update: 2021-09-22 14:18    [W:0.093 / U:0.644 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site