Skip to contentSkip to conversation

Proposal to make x86 IOMMU driver support configurable

RFC Superseded Xenia Ragiadakou 4 participants 35 messages Dec 19, 2022 – Jan 12, 2023

v1 of 4 Superseded Latest is v4 →

lore
Share & tools
lore
#0 lore raw

cover Proposal to make x86 IOMMU driver support configurable

This series aims to provide a means to render the iommu driver support for x86 configurable. Currently, irrespectively of the target platform, both AMD and Intel iommu drivers are built. This is the case because the existent Kconfig infrastructure does not provide any facilities for finer-grained configuration.

The series adds two new Kconfig options, AMD_IOMMU and INTEL_VTD, that can be used to generate a tailored iommu configuration for a given platform.

This series will be part of a broader effort to separate platform specific code and it is sent as an RFC to gather feedback regarding the way the separation should be performed.

Xenia Ragiadakou (7):
x86/iommu: make AMD-Vi and Intel VT-d support configurable x86/iommu: amd_iommu_perdev_intremap is AMD-Vi specific x86/iommu: iommu_igfx, iommu_qinval and iommu_snoop are VT-d specific x86/acpi: separate AMD-Vi and VT-d specific functions x86/iommu: the code addressing CVE-2011-1898 is VT-d specific x86/iommu: call pi_update_irte through an hvm_function callback x86/dpci: move hvm_dpci_isairq_eoi() to generic HVM code

 xen/arch/x86/hvm/vmx/vmx.c               | 10 ++++
 xen/arch/x86/include/asm/acpi.h          | 14 ++++++
 xen/arch/x86/include/asm/hvm/hvm.h       | 22 ++++++++
 xen/arch/x86/include/asm/hvm/io.h        |  1 +
 xen/arch/x86/include/asm/hvm/vmx/vmx.h   | 11 ++++
 xen/arch/x86/include/asm/iommu.h         |  5 +-
 xen/arch/x86/pv/hypercall.c              |  2 +
 xen/arch/x86/x86_64/entry.S              |  2 +
 xen/drivers/passthrough/Kconfig          | 16 ++++++
 xen/drivers/passthrough/Makefile         |  4 +-
 xen/drivers/passthrough/amd/iommu_init.c |  2 +
 xen/drivers/passthrough/iommu.c          |  7 ++-
 xen/drivers/passthrough/vtd/x86/Makefile |  1 -
 xen/drivers/passthrough/vtd/x86/hvm.c    | 64 ------------------------
 xen/drivers/passthrough/x86/hvm.c        | 47 +++++++++++++++--
 xen/include/xen/acpi.h                   |  3 --
 xen/include/xen/iommu.h                  | 11 ++--
 17 files changed, 141 insertions(+), 81 deletions(-)
 delete mode 100644 xen/drivers/passthrough/vtd/x86/hvm.c
Signature · 1 line
2.37.2
#1 lore raw

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

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'.

---
 xen/drivers/passthrough/Kconfig  | 16 ++++++++++++++++
 xen/drivers/passthrough/Makefile |  4 ++--
 2 files changed, 18 insertions(+), 2 deletions(-)
xen/drivers/passthrough/Kconfig +16 -0
index 479d7de57a..82465aa627 100644
@@ -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
 
xen/drivers/passthrough/Makefile +2 -2
index a5efa22714..d4fc7a3ddc 100644
@@ -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/
 
Signature · 1 line
2.37.2
#2 lore raw

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

xen/drivers/passthrough/Kconfig config IPMMU_VMSA · line 44

Quoted 13 lines · Xenia Ragiadakou
xen/drivers/passthrough/Kconfig +5 -0
index 479d7de57a..82465aa627 100644
@@ -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

#3 lore raw

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

Quoted 9 lines · Andrew Cooper
Quoted 8 lines · Xenia Ragiadakou
xen/drivers/passthrough/Kconfig +0 -0
index 479d7de57a..82465aa627 100644
@@ -37,6 +37,22 @@ config IPMMU_VMSA
 
  endif
 
Quoted 7 lines

xen/drivers/passthrough/Kconfig config IPMMU_VMSA · line 44

Quoted 5 lines
xen/drivers/passthrough/Kconfig +5 -0
+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.

Quoted 2 lines

~Andrew

Signature · 1 line
Xenia
#4 lore raw

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

In reply to Xenia Ragiadakou
Quoted 8 lines · Xenia Ragiadakou

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.

Quoted 8 lines

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

#5 lore raw

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

Quoted 15 lines · Jan Beulich
Quoted 14 lines · Xenia Ragiadakou

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.

Quoted 7 lines
Quoted 2 lines

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.

Quoted 2 lines

Jan

Signature · 1 line
Xenia
#6 lore raw

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

Quoted 36 lines · Xenia Ragiadakou
Quoted 26 lines · Jan Beulich
Quoted 21 lines · Xenia Ragiadakou

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.

Quoted 3 lines

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

Quoted 7 lines

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.

Quoted 2 lines

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

#7 lore raw

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

Quoted 37 lines · Andrew Cooper
Quoted 36 lines · Xenia Ragiadakou
Quoted 33 lines · Jan Beulich
Quoted 21 lines · Xenia Ragiadakou

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.

Quoted 3 lines

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.

Quoted 7 lines
Quoted 2 lines

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

Quoted 4 lines

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.

Quoted 2 lines

~Andrew

Signature · 1 line
Xenia
#8 lore raw

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

In reply to Xenia Ragiadakou
Quoted 11 lines · Xenia Ragiadakou
xen/drivers/passthrough/Kconfig +5 -0
@@ -37,6 +37,22 @@ config IPMMU_VMSA
 
 endif
 
+config AMD_IOMMU
+	bool "AMD IOMMU"
+	depends on X86
+	default y
+	---help---

xen/drivers/passthrough/Kconfig config IPMMU_VMSA · line 54

Quoted 10 lines
xen/drivers/passthrough/Kconfig +10 -0
+	  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

#9 lore raw

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

Quoted 23 lines · Jan Beulich
Quoted 11 lines · Xenia Ragiadakou
xen/drivers/passthrough/Kconfig +5 -0
@@ -37,6 +37,22 @@ config IPMMU_VMSA
 
  endif
 
+config AMD_IOMMU
+	bool "AMD IOMMU"
+	depends on X86
+	default y
+	---help---

xen/drivers/passthrough/Kconfig config IPMMU_VMSA · line 54

Quoted 10 lines
xen/drivers/passthrough/Kconfig +10 -0
+	  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).
Quoted 7 lines

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.

Quoted 2 lines

Jan

Signature · 1 line
Xenia
#10 lore raw

