kvm.ko is nothing but library code shared by kvm-intel.ko and kvm-amd.ko.
It provides no functionality on its own and it is unnecessary unless one
of the vendor-specific module is compiled. In particular, /dev/kvm is
not created until one of kvm-intel.ko or kvm-amd.ko is loaded.
Use CONFIG_KVM to decide if it is built-in or a module, but use the
vendor-specific modules for the actual decision on whether to build it.
This also fixes a build failure when CONFIG_KVM_INTEL and CONFIG_KVM_AMD
are both disabled. The cpu_emergency_register_virt_callback() function
is called from kvm.ko, but it is only defined if at least one of
CONFIG_KVM_INTEL and CONFIG_KVM_AMD is provided.
Fixes: 590b09b1d88e ("KVM: x86: Register "emergency disable" callbacks when virt is enabled")
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
arch/x86/kvm/Kconfig | 7 +++++--
arch/x86/kvm/Makefile | 2 +-
2 files changed, 6 insertions(+), 3 deletions(-)
diff --git a/arch/x86/kvm/Kconfig b/arch/x86/kvm/Kconfig
index 730c2f34d347..81bce9dd9331 100644
--- a/arch/x86/kvm/Kconfig
+++ b/arch/x86/kvm/Kconfig
@@ -17,8 +17,8 @@ menuconfig VIRTUALIZATION
if VIRTUALIZATION
-config KVM
- tristate "Kernel-based Virtual Machine (KVM) support"
+config KVM_X86_COMMON
+ def_tristate KVM if KVM_INTEL || KVM_AMD
depends on X86_LOCAL_APIC
select KVM_COMMON
select KVM_GENERIC_MMU_NOTIFIER
@@ -45,6 +45,9 @@ config KVM
select KVM_GENERIC_HARDWARE_ENABLING
select KVM_GENERIC_PRE_FAULT_MEMORY
select KVM_WERROR if WERROR
+
+config KVM
+ tristate "Kernel-based Virtual Machine (KVM) support"
help
Support hosting fully virtualized guest machines using hardware
virtualization extensions. You will need a fairly recent
diff --git a/arch/x86/kvm/Makefile b/arch/x86/kvm/Makefile
index 5494669a055a..0d050cfaffb2 100644
--- a/arch/x86/kvm/Makefile
+++ b/arch/x86/kvm/Makefile
@@ -32,7 +32,7 @@ kvm-intel-y += vmx/vmx_onhyperv.o vmx/hyperv_evmcs.o
kvm-amd-y += svm/svm_onhyperv.o
endif
-obj-$(CONFIG_KVM) += kvm.o
+obj-$(CONFIG_KVM_X86_COMMON) += kvm.o
obj-$(CONFIG_KVM_INTEL) += kvm-intel.o
obj-$(CONFIG_KVM_AMD) += kvm-amd.o
--
2.43.5
Hi Paolo, kernel test robot noticed the following build errors: [auto build test ERROR on kvm/queue] [also build test ERROR on linus/master v6.12-rc1 next-20241004] [cannot apply to kvm/linux-next] [If your patch is applied to the wrong git tree, kindly drop us a note. And when submitting patch, we suggest to use '--base' as documented in https://git-scm.com/docs/git-format-patch#_base_tree_information] url: https://github.com/intel-lab-lkp/linux/commits/Paolo-Bonzini/KVM-x86-leave-kvm-ko-out-of-the-build-if-no-vendor-module-is-requested/20241004-071034 base: https://git.kernel.org/pub/scm/virt/kvm/kvm.git queue patch link: https://lore.kernel.org/r/20241003230806.229001-2-pbonzini%40redhat.com patch subject: [PATCH 1/2] KVM: x86: leave kvm.ko out of the build if no vendor module is requested config: i386-randconfig-r052-20241006 (https://download.01.org/0day-ci/archive/20241006/202410060426.e9Xsnkvi-lkp@intel.com/config) compiler: clang version 18.1.8 (https://github.com/llvm/llvm-project 3b5b5c1ec4a3095ab096dd780e84d7ab81f3d7ff) reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20241006/202410060426.e9Xsnkvi-lkp@intel.com/reproduce) If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags | Reported-by: kernel test robot <lkp@intel.com> | Closes: https://lore.kernel.org/oe-kbuild-all/202410060426.e9Xsnkvi-lkp@intel.com/ All errors (new ones prefixed by >>): >> arch/x86/kvm/vmx/vmx.c:759:2: error: use of undeclared identifier 'kvm_rebooting' 759 | kvm_rebooting = true; | ^ >> arch/x86/kvm/vmx/vmx.c:5903:7: error: call to undeclared function '__xfer_to_guest_mode_work_pending'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration] 5903 | if (__xfer_to_guest_mode_work_pending()) | ^ >> arch/x86/kvm/vmx/vmx.c:6822:17: error: no member named 'mmu_invalidate_seq' in 'struct kvm' 6822 | mmu_seq = kvm->mmu_invalidate_seq; | ~~~ ^ >> arch/x86/kvm/vmx/vmx.c:6835:6: error: call to undeclared function 'mmu_invalidate_retry_gfn'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration] 6835 | if (mmu_invalidate_retry_gfn(kvm, mmu_seq, gfn)) { | ^ 4 errors generated. -- >> arch/x86/kvm/vmx/posted_intr.c:178:3: error: call to undeclared function '__apic_send_IPI_self'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration] 178 | __apic_send_IPI_self(POSTED_INTR_WAKEUP_VECTOR); | ^ >> arch/x86/kvm/vmx/posted_intr.c:286:33: error: no member named 'irq_routing' in 'struct kvm' 286 | irq_rt = srcu_dereference(kvm->irq_routing, &kvm->irq_srcu); | ~~~ ^ include/linux/srcu.h:217:58: note: expanded from macro 'srcu_dereference' 217 | #define srcu_dereference(p, ssp) srcu_dereference_check((p), (ssp), 0) | ^ include/linux/srcu.h:204:27: note: expanded from macro 'srcu_dereference_check' 204 | __rcu_dereference_check((p), __UNIQUE_ID(rcu), \ | ^ include/linux/rcupdate.h:527:10: note: expanded from macro '__rcu_dereference_check' 527 | typeof(*p) *local = (typeof(*p) *__force)READ_ONCE(p); \ | ^ >> arch/x86/kvm/vmx/posted_intr.c:286:33: error: no member named 'irq_routing' in 'struct kvm' 286 | irq_rt = srcu_dereference(kvm->irq_routing, &kvm->irq_srcu); | ~~~ ^ include/linux/srcu.h:217:58: note: expanded from macro 'srcu_dereference' 217 | #define srcu_dereference(p, ssp) srcu_dereference_check((p), (ssp), 0) | ^ include/linux/srcu.h:204:27: note: expanded from macro 'srcu_dereference_check' 204 | __rcu_dereference_check((p), __UNIQUE_ID(rcu), \ | ^ include/linux/rcupdate.h:527:31: note: expanded from macro '__rcu_dereference_check' 527 | typeof(*p) *local = (typeof(*p) *__force)READ_ONCE(p); \ | ^ >> arch/x86/kvm/vmx/posted_intr.c:286:33: error: no member named 'irq_routing' in 'struct kvm' 286 | irq_rt = srcu_dereference(kvm->irq_routing, &kvm->irq_srcu); | ~~~ ^ include/linux/srcu.h:217:58: note: expanded from macro 'srcu_dereference' 217 | #define srcu_dereference(p, ssp) srcu_dereference_check((p), (ssp), 0) | ^ include/linux/srcu.h:204:27: note: expanded from macro 'srcu_dereference_check' 204 | __rcu_dereference_check((p), __UNIQUE_ID(rcu), \ | ^ include/linux/rcupdate.h:527:53: note: expanded from macro '__rcu_dereference_check' 527 | typeof(*p) *local = (typeof(*p) *__force)READ_ONCE(p); \ | ^ note: (skipping 3 expansions in backtrace; use -fmacro-backtrace-limit=0 to see all) include/linux/compiler_types.h:510:22: note: expanded from macro 'compiletime_assert' 510 | _compiletime_assert(condition, msg, __compiletime_assert_, __COUNTER__) | ^~~~~~~~~ include/linux/compiler_types.h:498:23: note: expanded from macro '_compiletime_assert' 498 | __compiletime_assert(condition, msg, prefix, suffix) | ^~~~~~~~~ include/linux/compiler_types.h:490:9: note: expanded from macro '__compiletime_assert' 490 | if (!(condition)) \ | ^~~~~~~~~ >> arch/x86/kvm/vmx/posted_intr.c:286:33: error: no member named 'irq_routing' in 'struct kvm' 286 | irq_rt = srcu_dereference(kvm->irq_routing, &kvm->irq_srcu); | ~~~ ^ include/linux/srcu.h:217:58: note: expanded from macro 'srcu_dereference' 217 | #define srcu_dereference(p, ssp) srcu_dereference_check((p), (ssp), 0) | ^ include/linux/srcu.h:204:27: note: expanded from macro 'srcu_dereference_check' 204 | __rcu_dereference_check((p), __UNIQUE_ID(rcu), \ | ^ include/linux/rcupdate.h:527:53: note: expanded from macro '__rcu_dereference_check' 527 | typeof(*p) *local = (typeof(*p) *__force)READ_ONCE(p); \ | ^ note: (skipping 3 expansions in backtrace; use -fmacro-backtrace-limit=0 to see all) include/linux/compiler_types.h:510:22: note: expanded from macro 'compiletime_assert' 510 | _compiletime_assert(condition, msg, __compiletime_assert_, __COUNTER__) | ^~~~~~~~~ include/linux/compiler_types.h:498:23: note: expanded from macro '_compiletime_assert' 498 | __compiletime_assert(condition, msg, prefix, suffix) | ^~~~~~~~~ include/linux/compiler_types.h:490:9: note: expanded from macro '__compiletime_assert' 490 | if (!(condition)) \ | ^~~~~~~~~ >> arch/x86/kvm/vmx/posted_intr.c:286:33: error: no member named 'irq_routing' in 'struct kvm' 286 | irq_rt = srcu_dereference(kvm->irq_routing, &kvm->irq_srcu); | ~~~ ^ include/linux/srcu.h:217:58: note: expanded from macro 'srcu_dereference' 217 | #define srcu_dereference(p, ssp) srcu_dereference_check((p), (ssp), 0) | ^ include/linux/srcu.h:204:27: note: expanded from macro 'srcu_dereference_check' 204 | __rcu_dereference_check((p), __UNIQUE_ID(rcu), \ | ^ include/linux/rcupdate.h:527:53: note: expanded from macro '__rcu_dereference_check' 527 | typeof(*p) *local = (typeof(*p) *__force)READ_ONCE(p); \ | ^ note: (skipping 3 expansions in backtrace; use -fmacro-backtrace-limit=0 to see all) include/linux/compiler_types.h:510:22: note: expanded from macro 'compiletime_assert' 510 | _compiletime_assert(condition, msg, __compiletime_assert_, __COUNTER__) | ^~~~~~~~~ include/linux/compiler_types.h:498:23: note: expanded from macro '_compiletime_assert' 498 | __compiletime_assert(condition, msg, prefix, suffix) | ^~~~~~~~~ include/linux/compiler_types.h:490:9: note: expanded from macro '__compiletime_assert' 490 | if (!(condition)) \ | ^~~~~~~~~ >> arch/x86/kvm/vmx/posted_intr.c:286:33: error: no member named 'irq_routing' in 'struct kvm' 286 | irq_rt = srcu_dereference(kvm->irq_routing, &kvm->irq_srcu); | ~~~ ^ include/linux/srcu.h:217:58: note: expanded from macro 'srcu_dereference' 217 | #define srcu_dereference(p, ssp) srcu_dereference_check((p), (ssp), 0) | ^ include/linux/srcu.h:204:27: note: expanded from macro 'srcu_dereference_check' 204 | __rcu_dereference_check((p), __UNIQUE_ID(rcu), \ | ^ include/linux/rcupdate.h:527:53: note: expanded from macro '__rcu_dereference_check' 527 | typeof(*p) *local = (typeof(*p) *__force)READ_ONCE(p); \ | ^ note: (skipping 3 expansions in backtrace; use -fmacro-backtrace-limit=0 to see all) include/linux/compiler_types.h:510:22: note: expanded from macro 'compiletime_assert' 510 | _compiletime_assert(condition, msg, __compiletime_assert_, __COUNTER__) | ^~~~~~~~~ include/linux/compiler_types.h:498:23: note: expanded from macro '_compiletime_assert' 498 | __compiletime_assert(condition, msg, prefix, suffix) | ^~~~~~~~~ include/linux/compiler_types.h:490:9: note: expanded from macro '__compiletime_assert' 490 | if (!(condition)) \ | ^~~~~~~~~ >> arch/x86/kvm/vmx/posted_intr.c:286:33: error: no member named 'irq_routing' in 'struct kvm' 286 | irq_rt = srcu_dereference(kvm->irq_routing, &kvm->irq_srcu); | ~~~ ^ include/linux/srcu.h:217:58: note: expanded from macro 'srcu_dereference' 217 | #define srcu_dereference(p, ssp) srcu_dereference_check((p), (ssp), 0) | ^ include/linux/srcu.h:204:27: note: expanded from macro 'srcu_dereference_check' 204 | __rcu_dereference_check((p), __UNIQUE_ID(rcu), \ | ^ include/linux/rcupdate.h:527:53: note: expanded from macro '__rcu_dereference_check' 527 | typeof(*p) *local = (typeof(*p) *__force)READ_ONCE(p); \ | ^ note: (skipping 2 expansions in backtrace; use -fmacro-backtrace-limit=0 to see all) include/linux/compiler_types.h:510:22: note: expanded from macro 'compiletime_assert' 510 | _compiletime_assert(condition, msg, __compiletime_assert_, __COUNTER__) | ^~~~~~~~~ include/linux/compiler_types.h:498:23: note: expanded from macro '_compiletime_assert' 498 | __compiletime_assert(condition, msg, prefix, suffix) | ^~~~~~~~~ include/linux/compiler_types.h:490:9: note: expanded from macro '__compiletime_assert' 490 | if (!(condition)) \ | ^~~~~~~~~ >> arch/x86/kvm/vmx/posted_intr.c:286:33: error: no member named 'irq_routing' in 'struct kvm' 286 | irq_rt = srcu_dereference(kvm->irq_routing, &kvm->irq_srcu); | ~~~ ^ include/linux/srcu.h:217:58: note: expanded from macro 'srcu_dereference' 217 | #define srcu_dereference(p, ssp) srcu_dereference_check((p), (ssp), 0) | ^ include/linux/srcu.h:204:27: note: expanded from macro 'srcu_dereference_check' 204 | __rcu_dereference_check((p), __UNIQUE_ID(rcu), \ | ^ include/linux/rcupdate.h:527:53: note: expanded from macro '__rcu_dereference_check' 527 | typeof(*p) *local = (typeof(*p) *__force)READ_ONCE(p); \ | ^ include/asm-generic/rwonce.h:50:14: note: expanded from macro 'READ_ONCE' 50 | __READ_ONCE(x); \ | ^ include/asm-generic/rwonce.h:44:65: note: expanded from macro '__READ_ONCE' 44 | #define __READ_ONCE(x) (*(const volatile __unqual_scalar_typeof(x) *)&(x)) | ^ include/linux/compiler_types.h:466:13: note: expanded from macro '__unqual_scalar_typeof' 466 | _Generic((x), \ | ^ >> arch/x86/kvm/vmx/posted_intr.c:286:33: error: no member named 'irq_routing' in 'struct kvm' 286 | irq_rt = srcu_dereference(kvm->irq_routing, &kvm->irq_srcu); | ~~~ ^ include/linux/srcu.h:217:58: note: expanded from macro 'srcu_dereference' 217 | #define srcu_dereference(p, ssp) srcu_dereference_check((p), (ssp), 0) | ^ include/linux/srcu.h:204:27: note: expanded from macro 'srcu_dereference_check' 204 | __rcu_dereference_check((p), __UNIQUE_ID(rcu), \ | ^ include/linux/rcupdate.h:527:53: note: expanded from macro '__rcu_dereference_check' 527 | typeof(*p) *local = (typeof(*p) *__force)READ_ONCE(p); \ | ^ include/asm-generic/rwonce.h:50:14: note: expanded from macro 'READ_ONCE' 50 | __READ_ONCE(x); \ | ^ include/asm-generic/rwonce.h:44:65: note: expanded from macro '__READ_ONCE' 44 | #define __READ_ONCE(x) (*(const volatile __unqual_scalar_typeof(x) *)&(x)) | ^ include/linux/compiler_types.h:473:15: note: expanded from macro '__unqual_scalar_typeof' 473 | default: (x))) | ^ >> arch/x86/kvm/vmx/posted_intr.c:286:33: error: no member named 'irq_routing' in 'struct kvm' 286 | irq_rt = srcu_dereference(kvm->irq_routing, &kvm->irq_srcu); | ~~~ ^ include/linux/srcu.h:217:58: note: expanded from macro 'srcu_dereference' 217 | #define srcu_dereference(p, ssp) srcu_dereference_check((p), (ssp), 0) | ^ include/linux/srcu.h:204:27: note: expanded from macro 'srcu_dereference_check' 204 | __rcu_dereference_check((p), __UNIQUE_ID(rcu), \ | ^ include/linux/rcupdate.h:527:53: note: expanded from macro '__rcu_dereference_check' 527 | typeof(*p) *local = (typeof(*p) *__force)READ_ONCE(p); \ | ^ include/asm-generic/rwonce.h:50:14: note: expanded from macro 'READ_ONCE' 50 | __READ_ONCE(x); \ | ^ include/asm-generic/rwonce.h:44:72: note: expanded from macro '__READ_ONCE' 44 | #define __READ_ONCE(x) (*(const volatile __unqual_scalar_typeof(x) *)&(x)) | ^ >> arch/x86/kvm/vmx/posted_intr.c:286:33: error: no member named 'irq_routing' in 'struct kvm' 286 | irq_rt = srcu_dereference(kvm->irq_routing, &kvm->irq_srcu); | ~~~ ^ include/linux/srcu.h:217:58: note: expanded from macro 'srcu_dereference' 217 | #define srcu_dereference(p, ssp) srcu_dereference_check((p), (ssp), 0) | ^ include/linux/srcu.h:204:27: note: expanded from macro 'srcu_dereference_check' 204 | __rcu_dereference_check((p), __UNIQUE_ID(rcu), \ | ^ include/linux/rcupdate.h:530:12: note: expanded from macro '__rcu_dereference_check' 530 | ((typeof(*p) __force __kernel *)(local)); \ | ^ >> arch/x86/kvm/vmx/posted_intr.c:286:9: error: assigning to 'struct kvm_irq_routing_table *' from incompatible type 'void' 286 | irq_rt = srcu_dereference(kvm->irq_routing, &kvm->irq_srcu); | ^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ >> arch/x86/kvm/vmx/posted_intr.c:287:25: error: incomplete definition of type 'struct kvm_irq_routing_table' 287 | if (guest_irq >= irq_rt->nr_rt_entries || | ~~~~~~^ include/linux/kvm_types.h:11:8: note: forward declaration of 'struct kvm_irq_routing_table' 11 | struct kvm_irq_routing_table; | ^ arch/x86/kvm/vmx/posted_intr.c:288:25: error: incomplete definition of type 'struct kvm_irq_routing_table' 288 | hlist_empty(&irq_rt->map[guest_irq])) { | ~~~~~~^ include/linux/kvm_types.h:11:8: note: forward declaration of 'struct kvm_irq_routing_table' 11 | struct kvm_irq_routing_table; | ^ arch/x86/kvm/vmx/posted_intr.c:290:26: error: incomplete definition of type 'struct kvm_irq_routing_table' 290 | guest_irq, irq_rt->nr_rt_entries); | ~~~~~~^ include/linux/printk.h:623:42: note: expanded from macro 'pr_warn_once' 623 | printk_once(KERN_WARNING pr_fmt(fmt), ##__VA_ARGS__) | ^~~~~~~~~~~ include/linux/printk.h:604:30: note: expanded from macro 'printk_once' 604 | DO_ONCE_LITE(printk, fmt, ##__VA_ARGS__) | ^~~~~~~~~~~ include/linux/once_lite.h:11:32: note: expanded from macro 'DO_ONCE_LITE' 11 | DO_ONCE_LITE_IF(true, func, ##__VA_ARGS__) | ^~~~~~~~~~~ include/linux/once_lite.h:31:9: note: expanded from macro 'DO_ONCE_LITE_IF' 31 | func(__VA_ARGS__); \ | ^~~~~~~~~~~ include/linux/printk.h:465:60: note: expanded from macro 'printk' 465 | #define printk(fmt, ...) printk_index_wrap(_printk, fmt, ##__VA_ARGS__) | ^~~~~~~~~~~ include/linux/printk.h:437:19: note: expanded from macro 'printk_index_wrap' 437 | _p_func(_fmt, ##__VA_ARGS__); \ | ^~~~~~~~~~~ include/linux/kvm_types.h:11:8: note: forward declaration of 'struct kvm_irq_routing_table' 11 | struct kvm_irq_routing_table; | ^ arch/x86/kvm/vmx/posted_intr.c:294:33: error: incomplete definition of type 'struct kvm_irq_routing_table' 294 | hlist_for_each_entry(e, &irq_rt->map[guest_irq], link) { | ~~~~~~^ include/linux/list.h:1163:31: note: expanded from macro 'hlist_for_each_entry' 1163 | for (pos = hlist_entry_safe((head)->first, typeof(*(pos)), member);\ | ^~~~ include/linux/list.h:1152:12: note: expanded from macro 'hlist_entry_safe' 1152 | ({ typeof(ptr) ____ptr = (ptr); \ | ^~~ include/linux/kvm_types.h:11:8: note: forward declaration of 'struct kvm_irq_routing_table' 11 | struct kvm_irq_routing_table; | ^ arch/x86/kvm/vmx/posted_intr.c:294:33: error: incomplete definition of type 'struct kvm_irq_routing_table' 294 | hlist_for_each_entry(e, &irq_rt->map[guest_irq], link) { | ~~~~~~^ include/linux/list.h:1163:31: note: expanded from macro 'hlist_for_each_entry' 1163 | for (pos = hlist_entry_safe((head)->first, typeof(*(pos)), member);\ | ^~~~ include/linux/list.h:1152:28: note: expanded from macro 'hlist_entry_safe' 1152 | ({ typeof(ptr) ____ptr = (ptr); \ | ^~~ include/linux/kvm_types.h:11:8: note: forward declaration of 'struct kvm_irq_routing_table' 11 | struct kvm_irq_routing_table; | ^ 18 errors generated. -- >> arch/x86/kvm/svm/svm.c:597:2: error: use of undeclared identifier 'kvm_rebooting' 597 | kvm_rebooting = true; | ^ 1 error generated. -- >> arch/x86/kvm/svm/avic.c:909:33: error: no member named 'irq_routing' in 'struct kvm' 909 | irq_rt = srcu_dereference(kvm->irq_routing, &kvm->irq_srcu); | ~~~ ^ include/linux/srcu.h:217:58: note: expanded from macro 'srcu_dereference' 217 | #define srcu_dereference(p, ssp) srcu_dereference_check((p), (ssp), 0) | ^ include/linux/srcu.h:204:27: note: expanded from macro 'srcu_dereference_check' 204 | __rcu_dereference_check((p), __UNIQUE_ID(rcu), \ | ^ include/linux/rcupdate.h:527:10: note: expanded from macro '__rcu_dereference_check' 527 | typeof(*p) *local = (typeof(*p) *__force)READ_ONCE(p); \ | ^ >> arch/x86/kvm/svm/avic.c:909:33: error: no member named 'irq_routing' in 'struct kvm' 909 | irq_rt = srcu_dereference(kvm->irq_routing, &kvm->irq_srcu); | ~~~ ^ include/linux/srcu.h:217:58: note: expanded from macro 'srcu_dereference' 217 | #define srcu_dereference(p, ssp) srcu_dereference_check((p), (ssp), 0) | ^ include/linux/srcu.h:204:27: note: expanded from macro 'srcu_dereference_check' 204 | __rcu_dereference_check((p), __UNIQUE_ID(rcu), \ | ^ include/linux/rcupdate.h:527:31: note: expanded from macro '__rcu_dereference_check' 527 | typeof(*p) *local = (typeof(*p) *__force)READ_ONCE(p); \ | ^ >> arch/x86/kvm/svm/avic.c:909:33: error: no member named 'irq_routing' in 'struct kvm' 909 | irq_rt = srcu_dereference(kvm->irq_routing, &kvm->irq_srcu); | ~~~ ^ include/linux/srcu.h:217:58: note: expanded from macro 'srcu_dereference' 217 | #define srcu_dereference(p, ssp) srcu_dereference_check((p), (ssp), 0) | ^ include/linux/srcu.h:204:27: note: expanded from macro 'srcu_dereference_check' 204 | __rcu_dereference_check((p), __UNIQUE_ID(rcu), \ | ^ include/linux/rcupdate.h:527:53: note: expanded from macro '__rcu_dereference_check' 527 | typeof(*p) *local = (typeof(*p) *__force)READ_ONCE(p); \ | ^ note: (skipping 3 expansions in backtrace; use -fmacro-backtrace-limit=0 to see all) include/linux/compiler_types.h:510:22: note: expanded from macro 'compiletime_assert' 510 | _compiletime_assert(condition, msg, __compiletime_assert_, __COUNTER__) | ^~~~~~~~~ include/linux/compiler_types.h:498:23: note: expanded from macro '_compiletime_assert' 498 | __compiletime_assert(condition, msg, prefix, suffix) | ^~~~~~~~~ include/linux/compiler_types.h:490:9: note: expanded from macro '__compiletime_assert' 490 | if (!(condition)) \ | ^~~~~~~~~ >> arch/x86/kvm/svm/avic.c:909:33: error: no member named 'irq_routing' in 'struct kvm' 909 | irq_rt = srcu_dereference(kvm->irq_routing, &kvm->irq_srcu); | ~~~ ^ include/linux/srcu.h:217:58: note: expanded from macro 'srcu_dereference' 217 | #define srcu_dereference(p, ssp) srcu_dereference_check((p), (ssp), 0) | ^ include/linux/srcu.h:204:27: note: expanded from macro 'srcu_dereference_check' 204 | __rcu_dereference_check((p), __UNIQUE_ID(rcu), \ | ^ include/linux/rcupdate.h:527:53: note: expanded from macro '__rcu_dereference_check' 527 | typeof(*p) *local = (typeof(*p) *__force)READ_ONCE(p); \ | ^ note: (skipping 3 expansions in backtrace; use -fmacro-backtrace-limit=0 to see all) include/linux/compiler_types.h:510:22: note: expanded from macro 'compiletime_assert' 510 | _compiletime_assert(condition, msg, __compiletime_assert_, __COUNTER__) | ^~~~~~~~~ include/linux/compiler_types.h:498:23: note: expanded from macro '_compiletime_assert' 498 | __compiletime_assert(condition, msg, prefix, suffix) | ^~~~~~~~~ include/linux/compiler_types.h:490:9: note: expanded from macro '__compiletime_assert' 490 | if (!(condition)) \ | ^~~~~~~~~ >> arch/x86/kvm/svm/avic.c:909:33: error: no member named 'irq_routing' in 'struct kvm' 909 | irq_rt = srcu_dereference(kvm->irq_routing, &kvm->irq_srcu); | ~~~ ^ include/linux/srcu.h:217:58: note: expanded from macro 'srcu_dereference' 217 | #define srcu_dereference(p, ssp) srcu_dereference_check((p), (ssp), 0) | ^ include/linux/srcu.h:204:27: note: expanded from macro 'srcu_dereference_check' 204 | __rcu_dereference_check((p), __UNIQUE_ID(rcu), \ | ^ include/linux/rcupdate.h:527:53: note: expanded from macro '__rcu_dereference_check' 527 | typeof(*p) *local = (typeof(*p) *__force)READ_ONCE(p); \ | ^ note: (skipping 3 expansions in backtrace; use -fmacro-backtrace-limit=0 to see all) include/linux/compiler_types.h:510:22: note: expanded from macro 'compiletime_assert' 510 | _compiletime_assert(condition, msg, __compiletime_assert_, __COUNTER__) | ^~~~~~~~~ include/linux/compiler_types.h:498:23: note: expanded from macro '_compiletime_assert' 498 | __compiletime_assert(condition, msg, prefix, suffix) | ^~~~~~~~~ include/linux/compiler_types.h:490:9: note: expanded from macro '__compiletime_assert' 490 | if (!(condition)) \ | ^~~~~~~~~ >> arch/x86/kvm/svm/avic.c:909:33: error: no member named 'irq_routing' in 'struct kvm' 909 | irq_rt = srcu_dereference(kvm->irq_routing, &kvm->irq_srcu); | ~~~ ^ include/linux/srcu.h:217:58: note: expanded from macro 'srcu_dereference' 217 | #define srcu_dereference(p, ssp) srcu_dereference_check((p), (ssp), 0) | ^ include/linux/srcu.h:204:27: note: expanded from macro 'srcu_dereference_check' 204 | __rcu_dereference_check((p), __UNIQUE_ID(rcu), \ | ^ include/linux/rcupdate.h:527:53: note: expanded from macro '__rcu_dereference_check' 527 | typeof(*p) *local = (typeof(*p) *__force)READ_ONCE(p); \ | ^ note: (skipping 3 expansions in backtrace; use -fmacro-backtrace-limit=0 to see all) include/linux/compiler_types.h:510:22: note: expanded from macro 'compiletime_assert' 510 | _compiletime_assert(condition, msg, __compiletime_assert_, __COUNTER__) | ^~~~~~~~~ include/linux/compiler_types.h:498:23: note: expanded from macro '_compiletime_assert' 498 | __compiletime_assert(condition, msg, prefix, suffix) | ^~~~~~~~~ include/linux/compiler_types.h:490:9: note: expanded from macro '__compiletime_assert' 490 | if (!(condition)) \ | ^~~~~~~~~ >> arch/x86/kvm/svm/avic.c:909:33: error: no member named 'irq_routing' in 'struct kvm' 909 | irq_rt = srcu_dereference(kvm->irq_routing, &kvm->irq_srcu); | ~~~ ^ include/linux/srcu.h:217:58: note: expanded from macro 'srcu_dereference' 217 | #define srcu_dereference(p, ssp) srcu_dereference_check((p), (ssp), 0) | ^ include/linux/srcu.h:204:27: note: expanded from macro 'srcu_dereference_check' 204 | __rcu_dereference_check((p), __UNIQUE_ID(rcu), \ | ^ include/linux/rcupdate.h:527:53: note: expanded from macro '__rcu_dereference_check' 527 | typeof(*p) *local = (typeof(*p) *__force)READ_ONCE(p); \ | ^ note: (skipping 2 expansions in backtrace; use -fmacro-backtrace-limit=0 to see all) include/linux/compiler_types.h:510:22: note: expanded from macro 'compiletime_assert' 510 | _compiletime_assert(condition, msg, __compiletime_assert_, __COUNTER__) | ^~~~~~~~~ include/linux/compiler_types.h:498:23: note: expanded from macro '_compiletime_assert' 498 | __compiletime_assert(condition, msg, prefix, suffix) | ^~~~~~~~~ include/linux/compiler_types.h:490:9: note: expanded from macro '__compiletime_assert' 490 | if (!(condition)) \ | ^~~~~~~~~ >> arch/x86/kvm/svm/avic.c:909:33: error: no member named 'irq_routing' in 'struct kvm' 909 | irq_rt = srcu_dereference(kvm->irq_routing, &kvm->irq_srcu); | ~~~ ^ include/linux/srcu.h:217:58: note: expanded from macro 'srcu_dereference' 217 | #define srcu_dereference(p, ssp) srcu_dereference_check((p), (ssp), 0) | ^ include/linux/srcu.h:204:27: note: expanded from macro 'srcu_dereference_check' 204 | __rcu_dereference_check((p), __UNIQUE_ID(rcu), \ | ^ include/linux/rcupdate.h:527:53: note: expanded from macro '__rcu_dereference_check' 527 | typeof(*p) *local = (typeof(*p) *__force)READ_ONCE(p); \ | ^ include/asm-generic/rwonce.h:50:14: note: expanded from macro 'READ_ONCE' 50 | __READ_ONCE(x); \ | ^ include/asm-generic/rwonce.h:44:65: note: expanded from macro '__READ_ONCE' 44 | #define __READ_ONCE(x) (*(const volatile __unqual_scalar_typeof(x) *)&(x)) | ^ include/linux/compiler_types.h:466:13: note: expanded from macro '__unqual_scalar_typeof' 466 | _Generic((x), \ | ^ >> arch/x86/kvm/svm/avic.c:909:33: error: no member named 'irq_routing' in 'struct kvm' 909 | irq_rt = srcu_dereference(kvm->irq_routing, &kvm->irq_srcu); | ~~~ ^ include/linux/srcu.h:217:58: note: expanded from macro 'srcu_dereference' 217 | #define srcu_dereference(p, ssp) srcu_dereference_check((p), (ssp), 0) | ^ include/linux/srcu.h:204:27: note: expanded from macro 'srcu_dereference_check' 204 | __rcu_dereference_check((p), __UNIQUE_ID(rcu), \ | ^ include/linux/rcupdate.h:527:53: note: expanded from macro '__rcu_dereference_check' 527 | typeof(*p) *local = (typeof(*p) *__force)READ_ONCE(p); \ | ^ include/asm-generic/rwonce.h:50:14: note: expanded from macro 'READ_ONCE' 50 | __READ_ONCE(x); \ | ^ include/asm-generic/rwonce.h:44:65: note: expanded from macro '__READ_ONCE' 44 | #define __READ_ONCE(x) (*(const volatile __unqual_scalar_typeof(x) *)&(x)) | ^ include/linux/compiler_types.h:473:15: note: expanded from macro '__unqual_scalar_typeof' 473 | default: (x))) | ^ >> arch/x86/kvm/svm/avic.c:909:33: error: no member named 'irq_routing' in 'struct kvm' 909 | irq_rt = srcu_dereference(kvm->irq_routing, &kvm->irq_srcu); | ~~~ ^ include/linux/srcu.h:217:58: note: expanded from macro 'srcu_dereference' 217 | #define srcu_dereference(p, ssp) srcu_dereference_check((p), (ssp), 0) | ^ include/linux/srcu.h:204:27: note: expanded from macro 'srcu_dereference_check' 204 | __rcu_dereference_check((p), __UNIQUE_ID(rcu), \ | ^ include/linux/rcupdate.h:527:53: note: expanded from macro '__rcu_dereference_check' 527 | typeof(*p) *local = (typeof(*p) *__force)READ_ONCE(p); \ | ^ include/asm-generic/rwonce.h:50:14: note: expanded from macro 'READ_ONCE' 50 | __READ_ONCE(x); \ | ^ include/asm-generic/rwonce.h:44:72: note: expanded from macro '__READ_ONCE' 44 | #define __READ_ONCE(x) (*(const volatile __unqual_scalar_typeof(x) *)&(x)) | ^ >> arch/x86/kvm/svm/avic.c:909:33: error: no member named 'irq_routing' in 'struct kvm' 909 | irq_rt = srcu_dereference(kvm->irq_routing, &kvm->irq_srcu); | ~~~ ^ include/linux/srcu.h:217:58: note: expanded from macro 'srcu_dereference' 217 | #define srcu_dereference(p, ssp) srcu_dereference_check((p), (ssp), 0) | ^ include/linux/srcu.h:204:27: note: expanded from macro 'srcu_dereference_check' 204 | __rcu_dereference_check((p), __UNIQUE_ID(rcu), \ | ^ include/linux/rcupdate.h:530:12: note: expanded from macro '__rcu_dereference_check' 530 | ((typeof(*p) __force __kernel *)(local)); \ | ^ >> arch/x86/kvm/svm/avic.c:909:9: error: assigning to 'struct kvm_irq_routing_table *' from incompatible type 'void' 909 | irq_rt = srcu_dereference(kvm->irq_routing, &kvm->irq_srcu); | ^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ >> arch/x86/kvm/svm/avic.c:911:25: error: incomplete definition of type 'struct kvm_irq_routing_table' 911 | if (guest_irq >= irq_rt->nr_rt_entries || | ~~~~~~^ include/linux/kvm_types.h:11:8: note: forward declaration of 'struct kvm_irq_routing_table' 11 | struct kvm_irq_routing_table; | ^ arch/x86/kvm/svm/avic.c:912:22: error: incomplete definition of type 'struct kvm_irq_routing_table' 912 | hlist_empty(&irq_rt->map[guest_irq])) { | ~~~~~~^ include/linux/kvm_types.h:11:8: note: forward declaration of 'struct kvm_irq_routing_table' 11 | struct kvm_irq_routing_table; | ^ arch/x86/kvm/svm/avic.c:914:26: error: incomplete definition of type 'struct kvm_irq_routing_table' 914 | guest_irq, irq_rt->nr_rt_entries); | ~~~~~~^ include/linux/printk.h:623:42: note: expanded from macro 'pr_warn_once' 623 | printk_once(KERN_WARNING pr_fmt(fmt), ##__VA_ARGS__) | ^~~~~~~~~~~ include/linux/printk.h:604:30: note: expanded from macro 'printk_once' 604 | DO_ONCE_LITE(printk, fmt, ##__VA_ARGS__) | ^~~~~~~~~~~ include/linux/once_lite.h:11:32: note: expanded from macro 'DO_ONCE_LITE' 11 | DO_ONCE_LITE_IF(true, func, ##__VA_ARGS__) | ^~~~~~~~~~~ include/linux/once_lite.h:31:9: note: expanded from macro 'DO_ONCE_LITE_IF' 31 | func(__VA_ARGS__); \ | ^~~~~~~~~~~ include/linux/printk.h:465:60: note: expanded from macro 'printk' 465 | #define printk(fmt, ...) printk_index_wrap(_printk, fmt, ##__VA_ARGS__) | ^~~~~~~~~~~ include/linux/printk.h:437:19: note: expanded from macro 'printk_index_wrap' 437 | _p_func(_fmt, ##__VA_ARGS__); \ | ^~~~~~~~~~~ include/linux/kvm_types.h:11:8: note: forward declaration of 'struct kvm_irq_routing_table' 11 | struct kvm_irq_routing_table; | ^ arch/x86/kvm/svm/avic.c:918:33: error: incomplete definition of type 'struct kvm_irq_routing_table' 918 | hlist_for_each_entry(e, &irq_rt->map[guest_irq], link) { | ~~~~~~^ include/linux/list.h:1163:31: note: expanded from macro 'hlist_for_each_entry' 1163 | for (pos = hlist_entry_safe((head)->first, typeof(*(pos)), member);\ | ^~~~ include/linux/list.h:1152:12: note: expanded from macro 'hlist_entry_safe' 1152 | ({ typeof(ptr) ____ptr = (ptr); \ | ^~~ include/linux/kvm_types.h:11:8: note: forward declaration of 'struct kvm_irq_routing_table' 11 | struct kvm_irq_routing_table; | ^ arch/x86/kvm/svm/avic.c:918:33: error: incomplete definition of type 'struct kvm_irq_routing_table' 918 | hlist_for_each_entry(e, &irq_rt->map[guest_irq], link) { | ~~~~~~^ include/linux/list.h:1163:31: note: expanded from macro 'hlist_for_each_entry' 1163 | for (pos = hlist_entry_safe((head)->first, typeof(*(pos)), member);\ | ^~~~ include/linux/list.h:1152:28: note: expanded from macro 'hlist_entry_safe' 1152 | ({ typeof(ptr) ____ptr = (ptr); \ | ^~~ include/linux/kvm_types.h:11:8: note: forward declaration of 'struct kvm_irq_routing_table' 11 | struct kvm_irq_routing_table; | ^ 17 errors generated. vim +/kvm_rebooting +759 arch/x86/kvm/vmx/vmx.c 22e420e127399f arch/x86/kvm/vmx/vmx.c Sean Christopherson 2023-07-21 753 590b09b1d88e18 arch/x86/kvm/vmx/vmx.c Sean Christopherson 2024-08-29 754 void vmx_emergency_disable_virtualization_cpu(void) 8f536b7697a0d4 arch/x86/kvm/vmx.c Zhang Yanfei 2012-12-06 755 { 8f536b7697a0d4 arch/x86/kvm/vmx.c Zhang Yanfei 2012-12-06 756 int cpu = raw_smp_processor_id(); 8f536b7697a0d4 arch/x86/kvm/vmx.c Zhang Yanfei 2012-12-06 757 struct loaded_vmcs *v; 8f536b7697a0d4 arch/x86/kvm/vmx.c Zhang Yanfei 2012-12-06 758 6ae44e012f4c35 arch/x86/kvm/vmx/vmx.c Sean Christopherson 2023-07-21 @759 kvm_rebooting = true; 6ae44e012f4c35 arch/x86/kvm/vmx/vmx.c Sean Christopherson 2023-07-21 760 a788fbb763b500 arch/x86/kvm/vmx/vmx.c Sean Christopherson 2023-07-21 761 /* a788fbb763b500 arch/x86/kvm/vmx/vmx.c Sean Christopherson 2023-07-21 762 * Note, CR4.VMXE can be _cleared_ in NMI context, but it can only be a788fbb763b500 arch/x86/kvm/vmx/vmx.c Sean Christopherson 2023-07-21 763 * set in task context. If this races with VMX is disabled by an NMI, a788fbb763b500 arch/x86/kvm/vmx/vmx.c Sean Christopherson 2023-07-21 764 * VMCLEAR and VMXOFF may #UD, but KVM will eat those faults due to a788fbb763b500 arch/x86/kvm/vmx/vmx.c Sean Christopherson 2023-07-21 765 * kvm_rebooting set. a788fbb763b500 arch/x86/kvm/vmx/vmx.c Sean Christopherson 2023-07-21 766 */ a788fbb763b500 arch/x86/kvm/vmx/vmx.c Sean Christopherson 2023-07-21 767 if (!(__read_cr4() & X86_CR4_VMXE)) a788fbb763b500 arch/x86/kvm/vmx/vmx.c Sean Christopherson 2023-07-21 768 return; a788fbb763b500 arch/x86/kvm/vmx/vmx.c Sean Christopherson 2023-07-21 769 8f536b7697a0d4 arch/x86/kvm/vmx.c Zhang Yanfei 2012-12-06 770 list_for_each_entry(v, &per_cpu(loaded_vmcss_on_cpu, cpu), 8f536b7697a0d4 arch/x86/kvm/vmx.c Zhang Yanfei 2012-12-06 771 loaded_vmcss_on_cpu_link) 8f536b7697a0d4 arch/x86/kvm/vmx.c Zhang Yanfei 2012-12-06 772 vmcs_clear(v->vmcs); 119b5cb4ffd016 arch/x86/kvm/vmx/vmx.c Sean Christopherson 2023-07-21 773 22e420e127399f arch/x86/kvm/vmx/vmx.c Sean Christopherson 2023-07-21 774 kvm_cpu_vmxoff(); 8f536b7697a0d4 arch/x86/kvm/vmx.c Zhang Yanfei 2012-12-06 775 } 8f536b7697a0d4 arch/x86/kvm/vmx.c Zhang Yanfei 2012-12-06 776 -- 0-DAY CI Kernel Test Service https://github.com/intel/lkp-tests/wiki
Hi Paolo, kernel test robot noticed the following build warnings: [auto build test WARNING on kvm/queue] [also build test WARNING on linus/master v6.12-rc1 next-20241004] [cannot apply to kvm/linux-next] [If your patch is applied to the wrong git tree, kindly drop us a note. And when submitting patch, we suggest to use '--base' as documented in https://git-scm.com/docs/git-format-patch#_base_tree_information] url: https://github.com/intel-lab-lkp/linux/commits/Paolo-Bonzini/KVM-x86-leave-kvm-ko-out-of-the-build-if-no-vendor-module-is-requested/20241004-071034 base: https://git.kernel.org/pub/scm/virt/kvm/kvm.git queue patch link: https://lore.kernel.org/r/20241003230806.229001-2-pbonzini%40redhat.com patch subject: [PATCH 1/2] KVM: x86: leave kvm.ko out of the build if no vendor module is requested config: x86_64-kismet-CONFIG_KVM_GENERIC_MEMORY_ATTRIBUTES-CONFIG_KVM_GENERIC_PRIVATE_MEM-0-0 (https://download.01.org/0day-ci/archive/20241005/202410050850.Ztr6bJEq-lkp@intel.com/config) reproduce: (https://download.01.org/0day-ci/archive/20241005/202410050850.Ztr6bJEq-lkp@intel.com/reproduce) If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags | Reported-by: kernel test robot <lkp@intel.com> | Closes: https://lore.kernel.org/oe-kbuild-all/202410050850.Ztr6bJEq-lkp@intel.com/ kismet warnings: (new ones prefixed by >>) >> kismet: WARNING: unmet direct dependencies detected for KVM_GENERIC_MEMORY_ATTRIBUTES when selected by KVM_GENERIC_PRIVATE_MEM WARNING: unmet direct dependencies detected for KVM_GENERIC_MEMORY_ATTRIBUTES Depends on [n]: KVM_GENERIC_MMU_NOTIFIER [=n] Selected by [y]: - KVM_GENERIC_PRIVATE_MEM [=y] -- 0-DAY CI Kernel Test Service https://github.com/intel/lkp-tests/wiki
On Thu, Oct 03, 2024, Paolo Bonzini wrote: > kvm.ko is nothing but library code shared by kvm-intel.ko and kvm-amd.ko. > It provides no functionality on its own and it is unnecessary unless one > of the vendor-specific module is compiled. In particular, /dev/kvm is > not created until one of kvm-intel.ko or kvm-amd.ko is loaded. > > Use CONFIG_KVM to decide if it is built-in or a module, but use the > vendor-specific modules for the actual decision on whether to build it. > > This also fixes a build failure when CONFIG_KVM_INTEL and CONFIG_KVM_AMD > are both disabled. The cpu_emergency_register_virt_callback() function > is called from kvm.ko, but it is only defined if at least one of > CONFIG_KVM_INTEL and CONFIG_KVM_AMD is provided. > > Fixes: 590b09b1d88e ("KVM: x86: Register "emergency disable" callbacks when virt is enabled") > Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> > --- > arch/x86/kvm/Kconfig | 7 +++++-- > arch/x86/kvm/Makefile | 2 +- > 2 files changed, 6 insertions(+), 3 deletions(-) > > diff --git a/arch/x86/kvm/Kconfig b/arch/x86/kvm/Kconfig > index 730c2f34d347..81bce9dd9331 100644 > --- a/arch/x86/kvm/Kconfig > +++ b/arch/x86/kvm/Kconfig > @@ -17,8 +17,8 @@ menuconfig VIRTUALIZATION > > if VIRTUALIZATION > > -config KVM > - tristate "Kernel-based Virtual Machine (KVM) support" > +config KVM_X86_COMMON Maybe just KVM_X86? I doubt anyone in KVM will care too much, and for the rest of the kernel, CONFIG_KVM_X86 is likely more intuitive than CONFIG_KVM_X86_COMMON.
© 2016 - 2024 Red Hat, Inc.