2022-01-14 23:06:19

by Matthew Rosato

[permalink] [raw]
Subject: [PATCH v2 23/30] vfio/pci: re-introduce CONFIG_VFIO_PCI_ZDEV

This was previously removed as unnecessary; while that was true, subsequent
changes will make KVM an additional required component for vfio-pci-zdev.
Let's re-introduce CONFIG_VFIO_PCI_ZDEV as now there is actually a reason
to say 'n' for it (when not planning to CONFIG_KVM).

Signed-off-by: Matthew Rosato <[email protected]>
---
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 860424ccda1b..fedd1d4cb592 100644
--- a/drivers/vfio/pci/Kconfig
+++ b/drivers/vfio/pci/Kconfig
@@ -42,5 +42,16 @@ config VFIO_PCI_IGD
and LPC bridge config space.

To enable Intel IGD assignment through vfio-pci, say Y.
+
+config VFIO_PCI_ZDEV
+ 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.
endif
endif
diff --git a/drivers/vfio/pci/Makefile b/drivers/vfio/pci/Makefile
index 349d68d242b4..01b1f83d83d7 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) += 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 ef9a44b6cf5d..5e2bca3b89db 100644
--- a/include/linux/vfio_pci_core.h
+++ b/include/linux/vfio_pci_core.h
@@ -195,7 +195,7 @@ static inline int vfio_pci_igd_init(struct vfio_pci_core_device *vdev)
}
#endif

-#ifdef CONFIG_S390
+#ifdef CONFIG_VFIO_PCI_ZDEV
extern int vfio_pci_info_zdev_add_caps(struct vfio_pci_core_device *vdev,
struct vfio_info_cap *caps);
#else
--
2.27.0


2022-01-20 19:15:07

by Pierre Morel

[permalink] [raw]
Subject: Re: [PATCH v2 23/30] vfio/pci: re-introduce CONFIG_VFIO_PCI_ZDEV



On 1/14/22 21:31, Matthew Rosato wrote:
> This was previously removed as unnecessary; while that was true, subsequent
> changes will make KVM an additional required component for vfio-pci-zdev.
> Let's re-introduce CONFIG_VFIO_PCI_ZDEV as now there is actually a reason
> to say 'n' for it (when not planning to CONFIG_KVM).
>
> Signed-off-by: Matthew Rosato <[email protected]>
> ---
> 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 860424ccda1b..fedd1d4cb592 100644
> --- a/drivers/vfio/pci/Kconfig
> +++ b/drivers/vfio/pci/Kconfig
> @@ -42,5 +42,16 @@ config VFIO_PCI_IGD
> and LPC bridge config space.
>
> To enable Intel IGD assignment through vfio-pci, say Y.
> +
> +config VFIO_PCI_ZDEV
> + 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.

In several patches we check on CONFIG_PCI (14,15,16,17 and 22) but we
may have PCI without VFIO_PCI, wouldn't it be a problem?

Here we define a new CONFIG entry and I have two questions:

1- there is no dependency on VFIO_PCI while the functionality is
obviously based on VFIO_PCI

2- Wouldn't it be possible to use this item and the single condition for
the different checks we need through the new VFIO interpretation
functionality.




> endif
> endif
> diff --git a/drivers/vfio/pci/Makefile b/drivers/vfio/pci/Makefile
> index 349d68d242b4..01b1f83d83d7 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) += 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 ef9a44b6cf5d..5e2bca3b89db 100644
> --- a/include/linux/vfio_pci_core.h
> +++ b/include/linux/vfio_pci_core.h
> @@ -195,7 +195,7 @@ static inline int vfio_pci_igd_init(struct vfio_pci_core_device *vdev)
> }
> #endif
>
> -#ifdef CONFIG_S390
> +#ifdef CONFIG_VFIO_PCI_ZDEV
> extern int vfio_pci_info_zdev_add_caps(struct vfio_pci_core_device *vdev,
> struct vfio_info_cap *caps);
> #else
>

--
Pierre Morel
IBM Lab Boeblingen

2022-01-20 20:28:26

by Matthew Rosato

