Skip to contentSkip to conversation

xen_pt: Present the size of 64 bit BARs correctly

PATCH In review Ross Lagerwall 2 participants 2 messages May 14, 2018 – May 17, 2018

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 xen_pt: Present the size of 64 bit BARs correctly

The full size of the BAR is stored in the lower PCIIORegion.size. The upper PCIIORegion.size is 0. Calculate the size of the upper half correctly from the lower half otherwise the size read by the guest will be incorrect.

---
 hw/xen/xen_pt_config_init.c | 2 ++
 1 file changed, 2 insertions(+)
hw/xen/xen_pt_config_init.c +2 -0
index a3ce33e..aee31c6 100644
@@ -504,6 +504,8 @@ static int xen_pt_bar_reg_write(XenPCIPassthroughState *s, XenPTReg *cfg_entry,
         bar_ro_mask = XEN_PT_BAR_IO_RO_MASK | (r_size - 1);
         break;
     case XEN_PT_BAR_FLAG_UPPER:
+        assert(index > 0);
+        r_size = d->io_regions[index - 1].size >> 32;
         bar_emu_mask = XEN_PT_BAR_ALLF;
         bar_ro_mask = r_size ? r_size - 1 : 0;
         break;
Signature · 7 lines
2.9.5


_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
Acked-by on v1 1/1
#1 lore raw
Quoted 6 lines · Ross Lagerwall

The full size of the BAR is stored in the lower PCIIORegion.size. The upper PCIIORegion.size is 0. Calculate the size of the upper half correctly from the lower half otherwise the size read by the guest will be incorrect.

Quoted 17 lines
---
 hw/xen/xen_pt_config_init.c | 2 ++
 1 file changed, 2 insertions(+)
hw/xen/xen_pt_config_init.c +2 -0
index a3ce33e..aee31c6 100644
@@ -504,6 +504,8 @@ static int xen_pt_bar_reg_write(XenPCIPassthroughState *s, XenPTReg *cfg_entry,
         bar_ro_mask = XEN_PT_BAR_IO_RO_MASK | (r_size - 1);
         break;
     case XEN_PT_BAR_FLAG_UPPER:
+        assert(index > 0);
+        r_size = d->io_regions[index - 1].size >> 32;
         bar_emu_mask = XEN_PT_BAR_ALLF;
         bar_ro_mask = r_size ? r_size - 1 : 0;
         break;
Signature · 6 lines
Anthony PERARD

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel