diff mbox series

[RFC,1/7] x86/iommu: make AMD-Vi and Intel VT-d support configurable

Message ID 20221219063456.2017996-2-burzalodowa@gmail.com (mailing list archive)
State New, archived
Headers show
Series Proposal to make x86 IOMMU driver support configurable | expand

Commit Message

Xenia Ragiadakou Dec. 19, 2022, 6:34 a.m. UTC
Currently, for x86 platforms, Xen does not provide to the users any
configuration control over the IOMMU support and can only be built with
both AMD and Intel IOMMU drivers enabled.
However, there are use cases, e.g in safety-critical systems, that require
Xen to be able to be configured to exclude unused code. A smaller tailored
configuration would help Xen to meet faster certification requirements for
individual platforms.

Introduce two new Kconfig options, AMD_IOMMU and INTEL_VTD, to allow code
specific to each IOMMU technology to be separated and, when not required,
stripped. AMD_IOMMU enables IOMMU support for platforms that implement the
AMD I/O Virtualization Technology. INTEL_VTD enables IOMMU support for
platforms that implement the Intel Virtualization Technology for Directed I/O.

Since no functional change is intended regarding the default configuration
of an x86 system, both options depend on x86 and default to 'y'.

Signed-off-by: Xenia Ragiadakou <burzalodowa@gmail.com>
---
 xen/drivers/passthrough/Kconfig  | 16 ++++++++++++++++
 xen/drivers/passthrough/Makefile |  4 ++--
 2 files changed, 18 insertions(+), 2 deletions(-)

Comments

Andrew Cooper Dec. 20, 2022, 10:26 a.m. UTC | #1
On 19/12/2022 6:34 am, Xenia Ragiadakou wrote:
> diff --git a/xen/drivers/passthrough/Kconfig b/xen/drivers/passthrough/Kconfig
> index 479d7de57a..82465aa627 100644
> --- a/xen/drivers/passthrough/Kconfig
> +++ b/xen/drivers/passthrough/Kconfig
> @@ -37,6 +37,22 @@ config IPMMU_VMSA
>  
>  endif
>  
> +config AMD_IOMMU
> +	bool "AMD IOMMU"
> +	depends on X86
> +	default y
> +	---help---

We're trying to phase out ---help---, so please just use help.

~Andrew
Jan Beulich Dec. 20, 2022, 5:01 p.m. UTC | #2
On 19.12.2022 07:34, Xenia Ragiadakou wrote:
> Currently, for x86 platforms, Xen does not provide to the users any
> configuration control over the IOMMU support and can only be built with
> both AMD and Intel IOMMU drivers enabled.
> However, there are use cases, e.g in safety-critical systems, that require
> Xen to be able to be configured to exclude unused code. A smaller tailored
> configuration would help Xen to meet faster certification requirements for
> individual platforms.
> 
> Introduce two new Kconfig options, AMD_IOMMU and INTEL_VTD, to allow code
> specific to each IOMMU technology to be separated and, when not required,
> stripped. AMD_IOMMU enables IOMMU support for platforms that implement the
> AMD I/O Virtualization Technology. INTEL_VTD enables IOMMU support for
> platforms that implement the Intel Virtualization Technology for Directed I/O.
> 
> Since no functional change is intended regarding the default configuration
> of an x86 system, both options depend on x86 and default to 'y'.

But do things also build successfully when one or both options are disabled?
I have to say that I would be quite surprised if that worked without further
adjustments. In which case initially these options want to be prompt-less,
with the prompts only added once 'n' also works.

Jan
Xenia Ragiadakou Dec. 20, 2022, 8:40 p.m. UTC | #3
On 12/20/22 12:26, Andrew Cooper wrote:
> On 19/12/2022 6:34 am, Xenia Ragiadakou wrote:
>> diff --git a/xen/drivers/passthrough/Kconfig b/xen/drivers/passthrough/Kconfig
>> index 479d7de57a..82465aa627 100644
>> --- a/xen/drivers/passthrough/Kconfig
>> +++ b/xen/drivers/passthrough/Kconfig
>> @@ -37,6 +37,22 @@ config IPMMU_VMSA
>>   
>>   endif
>>   
>> +config AMD_IOMMU
>> +	bool "AMD IOMMU"
>> +	depends on X86
>> +	default y
>> +	---help---
> 
> We're trying to phase out ---help---, so please just use help.

Ok.

