* [PATCH 1/2] kvm: rework memory prefault
@ 2026-05-26 12:52 Arnd Bergmann
2026-05-26 12:52 ` [PATCH 2/2] s390: kvm: arm64: add HAS_IOMEM dependency Arnd Bergmann
2026-05-26 17:05 ` [PATCH 1/2] kvm: rework memory prefault Steffen Eiden
0 siblings, 2 replies; 5+ messages in thread
From: Arnd Bergmann @ 2026-05-26 12:52 UTC (permalink / raw)
To: Steffen Eiden, Claudio Imbrenda, Christian Borntraeger,
Andreas Grapentin, Nina Schoetterl-Glausch
Cc: Janosch Frank, David Hildenbrand, kvm, Arnd Bergmann
From: Arnd Bergmann <arnd@arndb.de>
When both s390 and arm64 KVM modules are enabled on s390,
the latter fails to link against the s390 version of
kvm_arch_vcpu_pre_fault_memory():
ERROR: modpost: "kvm_arch_vcpu_pre_fault_memory" [arch/s390/kvm/arm64/kvm-arm64.ko] undefined!
Change the logic to reference this based on a target
specific macro rather than a global Kconfig symbol.
Fixes: f67bba50ef56 ("KVM: s390: arm64: Enable KVM_ARM64 config and Kbuild")
Fixes: 927ce4dee94f ("KVM: s390: Implement KVM_PRE_FAULT_MEMORY")
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
---
This is not yet an actual problem, but will be when both
the experimental 'sae' branch and the 7.2 contents from
current linux-next are merged.
Not sure who should carry this patch in the meantime, but
it would be possible to add it to kvm-next already in
preparation for the upcoming sae support.
---
arch/s390/include/asm/kvm_host_s390.h | 4 ++++
arch/s390/kvm/s390/Kconfig | 1 -
arch/x86/include/asm/kvm_host.h | 4 ++++
arch/x86/kvm/Kconfig | 1 -
include/linux/kvm_host.h | 5 -----
virt/kvm/Kconfig | 3 ---
virt/kvm/kvm_main.c | 4 ++--
7 files changed, 10 insertions(+), 12 deletions(-)
diff --git a/arch/s390/include/asm/kvm_host_s390.h b/arch/s390/include/asm/kvm_host_s390.h
index d4bf6d0df49f..9532dc680c5a 100644
--- a/arch/s390/include/asm/kvm_host_s390.h
+++ b/arch/s390/include/asm/kvm_host_s390.h
@@ -742,6 +742,10 @@ static inline void kvm_arch_vcpu_unblocking(struct kvm_vcpu *vcpu) {}
#define __KVM_HAVE_ARCH_VM_FREE
void kvm_arch_free_vm(struct kvm *kvm);
+#define __KVM_HAVE_ARCH_PRE_FAULT_MEMORY
+long kvm_arch_vcpu_pre_fault_memory(struct kvm_vcpu *vcpu,
+ struct kvm_pre_fault_memory *range);
+
struct zpci_kvm_hook {
int (*kvm_register)(void *opaque, struct kvm *kvm);
void (*kvm_unregister)(void *opaque);
diff --git a/arch/s390/kvm/s390/Kconfig b/arch/s390/kvm/s390/Kconfig
index 5777663e44b9..263ff29b9c9c 100644
--- a/arch/s390/kvm/s390/Kconfig
+++ b/arch/s390/kvm/s390/Kconfig
@@ -18,7 +18,6 @@ config KVM_S390
select KVM_VFIO
select VIRT_XFER_TO_GUEST_WORK
select KVM_MMU_LOCKLESS_AGING
- select KVM_GENERIC_PRE_FAULT_MEMORY
help
Support hosting paravirtualized s390 guest machines using the SIE
virtualization capability on the mainframe. This should work
diff --git a/arch/x86/include/asm/kvm_host.h b/arch/x86/include/asm/kvm_host.h
index 809b285161d9..dfb8d7e67db9 100644
--- a/arch/x86/include/asm/kvm_host.h
+++ b/arch/x86/include/asm/kvm_host.h
@@ -2077,6 +2077,10 @@ extern struct kvm_x86_ops kvm_x86_ops;
int kvm_x86_vendor_init(struct kvm_x86_init_ops *ops);
void kvm_x86_vendor_exit(void);
+#define __KVM_HAVE_ARCH_PRE_FAULT_MEMORY
+long kvm_arch_vcpu_pre_fault_memory(struct kvm_vcpu *vcpu,
+ struct kvm_pre_fault_memory *range);
+
#define __KVM_HAVE_ARCH_VM_ALLOC
static inline struct kvm *kvm_arch_alloc_vm(void)
{
diff --git a/arch/x86/kvm/Kconfig b/arch/x86/kvm/Kconfig
index a6824b6fbf10..1856dc502b07 100644
--- a/arch/x86/kvm/Kconfig
+++ b/arch/x86/kvm/Kconfig
@@ -45,7 +45,6 @@ config KVM_X86
select KVM_VFIO
select HAVE_KVM_PM_NOTIFIER if PM
select KVM_GENERIC_HARDWARE_ENABLING
- select KVM_GENERIC_PRE_FAULT_MEMORY
select KVM_WERROR if WERROR
select KVM_GUEST_MEMFD if X86_64
diff --git a/include/linux/kvm_host.h b/include/linux/kvm_host.h
index 690e34587414..70a1174df996 100644
--- a/include/linux/kvm_host.h
+++ b/include/linux/kvm_host.h
@@ -2605,9 +2605,4 @@ long kvm_gmem_populate(struct kvm *kvm, gfn_t gfn, void __user *src, long npages
void kvm_arch_gmem_invalidate(kvm_pfn_t start, kvm_pfn_t end);
#endif
-#ifdef CONFIG_KVM_GENERIC_PRE_FAULT_MEMORY
-long kvm_arch_vcpu_pre_fault_memory(struct kvm_vcpu *vcpu,
- struct kvm_pre_fault_memory *range);
-#endif
-
#endif
diff --git a/virt/kvm/Kconfig b/virt/kvm/Kconfig
index c4a983e41765..fefdf5d44646 100644
--- a/virt/kvm/Kconfig
+++ b/virt/kvm/Kconfig
@@ -65,9 +65,6 @@ config HAVE_KVM_INVALID_WAKEUPS
config KVM_GENERIC_DIRTYLOG_READ_PROTECT
bool
-config KVM_GENERIC_PRE_FAULT_MEMORY
- bool
-
config KVM_COMPAT
def_bool y
depends on KVM && COMPAT && !(S390 || ARM64 || RISCV)
diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c
index 0d36e4d264f5..10f0748ad077 100644
--- a/virt/kvm/kvm_main.c
+++ b/virt/kvm/kvm_main.c
@@ -4309,7 +4309,7 @@ static int kvm_vcpu_ioctl_get_stats_fd(struct kvm_vcpu *vcpu)
return fd;
}
-#ifdef CONFIG_KVM_GENERIC_PRE_FAULT_MEMORY
+#ifdef __KVM_HAVE_ARCH_PRE_FAULT_MEMORY
static int kvm_vcpu_pre_fault_memory(struct kvm_vcpu *vcpu,
struct kvm_pre_fault_memory *range)
{
@@ -4608,7 +4608,7 @@ static long kvm_vcpu_ioctl(struct file *filp,
r = kvm_vcpu_ioctl_get_stats_fd(vcpu);
break;
}
-#ifdef CONFIG_KVM_GENERIC_PRE_FAULT_MEMORY
+#ifdef __KVM_HAVE_ARCH_PRE_FAULT_MEMORY
case KVM_PRE_FAULT_MEMORY: {
struct kvm_pre_fault_memory range;
--
2.39.5
^ permalink raw reply related [flat|nested] 5+ messages in thread* [PATCH 2/2] s390: kvm: arm64: add HAS_IOMEM dependency
2026-05-26 12:52 [PATCH 1/2] kvm: rework memory prefault Arnd Bergmann
@ 2026-05-26 12:52 ` Arnd Bergmann
2026-05-26 17:08 ` Steffen Eiden
2026-05-26 17:05 ` [PATCH 1/2] kvm: rework memory prefault Steffen Eiden
1 sibling, 1 reply; 5+ messages in thread
From: Arnd Bergmann @ 2026-05-26 12:52 UTC (permalink / raw)
To: Steffen Eiden, Claudio Imbrenda, Christian Borntraeger,
Andreas Grapentin, Nina Schoetterl-Glausch
Cc: Janosch Frank, David Hildenbrand, kvm, Arnd Bergmann
From: Arnd Bergmann <arnd@arndb.de>
The arm64 kvm driver can only be enabled when MMIO support is part of
the host kernel:
arch/s390/kvm/arm64/../../../../virt/kvm/arm64/mmio.c:120:27: error: 'struct kvm_vcpu' has no member named 'mmio_needed'
s390 does not support MMIO if PCI is disabled, but in practice one
would not actually need kvm support in those configurations either.
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
---
This is currently needed for randconfig build testing the
'sae' branch, it is not yet in linux-next
---
arch/s390/kvm/arm64/Kconfig | 1 +
1 file changed, 1 insertion(+)
diff --git a/arch/s390/kvm/arm64/Kconfig b/arch/s390/kvm/arm64/Kconfig
index 42a1be50f6e1..65b9dc25fe62 100644
--- a/arch/s390/kvm/arm64/Kconfig
+++ b/arch/s390/kvm/arm64/Kconfig
@@ -3,6 +3,7 @@
config KVM_ARM64
def_tristate y
prompt "Kernel-based Virtual Machine (KVM) support for arm64 guests"
+ depends on HAS_IOMEM
select KVM
select KVM_VFIO
select IRQ_BYPASS_MANAGER
--
2.39.5
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH 2/2] s390: kvm: arm64: add HAS_IOMEM dependency
2026-05-26 12:52 ` [PATCH 2/2] s390: kvm: arm64: add HAS_IOMEM dependency Arnd Bergmann
@ 2026-05-26 17:08 ` Steffen Eiden
2026-05-26 21:20 ` Arnd Bergmann
0 siblings, 1 reply; 5+ messages in thread
From: Steffen Eiden @ 2026-05-26 17:08 UTC (permalink / raw)
To: Arnd Bergmann
Cc: Claudio Imbrenda, Christian Borntraeger, Andreas Grapentin,
Nina Schoetterl-Glausch, Janosch Frank, David Hildenbrand, kvm,
Arnd Bergmann
On Tue, May 26, 2026 at 02:52:20PM +0200, Arnd Bergmann wrote:
> From: Arnd Bergmann <arnd@arndb.de>
>
> The arm64 kvm driver can only be enabled when MMIO support is part of
> the host kernel:
>
> arch/s390/kvm/arm64/../../../../virt/kvm/arm64/mmio.c:120:27: error: 'struct kvm_vcpu' has no member named 'mmio_needed'
>
> s390 does not support MMIO if PCI is disabled, but in practice one
> would not actually need kvm support in those configurations either.
>
> Signed-off-by: Arnd Bergmann <arnd@arndb.de>
> ---
> This is currently needed for randconfig build testing the
> 'sae' branch, it is not yet in linux-next
> ---
> arch/s390/kvm/arm64/Kconfig | 1 +
> 1 file changed, 1 insertion(+)
>
> diff --git a/arch/s390/kvm/arm64/Kconfig b/arch/s390/kvm/arm64/Kconfig
> index 42a1be50f6e1..65b9dc25fe62 100644
> --- a/arch/s390/kvm/arm64/Kconfig
> +++ b/arch/s390/kvm/arm64/Kconfig
> @@ -3,6 +3,7 @@
> config KVM_ARM64
> def_tristate y
> prompt "Kernel-based Virtual Machine (KVM) support for arm64 guests"
> + depends on HAS_IOMEM
> select KVM
> select KVM_VFIO
> select IRQ_BYPASS_MANAGER
> --
> 2.39.5
>
Thank you,
I would squash this in v3 into the patch that creates this config:
KVM: s390: arm64: Enable KVM_ARM64 config and Kbuild
if that is OK for you.
Steffen
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH 2/2] s390: kvm: arm64: add HAS_IOMEM dependency
2026-05-26 17:08 ` Steffen Eiden
@ 2026-05-26 21:20 ` Arnd Bergmann
0 siblings, 0 replies; 5+ messages in thread
From: Arnd Bergmann @ 2026-05-26 21:20 UTC (permalink / raw)
To: Steffen Eiden, Arnd Bergmann
Cc: Claudio Imbrenda, Christian Borntraeger, Andreas Grapentin,
Nina Schoetterl-Glausch, Janosch Frank,
David Hildenbrand (Red Hat), kvm
On Tue, May 26, 2026, at 19:08, Steffen Eiden wrote:
>
> I would squash this in v3 into the patch that creates this config:
> KVM: s390: arm64: Enable KVM_ARM64 config and Kbuild
>
> if that is OK for you.
Yes, please do.
Arnd
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH 1/2] kvm: rework memory prefault
2026-05-26 12:52 [PATCH 1/2] kvm: rework memory prefault Arnd Bergmann
2026-05-26 12:52 ` [PATCH 2/2] s390: kvm: arm64: add HAS_IOMEM dependency Arnd Bergmann
@ 2026-05-26 17:05 ` Steffen Eiden
1 sibling, 0 replies; 5+ messages in thread
From: Steffen Eiden @ 2026-05-26 17:05 UTC (permalink / raw)
To: Arnd Bergmann
Cc: Claudio Imbrenda, Christian Borntraeger, Andreas Grapentin,
Nina Schoetterl-Glausch, Janosch Frank, David Hildenbrand, kvm,
Arnd Bergmann
On Tue, May 26, 2026 at 02:52:19PM +0200, Arnd Bergmann wrote:
> From: Arnd Bergmann <arnd@arndb.de>
>
> When both s390 and arm64 KVM modules are enabled on s390,
> the latter fails to link against the s390 version of
> kvm_arch_vcpu_pre_fault_memory():
>
> ERROR: modpost: "kvm_arch_vcpu_pre_fault_memory" [arch/s390/kvm/arm64/kvm-arm64.ko] undefined!
>
> Change the logic to reference this based on a target
> specific macro rather than a global Kconfig symbol.
>
> Fixes: f67bba50ef56 ("KVM: s390: arm64: Enable KVM_ARM64 config and Kbuild")
> Fixes: 927ce4dee94f ("KVM: s390: Implement KVM_PRE_FAULT_MEMORY")
>
Thanks for looking into this.
An alternative solution could be for the kvm-arm64 module to just implement the
function as well. The s390 implementation is purely gmap based and has no
dependencies to s390-kvm beside that. arm on s390 kvm could use the exact same
implementation as well.
I guess this is probably dead code as (I assume) qemu-aarch64 does not use the feature.
But I saw some proposals regarding this feature for KVM/arm64 on the list.
> Signed-off-by: Arnd Bergmann <arnd@arndb.de>
> ---
> This is not yet an actual problem, but will be when both
> the experimental 'sae' branch and the 7.2 contents from
> current linux-next are merged.
>
> Not sure who should carry this patch in the meantime, but
> it would be possible to add it to kvm-next already in
> preparation for the upcoming sae support.
I would prefer if you put it in next now. Less patches to carry around.
But If that is not feasible I can add it to series 1 once Claudios patches are
in 7.2.
Steffen
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2026-05-26 21:21 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-05-26 12:52 [PATCH 1/2] kvm: rework memory prefault Arnd Bergmann
2026-05-26 12:52 ` [PATCH 2/2] s390: kvm: arm64: add HAS_IOMEM dependency Arnd Bergmann
2026-05-26 17:08 ` Steffen Eiden
2026-05-26 21:20 ` Arnd Bergmann
2026-05-26 17:05 ` [PATCH 1/2] kvm: rework memory prefault Steffen Eiden
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.