Re: [PATCH] KVM: s390: pci: Hook to access KVM lowlevel from VFIO

From: Niklas Schnelle
Date: Fri Aug 19 2022 - 06:43:09 EST


On Fri, 2022-08-19 at 10:44 +0200, Pierre Morel wrote:
>
> On 8/19/22 09:14, Niklas Schnelle wrote:
> > On Thu, 2022-08-18 at 18:46 +0200, Pierre Morel wrote:
> > > 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.
> > >
> > > Reported-by: Randy Dunlap <rdunlap@xxxxxxxxxxxxx>
> > > Reported-by: kernel test robot <lkp@xxxxxxxxx>
> > > Signed-off-by: Pierre Morel <pmorel@xxxxxxxxxxxxx>
> > > 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
>
> > > Cc: <stable@xxxxxxxxxxxxxxx>
> > > ---
> > > 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<---
> > >
> > > 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;
> > > }
> > > diff --git a/arch/s390/pci/Makefile b/arch/s390/pci/Makefile
> > > index bf557a1b789c..c02dbfb415d9 100644
> > > --- a/arch/s390/pci/Makefile
> > > +++ b/arch/s390/pci/Makefile
> > > @@ -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?
>
> 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
>
> > > diff --git a/arch/s390/pci/pci_kvm_hook.c b/arch/s390/pci/pci_kvm_hook.c
> > > new file mode 100644
> > > index 000000000000..ff34baf50a3e
> > ---8<---
> >

Ok with the two things above plus the comment by Matt incorporated:

Reviewed-by: Niklas Schnelle <schnelle@xxxxxxxxxxxxx>