KVM: s390: pci: Hook to access KVM lowlevel from VFIO
Subsystems (6)
PATCH 1/1 KVM: s390: pci: Hook to access KVM lowlevel from VFIO
We have a cross dependency between KVM and VFIO when using s390 vfio_pci_zdev extensions for PCI passthrough
To be able to keep both subsystem modular we add a registering hook inside the S390 core code.
This fixes a build problem when VFIO is built-in and KVM is built as a module.
--- arch/s390/include/asm/kvm_host.h | 17 ++++++----------- arch/s390/kvm/pci.c | 10 ++++++---- arch/s390/pci/Makefile | 2 ++ arch/s390/pci/pci_kvm_hook.c | 11 +++++++++++ drivers/vfio/pci/vfio_pci_zdev.c | 8 ++++++-- 5 files changed, 31 insertions(+), 17 deletions(-) create mode 100644 arch/s390/pci/pci_kvm_hook.c
arch/s390/include/asm/kvm_host.h +6 -11
@@ -1038,16 +1038,11 @@ static inline void kvm_arch_vcpu_unblocking(struct kvm_vcpu *vcpu) {}#define __KVM_HAVE_ARCH_VM_FREEvoid kvm_arch_free_vm (struct kvm *kvm); -#ifdef CONFIG_VFIO_PCI_ZDEV_KVM -int kvm_s390_pci_register_kvm (struct zpci_dev *zdev,struct kvm *kvm); -void kvm_s390_pci_unregister_kvm (struct zpci_dev *zdev); -#else -static inline int kvm_s390_pci_register_kvm (struct zpci_dev *dev, -struct kvm *kvm) -{ -return -EPERM ; -} -static inline void kvm_s390_pci_unregister_kvm (struct zpci_dev *dev) {} -#endif +struct zpci_kvm_hook { +int (*kvm_register)(void *opaque,struct kvm *kvm); +void (*kvm_unregister)(void *opaque); +}; + +extern struct zpci_kvm_hook zpci_kvm_hook;#endif
arch/s390/kvm/pci.c +6 -4
@@ -431,8 +431,9 @@ static void kvm_s390_pci_dev_release(struct zpci_dev *zdev)* available, enable them and let userspace indicate whether or not they will * be used (specify SHM bit to disable). */ -int kvm_s390_pci_register_kvm (struct zpci_dev *zdev,struct kvm *kvm) +static int kvm_s390_pci_register_kvm (void *opaque,struct kvm *kvm) { +struct zpci_dev *zdev = opaque;int rc;if (!zdev)
@@ -510,10 +511,10 @@ int kvm_s390_pci_register_kvm(struct zpci_dev *zdev, struct kvm *kvm)kvm_put_kvm (kvm);return rc; } -EXPORT_SYMBOL_GPL (kvm_s390_pci_register_kvm); -void kvm_s390_pci_unregister_kvm (struct zpci_dev *zdev) +static void kvm_s390_pci_unregister_kvm (void *opaque) { +struct zpci_dev *zdev = opaque;struct kvm *kvm;if (!zdev)
@@ -566,7 +567,6 @@ void kvm_s390_pci_unregister_kvm(struct zpci_dev *zdev)kvm_put_kvm (kvm); } -EXPORT_SYMBOL_GPL (kvm_s390_pci_unregister_kvm);void kvm_s390_pci_init_list (struct kvm *kvm) {
@@ -678,6 +678,8 @@ int kvm_s390_pci_init(void)spin_lock_init (&aift->gait_lock);mutex_init (&aift->aift_lock); + zpci_kvm_hook.kvm_register = kvm_s390_pci_register_kvm; + zpci_kvm_hook.kvm_unregister = kvm_s390_pci_unregister_kvm;return 0 ; }
arch/s390/pci/Makefile +2 -0
@@ -7,3 +7,5 @@ obj-$(CONFIG_PCI) += pci.o pci_irq.o pci_dma.o pci_clp.o pci_sysfs.o \ pci_event.o pci_debug.o pci_insn.o pci_mmio.o \ pci_bus.o obj-$(CONFIG_PCI_IOV) += pci_iov.o + +obj-y += pci_kvm_hook.o
arch/s390/pci/pci_kvm_hook.c new file +11 -0
@@ -0,0 +1,11 @@ +// SPDX-License-Identifier: GPL-2.0-only +/* +* VFIO ZPCI devices support +* +* Copyright (C) IBM Corp. 2022. All rights reserved. +* Author(s): Pierre Morel <[email protected]> +*/ +#include <linux/kvm_host.h> + +struct zpci_kvm_hook zpci_kvm_hook; +EXPORT_SYMBOL_GPL (zpci_kvm_hook);
drivers/vfio/pci/vfio_pci_zdev.c +6 -2
@@ -151,7 +151,10 @@ int vfio_pci_zdev_open_device(struct vfio_pci_core_device *vdev)if (!vdev->vdev.kvm)return 0 ; -return kvm_s390_pci_register_kvm (zdev, vdev->vdev.kvm); +if (zpci_kvm_hook.kvm_register) +return zpci_kvm_hook.kvm_register (zdev, vdev->vdev.kvm); + +return -ENOENT ; }void vfio_pci_zdev_close_device (struct vfio_pci_core_device *vdev)
@@ -161,5 +164,6 @@ void vfio_pci_zdev_close_device(struct vfio_pci_core_device *vdev)if (!zdev || !vdev->vdev.kvm)return ; -kvm_s390_pci_unregister_kvm (zdev); +if (zpci_kvm_hook.kvm_unregister) + zpci_kvm_hook.kvm_unregister (zdev); }
Signature · 1 line
2.31.1
Quoted 86 lines · Pierre Morel
We have a cross dependency between KVM and VFIO when using s390
vfio_pci_zdevextensions for PCI passthrough
To be able to keep both subsystem modular we add a registering hook inside the S390 core code.This fixes a build problem when VFIO is built-in and KVM is built as a module.
Reported-by Randy Dunlap <[email protected]>Reported-by kernel test robot <[email protected]>Signed-off-by Pierre Morel <[email protected]>Fixes 09340b2fca007 ("KVM: s390: pci: add routines to start/stop inter..")Cc <[email protected]>--- arch/s390/include/asm/kvm_host.h | 17 ++++++----------- arch/s390/kvm/pci.c | 10 ++++++---- arch/s390/pci/Makefile | 2 ++ arch/s390/pci/pci_kvm_hook.c | 11 +++++++++++ drivers/vfio/pci/vfio_pci_zdev.c | 8 ++++++-- 5 files changed, 31 insertions(+), 17 deletions(-) create mode 100644 arch/s390/pci/pci_kvm_hook.carch/s390/include/asm/kvm_host.h +6
-11@@ -1038,16 +1038,11 @@ static inline void kvm_arch_vcpu_unblocking(struct kvm_vcpu *vcpu) {}#define __KVM_HAVE_ARCH_VM_FREEvoid kvm_arch_free_vm (struct kvm *kvm); -#ifdef CONFIG_VFIO_PCI_ZDEV_KVM -int kvm_s390_pci_register_kvm (struct zpci_dev *zdev,struct kvm *kvm); -void kvm_s390_pci_unregister_kvm (struct zpci_dev *zdev); -#else -static inline int kvm_s390_pci_register_kvm (struct zpci_dev *dev, -struct kvm *kvm) -{ -return -EPERM ; -} -static inline void kvm_s390_pci_unregister_kvm (struct zpci_dev *dev) {} -#endif +struct zpci_kvm_hook { +int (*kvm_register)(void *opaque,struct kvm *kvm); +void (*kvm_unregister)(void *opaque); +}; + +extern struct zpci_kvm_hook zpci_kvm_hook;#endif arch/s390/kvm/pci.c +4
-4@@ -431,8 +431,9 @@ static void kvm_s390_pci_dev_release(struct zpci_dev *zdev)* available, enable them and let userspace indicate whether or not they will * be used (specify SHM bit to disable). */ -int kvm_s390_pci_register_kvm (struct zpci_dev *zdev,struct kvm *kvm) +static int kvm_s390_pci_register_kvm (void *opaque,struct kvm *kvm) { +struct zpci_dev *zdev = opaque;int rc;if (!zdev)@@ -510,10 +511,10 @@ int kvm_s390_pci_register_kvm(struct zpci_dev *zdev, struct kvm *kvm)kvm_put_kvm (kvm);return rc; } -EXPORT_SYMBOL_GPL (kvm_s390_pci_register_kvm); -void kvm_s390_pci_unregister_kvm (struct zpci_dev *zdev) +static void kvm_s390_pci_unregister_kvm (void *opaque) { +struct zpci_dev *zdev = opaque;struct kvm *kvm;if (!zdev)@@ -566,7 +567,6 @@ void kvm_s390_pci_unregister_kvm(struct zpci_dev *zdev)kvm_put_kvm (kvm); } -EXPORT_SYMBOL_GPL (kvm_s390_pci_unregister_kvm);void kvm_s390_pci_init_list (struct kvm *kvm) {
arch/s390/kvm/pci.c int kvm_s390_pci_init(void) · line 685
Quoted 8 lines
arch/s390/kvm/pci.c +2
-0@@ -678,6 +678,8 @@ int kvm_s390_pci_init(void)spin_lock_init (&aift->gait_lock);mutex_init (&aift->aift_lock); + zpci_kvm_hook.kvm_register = kvm_s390_pci_register_kvm; + zpci_kvm_hook.kvm_unregister = kvm_s390_pci_unregister_kvm;return 0 ; }
You should also set these to NULL in kvm_s390_pci_exit (which is called from kvm_arch_exit). In practice, the kvm module would need to be loaded again before we have a nonzero vdev->vdev.kvm so it should never be an issue - but we should clean up anyway when the module is removed.
With that change:
Quoted 51 lines
arch/s390/pci/Makefile +2
-0@@ -7,3 +7,5 @@ obj-$(CONFIG_PCI) += pci.o pci_irq.o pci_dma.o pci_clp.o pci_sysfs.o \ pci_event.o pci_debug.o pci_insn.o pci_mmio.o \ pci_bus.o obj-$(CONFIG_PCI_IOV) += pci_iov.o + +obj-y += pci_kvm_hook.oarch/s390/pci/pci_kvm_hook.c new file +11
-0@@ -0,0 +1,11 @@ +// SPDX-License-Identifier: GPL-2.0-only +/* +* VFIO ZPCI devices support +* +* Copyright (C) IBM Corp. 2022. All rights reserved. +* Author(s): Pierre Morel <[email protected]> +*/ +#include <linux/kvm_host.h> + +struct zpci_kvm_hook zpci_kvm_hook; +EXPORT_SYMBOL_GPL (zpci_kvm_hook);drivers/vfio/pci/vfio_pci_zdev.c +6
-2@@ -151,7 +151,10 @@ int vfio_pci_zdev_open_device(struct vfio_pci_core_device *vdev)if (!vdev->vdev.kvm)return 0 ; -return kvm_s390_pci_register_kvm (zdev, vdev->vdev.kvm); +if (zpci_kvm_hook.kvm_register) +return zpci_kvm_hook.kvm_register (zdev, vdev->vdev.kvm); + +return -ENOENT ; }void vfio_pci_zdev_close_device (struct vfio_pci_core_device *vdev)@@ -161,5 +164,6 @@ void vfio_pci_zdev_close_device(struct vfio_pci_core_device *vdev)if (!zdev || !vdev->vdev.kvm)return ; -kvm_s390_pci_unregister_kvm (zdev); +if (zpci_kvm_hook.kvm_unregister) + zpci_kvm_hook.kvm_unregister (zdev); }
Quoted 93 lines · Matthew Rosato
Quoted 92 lines · Pierre Morel
We have a cross dependency between KVM and VFIO when using s390
vfio_pci_zdevextensions for PCI passthrough
To be able to keep both subsystem modular we add a registering hook inside the S390 core code.This fixes a build problem when VFIO is built-in and KVM is built as a module.
Reported-by Randy Dunlap <[email protected]>Reported-by kernel test robot <[email protected]>Signed-off-by Pierre Morel <[email protected]>Fixes 09340b2fca007 ("KVM: s390: pci: add routines to start/stop inter..")Cc <[email protected]>--- arch/s390/include/asm/kvm_host.h | 17 ++++++----------- arch/s390/kvm/pci.c | 10 ++++++---- arch/s390/pci/Makefile | 2 ++ arch/s390/pci/pci_kvm_hook.c | 11 +++++++++++ drivers/vfio/pci/vfio_pci_zdev.c | 8 ++++++-- 5 files changed, 31 insertions(+), 17 deletions(-)create mode 100644
arch/s390/pci/pci_kvm_hook.carch/s390/include/asm/kvm_host.h +6
-11@@ -1038,16 +1038,11 @@ static inline void kvm_arch_vcpu_unblocking(struct kvm_vcpu *vcpu) {}#define __KVM_HAVE_ARCH_VM_FREEvoid kvm_arch_free_vm (struct kvm *kvm); -#ifdef CONFIG_VFIO_PCI_ZDEV_KVM -int kvm_s390_pci_register_kvm (struct zpci_dev *zdev,struct kvm *kvm); -void kvm_s390_pci_unregister_kvm (struct zpci_dev *zdev); -#else -static inline int kvm_s390_pci_register_kvm (struct zpci_dev *dev, -struct kvm *kvm) -{ -return -EPERM ; -} -static inline void kvm_s390_pci_unregister_kvm (struct zpci_dev *dev) {} -#endif +struct zpci_kvm_hook { +int (*kvm_register)(void *opaque,struct kvm *kvm); +void (*kvm_unregister)(void *opaque); +}; + +extern struct zpci_kvm_hook zpci_kvm_hook;#endif arch/s390/kvm/pci.c +6
-4@@ -431,8 +431,9 @@ static void kvm_s390_pci_dev_release(struct zpci_dev *zdev)* available, enable them and let userspace indicate whether or not they will * be used (specify SHM bit to disable). */ -int kvm_s390_pci_register_kvm (struct zpci_dev *zdev,struct kvm *kvm) +static int kvm_s390_pci_register_kvm (void *opaque,struct kvm *kvm) { +struct zpci_dev *zdev = opaque;int rc;if (!zdev)@@ -510,10 +511,10 @@ int kvm_s390_pci_register_kvm(struct zpci_dev *zdev, struct kvm *kvm)kvm_put_kvm (kvm);return rc; } -EXPORT_SYMBOL_GPL (kvm_s390_pci_register_kvm); -void kvm_s390_pci_unregister_kvm (struct zpci_dev *zdev) +static void kvm_s390_pci_unregister_kvm (void *opaque) { +struct zpci_dev *zdev = opaque;struct kvm *kvm;if (!zdev)@@ -566,7 +567,6 @@ void kvm_s390_pci_unregister_kvm(struct zpci_dev *zdev)kvm_put_kvm (kvm); } -EXPORT_SYMBOL_GPL (kvm_s390_pci_unregister_kvm);void kvm_s390_pci_init_list (struct kvm *kvm) {@@ -678,6 +678,8 @@ int kvm_s390_pci_init(void)spin_lock_init (&aift->gait_lock);mutex_init (&aift->aift_lock); + zpci_kvm_hook.kvm_register = kvm_s390_pci_register_kvm; + zpci_kvm_hook.kvm_unregister = kvm_s390_pci_unregister_kvm;
Quoted 9 lines
arch/s390/kvm/pci.c int kvm_s390_pci_init(void) · line 685
Quoted 2 lines
arch/s390/kvm/pci.c +0
-0return 0 ; }You should also set these to NULL in
kvm_s390_pci_exit(which is called fromkvm_arch_exit). In practice, the kvm module would need to be loaded again before we have a nonzerovdev->vdev.kvmso it should never be an issue - but we should clean up anyway when the module is removed.With that change:
Reviewed-by Matthew Rosato <[email protected]>
Yes indeed, will do.
Thanks
Pierre
Signature · 2 lines
Pierre Morel IBM Lab Boeblingen
Niklas Schnelle
maintainerQuoted 5 lines · Pierre Morel
We have a cross dependency between KVM and VFIO when using s390
vfio_pci_zdevextensions for PCI passthrough
To be able to keep both subsystem modular we add a registering hook inside the S390 core code.
Quoted 7 lines
This fixes a build problem when VFIO is built-in and KVM is built as a module.
Reported-by Randy Dunlap <[email protected]>Reported-by kernel test robot <[email protected]>Signed-off-by Pierre Morel <[email protected]>Fixes 09340b2fca007 ("KVM: s390: pci: add routines to start/stop inter..")
Please don't shorten the Fixes tag, the subject line is likely also checked by some automated tools. It's okay for this line to be over the column limit and checkpatch.pl --strict also accepts it.
Quoted 11 lines
Cc <[email protected]>--- arch/s390/include/asm/kvm_host.h | 17 ++++++----------- arch/s390/kvm/pci.c | 10 ++++++---- arch/s390/pci/Makefile | 2 ++ arch/s390/pci/pci_kvm_hook.c | 11 +++++++++++ drivers/vfio/pci/vfio_pci_zdev.c | 8 ++++++-- 5 files changed, 31 insertions(+), 17 deletions(-) create mode 100644 arch/s390/pci/pci_kvm_hook.c
---8<---
Quoted 21 lines
arch/s390/kvm/pci.c +2
-1kvm_put_kvm (kvm); } -EXPORT_SYMBOL_GPL (kvm_s390_pci_unregister_kvm);void kvm_s390_pci_init_list (struct kvm *kvm) {@@ -678,6 +678,8 @@ int kvm_s390_pci_init(void)spin_lock_init (&aift->gait_lock);mutex_init (&aift->aift_lock); + zpci_kvm_hook.kvm_register = kvm_s390_pci_register_kvm; + zpci_kvm_hook.kvm_unregister = kvm_s390_pci_unregister_kvm;return 0 ; }arch/s390/pci/Makefile +0
-0
arch/s390/pci/Makefile obj-$(CONFIG_PCI) += pci.o pci_irq.o pci_dma.o pci_clp.o pci_sysfs.o \ · line 11
Quoted 5 lines
arch/s390/pci/Makefile +2
-0@@ -7,3 +7,5 @@ obj-$(CONFIG_PCI) += pci.o pci_irq.o pci_dma.o pci_clp.o pci_sysfs.o \ pci_event.o pci_debug.o pci_insn.o pci_mmio.o \ pci_bus.o obj-$(CONFIG_PCI_IOV) += pci_iov.o + +obj-y += pci_kvm_hook.o
I thought we wanted to compile this only for CONFIG_PCI?
arch/s390/pci/pci_kvm_hook.c
Quoted 3 lines
arch/s390/pci/pci_kvm_hook.c new file +0
-0
---8<---
Quoted 9 lines · Niklas Schnelle
Quoted 8 lines · Pierre Morel
We have a cross dependency between KVM and VFIO when using s390
vfio_pci_zdevextensions for PCI passthrough
To be able to keep both subsystem modular we add a registering hook inside the S390 core code.This fixes a build problem when VFIO is built-in and KVM is built as a module.
Quoted 9 lines
Quoted 4 lines
Reported-by Randy Dunlap <[email protected]>Reported-by kernel test robot <[email protected]>Signed-off-by Pierre Morel <[email protected]>Fixes 09340b2fca007 ("KVM: s390: pci: add routines to start/stop inter..")Please don't shorten the Fixes tag, the subject line is likely also checked by some automated tools. It's okay for this line to be over the column limit and checkpatch.pl --strict also accepts it.
OK
Quoted 26 lines
Quoted 11 lines
Cc <[email protected]>--- arch/s390/include/asm/kvm_host.h | 17 ++++++----------- arch/s390/kvm/pci.c | 10 ++++++---- arch/s390/pci/Makefile | 2 ++ arch/s390/pci/pci_kvm_hook.c | 11 +++++++++++ drivers/vfio/pci/vfio_pci_zdev.c | 8 ++++++-- 5 files changed, 31 insertions(+), 17 deletions(-)create mode 100644
arch/s390/pci/pci_kvm_hook.c---8<---
Quoted 14 lines
kvm_put_kvm(kvm); }arch/s390/kvm/pci.c +2
-1-EXPORT_SYMBOL_GPL (kvm_s390_pci_unregister_kvm);void kvm_s390_pci_init_list (struct kvm *kvm) {@@ -678,6 +678,8 @@ int kvm_s390_pci_init(void)spin_lock_init (&aift->gait_lock);mutex_init (&aift->aift_lock); + zpci_kvm_hook.kvm_register = kvm_s390_pci_register_kvm; + zpci_kvm_hook.kvm_unregister = kvm_s390_pci_unregister_kvm;
Quoted 14 lines
arch/s390/pci/Makefile obj-$(CONFIG_PCI) += pci.o pci_irq.o pci_dma.o pci_clp.o pci_sysfs.o \ · line 11
Quoted 12 lines
(quoted diff) +0
-0return 0; }arch/s390/pci/Makefile +2
-0@@ -7,3 +7,5 @@ obj-$(CONFIG_PCI) += pci.o pci_irq.o pci_dma.o pci_clp.o pci_sysfs.o \ pci_event.o pci_debug.o pci_insn.o pci_mmio.o \ pci_bus.o obj-$(CONFIG_PCI_IOV) += pci_iov.o + +obj-y += pci_kvm_hook.oI thought we wanted to compile this only for
CONFIG_PCI?
Ah sorry, that is indeed what I understood with Matt but then I misunderstood your own answer from yesterday. I change to
obj-$(CONFIG_PCI) += pci_kvm_hook.o
Quoted 6 lines
arch/s390/pci/pci_kvm_hook.c
Quoted 4 lines
arch/s390/pci/pci_kvm_hook.c new file +0
-0---8<---
Signature · 2 lines
Pierre Morel IBM Lab Boeblingen
Quoted 64 lines · Pierre Morel
Quoted 9 lines · Niklas Schnelle
Quoted 8 lines · Pierre Morel
We have a cross dependency between KVM and VFIO when using s390
vfio_pci_zdevextensions for PCI passthrough
To be able to keep both subsystem modular we add a registering hook inside the S390 core code.This fixes a build problem when VFIO is built-in and KVM is built as a module.
Quoted 9 lines
Quoted 4 lines
Reported-by Randy Dunlap <[email protected]>Reported-by kernel test robot <[email protected]>Signed-off-by Pierre Morel <[email protected]>Fixes 09340b2fca007 ("KVM: s390: pci: add routines to start/stop inter..")Please don't shorten the Fixes tag, the subject line is likely also checked by some automated tools. It's okay for this line to be over the column limit and checkpatch.pl --strict also accepts it.
OK
Quoted 26 lines
Quoted 11 lines
Cc <[email protected]>--- arch/s390/include/asm/kvm_host.h | 17 ++++++----------- arch/s390/kvm/pci.c | 10 ++++++---- arch/s390/pci/Makefile | 2 ++ arch/s390/pci/pci_kvm_hook.c | 11 +++++++++++ drivers/vfio/pci/vfio_pci_zdev.c | 8 ++++++-- 5 files changed, 31 insertions(+), 17 deletions(-)create mode 100644
arch/s390/pci/pci_kvm_hook.c---8<---
Quoted 14 lines
kvm_put_kvm(kvm); }arch/s390/kvm/pci.c +2
-1-EXPORT_SYMBOL_GPL (kvm_s390_pci_unregister_kvm);void kvm_s390_pci_init_list (struct kvm *kvm) {@@ -678,6 +678,8 @@ int kvm_s390_pci_init(void)spin_lock_init (&aift->gait_lock);mutex_init (&aift->aift_lock); + zpci_kvm_hook.kvm_register = kvm_s390_pci_register_kvm; + zpci_kvm_hook.kvm_unregister = kvm_s390_pci_unregister_kvm;Quoted 14 lines
arch/s390/pci/Makefile obj-$(CONFIG_PCI) += pci.o pci_irq.o pci_dma.o pci_clp.o pci_sysfs.o \ · line 11
Quoted 12 lines
(quoted diff) +0
-0return 0; }arch/s390/pci/Makefile +2
-0@@ -7,3 +7,5 @@ obj-$(CONFIG_PCI) += pci.o pci_irq.o pci_dma.o pci_clp.o pci_sysfs.o \ pci_event.o pci_debug.o pci_insn.o pci_mmio.o \ pci_bus.o obj-$(CONFIG_PCI_IOV) += pci_iov.o + +obj-y += pci_kvm_hook.oI thought we wanted to compile this only for
CONFIG_PCI?
Quoted 10 lines
Ah sorry, that is indeed what I understood with Matt but then I misunderstood your own answer from yesterday.
I change to
obj-$(CONFIG_PCI) += pci_kvm_hook.oQuoted 5 lines
arch/s390/pci/pci_kvm_hook.c
Quoted 3 lines
arch/s390/pci/pci_kvm_hook.c new file +0
-0---8<---
Ok with the two things above plus the comment by Matt incorporated:
Quoted 76 lines · Niklas Schnelle
Quoted 64 lines · Pierre Morel
Quoted 9 lines · Niklas Schnelle
Quoted 8 lines · Pierre Morel
We have a cross dependency between KVM and VFIO when using s390
vfio_pci_zdevextensions for PCI passthrough
To be able to keep both subsystem modular we add a registering hook inside the S390 core code.This fixes a build problem when VFIO is built-in and KVM is built as a module.
Quoted 9 lines
Quoted 4 lines
Reported-by Randy Dunlap <[email protected]>Reported-by kernel test robot <[email protected]>Signed-off-by Pierre Morel <[email protected]>Fixes 09340b2fca007 ("KVM: s390: pci: add routines to start/stop inter..")Please don't shorten the Fixes tag, the subject line is likely also checked by some automated tools. It's okay for this line to be over the column limit and checkpatch.pl --strict also accepts it.
OK
Quoted 26 lines
Quoted 11 lines
Cc <[email protected]>--- arch/s390/include/asm/kvm_host.h | 17 ++++++----------- arch/s390/kvm/pci.c | 10 ++++++---- arch/s390/pci/Makefile | 2 ++ arch/s390/pci/pci_kvm_hook.c | 11 +++++++++++ drivers/vfio/pci/vfio_pci_zdev.c | 8 ++++++-- 5 files changed, 31 insertions(+), 17 deletions(-)create mode 100644
arch/s390/pci/pci_kvm_hook.c---8<---
Quoted 14 lines
kvm_put_kvm(kvm); }arch/s390/kvm/pci.c +2
-1-EXPORT_SYMBOL_GPL (kvm_s390_pci_unregister_kvm);void kvm_s390_pci_init_list (struct kvm *kvm) {@@ -678,6 +678,8 @@ int kvm_s390_pci_init(void)spin_lock_init (&aift->gait_lock);mutex_init (&aift->aift_lock); + zpci_kvm_hook.kvm_register = kvm_s390_pci_register_kvm; + zpci_kvm_hook.kvm_unregister = kvm_s390_pci_unregister_kvm;Quoted 14 lines
arch/s390/pci/Makefile obj-$(CONFIG_PCI) += pci.o pci_irq.o pci_dma.o pci_clp.o pci_sysfs.o \ · line 11
Quoted 12 lines
(quoted diff) +0
-0return 0; }arch/s390/pci/Makefile +2
-0@@ -7,3 +7,5 @@ obj-$(CONFIG_PCI) += pci.o pci_irq.o pci_dma.o pci_clp.o pci_sysfs.o \ pci_event.o pci_debug.o pci_insn.o pci_mmio.o \ pci_bus.o obj-$(CONFIG_PCI_IOV) += pci_iov.o + +obj-y += pci_kvm_hook.oI thought we wanted to compile this only for
CONFIG_PCI?Quoted 10 lines
Ah sorry, that is indeed what I understood with Matt but then I misunderstood your own answer from yesterday.
I change to
obj-$(CONFIG_PCI) += pci_kvm_hook.oQuoted 5 lines
arch/s390/pci/pci_kvm_hook.c
Quoted 3 lines
arch/s390/pci/pci_kvm_hook.c new file +0
-0---8<---
Quoted 4 lines
Ok with the two things above plus the comment by Matt incorporated:
Reviewed-by Niklas Schnelle <[email protected]>
Just a little correction, it changes nothing if the pci_kvm_hook.c goes on same lines as other CONFIG_PCI depending files. So I put it on the same line.
Thanks
Pierre
Signature · 2 lines
Pierre Morel IBM Lab Boeblingen
Niklas Schnelle
maintainer---8<---
Quoted 29 lines
Quoted 24 lines
Quoted 13 lines
Quoted 4 lines
Quoted 4 lines
arch/s390/pci/Makefile +0
-0Quoted 8 lines
arch/s390/pci/Makefile obj-$(CONFIG_PCI) += pci.o pci_irq.o pci_dma.o pci_clp.o pci_sysfs.o \ · line 11
Quoted 6 lines
arch/s390/pci/Makefile +2
-0@@ -7,3 +7,5 @@ obj-$(CONFIG_PCI) += pci.o pci_irq.o pci_dma.o pci_clp.o pci_sysfs.o \ pci_event.o pci_debug.o pci_insn.o pci_mmio.o \ pci_bus.o obj-$(CONFIG_PCI_IOV) += pci_iov.o + +obj-y += pci_kvm_hook.oI thought we wanted to compile this only for
CONFIG_PCI?Quoted 10 lines
Ah sorry, that is indeed what I understood with Matt but then I misunderstood your own answer from yesterday.
I change to
obj-$(CONFIG_PCI) += pci_kvm_hook.oQuoted 5 lines
arch/s390/pci/pci_kvm_hook.c
Quoted 3 lines
arch/s390/pci/pci_kvm_hook.c new file +0
-0---8<---
Quoted 4 lines
Ok with the two things above plus the comment by Matt incorporated:
Reviewed-by Niklas Schnelle <[email protected]>
Quoted 8 lines
Just a little correction, it changes nothing if the
pci_kvm_hook.cgoes on same lines as otherCONFIG_PCIdepending files.
So I put it on the same line.Thanks
Pierre
Of course yes. Thanks for fixing this and I'm assuming this would either go through the KVM or vfio trees, correct?