From: Marc Zyngier <maz@kernel.org>
To: Sean Christopherson <seanjc@google.com>
Cc: Steffen Eiden <seiden@linux.ibm.com>,
kvm@vger.kernel.org, kvmarm@lists.linux.dev,
linux-arm-kernel@lists.infradead.org,
linux-kernel@vger.kernel.org, linux-s390@vger.kernel.org,
Alexander Gordeev <agordeev@linux.ibm.com>,
Andreas Grapentin <gra@linux.ibm.com>,
Arnd Bergmann <arnd@arndb.de>,
Catalin Marinas <catalin.marinas@arm.com>,
Christian Borntraeger <borntraeger@linux.ibm.com>,
Claudio Imbrenda <imbrenda@linux.ibm.com>,
David Hildenbrand <david@kernel.org>,
Friedrich Welter <fritz@linux.ibm.com>,
Fuad Tabba <tabba@google.com>, Gautam Gala <ggala@linux.ibm.com>,
Hariharan Mari <hari55@linux.ibm.com>,
Heiko Carstens <hca@linux.ibm.com>,
Hendrik Brueckner <brueckner@linux.ibm.com>,
Ilya Leoshkevich <iii@linux.ibm.com>,
Janosch Frank <frankja@linux.ibm.com>,
Joey Gouly <joey.gouly@arm.com>, Nico Boehr <nrb@linux.ibm.com>,
Nina Schoetterl-Glausch <oss@nina.schoetterlglausch.eu>,
Oliver Upton <oupton@kernel.org>,
Paolo Bonzini <pbonzini@redhat.com>,
Suzuki K Poulose <suzuki.poulose@arm.com>,
Sven Schnelle <svens@linux.ibm.com>,
Ulrich Weigand <Ulrich.Weigand@de.ibm.com>,
Vasily Gorbik <gor@linux.ibm.com>, Will Deacon <will@kernel.org>,
Zenghui Yu <yuzenghui@huawei.com>
Subject: Re: [PATCH v7 03/23] KVM: Allow KVM implementations to switch off MMIO independent of Kconfig
Date: Wed, 02 Sep 2026 09:30:17 +0100 [thread overview]
Message-ID: <87ik4om4x2.wl-maz@kernel.org> (raw)
In-Reply-To: <apdwHcdy2iYRTrww@google.com>
On Wed, 02 Sep 2026 01:38:53 +0100,
Sean Christopherson <seanjc@google.com> wrote:
>
> On Mon, Aug 31, 2026, Steffen Eiden wrote:
> > Only defining KVM_MMIO is not flexible enough for multi-KVM systems
> > where one KVM implements MMIO but others do not. Solve this by
> > additionally testing for the non-existence of KVM_NO_MMIO before
> > including MMIO code to KVM.
>
> Ewwwww. IIUC, s390 ends up with two KVM modules, i.e. there really are two different
> KVMs being built. Rather than have a KVM_MMIO and NO_KVM_MMIO, I vote very
> strongly to drop CONFIG_KVM_MMIO entirely and replace it with __KVM_HAVE_ARCH_MMIO,
> a la __KVM_HAVE_ARCH_VM_FREE and others. Tracking two separate macros is going
> to be annoying to maintain, and will definitely be confusing for non-s390 people.
>
> It'll mean linking in an emtpy coalesced_mmio.o on s390 when building without arm64
> support, but I'm guessing that won't be at all common for s390 builds.
>
I ended-up doing something very similar locally, because I couldn't
really make head or tail of the logic while being in holiday mode
(which doesn't help). However, I kept the negative logic, so that we
don't need to add anything to any architecture but S390 (they are the
odd one out here).
Untested hack follows.
M.
diff --git a/arch/arm64/kvm/Kconfig b/arch/arm64/kvm/Kconfig
index 449154f9a4852..dd138b730217e 100644
--- a/arch/arm64/kvm/Kconfig
+++ b/arch/arm64/kvm/Kconfig
@@ -22,7 +22,6 @@ menuconfig KVM
select KVM_COMMON
select KVM_GENERIC_HARDWARE_ENABLING
select HAVE_KVM_CPU_RELAX_INTERCEPT
- select KVM_MMIO
select KVM_GENERIC_DIRTYLOG_READ_PROTECT
select VIRT_XFER_TO_GUEST_WORK
select KVM_VFIO
diff --git a/arch/loongarch/kvm/Kconfig b/arch/loongarch/kvm/Kconfig
index 15da2d88c0c10..f03872ba0ba8c 100644
--- a/arch/loongarch/kvm/Kconfig
+++ b/arch/loongarch/kvm/Kconfig
@@ -28,7 +28,6 @@ config KVM
select KVM_COMMON
select KVM_GENERIC_DIRTYLOG_READ_PROTECT
select KVM_GENERIC_HARDWARE_ENABLING
- select KVM_MMIO
select VIRT_XFER_TO_GUEST_WORK
select SCHED_INFO
select GUEST_PERF_EVENTS if PERF_EVENTS
diff --git a/arch/mips/kvm/Kconfig b/arch/mips/kvm/Kconfig
index b1b9a1d677581..c65596fdf54f4 100644
--- a/arch/mips/kvm/Kconfig
+++ b/arch/mips/kvm/Kconfig
@@ -22,7 +22,6 @@ config KVM
select EXPORT_UASM
select KVM_COMMON
select KVM_GENERIC_DIRTYLOG_READ_PROTECT
- select KVM_MMIO
select KVM_GENERIC_HARDWARE_ENABLING
select HAVE_KVM_READONLY_MEM
help
diff --git a/arch/powerpc/kvm/Kconfig b/arch/powerpc/kvm/Kconfig
index b6bc2fc86dca6..c5565d6fb27e4 100644
--- a/arch/powerpc/kvm/Kconfig
+++ b/arch/powerpc/kvm/Kconfig
@@ -30,7 +30,6 @@ config KVM_BOOK3S_HANDLER
config KVM_BOOK3S_32_HANDLER
bool
select KVM_BOOK3S_HANDLER
- select KVM_MMIO
config KVM_BOOK3S_64_HANDLER
bool
@@ -38,7 +37,6 @@ config KVM_BOOK3S_64_HANDLER
config KVM_BOOK3S_PR_POSSIBLE
bool
- select KVM_MMIO
config KVM_BOOK3S_HV_POSSIBLE
bool
@@ -201,7 +199,6 @@ config KVM_E500V2
depends on PPC_E500 && !PPC_E500MC
depends on !CONTEXT_TRACKING_USER
select KVM
- select KVM_MMIO
help
Support running unmodified E500 guest kernels in virtual machines on
E500v2 host processors.
@@ -216,7 +213,6 @@ config KVM_E500MC
depends on PPC_E500MC
depends on !CONTEXT_TRACKING_USER
select KVM
- select KVM_MMIO
select KVM_BOOKE_HV
help
Support running unmodified E500MC/E5500/E6500 guest kernels in
diff --git a/arch/riscv/kvm/Kconfig b/arch/riscv/kvm/Kconfig
index ec2cee0a39e01..3aea8d4939d2e 100644
--- a/arch/riscv/kvm/Kconfig
+++ b/arch/riscv/kvm/Kconfig
@@ -28,7 +28,6 @@ config KVM
select KVM_COMMON
select KVM_GENERIC_DIRTYLOG_READ_PROTECT
select KVM_GENERIC_HARDWARE_ENABLING
- select KVM_MMIO
select VIRT_XFER_TO_GUEST_WORK
select SCHED_INFO
select GUEST_PERF_EVENTS if PERF_EVENTS
diff --git a/arch/s390/include/asm/kvm_host_s390.h b/arch/s390/include/asm/kvm_host_s390.h
index cd692f8fb7643..3c65c52d6682b 100644
--- a/arch/s390/include/asm/kvm_host_s390.h
+++ b/arch/s390/include/asm/kvm_host_s390.h
@@ -34,6 +34,8 @@
#define KVM_S390_MANAGES_S390_GUEST 1
+#define __KVM_NO_MMIO
+
/*
* These seem to be used for allocating ->chip in the routing table, which we
* don't use. 1 is as small as we can get to reduce the needed memory. If we
diff --git a/arch/x86/kvm/Kconfig b/arch/x86/kvm/Kconfig
index 538ed1e803326..48ca567b0a846 100644
--- a/arch/x86/kvm/Kconfig
+++ b/arch/x86/kvm/Kconfig
@@ -32,7 +32,6 @@ config KVM_X86
select VHOST_TASK
select KVM_ASYNC_PF
select USER_RETURN_NOTIFIER
- select KVM_MMIO
select SCHED_INFO
select PERF_EVENTS
select GUEST_PERF_EVENTS
diff --git a/include/linux/kvm_host.h b/include/linux/kvm_host.h
index 03bfc92864b6e..dc9b68793f0d7 100644
--- a/include/linux/kvm_host.h
+++ b/include/linux/kvm_host.h
@@ -833,7 +833,7 @@ struct kvm {
struct kvm_vm_stat stat;
struct kvm_arch arch;
refcount_t users_count;
-#ifdef CONFIG_KVM_MMIO
+#ifndef __KVM_NO_MMIO
struct kvm_coalesced_mmio_ring *coalesced_mmio_ring;
spinlock_t ring_lock;
struct list_head coalesced_zones;
diff --git a/virt/kvm/Kconfig b/virt/kvm/Kconfig
index c3c0ee253fc77..c012f30127e38 100644
--- a/virt/kvm/Kconfig
+++ b/virt/kvm/Kconfig
@@ -40,9 +40,6 @@ config NEED_KVM_DIRTY_RING_WITH_BITMAP
bool
depends on HAVE_KVM_DIRTY_RING
-config KVM_MMIO
- bool
-
config KVM_ASYNC_PF
bool
diff --git a/virt/kvm/Makefile.kvm b/virt/kvm/Makefile.kvm
index d047d4cf58c9f..c4fb1e01d0c89 100644
--- a/virt/kvm/Makefile.kvm
+++ b/virt/kvm/Makefile.kvm
@@ -5,9 +5,8 @@
KVM ?= ../../../virt/kvm
-kvm-y := $(KVM)/kvm_main.o $(KVM)/eventfd.o $(KVM)/binary_stats.o
+kvm-y := $(KVM)/kvm_main.o $(KVM)/eventfd.o $(KVM)/coalesced_mmio.o $(KVM)/binary_stats.o
kvm-$(CONFIG_KVM_VFIO) += $(KVM)/vfio.o
-kvm-$(CONFIG_KVM_MMIO) += $(KVM)/coalesced_mmio.o
kvm-$(CONFIG_KVM_ASYNC_PF) += $(KVM)/async_pf.o
kvm-$(CONFIG_HAVE_KVM_IRQ_ROUTING) += $(KVM)/irqchip.o
kvm-$(CONFIG_HAVE_KVM_DIRTY_RING) += $(KVM)/dirty_ring.o
diff --git a/virt/kvm/coalesced_mmio.c b/virt/kvm/coalesced_mmio.c
index 6b1d901610998..6bd4157b3ef41 100644
--- a/virt/kvm/coalesced_mmio.c
+++ b/virt/kvm/coalesced_mmio.c
@@ -15,6 +15,8 @@
#include <linux/slab.h>
#include <linux/kvm.h>
+#ifndef __KVM_NO_MMIO
+
#include "coalesced_mmio.h"
static inline struct kvm_coalesced_mmio_dev *to_mmio(struct kvm_io_device *dev)
@@ -188,3 +190,4 @@ int kvm_vm_ioctl_unregister_coalesced_mmio(struct kvm *kvm,
*/
return 0;
}
+#endif
diff --git a/virt/kvm/coalesced_mmio.h b/virt/kvm/coalesced_mmio.h
index 36f84264ed257..77b811dee27c2 100644
--- a/virt/kvm/coalesced_mmio.h
+++ b/virt/kvm/coalesced_mmio.h
@@ -11,7 +11,7 @@
*
*/
-#ifdef CONFIG_KVM_MMIO
+#ifndef __KVM_NO_MMIO
#include <linux/list.h>
diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c
index 65eb26a0520d8..2f25b75dbfd44 100644
--- a/virt/kvm/kvm_main.c
+++ b/virt/kvm/kvm_main.c
@@ -4059,7 +4059,7 @@ static vm_fault_t kvm_vcpu_fault(struct vm_fault *vmf)
else if (vmf->pgoff == KVM_PIO_PAGE_OFFSET)
page = virt_to_page(vcpu->arch.pio_data);
#endif
-#ifdef CONFIG_KVM_MMIO
+#ifndef __KVM_NO_MMIO
else if (vmf->pgoff == KVM_COALESCED_MMIO_PAGE_OFFSET)
page = virt_to_page(vcpu->kvm->coalesced_mmio_ring);
#endif
@@ -4900,7 +4900,7 @@ static int kvm_vm_ioctl_check_extension_generic(struct kvm *kvm, long arg)
case KVM_CAP_ENABLE_CAP_VM:
case KVM_CAP_HALT_POLL:
return 1;
-#ifdef CONFIG_KVM_MMIO
+#ifndef __KVM_NO_MMIO
case KVM_CAP_COALESCED_MMIO:
return KVM_COALESCED_MMIO_PAGE_OFFSET;
case KVM_CAP_COALESCED_PIO:
@@ -5241,7 +5241,7 @@ static long kvm_vm_ioctl(struct file *filp,
break;
}
#endif
-#ifdef CONFIG_KVM_MMIO
+#ifndef __KVM_NO_MMIO
case KVM_REGISTER_COALESCED_MMIO: {
struct kvm_coalesced_mmio_zone zone;
@@ -5563,7 +5563,7 @@ static long kvm_dev_ioctl(struct file *filp,
#ifdef CONFIG_X86
r += PAGE_SIZE; /* pio data page */
#endif
-#ifdef CONFIG_KVM_MMIO
+#ifndef __KVM_NO_MMIO
r += PAGE_SIZE; /* coalesced mmio ring page */
#endif
break;
--
Jazz isn't dead. It just smells funny.
next prev parent reply other threads:[~2026-09-02 8:28 UTC|newest]
Thread overview: 38+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-31 14:47 [PATCH v7 00/23] KVM: s390: Introduce arm64 KVM Steffen Eiden
2026-08-31 14:47 ` [PATCH v7 01/23] vfio: Use file-based reference counting for KVM Steffen Eiden
2026-08-31 14:47 ` [PATCH v7 02/23] KVM: Make device name configurable Steffen Eiden
2026-09-02 0:40 ` Sean Christopherson
2026-09-02 7:50 ` Steffen Eiden
2026-09-02 16:14 ` Sean Christopherson
2026-08-31 14:47 ` [PATCH v7 03/23] KVM: Allow KVM implementations to switch off MMIO independent of Kconfig Steffen Eiden
2026-09-02 0:38 ` Sean Christopherson
2026-09-02 8:22 ` Steffen Eiden
2026-09-02 8:30 ` Marc Zyngier [this message]
2026-09-02 9:13 ` Steffen Eiden
2026-09-02 13:00 ` Sean Christopherson
2026-09-02 15:50 ` Sean Christopherson
2026-08-31 14:47 ` [PATCH v7 04/23] arm64: Use proper include variant Steffen Eiden
2026-08-31 14:47 ` [PATCH v7 05/23] arm64: ptrace: Use constants for compat register numbers Steffen Eiden
2026-08-31 14:47 ` [PATCH v7 06/23] arm64: sysreg: Convert SPSR_ELx to automatic register generation Steffen Eiden
2026-08-31 14:47 ` [PATCH v7 07/23] KVM: arm64: Access elements of vcpu_gp_regs individually Steffen Eiden
2026-08-31 14:47 ` [PATCH v7 08/23] KVM: arm64: Use accessor functions for core regs Steffen Eiden
2026-08-31 14:47 ` [PATCH v7 09/23] arm64: Prepare sharing arm64 headers with s390 Steffen Eiden
2026-08-31 14:47 ` [PATCH v7 10/23] arm64: Share " Steffen Eiden
2026-08-31 14:47 ` [PATCH v7 11/23] KVM: arm64: Share arm64 code " Steffen Eiden
2026-09-01 8:13 ` Marc Zyngier
2026-09-01 8:40 ` Steffen Eiden
2026-09-02 7:41 ` Marc Zyngier
2026-09-02 12:41 ` Steffen Eiden
2026-08-31 14:47 ` [PATCH v7 12/23] s390/tools: Use arm64 headers Steffen Eiden
2026-08-31 14:47 ` [PATCH v7 13/23] KVM: s390: Use arm64 code Steffen Eiden
2026-08-31 14:47 ` [PATCH v7 14/23] KVM: s390: Prepare KVM/s390 for a second KVM module Steffen Eiden
2026-08-31 14:47 ` [PATCH v7 15/23] s390: Introduce Start Arm Execution instruction Steffen Eiden
2026-08-31 14:47 ` [PATCH v7 16/23] KVM: s390: arm64: Introduce host definitions Steffen Eiden
2026-08-31 14:47 ` [PATCH v7 17/23] s390/hwcaps: Report SAE support as hwcap Steffen Eiden
2026-08-31 14:47 ` [PATCH v7 18/23] KVM: s390: Add basic arm64 kvm module Steffen Eiden
2026-08-31 14:47 ` [PATCH v7 19/23] KVM: s390: arm64: Implement required functions Steffen Eiden
2026-08-31 14:47 ` [PATCH v7 20/23] KVM: s390: arm64: Implement vm/vcpu create destroy Steffen Eiden
2026-08-31 14:47 ` [PATCH v7 21/23] KVM: s390: arm64: Implement vCPU IOCTLs Steffen Eiden
2026-08-31 14:47 ` [PATCH v7 22/23] KVM: s390: arm64: Implement basic page fault handler Steffen Eiden
2026-08-31 14:48 ` [PATCH v7 23/23] KVM: s390: arm64: Add KVM_S390_ARM64 Kconfig and Makefile Steffen Eiden
2026-09-02 16:20 ` Sean Christopherson
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87ik4om4x2.wl-maz@kernel.org \
--to=maz@kernel.org \
--cc=Ulrich.Weigand@de.ibm.com \
--cc=agordeev@linux.ibm.com \
--cc=arnd@arndb.de \
--cc=borntraeger@linux.ibm.com \
--cc=brueckner@linux.ibm.com \
--cc=catalin.marinas@arm.com \
--cc=david@kernel.org \
--cc=frankja@linux.ibm.com \
--cc=fritz@linux.ibm.com \
--cc=ggala@linux.ibm.com \
--cc=gor@linux.ibm.com \
--cc=gra@linux.ibm.com \
--cc=hari55@linux.ibm.com \
--cc=hca@linux.ibm.com \
--cc=iii@linux.ibm.com \
--cc=imbrenda@linux.ibm.com \
--cc=joey.gouly@arm.com \
--cc=kvm@vger.kernel.org \
--cc=kvmarm@lists.linux.dev \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-s390@vger.kernel.org \
--cc=nrb@linux.ibm.com \
--cc=oss@nina.schoetterlglausch.eu \
--cc=oupton@kernel.org \
--cc=pbonzini@redhat.com \
--cc=seanjc@google.com \
--cc=seiden@linux.ibm.com \
--cc=suzuki.poulose@arm.com \
--cc=svens@linux.ibm.com \
--cc=tabba@google.com \
--cc=will@kernel.org \
--cc=yuzenghui@huawei.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox