kvm: rework memory prefault
PATCH 1/2 kvm: rework memory prefault
From: Arnd Bergmann <[email protected]>
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.
---
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(-)
arch/s390/include/asm/kvm_host_s390.h +4 -0
@@ -742,6 +742,10 @@ static inline void kvm_arch_vcpu_unblocking(struct kvm_vcpu *vcpu) {}#define __KVM_HAVE_ARCH_VM_FREEvoid 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);
arch/s390/kvm/s390/Kconfig +0 -1
@@ -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
arch/x86/include/asm/kvm_host.h +4 -0
@@ -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_ALLOCstatic inline struct kvm *kvm_arch_alloc_vm (void ) {
arch/x86/kvm/Kconfig +0 -1
@@ -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
include/linux/kvm_host.h +0 -5
@@ -2605,9 +2605,4 @@ long kvm_gmem_populate(struct kvm *kvm, gfn_t gfn, void __user *src, long npagesvoid 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
virt/kvm/Kconfig +0 -3
@@ -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)
virt/kvm/kvm_main.c +2 -2
@@ -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_MEMORYstatic 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_MEMORYcase KVM_PRE_FAULT_MEMORY : {struct kvm_pre_fault_memory range;
Signature · 1 line
2.39.5
PATCH 2/2 s390: kvm: arm64: add HAS_IOMEM dependency
From: Arnd Bergmann <[email protected]>
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.
---
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(+)
arch/s390/kvm/arm64/Kconfig +1 -0
@@ -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
Signature · 1 line
2.39.5
Steffen Eiden
reviewerRe: [PATCH 2/2] s390: kvm: arm64: add HAS_IOMEM dependency
Quoted 33 lines · Arnd Bergmann
From: Arnd Bergmann <[email protected]>
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: 'structkvm_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 <[email protected]>---
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(+)arch/s390/kvm/arm64/Kconfig +1
-0@@ -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_MANAGERSignature · 1 line
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
Re: [PATCH 2/2] s390: kvm: arm64: add HAS_IOMEM dependency
Quoted 5 lines · Steffen Eiden
I would squash this in v3 into the patch that creates this config:
KVM: s390: arm64: EnableKVM_ARM64config andKbuildif that is OK for you.
Yes, please do.
Arnd
Steffen Eiden
reviewerQuoted 6 lines · Arnd Bergmann
From: Arnd Bergmann <[email protected]>
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():
Quoted 8 lines
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
Kconfigsymbol.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.
Quoted 9 lines
Signed-off-by Arnd Bergmann <[email protected]>---
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