Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

x86/fred: Install system vector handlers even if FRED isn't fully enabled

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

authored by

Sean Christopherson and committed by
Peter Zijlstra
2d1435b7 c8ed0812

+6 -9
+2 -7
arch/x86/include/asm/idtentry.h
··· 460 460 #endif 461 461 462 462 void idt_install_sysvec(unsigned int n, const void *function); 463 - 464 - #ifdef CONFIG_X86_FRED 465 463 void fred_install_sysvec(unsigned int vector, const idtentry_t function); 466 - #else 467 - static inline void fred_install_sysvec(unsigned int vector, const idtentry_t function) { } 468 - #endif 469 464 470 465 #define sysvec_install(vector, function) { \ 471 - if (cpu_feature_enabled(X86_FEATURE_FRED)) \ 466 + if (IS_ENABLED(CONFIG_X86_FRED)) \ 472 467 fred_install_sysvec(vector, function); \ 473 - else \ 468 + if (!cpu_feature_enabled(X86_FEATURE_FRED)) \ 474 469 idt_install_sysvec(vector, asm_##function); \ 475 470 } 476 471
+4 -2
arch/x86/kernel/irqinit.c
··· 97 97 /* Execute any quirks before the call gates are initialised: */ 98 98 x86_init.irqs.pre_vector_init(); 99 99 100 - if (cpu_feature_enabled(X86_FEATURE_FRED)) 100 + /* FRED's IRQ path may be used even if FRED isn't fully enabled. */ 101 + if (IS_ENABLED(CONFIG_X86_FRED)) 101 102 fred_complete_exception_setup(); 102 - else 103 + 104 + if (!cpu_feature_enabled(X86_FEATURE_FRED)) 103 105 idt_setup_apic_and_irq_gates(); 104 106 105 107 lapic_assign_system_vectors();