diff options
author | Keir Fraser <keir@xen.org> | 2010-11-19 13:45:08 +0000 |
---|---|---|
committer | Keir Fraser <keir@xen.org> | 2010-11-19 13:45:08 +0000 |
commit | 77598c0f3df56ea8d2e98c0f557f9de3029d3b65 (patch) | |
tree | c99b6c795d8bc8d0956af3e05d5a6a80b39dffb9 /xen/arch/x86/physdev.c | |
parent | 0b469cd6870899a52c41be1cb3c982976531d59d (diff) | |
download | xen-77598c0f3df56ea8d2e98c0f557f9de3029d3b65.tar.gz xen-77598c0f3df56ea8d2e98c0f557f9de3029d3b65.tar.bz2 xen-77598c0f3df56ea8d2e98c0f557f9de3029d3b65.zip |
Introduce PHYSDEVOP_get_free_pirq
Introduce a new physdev_op called PHYSDEVOP_get_free_pirq to allow a
guest to get a free pirq number from Xen; the hypervisor would keep
that pirq free for the guest to use in a mapping.
Signed-off-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
Diffstat (limited to 'xen/arch/x86/physdev.c')
-rw-r--r-- | xen/arch/x86/physdev.c | 22 |
1 files changed, 21 insertions, 1 deletions
diff --git a/xen/arch/x86/physdev.c b/xen/arch/x86/physdev.c index 453b4f3006..2913a9c1b7 100644 --- a/xen/arch/x86/physdev.c +++ b/xen/arch/x86/physdev.c @@ -121,7 +121,7 @@ static int physdev_map_pirq(struct physdev_map_pirq *map) } irq = domain_pirq_to_irq(current->domain, map->index); - if ( !irq ) + if ( irq <= 0 ) { if ( IS_PRIV(current->domain) ) irq = map->index; @@ -557,6 +557,26 @@ ret_t do_physdev_op(int cmd, XEN_GUEST_HANDLE(void) arg) setup_gsi.polarity); break; } + case PHYSDEVOP_get_free_pirq: { + struct physdev_get_free_pirq out; + struct domain *d; + + d = rcu_lock_current_domain(); + + ret = -EFAULT; + if ( copy_from_guest(&out, arg, 1) != 0 ) + break; + + spin_lock(&d->event_lock); + out.pirq = get_free_pirq(d, out.type, 0); + d->arch.pirq_irq[out.pirq] = PIRQ_ALLOCATED; + spin_unlock(&d->event_lock); + + ret = copy_to_guest(arg, &out, 1) ? -EFAULT : 0; + + rcu_unlock_domain(d); + break; + } default: ret = -ENOSYS; break; |