All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 2/2] libxc: enabling emulated MSI injection
@ 2011-05-26  3:09 Wei Liu
  2011-05-26 12:34 ` Konrad Rzeszutek Wilk
  0 siblings, 1 reply; 5+ messages in thread
From: Wei Liu @ 2011-05-26  3:09 UTC (permalink / raw)
  To: xen-devel; +Cc: Stefano Stabellini

commit 67038b5b18096b3bdcda7fe393d1be6a91dc75a6
Author: Wei Liu <liuw@liuw.name>
Date:   Thu May 26 10:27:41 2011 +0800

    libxc: add new operation in HVMOP to deliver emulated MSI.

    Signed-off-by: Wei Liu <liuw@liuw.name>

diff --git a/tools/libxc/xc_misc.c b/tools/libxc/xc_misc.c
index b87bbc0..38af397 100644
--- a/tools/libxc/xc_misc.c
+++ b/tools/libxc/xc_misc.c
@@ -417,6 +417,35 @@ int xc_hvm_set_pci_link_route(
     return rc;
 }

+int xc_hvm_inj_msi(
+    xc_interface *xch, domid_t dom, uint64_t addr, uint32_t data)
+{
+    DECLARE_HYPERCALL;
+    DECLARE_HYPERCALL_BUFFER(struct xen_hvm_inj_msi, arg);
+    int rc;
+
+    arg = xc_hypercall_buffer_alloc(xch, arg, sizeof(*arg));
+    if ( arg == NULL )
+    {
+        PERROR("Could not allocate memory for xc_hvm_inj_msi hypercall");
+        return -1;
+    }
+
+    hypercall.op     = __HYPERVISOR_hvm_op;
+    hypercall.arg[0] = HVMOP_inj_msi;
+    hypercall.arg[1] = HYPERCALL_BUFFER_AS_ARG(arg);
+
+    arg->domid = dom;
+    arg->addr  = addr;
+    arg->data  = data;
+
+    rc = do_xen_hypercall(xch, &hypercall);
+
+    xc_hypercall_buffer_free(xch, arg);
+
+    return rc;
+}
+
 int xc_hvm_track_dirty_vram(
     xc_interface *xch, domid_t dom,
     uint64_t first_pfn, uint64_t nr,
diff --git a/tools/libxc/xenctrl.h b/tools/libxc/xenctrl.h
index 9a4355f..2442c84 100644
--- a/tools/libxc/xenctrl.h
+++ b/tools/libxc/xenctrl.h
@@ -1387,6 +1387,8 @@ int xc_hvm_set_isa_irq_level(
 int xc_hvm_set_pci_link_route(
     xc_interface *xch, domid_t dom, uint8_t link, uint8_t isa_irq);

+int xc_hvm_inj_msi(
+    xc_interface *xch, domid_t dom, uint64_t addr, uint32_t data);

 /*
  * Track dirty bit changes in the VRAM area

-- 
Best regards
Wei Liu
Twitter: @iliuw
Site: http://liuw.name

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH 2/2] libxc: enabling emulated MSI injection
  2011-05-26  3:09 [PATCH 2/2] libxc: enabling emulated MSI injection Wei Liu
@ 2011-05-26 12:34 ` Konrad Rzeszutek Wilk
  2011-05-26 12:56   ` Wei Liu
  2011-05-26 12:59   ` Wei Liu
  0 siblings, 2 replies; 5+ messages in thread
From: Konrad Rzeszutek Wilk @ 2011-05-26 12:34 UTC (permalink / raw)
  To: Wei Liu; +Cc: xen-devel, Stefano Stabellini

On Thu, May 26, 2011 at 11:09:43AM +0800, Wei Liu wrote:
> commit 67038b5b18096b3bdcda7fe393d1be6a91dc75a6
> Author: Wei Liu <liuw@liuw.name>
> Date:   Thu May 26 10:27:41 2011 +0800
> 
>     libxc: add new operation in HVMOP to deliver emulated MSI.

