]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
x86/fred: Install system vector handlers even if FRED isn't fully enabled
authorSean Christopherson <seanjc@google.com>
Fri, 2 May 2025 14:24:01 +0000 (07:24 -0700)
committerPeter Zijlstra <peterz@infradead.org>
Mon, 18 Aug 2025 12:23:08 +0000 (14:23 +0200)
Install the system vector IRQ handlers for FRED even if FRED isn't fully
enabled in hardware.  This will allow KVM to use the FRED IRQ path even
on non-FRED hardware, which in turn will eliminate a non-CFI indirect CALL
(KVM currently invokes the IRQ handler via an IDT lookup on the vector).

[sean: extract from diff, drop stub, write changelog]
Signed-off-by: Sean Christopherson <seanjc@google.com>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Link: https://lkml.kernel.org/r/20250714103441.121251108@infradead.org
arch/x86/include/asm/idtentry.h
arch/x86/kernel/irqinit.c

index a4ec27c6798875900cbdbba927918e70b900f63b..abd637e54e94e3d81cfde9435535d006457f6090 100644 (file)
@@ -460,17 +460,12 @@ __visible noinstr void func(struct pt_regs *regs,                 \
 #endif
 
 void idt_install_sysvec(unsigned int n, const void *function);
-
-#ifdef CONFIG_X86_FRED
 void fred_install_sysvec(unsigned int vector, const idtentry_t function);
-#else
-static inline void fred_install_sysvec(unsigned int vector, const idtentry_t function) { }
-#endif
 
 #define sysvec_install(vector, function) {                             \
-       if (cpu_feature_enabled(X86_FEATURE_FRED))                      \
+       if (IS_ENABLED(CONFIG_X86_FRED))                                \
                fred_install_sysvec(vector, function);                  \
-       else                                                            \
+       if (!cpu_feature_enabled(X86_FEATURE_FRED))                     \
                idt_install_sysvec(vector, asm_##function);             \
 }
 
index f79c5edc0b892da8e3dff9afda2324ae0dae5944..6ab9eac64670acf8ce8a96dc78c4649057b8907e 100644 (file)
@@ -97,9 +97,11 @@ void __init native_init_IRQ(void)
        /* Execute any quirks before the call gates are initialised: */
        x86_init.irqs.pre_vector_init();
 
-       if (cpu_feature_enabled(X86_FEATURE_FRED))
+       /* FRED's IRQ path may be used even if FRED isn't fully enabled. */
+       if (IS_ENABLED(CONFIG_X86_FRED))
                fred_complete_exception_setup();
-       else
+
+       if (!cpu_feature_enabled(X86_FEATURE_FRED))
                idt_setup_apic_and_irq_gates();
 
        lapic_assign_system_vectors();