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

x86: replace CONFIG_HAVE_KVM with IS_ENABLED(CONFIG_KVM)

It is more accurate to check if KVM is enabled, instead of having the
architecture say so. Architectures always "have" KVM, so for example
checking CONFIG_HAVE_KVM in x86 code is pointless, but if KVM is disabled
in a specific build, there is no need for support code.

Alternatively, many of the #ifdefs could simply be deleted. However,
this would add completely dead code. For example, when KVM is disabled,
there should not be any posted interrupts, i.e. NOT wiring up the "dummy"
handlers and treating IRQs on those vectors as spurious is the right
thing to do.

Cc: x86@kernel.org
Cc: kbingham@kernel.org
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>

+14 -10
+1 -1
arch/x86/include/asm/hardirq.h
··· 15 15 unsigned int irq_spurious_count; 16 16 unsigned int icr_read_retry_count; 17 17 #endif 18 - #ifdef CONFIG_HAVE_KVM 18 + #if IS_ENABLED(CONFIG_KVM) 19 19 unsigned int kvm_posted_intr_ipis; 20 20 unsigned int kvm_posted_intr_wakeup_ipis; 21 21 unsigned int kvm_posted_intr_nested_ipis;
+1 -1
arch/x86/include/asm/idtentry.h
··· 675 675 # endif 676 676 #endif 677 677 678 - #ifdef CONFIG_HAVE_KVM 678 + #if IS_ENABLED(CONFIG_KVM) 679 679 DECLARE_IDTENTRY_SYSVEC(POSTED_INTR_VECTOR, sysvec_kvm_posted_intr_ipi); 680 680 DECLARE_IDTENTRY_SYSVEC(POSTED_INTR_WAKEUP_VECTOR, sysvec_kvm_posted_intr_wakeup_ipi); 681 681 DECLARE_IDTENTRY_SYSVEC(POSTED_INTR_NESTED_VECTOR, sysvec_kvm_posted_intr_nested_ipi);
+1 -1
arch/x86/include/asm/irq.h
··· 29 29 30 30 extern void fixup_irqs(void); 31 31 32 - #ifdef CONFIG_HAVE_KVM 32 + #if IS_ENABLED(CONFIG_KVM) 33 33 extern void kvm_set_posted_intr_wakeup_handler(void (*handler)(void)); 34 34 #endif 35 35
+1 -1
arch/x86/include/asm/irq_vectors.h
··· 84 84 #define HYPERVISOR_CALLBACK_VECTOR 0xf3 85 85 86 86 /* Vector for KVM to deliver posted interrupt IPI */ 87 - #ifdef CONFIG_HAVE_KVM 87 + #if IS_ENABLED(CONFIG_KVM) 88 88 #define POSTED_INTR_VECTOR 0xf2 89 89 #define POSTED_INTR_WAKEUP_VECTOR 0xf1 90 90 #define POSTED_INTR_NESTED_VECTOR 0xf0
+1 -1
arch/x86/kernel/idt.c
··· 153 153 #ifdef CONFIG_X86_LOCAL_APIC 154 154 INTG(LOCAL_TIMER_VECTOR, asm_sysvec_apic_timer_interrupt), 155 155 INTG(X86_PLATFORM_IPI_VECTOR, asm_sysvec_x86_platform_ipi), 156 - # ifdef CONFIG_HAVE_KVM 156 + # if IS_ENABLED(CONFIG_KVM) 157 157 INTG(POSTED_INTR_VECTOR, asm_sysvec_kvm_posted_intr_ipi), 158 158 INTG(POSTED_INTR_WAKEUP_VECTOR, asm_sysvec_kvm_posted_intr_wakeup_ipi), 159 159 INTG(POSTED_INTR_NESTED_VECTOR, asm_sysvec_kvm_posted_intr_nested_ipi),
+2 -2
arch/x86/kernel/irq.c
··· 164 164 #if defined(CONFIG_X86_IO_APIC) 165 165 seq_printf(p, "%*s: %10u\n", prec, "MIS", atomic_read(&irq_mis_count)); 166 166 #endif 167 - #ifdef CONFIG_HAVE_KVM 167 + #if IS_ENABLED(CONFIG_KVM) 168 168 seq_printf(p, "%*s: ", prec, "PIN"); 169 169 for_each_online_cpu(j) 170 170 seq_printf(p, "%10u ", irq_stats(j)->kvm_posted_intr_ipis); ··· 290 290 } 291 291 #endif 292 292 293 - #ifdef CONFIG_HAVE_KVM 293 + #if IS_ENABLED(CONFIG_KVM) 294 294 static void dummy_handler(void) {} 295 295 static void (*kvm_posted_intr_wakeup_handler)(void) = dummy_handler; 296 296
+5 -1
scripts/gdb/linux/constants.py.in
··· 130 130 LX_CONFIG(CONFIG_X86_MCE_AMD) 131 131 LX_CONFIG(CONFIG_X86_MCE) 132 132 LX_CONFIG(CONFIG_X86_IO_APIC) 133 - LX_CONFIG(CONFIG_HAVE_KVM) 133 + /* 134 + * CONFIG_KVM can be "m" but it affects common code too. Use CONFIG_KVM_COMMON 135 + * as a proxy for IS_ENABLED(CONFIG_KVM). 136 + */ 137 + LX_CONFIG_KVM = IS_BUILTIN(CONFIG_KVM_COMMON) 134 138 LX_CONFIG(CONFIG_NUMA) 135 139 LX_CONFIG(CONFIG_ARM64) 136 140 LX_CONFIG(CONFIG_ARM64_4K_PAGES)
+1 -1
scripts/gdb/linux/interrupts.py
··· 151 151 if cnt is not None: 152 152 text += "%*s: %10u\n" % (prec, "MIS", cnt['counter']) 153 153 154 - if constants.LX_CONFIG_HAVE_KVM: 154 + if constants.LX_CONFIG_KVM: 155 155 text += x86_show_irqstat(prec, "PIN", 'kvm_posted_intr_ipis', 'Posted-interrupt notification event') 156 156 text += x86_show_irqstat(prec, "NPI", 'kvm_posted_intr_nested_ipis', 'Nested posted-interrupt event') 157 157 text += x86_show_irqstat(prec, "PIW", 'kvm_posted_intr_wakeup_ipis', 'Posted-interrupt wakeup event')
+1 -1
tools/arch/x86/include/asm/irq_vectors.h
··· 84 84 #define HYPERVISOR_CALLBACK_VECTOR 0xf3 85 85 86 86 /* Vector for KVM to deliver posted interrupt IPI */ 87 - #ifdef CONFIG_HAVE_KVM 87 + #if IS_ENABLED(CONFIG_KVM) 88 88 #define POSTED_INTR_VECTOR 0xf2 89 89 #define POSTED_INTR_WAKEUP_VECTOR 0xf1 90 90 #define POSTED_INTR_NESTED_VECTOR 0xf0