Message ID | 20220816202855.189410-1-pmorel@linux.ibm.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | KVM: s390: pci: VFIO_PCI ZDEV configuration fix | expand |
On 8/16/22 4:28 PM, Pierre Morel wrote: > Fixing configuration for VFIO PCI interpretation. > > Reported-by: Randy Dunlap <rdunlap@infradead.org> > Reported-by: kernel test robot <lkp@intel.com> > Signed-off-by: Pierre Morel <pmorel@linux.ibm.com> > Fixes: 09340b2fca007 ("KVM: s390: pci: add routines to start/stop inter..") > Fixes: c435c54639aa5 ("vfio/pci: introduce CONFIG_VFIO_PCI_ZDEV_KVM..") > Cc: <stable@vger.kernel.org> > --- > arch/s390/include/asm/kvm_host.h | 9 --------- > arch/s390/kvm/Makefile | 2 +- > arch/s390/kvm/pci.c | 4 ++-- > drivers/vfio/pci/Kconfig | 4 ++-- > include/linux/vfio_pci_core.h | 2 +- > 5 files changed, 6 insertions(+), 15 deletions(-) > > diff --git a/arch/s390/include/asm/kvm_host.h b/arch/s390/include/asm/kvm_host.h > index f39092e0ceaa..f6cf961731af 100644 > --- a/arch/s390/include/asm/kvm_host.h > +++ b/arch/s390/include/asm/kvm_host.h > @@ -1038,16 +1038,7 @@ 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); > > -#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 > > #endif > diff --git a/arch/s390/kvm/Makefile b/arch/s390/kvm/Makefile > index 02217fb4ae10..be36afcfd6ff 100644 > --- a/arch/s390/kvm/Makefile > +++ b/arch/s390/kvm/Makefile > @@ -9,6 +9,6 @@ ccflags-y := -Ivirt/kvm -Iarch/s390/kvm > > kvm-y += kvm-s390.o intercept.o interrupt.o priv.o sigp.o > kvm-y += diag.o gaccess.o guestdbg.o vsie.o pv.o > +kvm-y += pci.o > > -kvm-$(CONFIG_VFIO_PCI_ZDEV_KVM) += pci.o You would need to switch this to CONFIG_PCI at least, else we get build errors with CONFIG_PCI=n. > obj-$(CONFIG_KVM) += kvm.o > diff --git a/arch/s390/kvm/pci.c b/arch/s390/kvm/pci.c > index 4946fb7757d6..cf8ab72a2109 100644 > --- a/arch/s390/kvm/pci.c > +++ b/arch/s390/kvm/pci.c > @@ -435,7 +435,7 @@ int kvm_s390_pci_register_kvm(struct zpci_dev *zdev, struct kvm *kvm) > { > int rc; > > - if (!zdev) > + if (!IS_ENABLED(CONFIG_VFIO_PCI_ZDEV_KVM) || !zdev) > return -EINVAL; > > mutex_lock(&zdev->kzdev_lock); > @@ -516,7 +516,7 @@ void kvm_s390_pci_unregister_kvm(struct zpci_dev *zdev) > { > struct kvm *kvm; > > - if (!zdev) > + if (!IS_ENABLED(CONFIG_VFIO_PCI_ZDEV_KVM) || !zdev) > return; > > mutex_lock(&zdev->kzdev_lock); > diff --git a/drivers/vfio/pci/Kconfig b/drivers/vfio/pci/Kconfig > index f9d0c908e738..bbc375b028ef 100644 > --- a/drivers/vfio/pci/Kconfig > +++ b/drivers/vfio/pci/Kconfig > @@ -45,9 +45,9 @@ config VFIO_PCI_IGD > endif > > config VFIO_PCI_ZDEV_KVM > - bool "VFIO PCI extensions for s390x KVM passthrough" > + def_tristate y > + prompt "VFIO PCI extensions for s390x KVM passthrough" > depends on S390 && KVM > - default y > help > Support s390x-specific extensions to enable support for enhancements > to KVM passthrough capabilities, such as interpretive execution of > diff --git a/include/linux/vfio_pci_core.h b/include/linux/vfio_pci_core.h > index 5579ece4347b..7db3bb8129b1 100644 > --- a/include/linux/vfio_pci_core.h > +++ b/include/linux/vfio_pci_core.h > @@ -205,7 +205,7 @@ static inline int vfio_pci_igd_init(struct vfio_pci_core_device *vdev) > } > #endif > > -#ifdef CONFIG_VFIO_PCI_ZDEV_KVM > +#if IS_ENABLED(CONFIG_VFIO_PCI_ZDEV_KVM) > int vfio_pci_info_zdev_add_caps(struct vfio_pci_core_device *vdev, > struct vfio_info_cap *caps); > int vfio_pci_zdev_open_device(struct vfio_pci_core_device *vdev); This still doesn't seem quite right... I tried some variations: 1) CONFIG_KVM=m CONFIG_VFIO_PCI_CORE=m CONFIG_VFIO_PCI=m CONFIG_VFIO_PCI_ZDEV_KVM=m compiles, works with a small change: diff --git a/include/linux/sched/user.h b/include/linux/sched/user.h index f054d0360a75..99734e135420 100644 --- a/include/linux/sched/user.h +++ b/include/linux/sched/user.h @@ -25,7 +25,7 @@ struct user_struct { #if defined(CONFIG_PERF_EVENTS) || defined(CONFIG_BPF_SYSCALL) || \ defined(CONFIG_NET) || defined(CONFIG_IO_URING) || \ - defined(CONFIG_VFIO_PCI_ZDEV_KVM) + IS_ENABLED(CONFIG_VFIO_PCI_ZDEV_KVM) 2) CONFIG_KVM=y CONFIG_VFIO_PCI_CORE=m CONFIG_VFIO_PCI=m CONFIG_VFIO_PCI_ZDEV_KVM=m compiles, works with above user.h change 3) CONFIG_KVM=y CONFIG_VFIO_PCI_CORE=y CONFIG_VFIO_PCI=y CONFIG_VFIO_PCI_ZDEV_KVM=y compiles, works with above user.h change 4) CONFIG_KVM=m CONFIG_VFIO_PCI_CORE=y CONFIG_VFIO_PCI=y CONFIG_VFIO_PCI_ZDEV_KVM=m fails with: ld: drivers/vfio/pci/vfio_pci_core.o: in function `vfio_pci_core_enable': /usr/src/linux/drivers/vfio/pci/vfio_pci_core.c:320: undefined reference to `vfio_pci_zdev_open_device' ld: /usr/src/linux/drivers/vfio/pci/vfio_pci_core.c:349: undefined reference to `vfio_pci_zdev_close_device' ld: drivers/vfio/pci/vfio_pci_core.o: in function `vfio_pci_core_disable': /usr/src/linux/drivers/vfio/pci/vfio_pci_core.c:428: undefined reference to `vfio_pci_zdev_close_device' ld: drivers/vfio/pci/vfio_pci_core.o: in function `vfio_pci_core_ioctl': /usr/src/linux/drivers/vfio/pci/vfio_pci_core.c:712: undefined reference to `vfio_pci_info_zdev_add_caps' 5) CONFIG_KVM=m CONFIG_VFIO_PCI_CORE=y CONFIG_VFIO_PCI=y CONFIG_VFIO_PCI_ZDEV_KVM=y This forces CONFIG_VFIO_PCI_ZDEV_KVM to 'm' and fails as above.
On 8/17/22 00:15, Matthew Rosato wrote: > On 8/16/22 4:28 PM, Pierre Morel wrote: >> Fixing configuration for VFIO PCI interpretation. >> > 4) > CONFIG_KVM=m > CONFIG_VFIO_PCI_CORE=y > CONFIG_VFIO_PCI=y > CONFIG_VFIO_PCI_ZDEV_KVM=m > > fails with: > > ld: drivers/vfio/pci/vfio_pci_core.o: in function `vfio_pci_core_enable': > /usr/src/linux/drivers/vfio/pci/vfio_pci_core.c:320: undefined reference to `vfio_pci_zdev_open_device' > ld: /usr/src/linux/drivers/vfio/pci/vfio_pci_core.c:349: undefined reference to `vfio_pci_zdev_close_device' > ld: drivers/vfio/pci/vfio_pci_core.o: in function `vfio_pci_core_disable': > /usr/src/linux/drivers/vfio/pci/vfio_pci_core.c:428: undefined reference to `vfio_pci_zdev_close_device' > ld: drivers/vfio/pci/vfio_pci_core.o: in function `vfio_pci_core_ioctl': > /usr/src/linux/drivers/vfio/pci/vfio_pci_core.c:712: undefined reference to `vfio_pci_info_zdev_add_caps' > > > 5) > CONFIG_KVM=m > CONFIG_VFIO_PCI_CORE=y > CONFIG_VFIO_PCI=y > CONFIG_VFIO_PCI_ZDEV_KVM=y > > This forces CONFIG_VFIO_PCI_ZDEV_KVM to 'm' and fails as above. > > > yes right I was really too stupid yesterday I think you are right and you should go as you proposed or use some pointer hook inside S390 to register with KVM.
diff --git a/arch/s390/include/asm/kvm_host.h b/arch/s390/include/asm/kvm_host.h index f39092e0ceaa..f6cf961731af 100644 --- a/arch/s390/include/asm/kvm_host.h +++ b/arch/s390/include/asm/kvm_host.h @@ -1038,16 +1038,7 @@ 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); -#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 #endif diff --git a/arch/s390/kvm/Makefile b/arch/s390/kvm/Makefile index 02217fb4ae10..be36afcfd6ff 100644 --- a/arch/s390/kvm/Makefile +++ b/arch/s390/kvm/Makefile @@ -9,6 +9,6 @@ ccflags-y := -Ivirt/kvm -Iarch/s390/kvm kvm-y += kvm-s390.o intercept.o interrupt.o priv.o sigp.o kvm-y += diag.o gaccess.o guestdbg.o vsie.o pv.o +kvm-y += pci.o -kvm-$(CONFIG_VFIO_PCI_ZDEV_KVM) += pci.o obj-$(CONFIG_KVM) += kvm.o diff --git a/arch/s390/kvm/pci.c b/arch/s390/kvm/pci.c index 4946fb7757d6..cf8ab72a2109 100644 --- a/arch/s390/kvm/pci.c +++ b/arch/s390/kvm/pci.c @@ -435,7 +435,7 @@ int kvm_s390_pci_register_kvm(struct zpci_dev *zdev, struct kvm *kvm) { int rc; - if (!zdev) + if (!IS_ENABLED(CONFIG_VFIO_PCI_ZDEV_KVM) || !zdev) return -EINVAL; mutex_lock(&zdev->kzdev_lock); @@ -516,7 +516,7 @@ void kvm_s390_pci_unregister_kvm(struct zpci_dev *zdev) { struct kvm *kvm; - if (!zdev) + if (!IS_ENABLED(CONFIG_VFIO_PCI_ZDEV_KVM) || !zdev) return; mutex_lock(&zdev->kzdev_lock); diff --git a/drivers/vfio/pci/Kconfig b/drivers/vfio/pci/Kconfig index f9d0c908e738..bbc375b028ef 100644 --- a/drivers/vfio/pci/Kconfig +++ b/drivers/vfio/pci/Kconfig @@ -45,9 +45,9 @@ config VFIO_PCI_IGD endif config VFIO_PCI_ZDEV_KVM - bool "VFIO PCI extensions for s390x KVM passthrough" + def_tristate y + prompt "VFIO PCI extensions for s390x KVM passthrough" depends on S390 && KVM - default y help Support s390x-specific extensions to enable support for enhancements to KVM passthrough capabilities, such as interpretive execution of diff --git a/include/linux/vfio_pci_core.h b/include/linux/vfio_pci_core.h index 5579ece4347b..7db3bb8129b1 100644 --- a/include/linux/vfio_pci_core.h +++ b/include/linux/vfio_pci_core.h @@ -205,7 +205,7 @@ static inline int vfio_pci_igd_init(struct vfio_pci_core_device *vdev) } #endif -#ifdef CONFIG_VFIO_PCI_ZDEV_KVM +#if IS_ENABLED(CONFIG_VFIO_PCI_ZDEV_KVM) int vfio_pci_info_zdev_add_caps(struct vfio_pci_core_device *vdev, struct vfio_info_cap *caps); int vfio_pci_zdev_open_device(struct vfio_pci_core_device *vdev);
Fixing configuration for VFIO PCI interpretation. Reported-by: Randy Dunlap <rdunlap@infradead.org> Reported-by: kernel test robot <lkp@intel.com> Signed-off-by: Pierre Morel <pmorel@linux.ibm.com> Fixes: 09340b2fca007 ("KVM: s390: pci: add routines to start/stop inter..") Fixes: c435c54639aa5 ("vfio/pci: introduce CONFIG_VFIO_PCI_ZDEV_KVM..") Cc: <stable@vger.kernel.org> --- arch/s390/include/asm/kvm_host.h | 9 --------- arch/s390/kvm/Makefile | 2 +- arch/s390/kvm/pci.c | 4 ++-- drivers/vfio/pci/Kconfig | 4 ++-- include/linux/vfio_pci_core.h | 2 +- 5 files changed, 6 insertions(+), 15 deletions(-)