From: Arnd Bergmann <arnd@kernel.org>
To: Steffen Eiden <seiden@linux.ibm.com>,
Claudio Imbrenda <imbrenda@linux.ibm.com>,
Christian Borntraeger <borntraeger@linux.ibm.com>,
Andreas Grapentin <gra@linux.ibm.com>,
Nina Schoetterl-Glausch <nsg@linux.ibm.com>
Cc: Janosch Frank <frankja@linux.ibm.com>,
David Hildenbrand <david@kernel.org>,
kvm@vger.kernel.org, Arnd Bergmann <arnd@arndb.de>
Subject: [PATCH 1/2] kvm: rework memory prefault
Date: Tue, 26 May 2026 14:52:19 +0200 [thread overview]
Message-ID: <20260526125220.1560451-1-arnd@kernel.org> (raw)
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
next reply other threads:[~2026-05-26 12:52 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-05-26 12:52 Arnd Bergmann [this message]
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
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=20260526125220.1560451-1-arnd@kernel.org \
--to=arnd@kernel.org \
--cc=arnd@arndb.de \
--cc=borntraeger@linux.ibm.com \
--cc=david@kernel.org \
--cc=frankja@linux.ibm.com \
--cc=gra@linux.ibm.com \
--cc=imbrenda@linux.ibm.com \
--cc=kvm@vger.kernel.org \
--cc=nsg@linux.ibm.com \
--cc=seiden@linux.ibm.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