[permalink] [raw]
Subject: Re: [PATCH v2 23/30] vfio/pci: re-introduce CONFIG_VFIO_PCI_ZDEV

On 1/18/22 12:20 PM, Pierre Morel wrote:
>
>
> On 1/14/22 21:31, Matthew Rosato wrote:
>> This was previously removed as unnecessary; while that was true,
>> subsequent
>> changes will make KVM an additional required component for vfio-pci-zdev.
>> Let's re-introduce CONFIG_VFIO_PCI_ZDEV as now there is actually a reason
>> to say 'n' for it (when not planning to CONFIG_KVM).
>>
>> Signed-off-by: Matthew Rosato <[email protected]>
>> ---
>>   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 860424ccda1b..fedd1d4cb592 100644
>> --- a/drivers/vfio/pci/Kconfig
>> +++ b/drivers/vfio/pci/Kconfig
>> @@ -42,5 +42,16 @@ config VFIO_PCI_IGD
>>         and LPC bridge config space.
>>         To enable Intel IGD assignment through vfio-pci, say Y.
>> +
>> +config VFIO_PCI_ZDEV
>> +    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.
>
> In several patches we check on CONFIG_PCI (14,15,16,17 and 22) but we
> may have PCI without VFIO_PCI, wouldn't it be a problem?
>
> Here we define a new CONFIG entry and I have two questions:
>
> 1- there is no dependency on VFIO_PCI while the functionality is
> obviously based on VFIO_PCI

It's not obvious from this diff, but this 'config VFIO_PCI_ZDEV'
statement is within an 'if VFIO_PCI' statement, just like VFIO_PCI_IGD
above -- so the dependency is there.

>
> 2- Wouldn't it be possible to use this item and the single condition for
> the different checks we need through the new VFIO interpretation
> functionality.

