Re: [PATCH 1/6] x86/irq: Add enumeration of NMI source reporting CPU feature
From: Jacob Pan
Date: Thu May 30 2024 - 12:14:31 EST
Hi Peter,
On Wed, 29 May 2024 13:49:40 -0700, "H. Peter Anvin" <hpa@xxxxxxxxx> wrote:
> On 5/29/24 13:33, Jacob Pan wrote:
> > diff --git a/arch/x86/kernel/cpu/cpuid-deps.c
> > b/arch/x86/kernel/cpu/cpuid-deps.c index b7d9f530ae16..3f1a1a1961fa
> > 100644 --- a/arch/x86/kernel/cpu/cpuid-deps.c
> > +++ b/arch/x86/kernel/cpu/cpuid-deps.c
> > @@ -84,6 +84,7 @@ static const struct cpuid_dep cpuid_deps[] = {
> > { X86_FEATURE_SHSTK,
> > X86_FEATURE_XSAVES }, { X86_FEATURE_FRED,
> > X86_FEATURE_LKGS }, { X86_FEATURE_FRED,
> > X86_FEATURE_WRMSRNS },
> > + { X86_FEATURE_FRED,
> > X86_FEATURE_NMI_SOURCE}, {}
> > };
> >
>
> This is incorrect. FRED does *not* inherently depend on NMI_SOURCE; the
> dependency is the reverse, but since it *also* depends on FRED being
> dynamically enabled, there is no need to add it to the static table; the
> dynamic test:
>
My misunderstanding of the dependency table, thanks for pointing it out.
Will remove.
> > diff --git a/arch/x86/kernel/traps.c b/arch/x86/kernel/traps.c
> > index 4fa0b17e5043..465f04e4a79f 100644
> > --- a/arch/x86/kernel/traps.c
> > +++ b/arch/x86/kernel/traps.c
> > @@ -1427,8 +1427,10 @@ early_param("fred", fred_setup);
> >
> > void __init trap_init(void)
> > {
> > - if (cpu_feature_enabled(X86_FEATURE_FRED) && !enable_fred)
> > + if (cpu_feature_enabled(X86_FEATURE_FRED) && !enable_fred) {
> > setup_clear_cpu_cap(X86_FEATURE_FRED);
> > + setup_clear_cpu_cap(X86_FEATURE_NMI_SOURCE);
> > + }
> >
> > /* Init cpu_entry_area before IST entries are set up */
> > setup_cpu_entry_areas();
>
> ... suffices just fine on its own.
I am not following, do you mean checking for FRED is sufficient for NMI
source? I think it works since NMI source cannot be disabled if FRED is on.
Just want to use the architectural CPUID bits to the fullest.
Thanks,
Jacob