public inbox for kvm@vger.kernel.org
 help / color / mirror / Atom feed
From: Matthew Rosato <mjrosato@linux.ibm.com>
To: Pierre Morel <pmorel@linux.ibm.com>
Cc: rdunlap@infradead.org, linux-kernel@vger.kernel.org,
	lkp@intel.com, borntraeger@linux.ibm.com, farman@linux.ibm.com,
	linux-s390@vger.kernel.org, kvm@vger.kernel.org
Subject: Re: [PATCH] KVM: s390: pci: VFIO_PCI ZDEV configuration fix
Date: Tue, 16 Aug 2022 18:15:17 -0400	[thread overview]
Message-ID: <b03be97f-cc03-cb58-bd1b-5eda3abd249a@linux.ibm.com> (raw)
In-Reply-To: <20220816202855.189410-1-pmorel@linux.ibm.com>

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.




  reply	other threads:[~2022-08-16 22:15 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-08-14 21:51 [PATCH] vfio-pci/zdev: require KVM to be built-in Randy Dunlap
2022-08-15  9:43 ` Pierre Morel
2022-08-16  6:04   ` Randy Dunlap
2022-08-16  7:55     ` Pierre Morel
2022-08-16 13:47       ` Pierre Morel
2022-08-16 18:06         ` Randy Dunlap
2022-08-16 19:46       ` Matthew Rosato
2022-08-16 20:22         ` Pierre Morel
2022-08-16 20:28           ` [PATCH] KVM: s390: pci: VFIO_PCI ZDEV configuration fix Pierre Morel
2022-08-16 22:15             ` Matthew Rosato [this message]
2022-08-17  7:10               ` Pierre Morel
2022-08-18 10:23           ` [PATCH] KVM: s390: pci: Hook to access KVM lowlevel from VFIO Pierre Morel
2022-08-18 13:33             ` Matthew Rosato
2022-08-18 14:06               ` Pierre Morel
2022-08-18 14:20               ` Niklas Schnelle
2022-08-18 15:13                 ` Matthew Rosato
2022-08-18 15:22                   ` Niklas Schnelle

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=b03be97f-cc03-cb58-bd1b-5eda3abd249a@linux.ibm.com \
    --to=mjrosato@linux.ibm.com \
    --cc=borntraeger@linux.ibm.com \
    --cc=farman@linux.ibm.com \
    --cc=kvm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-s390@vger.kernel.org \
    --cc=lkp@intel.com \
    --cc=pmorel@linux.ibm.com \
    --cc=rdunlap@infradead.org \
    /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