> 
> ~Andrew
Xenia Ragiadakou Dec. 20, 2022, 8:57 p.m. UTC | #4
On 12/20/22 19:01, Jan Beulich wrote:
> On 19.12.2022 07:34, Xenia Ragiadakou wrote:
>> Currently, for x86 platforms, Xen does not provide to the users any
>> configuration control over the IOMMU support and can only be built with
>> both AMD and Intel IOMMU drivers enabled.
>> However, there are use cases, e.g in safety-critical systems, that require
>> Xen to be able to be configured to exclude unused code. A smaller tailored
>> configuration would help Xen to meet faster certification requirements for
>> individual platforms.
>>
>> Introduce two new Kconfig options, AMD_IOMMU and INTEL_VTD, to allow code
>> specific to each IOMMU technology to be separated and, when not required,
>> stripped. AMD_IOMMU enables IOMMU support for platforms that implement the
>> AMD I/O Virtualization Technology. INTEL_VTD enables IOMMU support for
>> platforms that implement the Intel Virtualization Technology for Directed I/O.
>>
>> Since no functional change is intended regarding the default configuration
>> of an x86 system, both options depend on x86 and default to 'y'.
> 
> But do things also build successfully when one or both options are disabled?
> I have to say that I would be quite surprised if that worked without further
> adjustments. In which case initially these options want to be prompt-less,
> with the prompts only added once 'n' also works.

Without applying the whole series, disabling any of them or both won't 
work. Ok.

> 
> Jan
Andrew Cooper Dec. 20, 2022, 9 p.m. UTC | #5
On 20/12/2022 8:57 pm, Xenia Ragiadakou wrote:
>
> On 12/20/22 19:01, Jan Beulich wrote:
>> On 19.12.2022 07:34, Xenia Ragiadakou wrote:
>>> Currently, for x86 platforms, Xen does not provide to the users any
>>> configuration control over the IOMMU support and can only be built with
>>> both AMD and Intel IOMMU drivers enabled.
>>> However, there are use cases, e.g in safety-critical systems, that
>>> require
>>> Xen to be able to be configured to exclude unused code. A smaller
>>> tailored
>>> configuration would help Xen to meet faster certification
>>> requirements for
>>> individual platforms.
>>>
>>> Introduce two new Kconfig options, AMD_IOMMU and INTEL_VTD, to allow
>>> code
>>> specific to each IOMMU technology to be separated and, when not
>>> required,
>>> stripped. AMD_IOMMU enables IOMMU support for platforms that
>>> implement the
>>> AMD I/O Virtualization Technology. INTEL_VTD enables IOMMU support for
>>> platforms that implement the Intel Virtualization Technology for
>>> Directed I/O.
>>>
>>> Since no functional change is intended regarding the default
>>> configuration
>>> of an x86 system, both options depend on x86 and default to 'y'.
>>
>> But do things also build successfully when one or both options are
>> disabled?
>> I have to say that I would be quite surprised if that worked without
>> further
>> adjustments. In which case initially these options want to be
>> prompt-less,
>> with the prompts only added once 'n' also works.
>
> Without applying the whole series, disabling any of them or both won't
> work. Ok.

To do a multi-step implementation, you start with

config FOO
    bool y

then rearrange them main code to use CONFIG_FOO as appropriate, then
have a final patch that adds a Kconfig name, help text, etc which is
what makes the config option user selectable and able to be turned off.

~Andrew
Xenia Ragiadakou Dec. 20, 2022, 9:28 p.m. UTC | #6
On 12/20/22 23:00, Andrew Cooper wrote:
> On 20/12/2022 8:57 pm, Xenia Ragiadakou wrote:
>>
>> On 12/20/22 19:01, Jan Beulich wrote:
>>> On 19.12.2022 07:34, Xenia Ragiadakou wrote:
>>>> Currently, for x86 platforms, Xen does not provide to the users any
>>>> configuration control over the IOMMU support and can only be built with
>>>> both AMD and Intel IOMMU drivers enabled.
>>>> However, there are use cases, e.g in safety-critical systems, that
>>>> require
>>>> Xen to be able to be configured to exclude unused code. A smaller
>>>> tailored
>>>> configuration would help Xen to meet faster certification
>>>> requirements for
>>>> individual platforms.
>>>>
>>>> Introduce two new Kconfig options, AMD_IOMMU and INTEL_VTD, to allow
>>>> code
>>>> specific to each IOMMU technology to be separated and, when not
>>>> required,
>>>> stripped. AMD_IOMMU enables IOMMU support for platforms that
>>>> implement the
>>>> AMD I/O Virtualization Technology. INTEL_VTD enables IOMMU support for
>>>> platforms that implement the Intel Virtualization Technology for
>>>> Directed I/O.
>>>>
>>>> Since no functional change is intended regarding the default
>>>> configuration
>>>> of an x86 system, both options depend on x86 and default to 'y'.
>>>
>>> But do things also build successfully when one or both options are
>>> disabled?
>>> I have to say that I would be quite surprised if that worked without
>>> further
>>> adjustments. In which case initially these options want to be
>>> prompt-less,
>>> with the prompts only added once 'n' also works.
>>
>> Without applying the whole series, disabling any of them or both won't
>> work. Ok.
> 
> To do a multi-step implementation, you start with
> 
> config FOO
>      bool y