Possibly, but 1) we'd have to make linking arch/s390/kvm/pci.o dependent
on CONFIG_VFIO_PCI instead of CONFIG_PCI in patch 14 and 2) if the
relationship between CONFIG_VFIO_PCI and CONFIG_PCI were to ever change
(though I don't see why it would..), we would be broken because the
symbols we are referencing really require CONFIG_PCI (as they are
located in s390 PCI).

2022-01-20 21:18:29

by Pierre Morel

[permalink] [raw]
Subject: Re: [PATCH v2 23/30] vfio/pci: re-introduce CONFIG_VFIO_PCI_ZDEV



On 1/18/22 18:32, Matthew Rosato wrote:
> On 1/18/22 12:20 PM, Pierre Morel wrote:
>>
>>
>> On 1/14/22 21:31, Matthew Rosato wrote:
>>> This was previously removed as unnecessary; while that was true,
>>> subsequent
>>> changes will make KVM an additional required component for
>>> vfio-pci-zdev.
>>> Let's re-introduce CONFIG_VFIO_PCI_ZDEV as now there is actually a
>>> reason
>>> to say 'n' for it (when not planning to CONFIG_KVM).
>>>
>>> Signed-off-by: Matthew Rosato <[email protected]>
>>> ---
>>>   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 860424ccda1b..fedd1d4cb592 100644
>>> --- a/drivers/vfio/pci/Kconfig
>>> +++ b/drivers/vfio/pci/Kconfig
>>> @@ -42,5 +42,16 @@ config VFIO_PCI_IGD
>>>         and LPC bridge config space.
>>>         To enable Intel IGD assignment through vfio-pci, say Y.
>>> +
>>> +config VFIO_PCI_ZDEV
>>> +    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.
>>
>> In several patches we check on CONFIG_PCI (14,15,16,17 and 22) but we
>> may have PCI without VFIO_PCI, wouldn't it be a problem?
>>
>> Here we define a new CONFIG entry and I have two questions:
>>
>> 1- there is no dependency on VFIO_PCI while the functionality is
>> obviously based on VFIO_PCI
>
> It's not obvious from this diff, but this 'config VFIO_PCI_ZDEV'
> statement is within an 'if VFIO_PCI' statement, just like VFIO_PCI_IGD
> above -- so the dependency is there.

sorry, I remember now you already answered this to Christian last time.

>
>>
>> 2- Wouldn't it be possible to use this item and the single condition
>> for the different checks we need through the new VFIO interpretation
>> functionality.
>
> Possibly, but 1) we'd have to make linking arch/s390/kvm/pci.o dependent
> on CONFIG_VFIO_PCI instead of CONFIG_PCI in patch 14 and 2) if the
> relationship between CONFIG_VFIO_PCI and CONFIG_PCI were to ever change
> (though I don't see why it would..), we would be broken because the
> symbols we are referencing really require CONFIG_PCI (as they are
> located in s390 PCI).
>

Yes but VFIO_PCI_ZDEV depends on KVM, PCI and on VFIO_PCI
Wouldn't a single config item for this new code be easier to manage and
understand?

--
Pierre Morel
IBM Lab Boeblingen

2022-01-20 21:26:38

by Matthew Rosato

[permalink] [raw]
Subject: Re: [PATCH v2 23/30] vfio/pci: re-introduce CONFIG_VFIO_PCI_ZDEV

On 1/18/22 12:45 PM, Pierre Morel wrote:
>
>
> On 1/18/22 18:32, Matthew Rosato wrote:
>> On 1/18/22 12:20 PM, Pierre Morel wrote:
>>>
>>>
>>> On 1/14/22 21:31, Matthew Rosato wrote:
>>>> This was previously removed as unnecessary; while that was true,
>>>> subsequent
>>>> changes will make KVM an additional required component for
>>>> vfio-pci-zdev.
>>>> Let's re-introduce CONFIG_VFIO_PCI_ZDEV as now there is actually a
>>>> reason
>>>> to say 'n' for it (when not planning to CONFIG_KVM).
>>>>
>>>> Signed-off-by: Matthew Rosato <[email protected]>
>>>> ---
>>>>   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 860424ccda1b..fedd1d4cb592 100644
>>>> --- a/drivers/vfio/pci/Kconfig
>>>> +++ b/drivers/vfio/pci/Kconfig
>>>> @@ -42,5 +42,16 @@ config VFIO_PCI_IGD
>>>>         and LPC bridge config space.
>>>>         To enable Intel IGD assignment through vfio-pci, say Y.
>>>> +
>>>> +config VFIO_PCI_ZDEV
>>>> +    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.
>>>
>>> In several patches we check on CONFIG_PCI (14,15,16,17 and 22) but we
>>> may have PCI without VFIO_PCI, wouldn't it be a problem?
>>>
>>> Here we define a new CONFIG entry and I have two questions:
>>>
>>> 1- there is no dependency on VFIO_PCI while the functionality is
>>> obviously based on VFIO_PCI
>>
>> It's not obvious from this diff, but this 'config VFIO_PCI_ZDEV'
>> statement is within an 'if VFIO_PCI' statement, just like VFIO_PCI_IGD
>> above -- so the dependency is there.
>
> sorry, I remember now you already answered this to Christian last time.
>
>>
>>>
>>> 2- Wouldn't it be possible to use this item and the single condition
>>> for the different checks we need through the new VFIO interpretation
>>> functionality.
>>
>> Possibly, but 1) we'd have to make linking arch/s390/kvm/pci.o
>> dependent on CONFIG_VFIO_PCI instead of CONFIG_PCI in patch 14 and 2)
>> if the relationship between CONFIG_VFIO_PCI and CONFIG_PCI were to
>> ever change (though I don't see why it would..), we would be broken
>> because the symbols we are referencing really require CONFIG_PCI (as
>> they are located in s390 PCI).
>>
>
> Yes but VFIO_PCI_ZDEV depends on KVM, PCI and on VFIO_PCI
> Wouldn't a single config item for this new code be easier to manage and
> understand?
>

I guess my primary resistance is to abstracting/hiding the dependency.
Yes, userspace will never setup for zPCI interpretation without
CONFIG_VFIO_PCI{_ZDEV}, but that's not where the compilation dependency
is -- it's on CONFIG_PCI specifically.

But I guess on the other hand you could argue why even bother building
pci.o into kvm without CONFIG_VFIO_PCI_ZDEV as it will never be used.

OK, I will have a look at making this change. It will require a little
reorganization, at least moving this patch up before patch 14.