Skip to contentSkip to conversation

AMD/guest_iommu: Disable guest iommu support

PATCH In review Andrew Cooper 4 participants 7 messages Oct 2, 2014 – Oct 6, 2014

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 AMD/guest_iommu: Disable guest iommu support

AMD Guest IOMMU support was added to allow correct use of PASID and PRI hardware support with an ATS-aware guest driver.

However, support cannot possibly function as guest_iommu_set_base() has no callers. This means that its MMIO region's P2M pages are not set to p2m_mmio_dm, preventing any invocation of the MMIO read/write handlers.

c/s fd186384 "x86/HVM: extend LAPIC shortcuts around P2M lookups" introduces a path (via hvm_mmio_internal()) where iommu_mmio_handler claims its MMIO range, and causes __hvm_copy() to fail with HVMCOPY_bad_gfn_to_mfn.

iommu->mmio_base defaults to 0, with a range of 8 pages, and is unilaterally enabled in any HVM guests when the host IOMMU(s) supports any extended features.

Unfortunately, HVMLoader's AP boot trampoline executes an lmsw instruction at linear address 0x100c which unconditionally requires emulation. The instruction fetch in turn fails as __hvm_copy() fails with HVMCOPY_bad_gfn_to_mfn.

The result is that multi-vcpu HVM guests do not work on newer AMD hardware, if IOMMU support is enabled in the BIOS.

Change the default mmio_base address to ~0ULL. This prevents guest_iommu_mmio_range() from actually claiming any physical range whatsoever, which allows the emulation of lmsw to succeed.

---
 xen/drivers/passthrough/amd/iommu_guest.c |    1 +
 1 file changed, 1 insertion(+)
xen/drivers/passthrough/amd/iommu_guest.c +1 -0
index 5660020..98e7b38 100644
@@ -885,6 +885,7 @@ int guest_iommu_init(struct domain* d)
     }
 
     guest_iommu_reg_init(iommu);
+    iommu->mmio_base = ~0ULL;
     iommu->domain = d;
     hd->arch.g_iommu = iommu;
 
Signature · 1 line
1.7.10.4
#1 lore raw
Quoted 27 lines · Andrew Cooper

AMD Guest IOMMU support was added to allow correct use of PASID and PRI hardware support with an ATS-aware guest driver.

However, support cannot possibly function as guest_iommu_set_base() has no callers. This means that its MMIO region's P2M pages are not set to p2m_mmio_dm, preventing any invocation of the MMIO read/write handlers.

c/s fd186384 "x86/HVM: extend LAPIC shortcuts around P2M lookups" introduces a path (via hvm_mmio_internal()) where iommu_mmio_handler claims its MMIO range, and causes __hvm_copy() to fail with HVMCOPY_bad_gfn_to_mfn.

iommu->mmio_base defaults to 0, with a range of 8 pages, and is unilaterally enabled in any HVM guests when the host IOMMU(s) supports any extended features.

Unfortunately, HVMLoader's AP boot trampoline executes an lmsw instruction at linear address 0x100c which unconditionally requires emulation. The instruction fetch in turn fails as __hvm_copy() fails with HVMCOPY_bad_gfn_to_mfn.

The result is that multi-vcpu HVM guests do not work on newer AMD hardware, if IOMMU support is enabled in the BIOS.

Change the default mmio_base address to ~0ULL. This prevents guest_iommu_mmio_range() from actually claiming any physical range whatsoever, which allows the emulation of lmsw to succeed.

Quoted 7 lines

---

I forgot to explicitly indicate, but this is a bugfix and is therefore intended for inclusion in 4.5

~Andrew

#2 lore raw
Quoted 3 lines
Quoted 1 line
Quoted 1 line · On 02.10.14 at 16:08, <[email protected]> wrote:

I forgot to explicitly indicate, but this is a bugfix and is therefore intended for inclusion in 4.5

And I continue to think that this also isn't necessary until pretty late in the release process. We really need this indication for late features coming in.

Jan

#3 lore raw
Quoted 7 lines · Jan Beulich
Quoted 3 lines
Quoted 1 line
Quoted 1 line · On 02.10.14 at 16:08, <[email protected]> wrote:

