Skip to contentSkip to conversation

x86/vtd: relax EPT page table sharing check

PATCH In review Roger Pau Monne 3 participants 3 messages Apr 17, 2020 – Apr 20, 2020

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 x86/vtd: relax EPT page table sharing check

The EPT page tables can be shared with the IOMMU as long as the page sizes supported by EPT are also supported by the IOMMU.

Current code checks that both the IOMMU and EPT support the same page sizes, but this is not strictly required, the IOMMU supporting more page sizes than EPT is fine and shouldn't block page table sharing.

This is likely not a common case (IOMMU supporting more page sizes than EPT), but should still be fixed for correctness.

---
Cc: Jan Beulich <[email protected]>
---
Changes since v1:
- Use <= to compare caps.
- Reword subject/commit message.

---
 xen/drivers/passthrough/vtd/iommu.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
xen/drivers/passthrough/vtd/iommu.c +2 -2
index 07d40b37fe..208b33c0e4 100644
@@ -1914,8 +1914,8 @@ static int __init vtd_ept_page_compatible(struct vtd_iommu *iommu)
     if ( rdmsr_safe(MSR_IA32_VMX_EPT_VPID_CAP, ept_cap) != 0 ) 
         return 0;
 
-    return (ept_has_2mb(ept_cap) && opt_hap_2mb) == cap_sps_2mb(vtd_cap) &&
-           (ept_has_1gb(ept_cap) && opt_hap_1gb) == cap_sps_1gb(vtd_cap);
+    return (ept_has_2mb(ept_cap) && opt_hap_2mb) <= cap_sps_2mb(vtd_cap) &&
+           (ept_has_1gb(ept_cap) && opt_hap_1gb) <= cap_sps_1gb(vtd_cap);
 }
 
 /*
Signature · 1 line
2.26.0
Reviewed-by on v1 1/1
#1 lore raw
Quoted 11 lines · Roger Pau Monne

The EPT page tables can be shared with the IOMMU as long as the page sizes supported by EPT are also supported by the IOMMU.

Current code checks that both the IOMMU and EPT support the same page sizes, but this is not strictly required, the IOMMU supporting more page sizes than EPT is fine and shouldn't block page table sharing.

This is likely not a common case (IOMMU supporting more page sizes than EPT), but should still be fixed for correctness.

Reviewed-by on v1 1/1
#2 lore raw
In reply to Roger Pau Monne
Quoted 6 lines

From: Roger Pau Monne <[email protected]>
Sent: Friday, April 17, 2020 7:30 PM

The EPT page tables can be shared with the IOMMU as long as the page sizes supported by EPT are also supported by the IOMMU.

Quoted 8 lines

Current code checks that both the IOMMU and EPT support the same page sizes, but this is not strictly required, the IOMMU supporting more page sizes than EPT is fine and shouldn't block page table sharing.

This is likely not a common case (IOMMU supporting more page sizes than EPT), but should still be fixed for correctness.