[1/4] KVM: introduce CONFIG_KVM_COMMON
Commit Message
CONFIG_HAVE_KVM is currently used by some architectures to either
enabled the KVM config proper, or to enable host-side code that is
not part of the KVM module. However, the "select" statement in
virt/kvm/Kconfig corresponds to a third meaning, namely to
enable common Kconfigs required by all architectures that support
KVM.
These three meanings can be replaced respectively by an
architecture-specific Kconfig, by IS_ENABLED(CONFIG_KVM), or by
a new Kconfig symbol that is in turn selected by the
architecture-specific "config KVM".
Start by introducing such a new Kconfig symbol, CONFIG_KVM_COMMON.
Unlike CONFIG_HAVE_KVM, it is selected by CONFIG_KVM, not by
architecture code.
Fixes: 8132d887a702 ("KVM: remove CONFIG_HAVE_KVM_EVENTFD", 2023-12-08)
Cc: Andrew Jones <ajones@ventanamicro.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
arch/arm64/kvm/Kconfig | 1 +
arch/loongarch/kvm/Kconfig | 1 +
arch/mips/kvm/Kconfig | 1 +
arch/powerpc/kvm/Kconfig | 1 +
arch/riscv/kvm/Kconfig | 1 +
arch/s390/kvm/Kconfig | 1 +
arch/x86/kvm/Kconfig | 1 +
virt/kvm/Kconfig | 3 +++
8 files changed, 10 insertions(+)
Comments
On Thu, Jan 04, 2024 at 03:59:56PM -0500, Paolo Bonzini wrote:
> CONFIG_HAVE_KVM is currently used by some architectures to either
> enabled the KVM config proper, or to enable host-side code that is
> not part of the KVM module. However, the "select" statement in
> virt/kvm/Kconfig corresponds to a third meaning, namely to
> enable common Kconfigs required by all architectures that support
> KVM.
>
> These three meanings can be replaced respectively by an
> architecture-specific Kconfig, by IS_ENABLED(CONFIG_KVM), or by
> a new Kconfig symbol that is in turn selected by the
> architecture-specific "config KVM".
>
> Start by introducing such a new Kconfig symbol, CONFIG_KVM_COMMON.
> Unlike CONFIG_HAVE_KVM, it is selected by CONFIG_KVM, not by
> architecture code.
>
> Fixes: 8132d887a702 ("KVM: remove CONFIG_HAVE_KVM_EVENTFD", 2023-12-08)
> Cc: Andrew Jones <ajones@ventanamicro.com>
> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
> ---
> arch/arm64/kvm/Kconfig | 1 +
> arch/loongarch/kvm/Kconfig | 1 +
> arch/mips/kvm/Kconfig | 1 +
> arch/powerpc/kvm/Kconfig | 1 +
> arch/riscv/kvm/Kconfig | 1 +
> arch/s390/kvm/Kconfig | 1 +
> arch/x86/kvm/Kconfig | 1 +
> virt/kvm/Kconfig | 3 +++
> 8 files changed, 10 insertions(+)
Reviewed-by: Andrew Jones <ajones@ventanamicro.com>
On Thu, Jan 04, 2024, Paolo Bonzini wrote:
> CONFIG_HAVE_KVM is currently used by some architectures to either
> enabled the KVM config proper, or to enable host-side code that is
> not part of the KVM module. However, the "select" statement in
> virt/kvm/Kconfig corresponds to a third meaning, namely to
> enable common Kconfigs required by all architectures that support
> KVM.
>
> These three meanings can be replaced respectively by an
> architecture-specific Kconfig, by IS_ENABLED(CONFIG_KVM), or by
> a new Kconfig symbol that is in turn selected by the
> architecture-specific "config KVM".
>
> Start by introducing such a new Kconfig symbol, CONFIG_KVM_COMMON.
> Unlike CONFIG_HAVE_KVM, it is selected by CONFIG_KVM, not by
> architecture code.
Why? I don't get it, just have code that cares do IS_ENABLED(CONFIG_KVM). Except
for the MIPS usage of HAVE_KVM that you solved by adding CPU_SUPPORTS_VZ, I got
all the way there using just CONFIG_KVM[*].
Ah, and so does this series for the most part, the only usage of CONFIG_KVM_COMMON
is in scripts/gdb/linux/constants.py.in. Honestly, adding a Kconfig just so that
VMX's posted interrupts that arrive in the host can be printed when KVM is built
as a module is a waste of a Kconfig.
[*] https://lore.kernel.org/all/20230916003118.2540661-12-seanjc@google.com
On Fri, Jan 5, 2024 at 8:13 PM Sean Christopherson <seanjc@google.com> wrote:
> > Start by introducing such a new Kconfig symbol, CONFIG_KVM_COMMON.
> > Unlike CONFIG_HAVE_KVM, it is selected by CONFIG_KVM, not by
> > architecture code.
>
> Why? I don't get it, just have code that cares do IS_ENABLED(CONFIG_KVM). Except
> for the MIPS usage of HAVE_KVM that you solved by adding CPU_SUPPORTS_VZ, I got
> all the way there using just CONFIG_KVM[*].
>
> Ah, and so does this series for the most part, the only usage of CONFIG_KVM_COMMON
> is in scripts/gdb/linux/constants.py.in. Honestly, adding a Kconfig just so that
> VMX's posted interrupts that arrive in the host can be printed when KVM is built
> as a module is a waste of a Kconfig.
There is one extra thing that CONFIG_KVM_COMMON does, which is to
avoid having to select common requirements in all architectures.
I jotted this to solve the reported randconfig failure, which is why
CONFIG_KVM_COMMON only requires "select EVENTFD", but looking more
closely it should also select PREEMPT_NOTIFIERS and INTERVAL_TREE.
Both are used by virt/kvm/kvm_main.c, and loongarch + riscv both lack
INTERVAL_TREE so I do think it's a good idea to introduce this symbol
(though it requires a v2).
> [*] https://lore.kernel.org/all/20230916003118.2540661-12-seanjc@google.com
I guess you mean
https://lore.kernel.org/all/20230916003118.2540661-8-seanjc@google.com/.
Paolo
On Fri, Jan 05, 2024, Paolo Bonzini wrote:
> On Fri, Jan 5, 2024 at 8:13 PM Sean Christopherson <seanjc@google.com> wrote:
> > > Start by introducing such a new Kconfig symbol, CONFIG_KVM_COMMON.
> > > Unlike CONFIG_HAVE_KVM, it is selected by CONFIG_KVM, not by
> > > architecture code.
> >
> > Why? I don't get it, just have code that cares do IS_ENABLED(CONFIG_KVM). Except
> > for the MIPS usage of HAVE_KVM that you solved by adding CPU_SUPPORTS_VZ, I got
> > all the way there using just CONFIG_KVM[*].
> >
> > Ah, and so does this series for the most part, the only usage of CONFIG_KVM_COMMON
> > is in scripts/gdb/linux/constants.py.in. Honestly, adding a Kconfig just so that
> > VMX's posted interrupts that arrive in the host can be printed when KVM is built
> > as a module is a waste of a Kconfig.
>
> There is one extra thing that CONFIG_KVM_COMMON does, which is to
> avoid having to select common requirements in all architectures.
Oooh, gotcha. FWIW, I would love to unify the "menuconfig VIRTUALIZATION" and
"config KVM" entries, but I can't think of a sane way to do that without ending
up with something like KVM_COMMON. :-/
> I jotted this to solve the reported randconfig failure, which is why
> CONFIG_KVM_COMMON only requires "select EVENTFD", but looking more
> closely it should also select PREEMPT_NOTIFIERS and INTERVAL_TREE.
> Both are used by virt/kvm/kvm_main.c, and loongarch + riscv both lack
> INTERVAL_TREE so I do think it's a good idea to introduce this symbol
> (though it requires a v2).
>
> > [*] https://lore.kernel.org/all/20230916003118.2540661-12-seanjc@google.com
>
> I guess you mean
> https://lore.kernel.org/all/20230916003118.2540661-8-seanjc@google.com/.
Doh, yes.
@@ -21,6 +21,7 @@ if VIRTUALIZATION
menuconfig KVM
bool "Kernel-based Virtual Machine (KVM) support"
depends on HAVE_KVM
+ select KVM_COMMON
select KVM_GENERIC_HARDWARE_ENABLING
select KVM_GENERIC_MMU_NOTIFIER
select PREEMPT_NOTIFIERS
@@ -23,6 +23,7 @@ config KVM
depends on HAVE_KVM
select HAVE_KVM_DIRTY_RING_ACQ_REL
select HAVE_KVM_VCPU_ASYNC_IOCTL
+ select KVM_COMMON
select KVM_GENERIC_DIRTYLOG_READ_PROTECT
select KVM_GENERIC_HARDWARE_ENABLING
select KVM_GENERIC_MMU_NOTIFIER
@@ -21,6 +21,7 @@ config KVM
depends on MIPS_FP_SUPPORT
select EXPORT_UASM
select PREEMPT_NOTIFIERS
+ select KVM_COMMON
select KVM_GENERIC_DIRTYLOG_READ_PROTECT
select HAVE_KVM_VCPU_ASYNC_IOCTL
select KVM_MMIO
@@ -20,6 +20,7 @@ if VIRTUALIZATION
config KVM
bool
select PREEMPT_NOTIFIERS
+ select KVM_COMMON
select HAVE_KVM_VCPU_ASYNC_IOCTL
select KVM_VFIO
select IRQ_BYPASS_MANAGER
@@ -24,6 +24,7 @@ config KVM
select HAVE_KVM_IRQ_ROUTING
select HAVE_KVM_MSI
select HAVE_KVM_VCPU_ASYNC_IOCTL
+ select KVM_COMMON
select KVM_GENERIC_DIRTYLOG_READ_PROTECT
select KVM_GENERIC_HARDWARE_ENABLING
select KVM_MMIO
@@ -25,6 +25,7 @@ config KVM
select HAVE_KVM_VCPU_ASYNC_IOCTL
select KVM_ASYNC_PF
select KVM_ASYNC_PF_SYNC
+ select KVM_COMMON
select HAVE_KVM_IRQCHIP
select HAVE_KVM_IRQ_ROUTING
select HAVE_KVM_INVALID_WAKEUPS
@@ -24,6 +24,7 @@ config KVM
depends on HIGH_RES_TIMERS
depends on X86_LOCAL_APIC
select PREEMPT_NOTIFIERS
+ select KVM_COMMON
select KVM_GENERIC_MMU_NOTIFIER
select HAVE_KVM_IRQCHIP
select HAVE_KVM_PFNCACHE
@@ -3,6 +3,9 @@
config HAVE_KVM
bool
+
+config KVM_COMMON
+ bool
select EVENTFD
config HAVE_KVM_PFNCACHE