[Qemu-devel] [PATCH] xen_pt: Present the size of 64 bit BARs correctly

Ross Lagerwall posted 1 patch 7 years, 5 months ago
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/qemu tags/patchew/20180514095746.5058-1-ross.lagerwall@citrix.com
Test checkpatch passed
Test docker-mingw@fedora passed
Test docker-quick@centos7 passed
Test s390x passed
hw/xen/xen_pt_config_init.c | 2 ++
1 file changed, 2 insertions(+)
[Qemu-devel] [PATCH] xen_pt: Present the size of 64 bit BARs correctly
Posted by Ross Lagerwall 7 years, 5 months ago
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.

Signed-off-by: Ross Lagerwall <ross.lagerwall@citrix.com>
---
 hw/xen/xen_pt_config_init.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/hw/xen/xen_pt_config_init.c b/hw/xen/xen_pt_config_init.c
index a3ce33e..aee31c6 100644
--- a/hw/xen/xen_pt_config_init.c
+++ b/hw/xen/xen_pt_config_init.c
@@ -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;
-- 
2.9.5


Re: [Qemu-devel] [PATCH] xen_pt: Present the size of 64 bit BARs correctly
Posted by Anthony PERARD 7 years, 5 months ago
On Mon, May 14, 2018 at 10:57:46AM +0100, Ross Lagerwall wrote:
> 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.
> 
> Signed-off-by: Ross Lagerwall <ross.lagerwall@citrix.com>

Acked-by: Anthony PERARD <anthony.perard@citrix.com>

> ---
>  hw/xen/xen_pt_config_init.c | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/hw/xen/xen_pt_config_init.c b/hw/xen/xen_pt_config_init.c
> index a3ce33e..aee31c6 100644
> --- a/hw/xen/xen_pt_config_init.c
> +++ b/hw/xen/xen_pt_config_init.c
> @@ -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;


-- 
Anthony PERARD