RFC 2/7 x86/iommu: amd_iommu_perdev_intremap is AMD-Vi specific

In reply to Xenia Ragiadakou

Move its definition to the AMD-Vi driver and use CONFIG_AMD_IOMMU to guard its usage in common code.

Take the opportunity to replace bool_t with bool and 1 with true.

No functional change intended.

---
 xen/drivers/passthrough/amd/iommu_init.c | 2 ++
 xen/drivers/passthrough/iommu.c          | 3 ++-
 xen/include/xen/iommu.h                  | 4 +++-
 3 files changed, 7 insertions(+), 2 deletions(-)
xen/drivers/passthrough/amd/iommu_init.c +2 -0
index 1f14aaf49e..c4a41630e5 100644
@@ -36,6 +36,8 @@ static struct radix_tree_root ivrs_maps;
 LIST_HEAD_READ_MOSTLY(amd_iommu_head);
 bool_t iommuv2_enabled;
 
+bool __read_mostly amd_iommu_perdev_intremap = true;
+
 static bool iommu_has_ht_flag(struct amd_iommu *iommu, u8 mask)
 {
     return iommu->ht_flags & mask;
xen/drivers/passthrough/iommu.c +2 -1
index 5e2a720d29..1a02fdc453 100644
@@ -58,7 +58,6 @@ bool __read_mostly iommu_hap_pt_share = true;
 #endif
 
 bool_t __read_mostly iommu_debug;
-bool_t __read_mostly amd_iommu_perdev_intremap = 1;
 
 DEFINE_PER_CPU(bool_t, iommu_dont_flush_iotlb);
 
@@ -115,8 +114,10 @@ static int __init cf_check parse_iommu_param(const char *s)
             if ( val )
                 iommu_verbose = 1;
         }
+#ifdef CONFIG_AMD_IOMMU
         else if ( (val = parse_boolean("amd-iommu-perdev-intremap", s, ss)) >= 0 )
             amd_iommu_perdev_intremap = val;
+#endif
         else if ( (val = parse_boolean("dom0-passthrough", s, ss)) >= 0 )
             iommu_hwdom_passthrough = val;
         else if ( (val = parse_boolean("dom0-strict", s, ss)) >= 0 )
xen/include/xen/iommu.h +3 -1
index 4f22fc1bed..6b06732792 100644
@@ -104,7 +104,9 @@ static inline void clear_iommu_hap_pt_share(void)
 }
 
 extern bool_t iommu_debug;
-extern bool_t amd_iommu_perdev_intremap;
+#ifdef CONFIG_AMD_IOMMU
+extern bool amd_iommu_perdev_intremap;
+#endif
 
 extern bool iommu_hwdom_strict, iommu_hwdom_passthrough, iommu_hwdom_inclusive;
 extern int8_t iommu_hwdom_reserved;
Signature · 1 line
2.37.2
#11 lore raw

Re: [RFC 2/7] x86/iommu: amd_iommu_perdev_intremap is AMD-Vi specific

Quoted 13 lines · Xenia Ragiadakou
xen/drivers/passthrough/iommu.c +0 -1
index 5e2a720d29..1a02fdc453 100644
@@ -58,7 +58,6 @@ bool __read_mostly iommu_hap_pt_share = true;
 #endif
 
 bool_t __read_mostly iommu_debug;
-bool_t __read_mostly amd_iommu_perdev_intremap = 1;
 
 DEFINE_PER_CPU(bool_t, iommu_dont_flush_iotlb);
 

xen/drivers/passthrough/iommu.c static int __init cf_check parse_iommu_param(const char *s) · line 120

Quoted 7 lines
xen/drivers/passthrough/iommu.c +2 -0
@@ -115,8 +114,10 @@ static int __init cf_check parse_iommu_param(const char *s)
             if ( val )
                 iommu_verbose = 1;
         }
+#ifdef CONFIG_AMD_IOMMU
         else if ( (val = parse_boolean("amd-iommu-perdev-intremap", s, ss)) >= 0 )
             amd_iommu_perdev_intremap = val;
+#endif

See parse_cet() and the use of no_config_param() so users get a bit of a hint as to why the option they specified is getting ignored.

~Andrew

#12 lore raw

Re: [RFC 2/7] x86/iommu: amd_iommu_perdev_intremap is AMD-Vi specific

Quoted 13 lines · Andrew Cooper
Quoted 12 lines · Xenia Ragiadakou
xen/drivers/passthrough/iommu.c +0 -1
index 5e2a720d29..1a02fdc453 100644
@@ -58,7 +58,6 @@ bool __read_mostly iommu_hap_pt_share = true;
  #endif
 
  bool_t __read_mostly iommu_debug;
-bool_t __read_mostly amd_iommu_perdev_intremap = 1;
 
  DEFINE_PER_CPU(bool_t, iommu_dont_flush_iotlb);
 
Quoted 11 lines

xen/drivers/passthrough/iommu.c static int __init cf_check parse_iommu_param(const char *s) · line 120

Quoted 8 lines
xen/drivers/passthrough/iommu.c +2 -0
@@ -115,8 +114,10 @@ static int __init cf_check parse_iommu_param(const char *s)
              if ( val )
                  iommu_verbose = 1;
          }
+#ifdef CONFIG_AMD_IOMMU
          else if ( (val = parse_boolean("amd-iommu-perdev-intremap", s, ss)) >= 0 )
              amd_iommu_perdev_intremap = val;
+#endif

See parse_cet() and the use of no_config_param() so users get a bit of a hint as to why the option they specified is getting ignored.

Ah, ok I see. Thx for pointing that out.

Quoted 2 lines

~Andrew

Signature · 1 line
Xenia
#13 lore raw

Re: [RFC 2/7] x86/iommu: amd_iommu_perdev_intremap is AMD-Vi specific

In reply to Xenia Ragiadakou
Quoted 4 lines · Xenia Ragiadakou

Move its definition to the AMD-Vi driver and use CONFIG_AMD_IOMMU to guard its usage in common code.

Take the opportunity to replace bool_t with bool and 1 with true.

Please further take the opportunity and use ...

xen/drivers/passthrough/amd/iommu_init.c static struct radix_tree_root ivrs_maps; · line 39

Quoted 7 lines
xen/drivers/passthrough/amd/iommu_init.c +1 -0
@@ -36,6 +36,8 @@ static struct radix_tree_root ivrs_maps;
 LIST_HEAD_READ_MOSTLY(amd_iommu_head);
 bool_t iommuv2_enabled;
 
+bool __read_mostly amd_iommu_perdev_intremap = true;

... __ro_after_init here.

xen/include/xen/iommu.h static inline void clear_iommu_hap_pt_share(void) · line 109

Quoted 10 lines
xen/include/xen/iommu.h +3 -1
@@ -104,7 +104,9 @@ static inline void clear_iommu_hap_pt_share(void)
 }
 
 extern bool_t iommu_debug;
-extern bool_t amd_iommu_perdev_intremap;
+#ifdef CONFIG_AMD_IOMMU
+extern bool amd_iommu_perdev_intremap;
+#endif

We try to avoid such #ifdef-ary: There's no real harm from the declaration being in scope; in the worst case the build will fail not at the compile, but at the linking stage.

Jan

#14 lore raw

Re: [RFC 2/7] x86/iommu: amd_iommu_perdev_intremap is AMD-Vi specific

Quoted 23 lines · Jan Beulich
Quoted 4 lines · Xenia Ragiadakou

Move its definition to the AMD-Vi driver and use CONFIG_AMD_IOMMU to guard its usage in common code.

Take the opportunity to replace bool_t with bool and 1 with true.

Please further take the opportunity and use ...

xen/drivers/passthrough/amd/iommu_init.c static struct radix_tree_root ivrs_maps; · line 39

Quoted 7 lines
xen/drivers/passthrough/amd/iommu_init.c +1 -0
@@ -36,6 +36,8 @@ static struct radix_tree_root ivrs_maps;
  LIST_HEAD_READ_MOSTLY(amd_iommu_head);
  bool_t iommuv2_enabled;
 
+bool __read_mostly amd_iommu_perdev_intremap = true;

... __ro_after_init here.

Quoted 5 lines
xen/include/xen/iommu.h +0 -0
@@ -104,7 +104,9 @@ static inline void clear_iommu_hap_pt_share(void)
  }
 
Quoted 9 lines

xen/include/xen/iommu.h static inline void clear_iommu_hap_pt_share(void) · line 109

Quoted 5 lines
xen/include/xen/iommu.h +3 -1
  extern bool_t iommu_debug;
-extern bool_t amd_iommu_perdev_intremap;
+#ifdef CONFIG_AMD_IOMMU
+extern bool amd_iommu_perdev_intremap;
+#endif

We try to avoid such #ifdef-ary: There's no real harm from the declaration being in scope; in the worst case the build will fail not at the compile, but at the linking stage.

That's true. I will leave it as it is.

Quoted 2 lines

Jan

Signature · 1 line
Xenia
#15 lore raw

RFC 3/7 x86/iommu: iommu_igfx, iommu_qinval and iommu_snoop are VT-d specific

In reply to Xenia Ragiadakou

Use CONFIG_INTEL_VTD to guard their usage in common code.

No functional change intended.

---
 xen/drivers/passthrough/iommu.c | 4 +++-
 xen/include/xen/iommu.h         | 6 +++++-
 2 files changed, 8 insertions(+), 2 deletions(-)
xen/drivers/passthrough/iommu.c +3 -1
index 1a02fdc453..dcb5ec49ac 100644
@@ -82,11 +82,13 @@ static int __init cf_check parse_iommu_param(const char *s)
         else if ( ss == s + 23 && !strncmp(s, "quarantine=scratch-page", 23) )
             iommu_quarantine = IOMMU_quarantine_scratch_page;
 #endif
-#ifdef CONFIG_X86
+#ifdef CONFIG_INTEL_VTD
         else if ( (val = parse_boolean("igfx", s, ss)) >= 0 )
             iommu_igfx = val;
         else if ( (val = parse_boolean("qinval", s, ss)) >= 0 )
             iommu_qinval = val;
+#endif
+#ifdef CONFIG_X86
         else if ( (val = parse_boolean("superpages", s, ss)) >= 0 )
             iommu_superpages = val;
 #endif
xen/include/xen/iommu.h +5 -1
index 6b06732792..d9285a7760 100644
@@ -74,9 +74,13 @@ extern enum __packed iommu_intremap {
    iommu_intremap_restricted,
    iommu_intremap_full,
 } iommu_intremap;
-extern bool iommu_igfx, iommu_qinval, iommu_snoop;
 #else
 # define iommu_intremap false
+#endif
+
+#ifdef CONFIG_INTEL_VTD
+extern bool iommu_igfx, iommu_qinval, iommu_snoop;
+#else
 # define iommu_snoop false
 #endif
 
Signature · 1 line
2.37.2
#16 lore raw

RFC 4/7 x86/acpi: separate AMD-Vi and VT-d specific functions

In reply to Xenia Ragiadakou

The functions acpi_dmar_init() and acpi_dmar_zap/reinstate() are VT-d specific while the function acpi_ivrs_init() is AMD-Vi specific. To eliminate dead code, they need to be guarded under CONFIG_INTEL_VTD and CONFIG_AMD_IOMMU, respectively.

Instead of adding #ifdef guards around the function calls, implement them as empty static inline functions.

Take the opportunity to move the declarations of acpi_dmar_zap/reinstate() to the arch specific header.

No functional change intended.

---
 xen/arch/x86/include/asm/acpi.h | 14 ++++++++++++++
 xen/include/xen/acpi.h          |  3 ---
 2 files changed, 14 insertions(+), 3 deletions(-)
xen/arch/x86/include/asm/acpi.h +14 -0
index c453450a74..06461fedcd 100644
@@ -140,8 +140,22 @@ extern u32 pmtmr_ioport;
 extern unsigned int pmtmr_width;
 
 void acpi_iommu_init(void);
+
+#ifdef CONFIG_INTEL_VTD
 int acpi_dmar_init(void);
+void acpi_dmar_zap(void);
+void acpi_dmar_reinstate(void);
+#else
+static inline int acpi_dmar_init(void) { return -ENODEV; }
+static inline void acpi_dmar_zap(void) {}
+static inline void acpi_dmar_reinstate(void) {}
+#endif
+
+#ifdef CONFIG_AMD_IOMMU
 int acpi_ivrs_init(void);
+#else
+static inline int acpi_ivrs_init(void) { return -ENODEV; }
+#endif
 
 void acpi_mmcfg_init(void);
 
xen/include/xen/acpi.h +0 -3
index 1b9c75e68f..82b24a5ef0 100644
@@ -206,9 +206,6 @@ static inline int acpi_get_pxm(acpi_handle handle)
 
 void acpi_reboot(void);
 
-void acpi_dmar_zap(void);
-void acpi_dmar_reinstate(void);
-
 #endif /* __ASSEMBLY__ */
 
 #endif /*_LINUX_ACPI_H*/
Signature · 1 line
2.37.2
Reviewed-by on v1 4/7
#17 lore raw

