Message ID | 20241003230806.229001-2-pbonzini@redhat.com (mailing list archive) |
---|---|
State | New |
Headers | show |
Series | KVM: x86: only build common code if at least one vendor module was picked | expand |
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.
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]
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
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(-)