Message ID | 20220606203325.110625-11-mjrosato@linux.ibm.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | KVM: s390: enable zPCI for interpretive execution | expand |
On 06/06/2022 22.33, Matthew Rosato wrote: > The current contents of vfio-pci-zdev are today only useful in a KVM > environment; let's tie everything currently under vfio-pci-zdev to > this Kconfig statement and require KVM in this case, reducing complexity > (e.g. symbol lookups). > > Signed-off-by: Matthew Rosato <mjrosato@linux.ibm.com> > --- > drivers/vfio/pci/Kconfig | 11 +++++++++++ > drivers/vfio/pci/Makefile | 2 +- > include/linux/vfio_pci_core.h | 2 +- > 3 files changed, 13 insertions(+), 2 deletions(-) > > diff --git a/drivers/vfio/pci/Kconfig b/drivers/vfio/pci/Kconfig > index 4da1914425e1..f9d0c908e738 100644 > --- a/drivers/vfio/pci/Kconfig > +++ b/drivers/vfio/pci/Kconfig > @@ -44,6 +44,17 @@ config VFIO_PCI_IGD > To enable Intel IGD assignment through vfio-pci, say Y. > endif > > +config VFIO_PCI_ZDEV_KVM > + bool "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 > + zPCI instructions. > + > + To enable s390x KVM vfio-pci extensions, say Y. Is it still possible to disable CONFIG_VFIO_PCI_ZDEV_KVM ? Looking at the later patches (e.g. 20/21 where you call kvm_s390_pci_zpci_op() from kvm-s390.c), it rather seems to me that it currently cannot be disabled independently (as long as KVM is enabled). So if you want to make this selectable by the user, I think you have to put some more #ifdefs in the following patches. But if this was not meant to be selectable by the user, I think it should not get a help text and rather be selected by the KVM switch in arch/s390/kvm/Kconfig instead of having a "default y". Thomas
On 6/8/22 2:19 AM, Thomas Huth wrote: > On 06/06/2022 22.33, Matthew Rosato wrote: >> The current contents of vfio-pci-zdev are today only useful in a KVM >> environment; let's tie everything currently under vfio-pci-zdev to >> this Kconfig statement and require KVM in this case, reducing complexity >> (e.g. symbol lookups). >> >> Signed-off-by: Matthew Rosato <mjrosato@linux.ibm.com> >> --- >> drivers/vfio/pci/Kconfig | 11 +++++++++++ >> drivers/vfio/pci/Makefile | 2 +- >> include/linux/vfio_pci_core.h | 2 +- >> 3 files changed, 13 insertions(+), 2 deletions(-) >> >> diff --git a/drivers/vfio/pci/Kconfig b/drivers/vfio/pci/Kconfig >> index 4da1914425e1..f9d0c908e738 100644 >> --- a/drivers/vfio/pci/Kconfig >> +++ b/drivers/vfio/pci/Kconfig >> @@ -44,6 +44,17 @@ config VFIO_PCI_IGD >> To enable Intel IGD assignment through vfio-pci, say Y. >> endif >> +config VFIO_PCI_ZDEV_KVM >> + bool "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 >> + zPCI instructions. >> + >> + To enable s390x KVM vfio-pci extensions, say Y. > > Is it still possible to disable CONFIG_VFIO_PCI_ZDEV_KVM ? Looking at > the later patches (e.g. 20/21 where you call kvm_s390_pci_zpci_op() from > kvm-s390.c), it rather seems to me that it currently cannot be disabled > independently (as long as KVM is enabled). Yes, you can build with, for example, CONFIG_VFIO_PCI_ZDEV_KVM=n and CONFIG_KVM=m -- I tested it again just now. The result is kvm and vfio-pci are built and vfio-pci works, but none of the vfio-pci-zdev extensions are available (including zPCI interpretation). This is accomplished via the placement of some IS_ENABLED checks. Some calls (e.g. AEN init) are fenced by IS_ENABLED(CONFIG_VFIO_PCI_ZDEV_KVM). There are also some areas that are fenced off via a call to kvm_s390_pci_interp_allowed() which also includes an IS_ENABLED check along with checks for facility and cpu id. Using patch 20 as an example, KVM_CAP_S390_ZPCI_OP will always be reported as unavailable to userspace if CONFIG_VFIO_PCI_ZDEV_KVM=n due to the call to kvm_s390_pci_interp_allowed(). If userspace sends us the ioctl anyway, we will return -EINVAL because there is again a IS_ENABLED(CONFIG_VFIO_PCI_ZDEV_KVM) check before we read the ioctl args from userspace. > > So if you want to make this selectable by the user, I think you have to > put some more #ifdefs in the following patches. > But if this was not meant to be selectable by the user, I think it > should not get a help text and rather be selected by the KVM switch in > arch/s390/kvm/Kconfig instead of having a "default y". > > Thomas >
On 6/8/22 15:15, Matthew Rosato wrote: > On 6/8/22 2:19 AM, Thomas Huth wrote: >> On 06/06/2022 22.33, Matthew Rosato wrote: >>> The current contents of vfio-pci-zdev are today only useful in a KVM >>> environment; let's tie everything currently under vfio-pci-zdev to >>> this Kconfig statement and require KVM in this case, reducing complexity >>> (e.g. symbol lookups). >>> >>> Signed-off-by: Matthew Rosato <mjrosato@linux.ibm.com> Reviewed-by: Pierre Morel <pmorel@linux.ibm.com> >>> --- >>> drivers/vfio/pci/Kconfig | 11 +++++++++++ >>> drivers/vfio/pci/Makefile | 2 +- >>> include/linux/vfio_pci_core.h | 2 +- >>> 3 files changed, 13 insertions(+), 2 deletions(-) >>> >>> diff --git a/drivers/vfio/pci/Kconfig b/drivers/vfio/pci/Kconfig >>> index 4da1914425e1..f9d0c908e738 100644 >>> --- a/drivers/vfio/pci/Kconfig >>> +++ b/drivers/vfio/pci/Kconfig >>> @@ -44,6 +44,17 @@ config VFIO_PCI_IGD >>> To enable Intel IGD assignment through vfio-pci, say Y. >>> endif >>> +config VFIO_PCI_ZDEV_KVM >>> + bool "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 >>> + zPCI instructions. >>> + >>> + To enable s390x KVM vfio-pci extensions, say Y. >> >> Is it still possible to disable CONFIG_VFIO_PCI_ZDEV_KVM ? Looking at >> the later patches (e.g. 20/21 where you call kvm_s390_pci_zpci_op() >> from kvm-s390.c), it rather seems to me that it currently cannot be >> disabled independently (as long as KVM is enabled). > > Yes, you can build with, for example, CONFIG_VFIO_PCI_ZDEV_KVM=n and > CONFIG_KVM=m -- I tested it again just now. The result is kvm and > vfio-pci are built and vfio-pci works, but none of the vfio-pci-zdev > extensions are available (including zPCI interpretation). > > This is accomplished via the placement of some IS_ENABLED checks. Some > calls (e.g. AEN init) are fenced by > IS_ENABLED(CONFIG_VFIO_PCI_ZDEV_KVM). There are also some areas that > are fenced off via a call to kvm_s390_pci_interp_allowed() which also > includes an IS_ENABLED check along with checks for facility and cpu id. > > Using patch 20 as an example, KVM_CAP_S390_ZPCI_OP will always be > reported as unavailable to userspace if CONFIG_VFIO_PCI_ZDEV_KVM=n due > to the call to kvm_s390_pci_interp_allowed(). If userspace sends us the > ioctl anyway, we will return -EINVAL because there is again a > IS_ENABLED(CONFIG_VFIO_PCI_ZDEV_KVM) check before we read the ioctl args > from userspace. Yes and the code will not be generated by the compiler in patch 20 after the break if CONFIG_VFIO_PCI_ZDEV_KVM is not enabled. + case KVM_S390_ZPCI_OP: { + struct kvm_s390_zpci_op args; + + r = -EINVAL; + if (!IS_ENABLED(CONFIG_VFIO_PCI_ZDEV_KVM)) + break; Code not generated----v + if (copy_from_user(&args, argp, sizeof(args))) { + r = -EFAULT; + break; + } + r = kvm_s390_pci_zpci_op(kvm, &args); + break; ----------^ + } > >> >> So if you want to make this selectable by the user, I think you have >> to put some more #ifdefs in the following patches. >> But if this was not meant to be selectable by the user, I think it >> should not get a help text and rather be selected by the KVM switch in >> arch/s390/kvm/Kconfig instead of having a "default y". >> >> Thomas >> >
On 14/06/2022 10.56, Pierre Morel wrote: > > > On 6/8/22 15:15, Matthew Rosato wrote: >> On 6/8/22 2:19 AM, Thomas Huth wrote: >>> On 06/06/2022 22.33, Matthew Rosato wrote: >>>> The current contents of vfio-pci-zdev are today only useful in a KVM >>>> environment; let's tie everything currently under vfio-pci-zdev to >>>> this Kconfig statement and require KVM in this case, reducing complexity >>>> (e.g. symbol lookups). >>>> >>>> Signed-off-by: Matthew Rosato <mjrosato@linux.ibm.com> > > Reviewed-by: Pierre Morel <pmorel@linux.ibm.com> > > >>>> --- >>>> drivers/vfio/pci/Kconfig | 11 +++++++++++ >>>> drivers/vfio/pci/Makefile | 2 +- >>>> include/linux/vfio_pci_core.h | 2 +- >>>> 3 files changed, 13 insertions(+), 2 deletions(-) >>>> >>>> diff --git a/drivers/vfio/pci/Kconfig b/drivers/vfio/pci/Kconfig >>>> index 4da1914425e1..f9d0c908e738 100644 >>>> --- a/drivers/vfio/pci/Kconfig >>>> +++ b/drivers/vfio/pci/Kconfig >>>> @@ -44,6 +44,17 @@ config VFIO_PCI_IGD >>>> To enable Intel IGD assignment through vfio-pci, say Y. >>>> endif >>>> +config VFIO_PCI_ZDEV_KVM >>>> + bool "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 >>>> + zPCI instructions. >>>> + >>>> + To enable s390x KVM vfio-pci extensions, say Y. >>> >>> Is it still possible to disable CONFIG_VFIO_PCI_ZDEV_KVM ? Looking at the >>> later patches (e.g. 20/21 where you call kvm_s390_pci_zpci_op() from >>> kvm-s390.c), it rather seems to me that it currently cannot be disabled >>> independently (as long as KVM is enabled). >> >> Yes, you can build with, for example, CONFIG_VFIO_PCI_ZDEV_KVM=n and >> CONFIG_KVM=m -- I tested it again just now. The result is kvm and >> vfio-pci are built and vfio-pci works, but none of the vfio-pci-zdev >> extensions are available (including zPCI interpretation). >> >> This is accomplished via the placement of some IS_ENABLED checks. Some >> calls (e.g. AEN init) are fenced by IS_ENABLED(CONFIG_VFIO_PCI_ZDEV_KVM). >> There are also some areas that are fenced off via a call to >> kvm_s390_pci_interp_allowed() which also includes an IS_ENABLED check >> along with checks for facility and cpu id. >> >> Using patch 20 as an example, KVM_CAP_S390_ZPCI_OP will always be reported >> as unavailable to userspace if CONFIG_VFIO_PCI_ZDEV_KVM=n due to the call >> to kvm_s390_pci_interp_allowed(). If userspace sends us the ioctl anyway, >> we will return -EINVAL because there is again a >> IS_ENABLED(CONFIG_VFIO_PCI_ZDEV_KVM) check before we read the ioctl args >> from userspace. > > Yes and the code will not be generated by the compiler in patch 20 after the > break if CONFIG_VFIO_PCI_ZDEV_KVM is not enabled. > > + case KVM_S390_ZPCI_OP: { > + struct kvm_s390_zpci_op args; > + > + r = -EINVAL; > + if (!IS_ENABLED(CONFIG_VFIO_PCI_ZDEV_KVM)) > + break; > > Code not generated----v > > + if (copy_from_user(&args, argp, sizeof(args))) { > + r = -EFAULT; > + break; > + } > + r = kvm_s390_pci_zpci_op(kvm, &args); > + break; > > ----------^ OK, good to know, thanks for the clarification! Thomas
On Mon, 6 Jun 2022 16:33:14 -0400 Matthew Rosato <mjrosato@linux.ibm.com> wrote: > The current contents of vfio-pci-zdev are today only useful in a KVM > environment; let's tie everything currently under vfio-pci-zdev to > this Kconfig statement and require KVM in this case, reducing complexity > (e.g. symbol lookups). > > Signed-off-by: Matthew Rosato <mjrosato@linux.ibm.com> > --- > drivers/vfio/pci/Kconfig | 11 +++++++++++ > drivers/vfio/pci/Makefile | 2 +- > include/linux/vfio_pci_core.h | 2 +- > 3 files changed, 13 insertions(+), 2 deletions(-) Acked-by: Alex Williamson <alex.williamson@redhat.com> > diff --git a/drivers/vfio/pci/Kconfig b/drivers/vfio/pci/Kconfig > index 4da1914425e1..f9d0c908e738 100644 > --- a/drivers/vfio/pci/Kconfig > +++ b/drivers/vfio/pci/Kconfig > @@ -44,6 +44,17 @@ config VFIO_PCI_IGD > To enable Intel IGD assignment through vfio-pci, say Y. > endif > > +config VFIO_PCI_ZDEV_KVM > + bool "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 > + zPCI instructions. > + > + To enable s390x KVM vfio-pci extensions, say Y. > + > source "drivers/vfio/pci/mlx5/Kconfig" > > source "drivers/vfio/pci/hisilicon/Kconfig" > diff --git a/drivers/vfio/pci/Makefile b/drivers/vfio/pci/Makefile > index 7052ebd893e0..24c524224da5 100644 > --- a/drivers/vfio/pci/Makefile > +++ b/drivers/vfio/pci/Makefile > @@ -1,7 +1,7 @@ > # SPDX-License-Identifier: GPL-2.0-only > > vfio-pci-core-y := vfio_pci_core.o vfio_pci_intrs.o vfio_pci_rdwr.o vfio_pci_config.o > -vfio-pci-core-$(CONFIG_S390) += vfio_pci_zdev.o > +vfio-pci-core-$(CONFIG_VFIO_PCI_ZDEV_KVM) += vfio_pci_zdev.o > obj-$(CONFIG_VFIO_PCI_CORE) += vfio-pci-core.o > > vfio-pci-y := vfio_pci.o > diff --git a/include/linux/vfio_pci_core.h b/include/linux/vfio_pci_core.h > index 23c176d4b073..63af2897939c 100644 > --- a/include/linux/vfio_pci_core.h > +++ b/include/linux/vfio_pci_core.h > @@ -206,7 +206,7 @@ static inline int vfio_pci_igd_init(struct vfio_pci_core_device *vdev) > } > #endif > > -#ifdef CONFIG_S390 > +#ifdef CONFIG_VFIO_PCI_ZDEV_KVM > extern int vfio_pci_info_zdev_add_caps(struct vfio_pci_core_device *vdev, > struct vfio_info_cap *caps); > #else
diff --git a/drivers/vfio/pci/Kconfig b/drivers/vfio/pci/Kconfig index 4da1914425e1..f9d0c908e738 100644 --- a/drivers/vfio/pci/Kconfig +++ b/drivers/vfio/pci/Kconfig @@ -44,6 +44,17 @@ config VFIO_PCI_IGD To enable Intel IGD assignment through vfio-pci, say Y. endif +config VFIO_PCI_ZDEV_KVM + bool "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 + zPCI instructions. + + To enable s390x KVM vfio-pci extensions, say Y. + source "drivers/vfio/pci/mlx5/Kconfig" source "drivers/vfio/pci/hisilicon/Kconfig" diff --git a/drivers/vfio/pci/Makefile b/drivers/vfio/pci/Makefile index 7052ebd893e0..24c524224da5 100644 --- a/drivers/vfio/pci/Makefile +++ b/drivers/vfio/pci/Makefile @@ -1,7 +1,7 @@ # SPDX-License-Identifier: GPL-2.0-only vfio-pci-core-y := vfio_pci_core.o vfio_pci_intrs.o vfio_pci_rdwr.o vfio_pci_config.o -vfio-pci-core-$(CONFIG_S390) += vfio_pci_zdev.o +vfio-pci-core-$(CONFIG_VFIO_PCI_ZDEV_KVM) += vfio_pci_zdev.o obj-$(CONFIG_VFIO_PCI_CORE) += vfio-pci-core.o vfio-pci-y := vfio_pci.o diff --git a/include/linux/vfio_pci_core.h b/include/linux/vfio_pci_core.h index 23c176d4b073..63af2897939c 100644 --- a/include/linux/vfio_pci_core.h +++ b/include/linux/vfio_pci_core.h @@ -206,7 +206,7 @@ static inline int vfio_pci_igd_init(struct vfio_pci_core_device *vdev) } #endif -#ifdef CONFIG_S390 +#ifdef CONFIG_VFIO_PCI_ZDEV_KVM extern int vfio_pci_info_zdev_add_caps(struct vfio_pci_core_device *vdev, struct vfio_info_cap *caps); #else
The current contents of vfio-pci-zdev are today only useful in a KVM environment; let's tie everything currently under vfio-pci-zdev to this Kconfig statement and require KVM in this case, reducing complexity (e.g. symbol lookups). Signed-off-by: Matthew Rosato <mjrosato@linux.ibm.com> --- drivers/vfio/pci/Kconfig | 11 +++++++++++ drivers/vfio/pci/Makefile | 2 +- include/linux/vfio_pci_core.h | 2 +- 3 files changed, 13 insertions(+), 2 deletions(-)