Here, I think you mean def_bool y

> 
> then rearrange them main code to use CONFIG_FOO as appropriate, then
> have a final patch that adds a Kconfig name, help text, etc which is
> what makes the config option user selectable and able to be turned off.

Thank you both, for pointing that out. I will fix it.

> 
> ~Andrew
Jan Beulich Dec. 21, 2022, 7:51 a.m. UTC | #7
On 19.12.2022 07:34, Xenia Ragiadakou wrote:
> --- a/xen/drivers/passthrough/Kconfig
> +++ b/xen/drivers/passthrough/Kconfig
> @@ -37,6 +37,22 @@ config IPMMU_VMSA
>  
>  endif
>  
> +config AMD_IOMMU
> +	bool "AMD IOMMU"
> +	depends on X86
> +	default y
> +	---help---
> +	  Enables I/O virtualization on platforms that implement the
> +	  AMD I/O Virtualization Technology (IOMMU).
> +
> +config INTEL_VTD
> +	bool "Intel VT-d"
> +	depends on X86
> +	default y
> +	---help---
> +	  Enables I/O virtualization on platforms that implement the
> +	  Intel Virtualization Technology for Directed I/O (Intel VT-d).

One more thing Andrew and I have been talking about: As he has mentioned
elsewhere, IOMMU support is needed to boot systems with more than 254
CPUs (depending on APIC ID layout the boundary may actually be lower).
Hence it needs to at least be considered to make the prompts here (to
be precise: in the much later patch adding the prompts) dependent on
EXPERT, to prevent people from unknowingly building a non-functioning
(on some systems) hypervisor.

Jan
Xenia Ragiadakou Dec. 21, 2022, 10:28 a.m. UTC | #8
On 12/21/22 09:51, Jan Beulich wrote:
> On 19.12.2022 07:34, Xenia Ragiadakou wrote:
>> --- a/xen/drivers/passthrough/Kconfig
>> +++ b/xen/drivers/passthrough/Kconfig
>> @@ -37,6 +37,22 @@ config IPMMU_VMSA
>>   
>>   endif
>>   
>> +config AMD_IOMMU
>> +	bool "AMD IOMMU"
>> +	depends on X86
>> +	default y
>> +	---help---
>> +	  Enables I/O virtualization on platforms that implement the
>> +	  AMD I/O Virtualization Technology (IOMMU).
>> +
>> +config INTEL_VTD
>> +	bool "Intel VT-d"
>> +	depends on X86
>> +	default y
>> +	---help---
>> +	  Enables I/O virtualization on platforms that implement the
>> +	  Intel Virtualization Technology for Directed I/O (Intel VT-d).
> 
> One more thing Andrew and I have been talking about: As he has mentioned
> elsewhere, IOMMU support is needed to boot systems with more than 254
> CPUs (depending on APIC ID layout the boundary may actually be lower).
> Hence it needs to at least be considered to make the prompts here (to
> be precise: in the much later patch adding the prompts) dependent on
> EXPERT, to prevent people from unknowingly building a non-functioning
> (on some systems) hypervisor.

I will mention it in help as Andrew suggested and I will make it visible 
only if EXPERT.

> 
> Jan
diff mbox series

Patch

diff --git a/xen/drivers/passthrough/Kconfig b/xen/drivers/passthrough/Kconfig
index 479d7de57a..82465aa627 100644
--- a/xen/drivers/passthrough/Kconfig
+++ b/xen/drivers/passthrough/Kconfig
@@ -37,6 +37,22 @@  config IPMMU_VMSA
 
 endif
 
+config AMD_IOMMU
+	bool "AMD IOMMU"
+	depends on X86
+	default y
+	---help---
+	  Enables I/O virtualization on platforms that implement the
+	  AMD I/O Virtualization Technology (IOMMU).
+
+config INTEL_VTD
+	bool "Intel VT-d"
+	depends on X86
+	default y
+	---help---
+	  Enables I/O virtualization on platforms that implement the
+	  Intel Virtualization Technology for Directed I/O (Intel VT-d).
+
 config IOMMU_FORCE_PT_SHARE
 	bool
 
diff --git a/xen/drivers/passthrough/Makefile b/xen/drivers/passthrough/Makefile
index a5efa22714..d4fc7a3ddc 100644
--- a/xen/drivers/passthrough/Makefile
+++ b/xen/drivers/passthrough/Makefile
@@ -1,5 +1,5 @@ 
-obj-$(CONFIG_X86) += vtd/
-obj-$(CONFIG_X86) += amd/
+obj-$(CONFIG_INTEL_VTD) += vtd/
+obj-$(CONFIG_AMD_IOMMU) += amd/
 obj-$(CONFIG_X86) += x86/
 obj-$(CONFIG_ARM) += arm/