[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Xen-devel] [PATCH v2 10/21] xen/arm: Implement hypercall PHYSDEVOP_{, un}map_pirq





On 29/08/14 08:34, Andrii Tseglytskyi wrote:
Hi Julien,

Hi Andrii,

+static int physdev_map_pirq(domid_t domid, int type, int index, int *pirq_p)
+{
+    struct domain *d;
+    int ret;
+    int irq = index;
+    int virq = 0;
+
+    d = rcu_lock_domain_by_any_id(domid);
+    if ( d == NULL )
+        return -ESRCH;
+
+    ret = xsm_map_domain_pirq(XSM_TARGET, d);
+    if ( ret )
+        goto free_domain;
+
+    /* For now we only suport GSI */
+    if ( type != MAP_PIRQ_TYPE_GSI )
+    {
+        ret = -EINVAL;
+        dprintk(XENLOG_G_ERR, "dom%u: wrong map_pirq type 0x%x\n",
+                d->domain_id, type);
+        goto free_domain;
+    }
+
+    if ( !is_assignable_irq(irq) )
+    {
+        ret = -EINVAL;
+        dprintk(XENLOG_G_ERR, "IRQ%u is not routable to a guest\n", irq);
+        goto free_domain;
+    }
+
+    ret = -EPERM;
+    if ( !irq_access_permitted(current->domain, irq) )
+        goto free_domain;

I have a question here. This code is executed when dom0 creates domU.
current->domain points to dom0 here, in other words access to IRQ must
be permitted for dom0. Right ?
But in this case following call of route_irq_to_guest() fails with message:

(XEN) irq.c:459: IRQ 53 is already used by domain 0

I reproduced this in the following steps:
- define IRQ in device tree, which is used by dom0, as result IRQ is
mapped to dom0
- after I defined it in domU configuration file, tried to launch domU
and got this error

What I'm doing wrong here?

PHYSDEVOP_map_pirq can assign an IRQ to a domain if it's free.

My series is assuming that the device is not used by anyone (status = "disabled" property in the device tree node).

In general, a device should not be shared between domains. If you need to use it at boot in DOM0, for now, you will have to disable the drivers and unmap every IRQ (see PHYSDEVOP_unmap_irq).

+
+    virq = vgic_allocate_virq(d, irq);
+    ret = -EMFILE;
+    if ( virq == -1 )
+        goto free_domain;
+
+    ret = route_irq_to_guest(d, virq, irq, "routed IRQ");
+

This call fails for me with the message:

(XEN) irq.c:440: IRQ 53 has not been configured.

Locally I added the following code, which sets IRQ type:

diff --git a/xen/arch/arm/physdev.c b/xen/arch/arm/physdev.c
index 9333aa0..e853e80 100644
--- a/xen/arch/arm/physdev.c
+++ b/xen/arch/arm/physdev.c
@@ -55,6 +55,7 @@ static int physdev_map_pirq(domid_t domid, int type,
int index, int *pirq_p)
      if ( virq == -1 )
          goto free_domain;

+    irq_set_spi_type(irq, DT_IRQ_TYPE_LEVEL_MASK);
      ret = route_irq_to_guest(d, virq, irq, "routed IRQ");

      if ( !ret )


Should it be added, or I need to do this in a different way - some
extra options for IRQ in config file, or something else?

At boot Xen is browsing the device tree to configure every IRQ. Does you IRQ describe in the device tree?

Regards,

--
Julien Grall

_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxx
http://lists.xen.org/xen-devel


 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.