Re: [RFC 4/7] x86/acpi: separate AMD-Vi and VT-d specific functions

Quoted 8 lines · Xenia Ragiadakou

The functions acpi_dmar_init() and acpi_dmar_zap/reinstate() are VT-d specific while the function acpi_ivrs_init() is AMD-Vi specific. To eliminate dead code, they need to be guarded under CONFIG_INTEL_VTD and CONFIG_AMD_IOMMU, respectively.

Instead of adding #ifdef guards around the function calls, implement them as empty static inline functions.

Quoted 6 lines

Take the opportunity to move the declarations of acpi_dmar_zap/reinstate() to the arch specific header.

No functional change intended.

#18 lore raw

RFC 5/7 x86/iommu: the code addressing CVE-2011-1898 is VT-d specific

In reply to Xenia Ragiadakou

The variable untrusted_msi indicates whether the system is vulnerable to CVE-2011-1898. This vulnerablity is VT-d specific.
Place the code that addresses the issue under CONFIG_INTEL_VTD.

No functional change intended.

---
 xen/arch/x86/include/asm/iommu.h | 2 ++
 xen/arch/x86/pv/hypercall.c      | 2 ++
 xen/arch/x86/x86_64/entry.S      | 2 ++
 3 files changed, 6 insertions(+)
xen/arch/x86/include/asm/iommu.h +2 -0
index fc0afe35bf..41bd1b9e05 100644
@@ -127,7 +127,9 @@ int iommu_identity_mapping(struct domain *d, p2m_access_t p2ma,
                            unsigned int flag);
 void iommu_identity_map_teardown(struct domain *d);
 
+#ifdef CONFIG_INTEL_VTD
 extern bool untrusted_msi;
+#endif
 
 int pi_update_irte(const struct pi_desc *pi_desc, const struct pirq *pirq,
                    const uint8_t gvec);
xen/arch/x86/pv/hypercall.c +2 -0
index 2eedfbfae8..0e1b03904c 100644
@@ -193,8 +193,10 @@ void pv_ring1_init_hypercall_page(void *p)
 
 void do_entry_int82(struct cpu_user_regs *regs)
 {
+#ifdef CONFIG_INTEL_VTD
     if ( unlikely(untrusted_msi) )
         check_for_unexpected_msi((uint8_t)regs->entry_vector);
+#endif
 
     _pv_hypercall(regs, true /* compat */);
 }
xen/arch/x86/x86_64/entry.S +2 -0
index ae01285181..2e06c0a6c1 100644
@@ -406,11 +406,13 @@ ENTRY(int80_direct_trap)
 .Lint80_cr3_okay:
         sti
 
+#ifdef CONFIG_INTEL_VTD
         cmpb  $0,untrusted_msi(%rip)
 UNLIKELY_START(ne, msi_check)
         movl  $0x80,%edi
         call  check_for_unexpected_msi
 UNLIKELY_END(msi_check)
+#endif
 
         movq  STACK_CPUINFO_FIELD(current_vcpu)(%rbx), %rbx
 
Signature · 1 line
2.37.2
#19 lore raw

Re: [RFC 5/7] x86/iommu: the code addressing CVE-2011-1898 is VT-d specific

Quoted 7 lines · Xenia Ragiadakou

The variable untrusted_msi indicates whether the system is vulnerable to CVE-2011-1898. This vulnerablity is VT-d specific.
Place the code that addresses the issue under CONFIG_INTEL_VTD.

No functional change intended.

Actually, this variable is pretty bogus.  I think I'd like to delete it entirely.

There are systems with no IOMMU at all, and we certainly used to let PV Passthrough go ahead.  (Not sure we do any more.)

There are systems with DMA remapping only, but no interrupt remapping. These are known insecure.  I'm honestly not convinced that an ISR read and crash is useful when the user has already constructed an known-unsafe configuration, because a malicious guest in that case can still fully mess with dom0 by sending vectors other than 0x80 and 0x82.

In particular, this option does not get activated on AMD when the user elects to disable interrupt remapping, and I'm disinclined to wire it up in that case too.

~Andrew

P.S. It occurs to me that FRED obsoletes the need for this anyway, seeing as it does properly distinguish the source of an event.

#20 lore raw

Re: [RFC 5/7] x86/iommu: the code addressing CVE-2011-1898 is VT-d specific

Quoted 11 lines · Andrew Cooper
Quoted 7 lines · Xenia Ragiadakou

The variable untrusted_msi indicates whether the system is vulnerable to CVE-2011-1898. This vulnerablity is VT-d specific.
Place the code that addresses the issue under CONFIG_INTEL_VTD.

No functional change intended.

Actually, this variable is pretty bogus.  I think I'd like to delete it entirely.

Nevertheless, I don't think that it would be appropriate to be done as part of this series.

Quoted 18 lines

There are systems with no IOMMU at all, and we certainly used to let PV Passthrough go ahead.  (Not sure we do any more.)

There are systems with DMA remapping only, but no interrupt remapping. These are known insecure.  I'm honestly not convinced that an ISR read and crash is useful when the user has already constructed an known-unsafe configuration, because a malicious guest in that case can still fully mess with dom0 by sending vectors other than 0x80 and 0x82.

In particular, this option does not get activated on AMD when the user elects to disable interrupt remapping, and I'm disinclined to wire it up in that case too.

~Andrew

P.S. It occurs to me that FRED obsoletes the need for this anyway, seeing as it does properly distinguish the source of an event.

Signature · 1 line
Xenia
#21 lore raw

Re: [RFC 5/7] x86/iommu: the code addressing CVE-2011-1898 is VT-d specific

Quoted 7 lines · Xenia Ragiadakou
Quoted 5 lines · Andrew Cooper
Quoted 4 lines · Xenia Ragiadakou

The variable untrusted_msi indicates whether the system is vulnerable to CVE-2011-1898. This vulnerablity is VT-d specific.
Place the code that addresses the issue under CONFIG_INTEL_VTD.

Quoted 6 lines
Quoted 6 lines
Quoted 3 lines

No functional change intended.

Actually, this variable is pretty bogus.  I think I'd like to delete it entirely.

The important difference between Intel and AMD was that Intel initially supplied DMA-remap-only IOMMUs, while AMD had intremap from the beginning. Hence Intel hardware could be unsafe by default, whereas on AMD an admin would need to come and turn off intremap. Deleting the variable would be okay only if we declared Xen security-unsupported on inremap-less Intel hardware. Extending coverage to AMD wouldn't seem unreasonable to me, if we knew that there were people turning off intremap _and_ caring about this particular class of attack. With no-one having complained in over 10 years, perhaps there's no-one of this kind ...

