ia64/xen-unstable

changeset 1258:bab99b03bc2b

bitkeeper revision 1.825.3.17 (40693a952A4uQatvbQf9p4edlPR6ww)

irq.c, sched.h, event_channel.c, Rules.mk:
Fix a memory bug in new PIRQ code in Xen.
author kaf24@scramble.cl.cam.ac.uk
date Tue Mar 30 09:15:01 2004 +0000 (2004-03-30)
parents 128166f77232
children 109663e1ac8d
files xen/arch/i386/Rules.mk xen/arch/i386/irq.c xen/common/event_channel.c xen/include/xen/sched.h xenolinux-2.4.25-sparse/arch/xen/kernel/irq.c
line diff
     1.1 --- a/xen/arch/i386/Rules.mk	Mon Mar 29 17:15:34 2004 +0000
     1.2 +++ b/xen/arch/i386/Rules.mk	Tue Mar 30 09:15:01 2004 +0000
     1.3 @@ -7,8 +7,8 @@ LD := ld
     1.4  MONITOR_BASE := 0xFC500000
     1.5  # Bootloader should load monitor to this real address
     1.6  LOAD_BASE    := 0x00100000
     1.7 -CFLAGS  := -nostdinc -fno-builtin -fno-common -fno-strict-aliasing 
     1.8 -CFLAGS  += -iwithprefix include -O3 -Wall -Werror -DMONITOR_BASE=$(MONITOR_BASE)
     1.9 +CFLAGS  := -nostdinc -fno-builtin -fno-common -fno-strict-aliasing -O3
    1.10 +CFLAGS  += -iwithprefix include -Wall -Werror -DMONITOR_BASE=$(MONITOR_BASE)
    1.11  CFLAGS  += -fomit-frame-pointer -I$(BASEDIR)/include -D__KERNEL__ -DNDEBUG
    1.12  #CFLAGS  += -fomit-frame-pointer -I$(BASEDIR)/include -D__KERNEL__
    1.13  CFLAGS  += -Wno-pointer-arith -Wredundant-decls -m32
     2.1 --- a/xen/arch/i386/irq.c	Mon Mar 29 17:15:34 2004 +0000
     2.2 +++ b/xen/arch/i386/irq.c	Tue Mar 30 09:15:01 2004 +0000
     2.3 @@ -995,7 +995,7 @@ int pirq_guest_bind(struct task_struct *
     2.4      unsigned long flags;
     2.5      irq_desc_t *desc = &irq_desc[irq];
     2.6      irq_guest_action_t *action;
     2.7 -    int rc;
     2.8 +    int rc = 0;
     2.9  
    2.10      if ( !IS_PRIV(p) )
    2.11          return -EPERM;
    2.12 @@ -1006,19 +1006,19 @@ int pirq_guest_bind(struct task_struct *
    2.13  
    2.14      if ( !(desc->status & IRQ_GUEST) )
    2.15      {
    2.16 -        rc = -EBUSY;
    2.17          if ( desc->action != NULL )
    2.18          {
    2.19              DPRINTK("Cannot bind IRQ %d to guest. In use by '%s'.\n",
    2.20                      irq, desc->action->name);
    2.21 +            rc = -EBUSY;
    2.22              goto out;
    2.23          }
    2.24  
    2.25 -        rc = -ENOMEM;
    2.26          action = kmalloc(sizeof(irq_guest_action_t), GFP_KERNEL);
    2.27          if ( (desc->action = (struct irqaction *)action) == NULL )
    2.28          {
    2.29              DPRINTK("Cannot bind IRQ %d to guest. Out of memory.\n", irq);
    2.30 +            rc = -ENOMEM;
    2.31              goto out;
    2.32          }
    2.33  
    2.34 @@ -1038,17 +1038,15 @@ int pirq_guest_bind(struct task_struct *
    2.35          goto out;
    2.36      }
    2.37  
    2.38 -    rc = -EBUSY;
    2.39      if ( action->nr_guests == IRQ_MAX_GUESTS )
    2.40      {
    2.41          DPRINTK("Cannot bind IRQ %d to guest. Already at max share.\n", irq);
    2.42 +        rc = -EBUSY;
    2.43          goto out;
    2.44      }
    2.45  
    2.46      action->guest[action->nr_guests++] = p;
    2.47  
    2.48 -    rc = 0;
    2.49 -
    2.50   out:
    2.51      spin_unlock_irqrestore(&desc->lock, flags);
    2.52      return rc;
     3.1 --- a/xen/common/event_channel.c	Mon Mar 29 17:15:34 2004 +0000
     3.2 +++ b/xen/common/event_channel.c	Tue Mar 30 09:15:01 2004 +0000
     3.3 @@ -46,7 +46,7 @@ static int get_free_port(struct task_str
     3.4          if ( max == MAX_EVENT_CHANNELS )
     3.5              return -ENOSPC;
     3.6          
     3.7 -        max = (max == 0) ? 4 : (max * 2);
     3.8 +        max *= 2;
     3.9          
    3.10          chn = kmalloc(max * sizeof(event_channel_t), GFP_KERNEL);
    3.11          if ( unlikely(chn == NULL) )
    3.12 @@ -287,10 +287,7 @@ static long __evtchn_close(struct task_s
    3.13          if ( chn2[port2].u.remote.dom != p1 )
    3.14              BUG();
    3.15  
    3.16 -        chn2[port2].state         = ECS_UNBOUND;
    3.17 -        chn2[port2].u.remote.dom  = NULL;
    3.18 -        chn2[port2].u.remote.port = 0xFFFF;
    3.19 -
    3.20 +        chn2[port2].state = ECS_UNBOUND;
    3.21          evtchn_set_exception(p2, port2);
    3.22  
    3.23          break;
    3.24 @@ -299,10 +296,7 @@ static long __evtchn_close(struct task_s
    3.25          BUG();
    3.26      }
    3.27  
    3.28 -    chn1[port1].state         = ECS_FREE;
    3.29 -    chn1[port1].u.remote.dom  = NULL;
    3.30 -    chn1[port1].u.remote.port = 0xFFFF;
    3.31 -    
    3.32 +    chn1[port1].state = ECS_FREE;
    3.33      evtchn_set_exception(p1, port1);
    3.34  
    3.35   out:
     4.1 --- a/xen/include/xen/sched.h	Mon Mar 29 17:15:34 2004 +0000
     4.2 +++ b/xen/include/xen/sched.h	Tue Mar 30 09:15:01 2004 +0000
     4.3 @@ -164,9 +164,10 @@ struct task_struct
     4.4       * domain's event-channel spinlock. Read accesses can also synchronise on 
     4.5       * the lock, but races don't usually matter.
     4.6       */
     4.7 -    u16 pirq_to_evtchn[128];
     4.8 +#define NR_PIRQS 128 /* Put this somewhere sane! */
     4.9 +    u16 pirq_to_evtchn[NR_PIRQS];
    4.10      u16 virq_to_evtchn[NR_VIRQS];
    4.11 -    u32 pirq_mask[2];
    4.12 +    u32 pirq_mask[NR_PIRQS/32];
    4.13  
    4.14      /* Physical I/O */
    4.15      spinlock_t       pcidev_lock;
     5.1 --- a/xenolinux-2.4.25-sparse/arch/xen/kernel/irq.c	Mon Mar 29 17:15:34 2004 +0000
     5.2 +++ b/xenolinux-2.4.25-sparse/arch/xen/kernel/irq.c	Tue Mar 30 09:15:01 2004 +0000
     5.3 @@ -824,7 +824,7 @@ unsigned long probe_irq_on(void)
     5.4  	 * something may have generated an irq long ago and we want to
     5.5  	 * flush such a longstanding irq before considering it as spurious. 
     5.6  	 */
     5.7 -	for (i = NR_IRQS-1; i > 0; i--)  {
     5.8 +	for (i = NR_PIRQS-1; i > 0; i--)  {
     5.9  		desc = irq_desc + i;
    5.10  
    5.11  		spin_lock_irq(&desc->lock);
    5.12 @@ -842,7 +842,7 @@ unsigned long probe_irq_on(void)
    5.13  	 * (we must startup again here because if a longstanding irq
    5.14  	 * happened in the previous stage, it may have masked itself)
    5.15  	 */
    5.16 -	for (i = NR_IRQS-1; i > 0; i--) {
    5.17 +	for (i = NR_PIRQS-1; i > 0; i--) {
    5.18  		desc = irq_desc + i;
    5.19  
    5.20  		spin_lock_irq(&desc->lock);
    5.21 @@ -864,7 +864,7 @@ unsigned long probe_irq_on(void)
    5.22  	 * Now filter out any obviously spurious interrupts
    5.23  	 */
    5.24  	val = 0;
    5.25 -	for (i = 0; i < NR_IRQS; i++) {
    5.26 +	for (i = 0; i < NR_PIRQS; i++) {
    5.27  		irq_desc_t *desc = irq_desc + i;
    5.28  		unsigned int status;
    5.29  
    5.30 @@ -909,7 +909,7 @@ unsigned int probe_irq_mask(unsigned lon
    5.31  	unsigned int mask;
    5.32  
    5.33  	mask = 0;
    5.34 -	for (i = 0; i < NR_IRQS; i++) {
    5.35 +	for (i = 0; i < NR_PIRQS; i++) {
    5.36  		irq_desc_t *desc = irq_desc + i;
    5.37  		unsigned int status;
    5.38  
    5.39 @@ -959,7 +959,7 @@ int probe_irq_off(unsigned long val)
    5.40  
    5.41  	nr_irqs = 0;
    5.42  	irq_found = 0;
    5.43 -	for (i = 0; i < NR_IRQS; i++) {
    5.44 +	for (i = 0; i < NR_PIRQS; i++) {
    5.45  		irq_desc_t *desc = irq_desc + i;
    5.46  		unsigned int status;
    5.47