I forgot to explicitly indicate, but this is a bugfix and is therefore intended for inclusion in 4.5

And I continue to think that this also isn't necessary until pretty late in the release process. We really need this indication for late features coming in.

I am OK with bugfixes being added in before RC0 without having to rubber-stamp them (as surely the maintainers know best whether the bug-fix should go in or not).

But after RC0 I believe it makes sense to take a step to figure out the regression factor (if any).

Quoted 8 lines

Jan

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel

Acked-by on v1 1/1
#4 lore raw
In reply to Andrew Cooper
Quoted 43 lines · Andrew Cooper

AMD Guest IOMMU support was added to allow correct use of PASID and PRI hardware support with an ATS-aware guest driver.

However, support cannot possibly function as guest_iommu_set_base() has no callers. This means that its MMIO region's P2M pages are not set to p2m_mmio_dm, preventing any invocation of the MMIO read/write handlers.

c/s fd186384 "x86/HVM: extend LAPIC shortcuts around P2M lookups" introduces a path (via hvm_mmio_internal()) where iommu_mmio_handler claims its MMIO range, and causes __hvm_copy() to fail with HVMCOPY_bad_gfn_to_mfn.

iommu->mmio_base defaults to 0, with a range of 8 pages, and is unilaterally enabled in any HVM guests when the host IOMMU(s) supports any extended features.

Unfortunately, HVMLoader's AP boot trampoline executes an lmsw instruction at linear address 0x100c which unconditionally requires emulation. The instruction fetch in turn fails as __hvm_copy() fails with HVMCOPY_bad_gfn_to_mfn.

The result is that multi-vcpu HVM guests do not work on newer AMD hardware, if IOMMU support is enabled in the BIOS.

Change the default mmio_base address to ~0ULL. This prevents guest_iommu_mmio_range() from actually claiming any physical range whatsoever, which allows the emulation of lmsw to succeed.

---
  xen/drivers/passthrough/amd/iommu_guest.c |    1 +
  1 file changed, 1 insertion(+)
xen/drivers/passthrough/amd/iommu_guest.c +0 -0
index 5660020..98e7b38 100644

xen/drivers/passthrough/amd/iommu_guest.c int guest_iommu_init(struct domain* d) · line 891

Quoted 7 lines
xen/drivers/passthrough/amd/iommu_guest.c +1 -0
@@ -885,6 +885,7 @@ int guest_iommu_init(struct domain* d)
      }
 
      guest_iommu_reg_init(iommu);
+    iommu->mmio_base = ~0ULL;
      iommu->domain = d;
      hd->arch.g_iommu = iommu;
 

Thank you, Andrew.

Jan,

The function guest_iommu_set_base() was added by Wei before my time. I checked the log and didn't see the evidence that this code has ever been used. Do you remember why he added this code to begin with, and how this was planned to be used?

Suravee

#5 lore raw
Quoted 5 lines
Quoted 1 line
Quoted 1 line · On 06.10.14 at 08:46, <[email protected]> wrote:

The function guest_iommu_set_base() was added by Wei before my time. I checked the log and didn't see the evidence that this code has ever been used. Do you remember why he added this code to begin with, and how this was planned to be used?

The plan here clearly was to allow guests to see a virtual IOMMU, and the setting of the respective base address would then be a requirement for tool stack and/or virtual firmware to set up the environment for the guest.

Jan

#6 lore raw
Quoted 5 lines · Jan Beulich
Quoted 5 lines
Quoted 1 line
Quoted 1 line · On 06.10.14 at 08:46, <[email protected]> wrote:

The function guest_iommu_set_base() was added by Wei before my time. I checked the log and didn't see the evidence that this code has ever been used. Do you remember why he added this code to begin with, and how this was planned to be used?

Quoted 7 lines

The plan here clearly was to allow guests to see a virtual IOMMU, and the setting of the respective base address would then be a requirement for tool stack and/or virtual firmware to set up the environment for the guest.

Jan

The commit which introduces the virtual IOMMU (c/s 4547137c3) indicates that a virtual IOMMU is necessary for correct functioning of ATS-capable guest device drivers using PASID or PRI, in passthrough.

~Andrew