Quoted 2 lines

Nevertheless, I don't think that it would be appropriate to be done as part of this series.

I agree, but I'll want to comment on v2 nevertheless, rather than simply ack-ing it.

Jan

#22 lore raw

RFC 6/7 x86/iommu: call pi_update_irte through an hvm_function callback

In reply to Xenia Ragiadakou

Posted interrupt support in Xen is currently implemented only for the Intel platforms. Instead of calling directly pi_update_irte() from the common hvm code, add a pi_update_irte callback to the hvm_function_table. Then, create a wrapper function hvm_pi_update_irte() to be used by the common hvm code.

In the pi_update_irte callback prototype, pass the vcpu as first parameter instead of the posted-interrupt descriptor that is platform specific, and remove the const qualifier from the parameter gvec since it is not needed and because it does not compile with the alternative code patching in use.

Move the declaration of pi_update_irte() from asm/iommu.h to asm/hvm/vmx/vmx.h since it is hvm and Intel specific.

No functional change intended.

---
 xen/arch/x86/hvm/vmx/vmx.c             | 10 ++++++++++
 xen/arch/x86/include/asm/hvm/hvm.h     | 22 ++++++++++++++++++++++
 xen/arch/x86/include/asm/hvm/vmx/vmx.h | 11 +++++++++++
 xen/arch/x86/include/asm/iommu.h       |  3 ---
 xen/drivers/passthrough/x86/hvm.c      |  5 ++---
 5 files changed, 45 insertions(+), 6 deletions(-)
xen/arch/x86/hvm/vmx/vmx.c +10 -0
index 7c81b80710..3080f1ef41 100644
@@ -2134,6 +2134,14 @@ static bool cf_check vmx_test_pir(const struct vcpu *v, uint8_t vec)
     return pi_test_pir(vec, &v->arch.hvm.vmx.pi_desc);
 }
 
+static int cf_check vmx_pi_update_irte(const struct vcpu *v,
+                                       const struct pirq *pirq, uint8_t gvec)
+{
+    const struct pi_desc *pi_desc = v ? &v->arch.hvm.vmx.pi_desc : NULL;
+
+    return pi_update_irte(pi_desc, pirq, gvec);
+}
+
 static void cf_check vmx_handle_eoi(uint8_t vector, int isr)
 {
     uint8_t old_svi = set_svi(isr);
@@ -2582,6 +2590,8 @@ static struct hvm_function_table __initdata_cf_clobber vmx_function_table = {
     .tsc_scaling = {
         .max_ratio = VMX_TSC_MULTIPLIER_MAX,
     },
+
+    .pi_update_irte = vmx_pi_update_irte,
 };
 
 /* Handle VT-d posted-interrupt when VCPU is blocked. */
xen/arch/x86/include/asm/hvm/hvm.h +22 -0
index 93254651f2..f16b9edeaf 100644
@@ -28,6 +28,8 @@
 #include <asm/x86_emulate.h>
 #include <asm/hvm/asid.h>
 
+struct pirq; /* needed by pi_update_irte */
+
 #ifdef CONFIG_HVM_FEP
 /* Permit use of the Forced Emulation Prefix in HVM guests */
 extern bool_t opt_hvm_fep;
@@ -250,6 +252,9 @@ struct hvm_function_table {
         /* Architecture function to setup TSC scaling ratio */
         void (*setup)(struct vcpu *v);
     } tsc_scaling;
+
+    int (*pi_update_irte)(const struct vcpu *v,
+                          const struct pirq *pirq, uint8_t gvec);
 };
 
 extern struct hvm_function_table hvm_funcs;
@@ -774,6 +779,16 @@ static inline void hvm_set_nonreg_state(struct vcpu *v,
         alternative_vcall(hvm_funcs.set_nonreg_state, v, nrs);
 }
 
+static inline int hvm_pi_update_irte(const struct vcpu *v,
+                                     const struct pirq *pirq, uint8_t gvec)
+{
+    if ( hvm_funcs.pi_update_irte )
+        return alternative_call(hvm_funcs.pi_update_irte, v, pirq, gvec);
+
+    return -EOPNOTSUPP;
+}
+
+
 #else  /* CONFIG_HVM */
 
 #define hvm_enabled false
@@ -893,6 +908,13 @@ static inline void hvm_set_reg(struct vcpu *v, unsigned int reg, uint64_t val)
     ASSERT_UNREACHABLE();
 }
 
+static inline int hvm_pi_update_irte(const struct vcpu *v,
+                                     const struct pirq *pirq, uint8_t gvec)
+{
+    ASSERT_UNREACHABLE();
+    return -EOPNOTSUPP;
+}
+
 #define is_viridian_domain(d) ((void)(d), false)
 #define is_viridian_vcpu(v) ((void)(v), false)
 #define has_viridian_time_ref_count(d) ((void)(d), false)
xen/arch/x86/include/asm/hvm/vmx/vmx.h +11 -0
index 8eedf59155..17f13e79a0 100644
@@ -155,6 +155,17 @@ static inline void pi_clear_sn(struct pi_desc *pi_desc)
     clear_bit(POSTED_INTR_SN, &pi_desc->control);
 }
 
+#ifdef CONFIG_INTEL_VTD
+int pi_update_irte(const struct pi_desc *pi_desc,
+                   const struct pirq *pirq, const uint8_t gvec);
+#else
+static inline int pi_update_irte(const struct pi_desc *pi_desc,
+                                 const struct pirq *pirq, const uint8_t gvec)
+{
+    return -EOPNOTSUPP;
+}
+#endif
+
 /*
  * Exit Reasons
  */
xen/arch/x86/include/asm/iommu.h +0 -3
index 41bd1b9e05..c433c75b76 100644
@@ -131,9 +131,6 @@ void iommu_identity_map_teardown(struct domain *d);
 extern bool untrusted_msi;
 #endif
 
-int pi_update_irte(const struct pi_desc *pi_desc, const struct pirq *pirq,
-                   const uint8_t gvec);
-
 extern bool iommu_non_coherent, iommu_superpages;
 
 static inline void iommu_sync_cache(const void *addr, unsigned int size)
