ia64/xen-unstable

changeset 7204:ec84b119e4ed

Allow EVTCHNOP_bind_{ipi,virq} to specify the vcpu to
bind to. Previously the alloacted port was implicitly
bound to the calling vcpu.

Signed-off-by: Keir Fraser <keir@xensource.com>
author kaf24@firebug.cl.cam.ac.uk
date Tue Oct 04 15:02:51 2005 +0100 (2005-10-04)
parents f13b4b730605
children 540d17fe32ce
files linux-2.6-xen-sparse/arch/xen/kernel/evtchn.c tools/libxc/xc_evtchn.c xen/common/event_channel.c xen/include/public/event_channel.h
line diff
     1.1 --- a/linux-2.6-xen-sparse/arch/xen/kernel/evtchn.c	Tue Oct 04 15:02:35 2005 +0100
     1.2 +++ b/linux-2.6-xen-sparse/arch/xen/kernel/evtchn.c	Tue Oct 04 15:02:51 2005 +0100
     1.3 @@ -189,6 +189,7 @@ int bind_virq_to_irq(int virq)
     1.4  	if ((irq = per_cpu(virq_to_irq, cpu)[virq]) == -1) {
     1.5  		op.cmd              = EVTCHNOP_bind_virq;
     1.6  		op.u.bind_virq.virq = virq;
     1.7 +		op.u.bind_virq.vcpu = cpu;
     1.8  		BUG_ON(HYPERVISOR_event_channel_op(&op) != 0);
     1.9  		evtchn = op.u.bind_virq.port;
    1.10  
    1.11 @@ -252,6 +253,7 @@ int bind_ipi_to_irq(int ipi)
    1.12  
    1.13  	if ((evtchn = per_cpu(ipi_to_evtchn, cpu)[ipi]) == -1) {
    1.14  		op.cmd = EVTCHNOP_bind_ipi;
    1.15 +		op.u.bind_ipi.vcpu = cpu;
    1.16  		BUG_ON(HYPERVISOR_event_channel_op(&op) != 0);
    1.17  		evtchn = op.u.bind_ipi.port;
    1.18  
    1.19 @@ -666,6 +668,7 @@ void irq_resume(void)
    1.20  		/* Get a new binding from Xen. */
    1.21  		op.cmd              = EVTCHNOP_bind_virq;
    1.22  		op.u.bind_virq.virq = virq;
    1.23 +		op.u.bind_virq.vcpu = 0;
    1.24  		BUG_ON(HYPERVISOR_event_channel_op(&op) != 0);
    1.25  		evtchn = op.u.bind_virq.port;
    1.26          
    1.27 @@ -687,6 +690,7 @@ void irq_resume(void)
    1.28  
    1.29  		/* Get a new binding from Xen. */
    1.30  		op.cmd = EVTCHNOP_bind_ipi;
    1.31 +		op.u.bind_ipi.vcpu = 0;
    1.32  		BUG_ON(HYPERVISOR_event_channel_op(&op) != 0);
    1.33  		evtchn = op.u.bind_ipi.port;
    1.34          
     2.1 --- a/tools/libxc/xc_evtchn.c	Tue Oct 04 15:02:35 2005 +0100
     2.2 +++ b/tools/libxc/xc_evtchn.c	Tue Oct 04 15:02:51 2005 +0100
     2.3 @@ -90,7 +90,8 @@ int xc_evtchn_bind_virq(int xc_handle,
     2.4  
     2.5      op.cmd = EVTCHNOP_bind_virq;
     2.6      op.u.bind_virq.virq = (u32)virq;
     2.7 -   
     2.8 +    op.u.bind_virq.vcpu = 0;
     2.9 +
    2.10      if ( (rc = do_evtchn_op(xc_handle, &op)) == 0 )
    2.11      {
    2.12          if ( port != NULL )
     3.1 --- a/xen/common/event_channel.c	Tue Oct 04 15:02:35 2005 +0100
     3.2 +++ b/xen/common/event_channel.c	Tue Oct 04 15:02:51 2005 +0100
     3.3 @@ -244,15 +244,15 @@ static long evtchn_bind_interdomain(evtc
     3.4  static long evtchn_bind_virq(evtchn_bind_virq_t *bind)
     3.5  {
     3.6      struct evtchn *chn;
     3.7 -    struct vcpu   *v = current;
     3.8 -    struct domain *d = v->domain;
     3.9 +    struct vcpu   *v;
    3.10 +    struct domain *d = current->domain;
    3.11      int            port, virq = bind->virq;
    3.12  
    3.13      if ( virq >= ARRAY_SIZE(v->virq_to_evtchn) )
    3.14          return -EINVAL;
    3.15  
    3.16 -    if ( d->domain_id == 0 && virq >= VIRQ_CONSOLE )
    3.17 -        v = d->vcpu[0];
    3.18 +    if ( (v = d->vcpu[bind->vcpu]) == NULL )
    3.19 +        return -ENOENT;
    3.20  
    3.21      spin_lock(&d->evtchn_lock);
    3.22  
    3.23 @@ -288,13 +288,16 @@ static long evtchn_bind_ipi(evtchn_bind_
    3.24      struct domain *d = current->domain;
    3.25      int            port;
    3.26  
    3.27 +    if ( d->vcpu[bind->vcpu] == NULL )
    3.28 +        return -ENOENT;
    3.29 +
    3.30      spin_lock(&d->evtchn_lock);
    3.31  
    3.32      if ( (port = get_free_port(d)) >= 0 )
    3.33      {
    3.34          chn = evtchn_from_port(d, port);
    3.35          chn->state          = ECS_IPI;
    3.36 -        chn->notify_vcpu_id = current->vcpu_id;
    3.37 +        chn->notify_vcpu_id = bind->vcpu;
    3.38      }
    3.39  
    3.40      spin_unlock(&d->evtchn_lock);
     4.1 --- a/xen/include/public/event_channel.h	Tue Oct 04 15:02:35 2005 +0100
     4.2 +++ b/xen/include/public/event_channel.h	Tue Oct 04 15:02:51 2005 +0100
     4.3 @@ -51,22 +51,24 @@ typedef struct evtchn_bind_interdomain {
     4.4  } evtchn_bind_interdomain_t;
     4.5  
     4.6  /*
     4.7 - * EVTCHNOP_bind_virq: Bind a local event channel to IRQ <irq> on calling vcpu.
     4.8 + * EVTCHNOP_bind_virq: Bind a local event channel to VIRQ <irq> on specified
     4.9 + * vcpu.
    4.10   * NOTES:
    4.11   *  1. A virtual IRQ may be bound to at most one event channel per vcpu.
    4.12 - *  2. The allocated event channel is bound to the calling vcpu. The binding
    4.13 + *  2. The allocated event channel is bound to the specified vcpu. The binding
    4.14   *     may not be changed.
    4.15   */
    4.16  #define EVTCHNOP_bind_virq        1
    4.17  typedef struct evtchn_bind_virq {
    4.18      /* IN parameters. */
    4.19      u32 virq;
    4.20 +    u32 vcpu;
    4.21      /* OUT parameters. */
    4.22      u32 port;
    4.23  } evtchn_bind_virq_t;
    4.24  
    4.25  /*
    4.26 - * EVTCHNOP_bind_pirq: Bind a local event channel to IRQ <irq>.
    4.27 + * EVTCHNOP_bind_pirq: Bind a local event channel to PIRQ <irq>.
    4.28   * NOTES:
    4.29   *  1. A physical IRQ may be bound to at most one event channel per domain.
    4.30   *  2. Only a sufficiently-privileged domain may bind to a physical IRQ.
    4.31 @@ -84,11 +86,12 @@ typedef struct evtchn_bind_pirq {
    4.32  /*
    4.33   * EVTCHNOP_bind_ipi: Bind a local event channel to receive events.
    4.34   * NOTES:
    4.35 - *  1. The allocated event channel is bound to the calling vcpu. The binding
    4.36 + *  1. The allocated event channel is bound to the specified vcpu. The binding
    4.37   *     may not be changed.
    4.38   */
    4.39  #define EVTCHNOP_bind_ipi         7
    4.40  typedef struct evtchn_bind_ipi {
    4.41 +    u32 vcpu;
    4.42      /* OUT parameters. */
    4.43      u32 port;
    4.44  } evtchn_bind_ipi_t;