diff mbox

hw/pt-graphics.c: Gave guest iomem permission for host opregion in qemu-xen-traditional

Message ID 1498536770-23566-1-git-send-email-xiong.y.zhang@intel.com (mailing list archive)
State New, archived
Headers show

Commit Message

Zhang, Xiong Y June 27, 2017, 4:12 a.m. UTC
Currently guest couldn't access host opregion when igd is passed through
to guest with qemu-xen-traditional. Because guest lack of
iomem permission to map guest allocated opregion pages to host opregion
pages.

So guest should get iomem permission for host opregion before mapping.

Signed-off-by: Xiong Zhang <xiong.y.zhang@intel.com>
---
 hw/pt-graphics.c | 12 +++++++++++-
 1 file changed, 11 insertions(+), 1 deletion(-)

Comments

Pasi Kärkkäinen July 10, 2017, 2:59 p.m. UTC | #1
Hi,

Perhaps Anthony can review this patch (noticing you reviewed other igd related patches recently..) ? 


Thanks,

-- Pasi

On Tue, Jun 27, 2017 at 12:12:50PM +0800, Xiong Zhang wrote:
> Currently guest couldn't access host opregion when igd is passed through
> to guest with qemu-xen-traditional. Because guest lack of
> iomem permission to map guest allocated opregion pages to host opregion
> pages.
> 
> So guest should get iomem permission for host opregion before mapping.
> 
> Signed-off-by: Xiong Zhang <xiong.y.zhang@intel.com>
> ---
>  hw/pt-graphics.c | 12 +++++++++++-
>  1 file changed, 11 insertions(+), 1 deletion(-)
> 
> diff --git a/hw/pt-graphics.c b/hw/pt-graphics.c
> index 7302b25..893bf12 100644
> --- a/hw/pt-graphics.c
> +++ b/hw/pt-graphics.c
> @@ -78,10 +78,20 @@ void igd_write_opregion(struct pt_dev *real_dev, uint32_t val)
>      igd_guest_opregion = (val & ~0xfff) | (host_opregion & 0xfff);
>      PT_LOG("Map OpRegion: %x -> %x\n", host_opregion, igd_guest_opregion);
>  
> +    ret = xc_domain_iomem_permission(xc_handle, domid,
> +            host_opregion >> XC_PAGE_SHIFT, 3, 1);
> +    if (ret)
> +    {
> +        PT_LOG("Error[%d]: Can't enable to access IGD host opregion: 0x%x\n",
> +                ret, host_opregion >> XC_PAGE_SHIFT);
> +        igd_guest_opregion = 0;
> +        return;
> +    }
> +
>      ret = xc_domain_memory_mapping(xc_handle, domid,
>              igd_guest_opregion >> XC_PAGE_SHIFT,
>              host_opregion >> XC_PAGE_SHIFT,
> -            2,
> +            3,
>              DPCI_ADD_MAPPING);
>  
>      if ( ret != 0 )
> -- 
> 2.7.4
> 
> 
> _______________________________________________
> Xen-devel mailing list
> Xen-devel@lists.xen.org
> https://lists.xen.org/xen-devel
Zhang, Xiong Y July 11, 2017, 1:45 a.m. UTC | #2
Actually, qemu-xen has done this in igd_write_opregion() of hw/xen/xen_pt_graphics.c, while qemu-xen-traditional lack of this, so I send this patch to fix it.

thanks
> -----Original Message-----
> From: Pasi Kärkkäinen [mailto:pasik@iki.fi]
> Sent: Monday, July 10, 2017 11:00 PM
> To: Anthony PERARD <anthony.perard@citrix.com>
> Cc: xen-devel@lists.xensource.com; ian.jackson@eu.citrix.com; Zhang, Xiong Y
> <xiong.y.zhang@intel.com>
> Subject: Re: [Xen-devel] [PATCH] hw/pt-graphics.c: Gave guest iomem
> permission for host opregion in qemu-xen-traditional
> 
> Hi,
> 
> Perhaps Anthony can review this patch (noticing you reviewed other igd
> related patches recently..) ?
> 
> 
> Thanks,
> 
> -- Pasi
> 
> On Tue, Jun 27, 2017 at 12:12:50PM +0800, Xiong Zhang wrote:
> > Currently guest couldn't access host opregion when igd is passed through
> > to guest with qemu-xen-traditional. Because guest lack of
> > iomem permission to map guest allocated opregion pages to host opregion
> > pages.
> >
> > So guest should get iomem permission for host opregion before mapping.
> >
> > Signed-off-by: Xiong Zhang <xiong.y.zhang@intel.com>
> > ---
> >  hw/pt-graphics.c | 12 +++++++++++-
> >  1 file changed, 11 insertions(+), 1 deletion(-)
> >
> > diff --git a/hw/pt-graphics.c b/hw/pt-graphics.c
> > index 7302b25..893bf12 100644
> > --- a/hw/pt-graphics.c
> > +++ b/hw/pt-graphics.c
> > @@ -78,10 +78,20 @@ void igd_write_opregion(struct pt_dev *real_dev,
> uint32_t val)
> >      igd_guest_opregion = (val & ~0xfff) | (host_opregion & 0xfff);
> >      PT_LOG("Map OpRegion: %x -> %x\n", host_opregion,
> igd_guest_opregion);
> >
> > +    ret = xc_domain_iomem_permission(xc_handle, domid,
> > +            host_opregion >> XC_PAGE_SHIFT, 3, 1);
> > +    if (ret)
> > +    {
> > +        PT_LOG("Error[%d]: Can't enable to access IGD host opregion:
> 0x%x\n",
> > +                ret, host_opregion >> XC_PAGE_SHIFT);
> > +        igd_guest_opregion = 0;
> > +        return;
> > +    }
> > +
> >      ret = xc_domain_memory_mapping(xc_handle, domid,
> >              igd_guest_opregion >> XC_PAGE_SHIFT,
> >              host_opregion >> XC_PAGE_SHIFT,
> > -            2,
> > +            3,
> >              DPCI_ADD_MAPPING);
> >
> >      if ( ret != 0 )
> > --
> > 2.7.4
> >
> >
> > _______________________________________________
> > Xen-devel mailing list
> > Xen-devel@lists.xen.org
> > https://lists.xen.org/xen-devel
diff mbox

Patch

diff --git a/hw/pt-graphics.c b/hw/pt-graphics.c
index 7302b25..893bf12 100644
--- a/hw/pt-graphics.c
+++ b/hw/pt-graphics.c
@@ -78,10 +78,20 @@  void igd_write_opregion(struct pt_dev *real_dev, uint32_t val)
     igd_guest_opregion = (val & ~0xfff) | (host_opregion & 0xfff);
     PT_LOG("Map OpRegion: %x -> %x\n", host_opregion, igd_guest_opregion);
 
+    ret = xc_domain_iomem_permission(xc_handle, domid,
+            host_opregion >> XC_PAGE_SHIFT, 3, 1);
+    if (ret)
+    {
+        PT_LOG("Error[%d]: Can't enable to access IGD host opregion: 0x%x\n",
+                ret, host_opregion >> XC_PAGE_SHIFT);
+        igd_guest_opregion = 0;
+        return;
+    }
+
     ret = xc_domain_memory_mapping(xc_handle, domid,
             igd_guest_opregion >> XC_PAGE_SHIFT,
             host_opregion >> XC_PAGE_SHIFT,
-            2,
+            3,
             DPCI_ADD_MAPPING);
 
     if ( ret != 0 )