xen/drivers/passthrough/x86/hvm.c +2 -3
index a16e0e5344..e720461a14 100644
@@ -381,8 +381,7 @@ int pt_irq_create_bind(
 
         /* Use interrupt posting if it is supported. */
         if ( iommu_intpost )
-            pi_update_irte(vcpu ? &vcpu->arch.hvm.vmx.pi_desc : NULL,
-                           info, pirq_dpci->gmsi.gvec);
+            hvm_pi_update_irte(vcpu, info, pirq_dpci->gmsi.gvec);
 
         if ( pt_irq_bind->u.msi.gflags & XEN_DOMCTL_VMSI_X86_UNMASKED )
         {
@@ -672,7 +671,7 @@ int pt_irq_destroy_bind(
             what = "bogus";
     }
     else if ( pirq_dpci && pirq_dpci->gmsi.posted )
-        pi_update_irte(NULL, pirq, 0);
+        hvm_pi_update_irte(NULL, pirq, 0);
 
     if ( pirq_dpci && (pirq_dpci->flags & HVM_IRQ_DPCI_MAPPED) &&
          list_empty(&pirq_dpci->digl_list) )
Signature · 1 line
2.37.2
#23 lore raw

Re: [RFC 6/7] x86/iommu: call pi_update_irte through an hvm_function callback

xen/arch/x86/include/asm/hvm/hvm.h static inline void hvm_set_nonreg_state(struct vcpu *v, · line 783

Quoted 6 lines · Xenia Ragiadakou
xen/arch/x86/include/asm/hvm/hvm.h +2 -0
@@ -774,6 +779,16 @@ static inline void hvm_set_nonreg_state(struct vcpu *v,
         alternative_vcall(hvm_funcs.set_nonreg_state, v, nrs);
 }
 
+static inline int hvm_pi_update_irte(const struct vcpu *v,
+                                     const struct pirq *pirq, uint8_t gvec)

Why "int" as return type when both call sites ignore the return value?

xen/arch/x86/include/asm/hvm/hvm.h static inline void hvm_set_reg(struct vcpu *v, unsigned int reg, uint64_t val) · line 916

Quoted 10 lines
xen/arch/x86/include/asm/hvm/hvm.h +6 -0
@@ -893,6 +908,13 @@ static inline void hvm_set_reg(struct vcpu *v, unsigned int reg, uint64_t val)
     ASSERT_UNREACHABLE();
 }
 
+static inline int hvm_pi_update_irte(const struct vcpu *v,
+                                     const struct pirq *pirq, uint8_t gvec)
+{
+    ASSERT_UNREACHABLE();
+    return -EOPNOTSUPP;
+}

I don't think you need this stub - both callers live in a file which is built only for HVM=y anyway.

Jan

#24 lore raw

Re: [RFC 6/7] x86/iommu: call pi_update_irte through an hvm_function callback

Quoted 9 lines · Jan Beulich

xen/arch/x86/include/asm/hvm/hvm.h static inline void hvm_set_nonreg_state(struct vcpu *v, · line 783

Quoted 6 lines · Xenia Ragiadakou
xen/arch/x86/include/asm/hvm/hvm.h +2 -0
@@ -774,6 +779,16 @@ static inline void hvm_set_nonreg_state(struct vcpu *v,
          alternative_vcall(hvm_funcs.set_nonreg_state, v, nrs);
  }
 
+static inline int hvm_pi_update_irte(const struct vcpu *v,
+                                     const struct pirq *pirq, uint8_t gvec)

Why "int" as return type when both call sites ignore the return value?

Because the original function returned int. I 'm not sure though why the returned value is ignored.

Quoted 5 lines
Quoted 5 lines
xen/arch/x86/include/asm/hvm/hvm.h +0 -0
@@ -893,6 +908,13 @@ static inline void hvm_set_reg(struct vcpu *v, unsigned int reg, uint64_t val)
      ASSERT_UNREACHABLE();
  }
 
Quoted 9 lines

xen/arch/x86/include/asm/hvm/hvm.h static inline void hvm_set_reg(struct vcpu *v, unsigned int reg, uint64_t val) · line 916

Quoted 6 lines
xen/arch/x86/include/asm/hvm/hvm.h +6 -0
+static inline int hvm_pi_update_irte(const struct vcpu *v,
+                                     const struct pirq *pirq, uint8_t gvec)
+{
+    ASSERT_UNREACHABLE();
+    return -EOPNOTSUPP;
+}

I don't think you need this stub - both callers live in a file which is built only for HVM=y anyway.

That's true. I will remove it.

Quoted 2 lines

Jan

Signature · 1 line
Xenia
#25 lore raw

Re: [RFC 6/7] x86/iommu: call pi_update_irte through an hvm_function callback

Quoted 7 lines · Xenia Ragiadakou
Quoted 5 lines · Jan Beulich
Quoted 4 lines · Xenia Ragiadakou
xen/arch/x86/include/asm/hvm/hvm.h +0 -0
@@ -774,6 +779,16 @@ static inline void hvm_set_nonreg_state(struct vcpu *v,
          alternative_vcall(hvm_funcs.set_nonreg_state, v, nrs);
  }
 
Quoted 6 lines
Quoted 4 lines

Review static inline void hvm_set_nonreg_state(struct vcpu *v, · line 783

Quoted 2 lines
(quoted diff) +2 -0
+static inline int hvm_pi_update_irte(const struct vcpu *v,
+                                     const struct pirq *pirq, uint8_t gvec)

Why "int" as return type when both call sites ignore the return value?

Because the original function returned int.

Hmm, indeed - looking more closely there can actually be errors, and those shouldn't really be ignored in all cases. At the very least an assertion would seem on order.

Quoted 1 line

I 'm not sure though why the returned value is ignored.

Kevin, thoughts?

Jan

#26 lore raw

RFC 7/7 x86/dpci: move hvm_dpci_isairq_eoi() to generic HVM code

In reply to Xenia Ragiadakou

The function hvm_dpci_isairq_eoi() has no dependencies on VT-d driver code and can be moved from xen/drivers/passthrough/vtd/x86/hvm.c to xen/drivers/passthrough/x86/hvm.c.

Remove the now empty xen/drivers/passthrough/vtd/x86/hvm.c.

Since the funcion is hvm specific, move its declaration from xen/iommu.h to asm/hvm/io.h.

No functional change intended.

---

I was not sure how to handle the copyright. I assume that I have to retain the copyright of Weidong Han <[email protected]>, right?

 xen/arch/x86/include/asm/hvm/io.h        |  1 +
 xen/drivers/passthrough/vtd/x86/Makefile |  1 -
 xen/drivers/passthrough/vtd/x86/hvm.c    | 64 ------------------------
 xen/drivers/passthrough/x86/hvm.c        | 42 ++++++++++++++++
 xen/include/xen/iommu.h                  |  1 -
 5 files changed, 43 insertions(+), 66 deletions(-)
 delete mode 100644 xen/drivers/passthrough/vtd/x86/hvm.c
xen/arch/x86/include/asm/hvm/io.h +1 -0
index 54e0161b49..5e1071b798 100644
@@ -102,6 +102,7 @@ bool handle_mmio_with_translation(unsigned long gla, unsigned long gpfn,
 bool handle_pio(uint16_t port, unsigned int size, int dir);
 void hvm_interrupt_post(struct vcpu *v, int vector, int type);
 void hvm_dpci_eoi(struct domain *d, unsigned int guest_irq);
+void hvm_dpci_isairq_eoi(struct domain *d, unsigned int isairq);
 void msix_write_completion(struct vcpu *);
 
 #ifdef CONFIG_HVM
xen/drivers/passthrough/vtd/x86/Makefile +0 -1
index 4ef00a4c5b..fe20a0b019 100644
@@ -1,3 +1,2 @@
 obj-y += ats.o
-obj-$(CONFIG_HVM) += hvm.o
 obj-y += vtd.o
xen/drivers/passthrough/vtd/x86/hvm.c deleted +0 -64

64 lines not on this page · raw message

xen/drivers/passthrough/x86/hvm.c +42 -0

48 lines not on this page · raw message

xen/include/xen/iommu.h +0 -1
index d9285a7760..b9e1288de8 100644
@@ -202,7 +202,6 @@ int hvm_do_IRQ_dpci(struct domain *, struct pirq *);
 int pt_irq_create_bind(struct domain *, const struct xen_domctl_bind_pt_irq *);
 int pt_irq_destroy_bind(struct domain *, const struct xen_domctl_bind_pt_irq *);
 
-void hvm_dpci_isairq_eoi(struct domain *d, unsigned int isairq);
 struct hvm_irq_dpci *domain_get_irq_dpci(const struct domain *);
 void free_hvm_irq_dpci(struct hvm_irq_dpci *dpci);
 
Signature · 1 line
2.37.2
#27 lore raw

Re: [RFC 7/7] x86/dpci: move hvm_dpci_isairq_eoi() to generic HVM code

Quoted 8 lines · Xenia Ragiadakou

The function hvm_dpci_isairq_eoi() has no dependencies on VT-d driver code and can be moved from xen/drivers/passthrough/vtd/x86/hvm.c to xen/drivers/passthrough/x86/hvm.c.

Remove the now empty xen/drivers/passthrough/vtd/x86/hvm.c.

Since the funcion is hvm specific, move its declaration from xen/iommu.h to asm/hvm/io.h.

While everything else looks good here, I question this part: The function is both HVM- and IOMMU-specific. However, by moving the definition ...

Quoted 5 lines

No functional change intended.

---

Quoted 7 lines

I was not sure how to handle the copyright. I assume that I have to retain the copyright of Weidong Han <[email protected]>, right?

 xen/arch/x86/include/asm/hvm/io.h        |  1 +
 xen/drivers/passthrough/vtd/x86/Makefile |  1 -
 xen/drivers/passthrough/vtd/x86/hvm.c    | 64 ------------------------
 xen/drivers/passthrough/x86/hvm.c        | 42 ++++++++++++++++

... here, you don't need a declaration anymore anyway - the function can simply become static then, as its only caller lives in this very file.

Jan

#28 lore raw

Re: [RFC 7/7] x86/dpci: move hvm_dpci_isairq_eoi() to generic HVM code

Quoted 21 lines · Jan Beulich
Quoted 8 lines · Xenia Ragiadakou

The function hvm_dpci_isairq_eoi() has no dependencies on VT-d driver code and can be moved from xen/drivers/passthrough/vtd/x86/hvm.c to xen/drivers/passthrough/x86/hvm.c.

Remove the now empty xen/drivers/passthrough/vtd/x86/hvm.c.

Since the funcion is hvm specific, move its declaration from xen/iommu.h to asm/hvm/io.h.

While everything else looks good here, I question this part: The function is both HVM- and IOMMU-specific. However, by moving the definition ...

Quoted 8 lines

No functional change intended.

---

I was not sure how to handle the copyright. I assume that I have to retain the copyright of Weidong Han <[email protected]>, right?

Quoted 7 lines
Quoted 4 lines
  xen/arch/x86/include/asm/hvm/io.h        |  1 +
  xen/drivers/passthrough/vtd/x86/Makefile |  1 -
  xen/drivers/passthrough/vtd/x86/hvm.c    | 64 ------------------------
  xen/drivers/passthrough/x86/hvm.c        | 42 ++++++++++++++++

... here, you don't need a declaration anymore anyway - the function can simply become static then, as its only caller lives in this very file.

I will change it to static.

Regarding the copyright, shall I add the copyright of Weidong Han <[email protected]>, that was in the deleted file?

Quoted 2 lines

Jan

Signature · 1 line
Xenia
#29 lore raw

Re: [RFC 7/7] x86/dpci: move hvm_dpci_isairq_eoi() to generic HVM code

Quoted 28 lines · Xenia Ragiadakou
Quoted 26 lines · Jan Beulich
Quoted 8 lines · Xenia Ragiadakou

The function hvm_dpci_isairq_eoi() has no dependencies on VT-d driver code and can be moved from xen/drivers/passthrough/vtd/x86/hvm.c to xen/drivers/passthrough/x86/hvm.c.

Remove the now empty xen/drivers/passthrough/vtd/x86/hvm.c.

Since the funcion is hvm specific, move its declaration from xen/iommu.h to asm/hvm/io.h.

While everything else looks good here, I question this part: The function is both HVM- and IOMMU-specific. However, by moving the definition ...

Quoted 12 lines

No functional change intended.

---

I was not sure how to handle the copyright. I assume that I have to retain the copyright of Weidong Han <[email protected]>, right?

  xen/arch/x86/include/asm/hvm/io.h        |  1 +
  xen/drivers/passthrough/vtd/x86/Makefile |  1 -
  xen/drivers/passthrough/vtd/x86/hvm.c    | 64 ------------------------
  xen/drivers/passthrough/x86/hvm.c        | 42 ++++++++++++++++
Quoted 7 lines
Quoted 2 lines

... here, you don't need a declaration anymore anyway - the function can simply become static then, as its only caller lives in this very file.

I will change it to static.

Regarding the copyright, shall I add the copyright of Weidong Han <[email protected]>, that was in the deleted file?

Strictly speaking you probably ought to, yes.

Jan

#30 lore raw
In reply to Xenia Ragiadakou
Quoted 11 lines · Xenia Ragiadakou

This series aims to provide a means to render the iommu driver support for x86 configurable. Currently, irrespectively of the target platform, both AMD and Intel iommu drivers are built. This is the case because the existent Kconfig infrastructure does not provide any facilities for finer-grained configuration.

The series adds two new Kconfig options, AMD_IOMMU and INTEL_VTD, that can be used to generate a tailored iommu configuration for a given platform.

This series will be part of a broader effort to separate platform specific code and it is sent as an RFC to gather feedback regarding the way the separation should be performed.

Hello,

Thanks for the series.

From discussions in the past, we do want CONFIG_INTEL/AMD/etc and we do want these to be selectable and available for randconfig to test.

Some sub-features are more complicated, because e.g. Centaur have CPUs with a VT-x implementation.  This will need expressing in whatever Kconfig scheme we end up with.

IOMMUs are more tricky still.  They are (for most intents and purposes) mandatory on systems with >254 CPUs.  We could in principle start supporting asymmetric IRQ routing on large systems, but Xen doesn't currently and it would be a lot work that's definitely not high on the priority list.  At a minimum, this will need expressing in the Kconfig help text.

We need to decide whether it is sensible to allow users to turn off IOMMU support.  It probably is, because you could trivially do this by selecting CONFIG_INTEL only, and booting the result on an AMD system.

For the names, I don't think AMD_IOMMU vs INTEL_VTD is a sensible. Probably wants to be INTEL_IOMMU to match.

~Andrew

#31 lore raw
Quoted 10 lines · Andrew Cooper

IOMMUs are more tricky still.  They are (for most intents and purposes) mandatory on systems with >254 CPUs.  We could in principle start supporting asymmetric IRQ routing on large systems, but Xen doesn't currently and it would be a lot work that's definitely not high on the priority list.  At a minimum, this will need expressing in the Kconfig help text.

We need to decide whether it is sensible to allow users to turn off IOMMU support.  It probably is, because you could trivially do this by selecting CONFIG_INTEL only, and booting the result on an AMD system.

One other thing Andrew and I have been talking about: We probably do not want to tie the IOMMU vendor control to CPU vendor one. IOW we'd like to be able to e.g. build a hypervisor supporting Intel (only) as the CPU vendor, but at the same time having support for an AMD IOMMU.

Quoted 2 lines

For the names, I don't think AMD_IOMMU vs INTEL_VTD is a sensible. Probably wants to be INTEL_IOMMU to match.

Or simply VTD, covering the case than some other vendor comes up with a clone. But of course we have that same issue with "AMD" and Hygon ...

Jan

#32 lore raw
Quoted 8 lines · Jan Beulich
Quoted 7 lines · Andrew Cooper

IOMMUs are more tricky still.  They are (for most intents and purposes) mandatory on systems with >254 CPUs.  We could in principle start supporting asymmetric IRQ routing on large systems, but Xen doesn't currently and it would be a lot work that's definitely not high on the priority list.  At a minimum, this will need expressing in the Kconfig help text.

Quoted 9 lines
Quoted 3 lines

We need to decide whether it is sensible to allow users to turn off IOMMU support.  It probably is, because you could trivially do this by selecting CONFIG_INTEL only, and booting the result on an AMD system.

One other thing Andrew and I have been talking about: We probably do not want to tie the IOMMU vendor control to CPU vendor one. IOW we'd like to be able to e.g. build a hypervisor supporting Intel (only) as the CPU vendor, but at the same time having support for an AMD IOMMU.

I totally understand. I am not aiming to tie the AMD/INTEL IOMMU support to any particular CPU vendor.

Quoted 6 lines
Quoted 2 lines

For the names, I don't think AMD_IOMMU vs INTEL_VTD is a sensible. Probably wants to be INTEL_IOMMU to match.

Or simply VTD, covering the case than some other vendor comes up with a clone. But of course we have that same issue with "AMD" and Hygon ...

I prefer INTEL_IOMMU over VTD, I think.

Quoted 1 line

Jan

Signature · 1 line
Xenia
#33 lore raw
In reply to Andrew Cooper

Hi,

Quoted 15 lines · Andrew Cooper
Quoted 11 lines · Xenia Ragiadakou

This series aims to provide a means to render the iommu driver support for x86 configurable. Currently, irrespectively of the target platform, both AMD and Intel iommu drivers are built. This is the case because the existent Kconfig infrastructure does not provide any facilities for finer-grained configuration.

The series adds two new Kconfig options, AMD_IOMMU and INTEL_VTD, that can be used to generate a tailored iommu configuration for a given platform.

This series will be part of a broader effort to separate platform specific code and it is sent as an RFC to gather feedback regarding the way the separation should be performed.

Hello,

Quoted 9 lines

Thanks for the series.

From discussions in the past, we do want CONFIG_INTEL/AMD/etc and we do
want these to be selectable and available for randconfig to test.

Some sub-features are more complicated, because e.g. Centaur have CPUs with a VT-x implementation.  This will need expressing in whatever Kconfig scheme we end up with.

What about having configuration per cpu vendor, per virtualization technology and per IOMMU technology? I mean sth like [CPU_AMD, CPU_HYGON, CPU_INTEL, CPU_SHANGHAI, CPU_CENTAUR], [AMD_SVM, INTEL_VMX] and [AMD_IOMMU, INTEL_IOMMU], respectively?

Quoted 7 lines

IOMMUs are more tricky still.  They are (for most intents and purposes) mandatory on systems with >254 CPUs.  We could in principle start supporting asymmetric IRQ routing on large systems, but Xen doesn't currently and it would be a lot work that's definitely not high on the priority list.  At a minimum, this will need expressing in the Kconfig help text.

Ok.

Quoted 4 lines

We need to decide whether it is sensible to allow users to turn off IOMMU support.  It probably is, because you could trivially do this by selecting CONFIG_INTEL only, and booting the result on an AMD system.

I cannot understand. I guess that if the code for the target system is disabled, Xen won't boot ... hopefully :).

If users are not allowed to turn off the IOMMU support, it can be always enabled unconditionally via Kconfig select based on the virtualization technology or other.

Quoted 4 lines

For the names, I don't think AMD_IOMMU vs INTEL_VTD is a sensible. Probably wants to be INTEL_IOMMU to match.

Ok.

Quoted 1 line

~Andrew

Signature · 1 line
Xenia
#34 lore raw
Quoted 11 lines · Xenia Ragiadakou
Quoted 4 lines

We need to decide whether it is sensible to allow users to turn off IOMMU support.  It probably is, because you could trivially do this by selecting CONFIG_INTEL only, and booting the result on an AMD system.

I cannot understand. I guess that if the code for the target system is disabled, Xen won't boot ... hopefully :).

If users are not allowed to turn off the IOMMU support, it can be always enabled unconditionally via Kconfig select based on the virtualization technology or other.

Just wanted to say that it should be fine either way. If we don't want to provide an option to disable the IOMMU, then it could be handled at the kconfig level.