Re: [PATCH] arch/x86/entry_fred: don't set up KVM IRQs if KVM is disabled

From: Xin Li
Date: Thu Feb 15 2024 - 21:10:49 EST


On 2/15/2024 11:55 AM, Sean Christopherson wrote:
+Paolo and Stephen

FYI, there's a build failure in -next due to a collision between kvm/next and
tip/x86/fred. The above makes everything happy.

On Thu, Feb 15, 2024, Max Kellermann wrote:
When KVM is disabled, the POSTED_INTR_* macros do not exist, and the
build fails.

Fixes: 14619d912b65 ("x86/fred: FRED entry/exit and dispatch code")
Signed-off-by: Max Kellermann <max.kellermann@xxxxxxxxx>
---
arch/x86/entry/entry_fred.c | 2 ++
1 file changed, 2 insertions(+)

diff --git a/arch/x86/entry/entry_fred.c b/arch/x86/entry/entry_fred.c
index ac120cbdaaf2..660b7f7f9a79 100644
--- a/arch/x86/entry/entry_fred.c
+++ b/arch/x86/entry/entry_fred.c
@@ -114,9 +114,11 @@ static idtentry_t sysvec_table[NR_SYSTEM_VECTORS] __ro_after_init = {
SYSVEC(IRQ_WORK_VECTOR, irq_work),
+#if IS_ENABLED(CONFIG_KVM)
SYSVEC(POSTED_INTR_VECTOR, kvm_posted_intr_ipi),
SYSVEC(POSTED_INTR_WAKEUP_VECTOR, kvm_posted_intr_wakeup_ipi),
SYSVEC(POSTED_INTR_NESTED_VECTOR, kvm_posted_intr_nested_ipi),
+#endif
};
static bool fred_setup_done __initdata;
--
2.39.2


We want to minimize #ifdeffery (which is why we didn't add any to
sysvec_table[]), would it be better to simply remove "#if IS_ENABLED(CONFIG_KVM)" around the the POSTED_INTR_* macros from the
Linux-next tree?

BTW, kvm_posted_intr_*() are defined to NULL if !IS_ENABLED(CONFIG_KVM).

diff --git a/arch/x86/include/asm/irq_vectors.h b/arch/x86/include/asm/irq_vectors.h
index 3a19904c2db6..d18bfb238f66 100644
--- a/arch/x86/include/asm/irq_vectors.h
+++ b/arch/x86/include/asm/irq_vectors.h
@@ -84,11 +84,9 @@
#define HYPERVISOR_CALLBACK_VECTOR 0xf3

/* Vector for KVM to deliver posted interrupt IPI */
-#if IS_ENABLED(CONFIG_KVM)
#define POSTED_INTR_VECTOR 0xf2
#define POSTED_INTR_WAKEUP_VECTOR 0xf1
#define POSTED_INTR_NESTED_VECTOR 0xf0
-#endif

#define MANAGED_IRQ_SHUTDOWN_VECTOR 0xef