What is the purpose of this call?
> 
>     Signed-off-by: Wei Liu <liuw@liuw.name>
> 
> diff --git a/tools/libxc/xc_misc.c b/tools/libxc/xc_misc.c
> index b87bbc0..38af397 100644
> --- a/tools/libxc/xc_misc.c
> +++ b/tools/libxc/xc_misc.c
> @@ -417,6 +417,35 @@ int xc_hvm_set_pci_link_route(
>      return rc;
>  }
> 
> +int xc_hvm_inj_msi(
> +    xc_interface *xch, domid_t dom, uint64_t addr, uint32_t data)
> +{
> +    DECLARE_HYPERCALL;
> +    DECLARE_HYPERCALL_BUFFER(struct xen_hvm_inj_msi, arg);
> +    int rc;
> +
> +    arg = xc_hypercall_buffer_alloc(xch, arg, sizeof(*arg));
> +    if ( arg == NULL )
> +    {
> +        PERROR("Could not allocate memory for xc_hvm_inj_msi hypercall");
> +        return -1;
> +    }
> +
> +    hypercall.op     = __HYPERVISOR_hvm_op;
> +    hypercall.arg[0] = HVMOP_inj_msi;
> +    hypercall.arg[1] = HYPERCALL_BUFFER_AS_ARG(arg);
> +
> +    arg->domid = dom;
> +    arg->addr  = addr;
> +    arg->data  = data;

Shouldn't those be done before you make the HYPERCALL_BUFFER_AS_ARG
in case they get bounced?

> +
> +    rc = do_xen_hypercall(xch, &hypercall);
> +
> +    xc_hypercall_buffer_free(xch, arg);
> +
> +    return rc;
> +}
> +
>  int xc_hvm_track_dirty_vram(
>      xc_interface *xch, domid_t dom,
>      uint64_t first_pfn, uint64_t nr,
> diff --git a/tools/libxc/xenctrl.h b/tools/libxc/xenctrl.h
> index 9a4355f..2442c84 100644
> --- a/tools/libxc/xenctrl.h
> +++ b/tools/libxc/xenctrl.h
> @@ -1387,6 +1387,8 @@ int xc_hvm_set_isa_irq_level(
>  int xc_hvm_set_pci_link_route(
>      xc_interface *xch, domid_t dom, uint8_t link, uint8_t isa_irq);
> 
> +int xc_hvm_inj_msi(
> +    xc_interface *xch, domid_t dom, uint64_t addr, uint32_t data);
> 
>  /*
>   * Track dirty bit changes in the VRAM area
> 
> -- 
> Best regards
> Wei Liu
> Twitter: @iliuw
> Site: http://liuw.name
> 
> _______________________________________________
> Xen-devel mailing list
> Xen-devel@lists.xensource.com
> http://lists.xensource.com/xen-devel

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH 2/2] libxc: enabling emulated MSI injection
  2011-05-26 12:34 ` Konrad Rzeszutek Wilk
@ 2011-05-26 12:56   ` Wei Liu
  2011-05-26 13:05     ` Konrad Rzeszutek Wilk
  2011-05-26 12:59   ` Wei Liu
  1 sibling, 1 reply; 5+ messages in thread
From: Wei Liu @ 2011-05-26 12:56 UTC (permalink / raw)
  To: Konrad Rzeszutek Wilk; +Cc: xen-devel, Stefano Stabellini

On Thu, May 26, 2011 at 8:34 PM, Konrad Rzeszutek Wilk
<konrad.wilk@oracle.com> wrote:
> On Thu, May 26, 2011 at 11:09:43AM +0800, Wei Liu wrote:
>> commit 67038b5b18096b3bdcda7fe393d1be6a91dc75a6
>> Author: Wei Liu <liuw@liuw.name>
>> Date:   Thu May 26 10:27:41 2011 +0800
>>
>>     libxc: add new operation in HVMOP to deliver emulated MSI.
>
> What is the purpose of this call?
>>
>>     Signed-off-by: Wei Liu <liuw@liuw.name>
>>
>> diff --git a/tools/libxc/xc_misc.c b/tools/libxc/xc_misc.c
>> index b87bbc0..38af397 100644
>> --- a/tools/libxc/xc_misc.c
>> +++ b/tools/libxc/xc_misc.c
>> @@ -417,6 +417,35 @@ int xc_hvm_set_pci_link_route(
>>      return rc;
>>  }
>>
>> +int xc_hvm_inj_msi(
>> +    xc_interface *xch, domid_t dom, uint64_t addr, uint32_t data)
>> +{
>> +    DECLARE_HYPERCALL;
>> +    DECLARE_HYPERCALL_BUFFER(struct xen_hvm_inj_msi, arg);
>> +    int rc;
>> +
>> +    arg = xc_hypercall_buffer_alloc(xch, arg, sizeof(*arg));
>> +    if ( arg == NULL )
>> +    {
>> +        PERROR("Could not allocate memory for xc_hvm_inj_msi hypercall");
>> +        return -1;
>> +    }
>> +
>> +    hypercall.op     = __HYPERVISOR_hvm_op;
>> +    hypercall.arg[0] = HVMOP_inj_msi;
>> +    hypercall.arg[1] = HYPERCALL_BUFFER_AS_ARG(arg);
>> +
>> +    arg->domid = dom;
>> +    arg->addr  = addr;
>> +    arg->data  = data;
>
> Shouldn't those be done before you make the HYPERCALL_BUFFER_AS_ARG
> in case they get bounced?
>

Hmm... I didn't think that far.

I just copy-and-edit from a previous hypercall. I think that should be OK then.

>> +
>> +    rc = do_xen_hypercall(xch, &hypercall);
>> +
>> +    xc_hypercall_buffer_free(xch, arg);
>> +
>> +    return rc;
>> +}
>> +
>>  int xc_hvm_track_dirty_vram(
>>      xc_interface *xch, domid_t dom,
>>      uint64_t first_pfn, uint64_t nr,
>> diff --git a/tools/libxc/xenctrl.h b/tools/libxc/xenctrl.h
>> index 9a4355f..2442c84 100644
>> --- a/tools/libxc/xenctrl.h
>> +++ b/tools/libxc/xenctrl.h
>> @@ -1387,6 +1387,8 @@ int xc_hvm_set_isa_irq_level(
>>  int xc_hvm_set_pci_link_route(
>>      xc_interface *xch, domid_t dom, uint8_t link, uint8_t isa_irq);
>>
>> +int xc_hvm_inj_msi(
>> +    xc_interface *xch, domid_t dom, uint64_t addr, uint32_t data);
>>
>>  /*
>>   * Track dirty bit changes in the VRAM area
>>
>> --
>> Best regards
>> Wei Liu
>> Twitter: @iliuw
>> Site: http://liuw.name
>>
>> _______________________________________________
>> Xen-devel mailing list
>> Xen-devel@lists.xensource.com
>> http://lists.xensource.com/xen-devel
>



-- 
Best regards
Wei Liu
Twitter: @iliuw
Site: http://liuw.name

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH 2/2] libxc: enabling emulated MSI injection
  2011-05-26 12:34 ` Konrad Rzeszutek Wilk
  2011-05-26 12:56   ` Wei Liu
@ 2011-05-26 12:59   ` Wei Liu
  1 sibling, 0 replies; 5+ messages in thread
From: Wei Liu @ 2011-05-26 12:59 UTC (permalink / raw)
  To: Konrad Rzeszutek Wilk; +Cc: xen-devel, Stefano Stabellini

On Thu, May 26, 2011 at 8:34 PM, Konrad Rzeszutek Wilk
<konrad.wilk@oracle.com> wrote:
> On Thu, May 26, 2011 at 11:09:43AM +0800, Wei Liu wrote:
>> commit 67038b5b18096b3bdcda7fe393d1be6a91dc75a6
>> Author: Wei Liu <liuw@liuw.name>
>> Date:   Thu May 26 10:27:41 2011 +0800
>>
>>     libxc: add new operation in HVMOP to deliver emulated MSI.
>
> What is the purpose of this call?

Sorry I missed this one.

Currently QEMU cannot inject MSI for emulated devices, which limits
virtio to use irq to deliver interrupts. This call is used to inject
MSI from QEMU to HVM, suggested by Stefano.

>>
>>     Signed-off-by: Wei Liu <liuw@liuw.name>
>>
>> diff --git a/tools/libxc/xc_misc.c b/tools/libxc/xc_misc.c
>> index b87bbc0..38af397 100644
>> --- a/tools/libxc/xc_misc.c
>> +++ b/tools/libxc/xc_misc.c
>> @@ -417,6 +417,35 @@ int xc_hvm_set_pci_link_route(
>>      return rc;
>>  }
>>
>> +int xc_hvm_inj_msi(
>> +    xc_interface *xch, domid_t dom, uint64_t addr, uint32_t data)
>> +{
>> +    DECLARE_HYPERCALL;
>> +    DECLARE_HYPERCALL_BUFFER(struct xen_hvm_inj_msi, arg);
>> +    int rc;
>> +
>> +    arg = xc_hypercall_buffer_alloc(xch, arg, sizeof(*arg));
>> +    if ( arg == NULL )
>> +    {
>> +        PERROR("Could not allocate memory for xc_hvm_inj_msi hypercall");
>> +        return -1;
>> +    }
>> +
>> +    hypercall.op     = __HYPERVISOR_hvm_op;
>> +    hypercall.arg[0] = HVMOP_inj_msi;
>> +    hypercall.arg[1] = HYPERCALL_BUFFER_AS_ARG(arg);
>> +
>> +    arg->domid = dom;
>> +    arg->addr  = addr;
>> +    arg->data  = data;
>
> Shouldn't those be done before you make the HYPERCALL_BUFFER_AS_ARG
> in case they get bounced?
>
>> +
>> +    rc = do_xen_hypercall(xch, &hypercall);
>> +
>> +    xc_hypercall_buffer_free(xch, arg);
>> +
>> +    return rc;
>> +}
>> +
>>  int xc_hvm_track_dirty_vram(
>>      xc_interface *xch, domid_t dom,
>>      uint64_t first_pfn, uint64_t nr,
>> diff --git a/tools/libxc/xenctrl.h b/tools/libxc/xenctrl.h
>> index 9a4355f..2442c84 100644
>> --- a/tools/libxc/xenctrl.h
>> +++ b/tools/libxc/xenctrl.h
>> @@ -1387,6 +1387,8 @@ int xc_hvm_set_isa_irq_level(
>>  int xc_hvm_set_pci_link_route(
>>      xc_interface *xch, domid_t dom, uint8_t link, uint8_t isa_irq);
>>
>> +int xc_hvm_inj_msi(
>> +    xc_interface *xch, domid_t dom, uint64_t addr, uint32_t data);
>>
>>  /*
>>   * Track dirty bit changes in the VRAM area
>>
>> --
>> Best regards
>> Wei Liu
>> Twitter: @iliuw
>> Site: http://liuw.name
>>
>> _______________________________________________
>> Xen-devel mailing list
>> Xen-devel@lists.xensource.com
>> http://lists.xensource.com/xen-devel
>



-- 
Best regards
Wei Liu
Twitter: @iliuw
Site: http://liuw.name

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH 2/2] libxc: enabling emulated MSI injection
  2011-05-26 12:56   ` Wei Liu
@ 2011-05-26 13:05     ` Konrad Rzeszutek Wilk
  0 siblings, 0 replies; 5+ messages in thread
From: Konrad Rzeszutek Wilk @ 2011-05-26 13:05 UTC (permalink / raw)
  To: Wei Liu; +Cc: xen-devel, Stefano Stabellini

> >> +    hypercall.op     = __HYPERVISOR_hvm_op;
> >> +    hypercall.arg[0] = HVMOP_inj_msi;
> >> +    hypercall.arg[1] = HYPERCALL_BUFFER_AS_ARG(arg);
> >> +
> >> +    arg->domid = dom;
> >> +    arg->addr  = addr;
> >> +    arg->data  = data;
> >
> > Shouldn't those be done before you make the HYPERCALL_BUFFER_AS_ARG
> > in case they get bounced?
> >
> 
> Hmm... I didn't think that far.
> 
> I just copy-and-edit from a previous hypercall. I think that should be OK then.

On a second look at the code, I believe you are right.

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2011-05-26 13:05 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-05-26  3:09 [PATCH 2/2] libxc: enabling emulated MSI injection Wei Liu
2011-05-26 12:34 ` Konrad Rzeszutek Wilk
2011-05-26 12:56   ` Wei Liu
2011-05-26 13:05     ` Konrad Rzeszutek Wilk
2011-05-26 12:59   ` Wei Liu

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.