Skip to contentSkip to conversation

x86/iommu: adjust type in arch_iommu_hwdom_init()

PATCH In review Roger Pau Monne 2 participants 2 messages May 24, 2023

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 x86/iommu: adjust type in arch_iommu_hwdom_init()

The 'i' iterator index stores a PDX, not a PFN, and hence the initial assignation of start (which stores a PFN) needs a conversion from PFN to PDX.

This is harmless currently, as the PDX compression skips the bottom MAX_ORDER bits which cover the low 1MB, but still do the conversion from PDX to PFN for type correctness.

---
Changes since v1:
- Soften the description as it's not an error.

---
 xen/drivers/passthrough/x86/iommu.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
xen/drivers/passthrough/x86/iommu.c +1 -1
index cb0788960a08..6bc79e7ec843 100644
@@ -406,7 +406,7 @@ void __hwdom_init arch_iommu_hwdom_init(struct domain *d)
      */
     start = paging_mode_translate(d) ? PFN_DOWN(MB(1)) : 0;
 
-    for ( i = start, count = 0; i < top; )
+    for ( i = pfn_to_pdx(start), count = 0; i < top; )
     {
         unsigned long pfn = pdx_to_pfn(i);
         unsigned int perms = hwdom_iommu_map(d, pfn, max_pfn);
Signature · 1 line
2.40.0
Acked-by on v2 1/1
#1 lore raw
Quoted 9 lines · Roger Pau Monne

The 'i' iterator index stores a PDX, not a PFN, and hence the initial assignation of start (which stores a PFN) needs a conversion from PFN to PDX.

This is harmless currently, as the PDX compression skips the bottom MAX_ORDER bits which cover the low 1MB, but still do the conversion from PDX to PFN for type correctness.