Re: [PATCH 1/6] x86/irq: Add enumeration of NMI source reporting CPU feature

From: H. Peter Anvin
Date: Wed May 29 2024 - 16:50:23 EST


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:

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.

-hpa