ia64/xen-unstable

changeset 6830:1cdc469bf78d

Clear pending interrupt on shared page when pic initialized
and irq base changed.

Signed-off-by: Yunhong Jiang <yunhong.jiang@intel.com>
author kaf24@firebug.cl.cam.ac.uk
date Wed Sep 14 13:28:45 2005 +0000 (2005-09-14)
parents b9b120c7631a
children 5e943af66571
files tools/ioemu/hw/i8259.c xen/arch/x86/vmx_intercept.c
line diff
     1.1 --- a/tools/ioemu/hw/i8259.c	Wed Sep 14 13:13:10 2005 +0000
     1.2 +++ b/tools/ioemu/hw/i8259.c	Wed Sep 14 13:28:45 2005 +0000
     1.3 @@ -128,21 +128,23 @@ static int pic_get_irq(PicState *s)
     1.4  /* pic[1] is connected to pin2 of pic[0] */
     1.5  #define CASCADE_IRQ 2
     1.6  
     1.7 -static void shared_page_update()
     1.8 +extern shared_iopage_t *shared_page;
     1.9 +
    1.10 +static void xen_update_shared_imr(void)
    1.11  {
    1.12 -    extern shared_iopage_t *shared_page;
    1.13 -    uint8_t * pmask = (uint8_t *)&(shared_page->sp_global.pic_mask[0]);
    1.14 -    int           index;
    1.15 +    uint8_t *pmask = (uint8_t *)shared_page->sp_global.pic_mask;
    1.16 +    int      index;
    1.17  
    1.18      index = pics[0].irq_base/8;
    1.19      pmask[index] = pics[0].imr;
    1.20 -    index = pics[1].irq_base/8;
    1.21  
    1.22 -    if ( pics[0].imr &  (1 << CASCADE_IRQ) ) {
    1.23 -        pmask[index] = 0xff;
    1.24 -    } else {
    1.25 -        pmask[index] = pics[1].imr;
    1.26 -    }
    1.27 +    index = pics[1].irq_base/8;
    1.28 +    pmask[index] = (pics[0].imr & (1 << CASCADE_IRQ)) ? 0xff : pics[1].imr;
    1.29 +}
    1.30 +
    1.31 +static void xen_clear_shared_irr(void)
    1.32 +{
    1.33 +    memset(shared_page->sp_global.pic_intr, 0, INTR_LEN);
    1.34  }
    1.35  
    1.36  /* raise irq to CPU if necessary. must be called every time the active
    1.37 @@ -174,7 +176,8 @@ static void pic_update_irq(void)
    1.38  #endif
    1.39          cpu_interrupt(cpu_single_env, CPU_INTERRUPT_HARD);
    1.40      }
    1.41 -    shared_page_update();
    1.42 +
    1.43 +    xen_update_shared_imr();
    1.44  }
    1.45  
    1.46  #ifdef DEBUG_IRQ_LATENCY
    1.47 @@ -283,7 +286,9 @@ static void pic_reset(void *opaque)
    1.48      tmp = s->elcr_mask;
    1.49      memset(s, 0, sizeof(PicState));
    1.50      s->elcr_mask = tmp;
    1.51 -    shared_page_update();
    1.52 +
    1.53 +    xen_update_shared_imr();
    1.54 +    xen_clear_shared_irr();
    1.55  }
    1.56  
    1.57  static void pic_ioport_write(void *opaque, uint32_t addr, uint32_t val)
     2.1 --- a/xen/arch/x86/vmx_intercept.c	Wed Sep 14 13:13:10 2005 +0000
     2.2 +++ b/xen/arch/x86/vmx_intercept.c	Wed Sep 14 13:28:45 2005 +0000
     2.3 @@ -227,6 +227,7 @@ void vmx_hooks_assist(struct vcpu *d)
     2.4      u64 *intr = &(sp->sp_global.pic_intr[0]);
     2.5      struct vmx_virpit_t *vpit = &(d->domain->arch.vmx_platform.vmx_pit);
     2.6      int rw_mode, reinit = 0;
     2.7 +    int oldvec = 0;
     2.8  
     2.9      /* load init count*/
    2.10      if (p->state == STATE_IORESP_HOOK) { 
    2.11 @@ -235,6 +236,7 @@ void vmx_hooks_assist(struct vcpu *d)
    2.12              VMX_DBG_LOG(DBG_LEVEL_1, "VMX_PIT: guest reset PIT with channel %lx!\n", (unsigned long) ((p->u.data >> 24) & 0x3) );
    2.13              rem_ac_timer(&(vpit->pit_timer));
    2.14              reinit = 1;
    2.15 +            oldvec = vpit->vector;
    2.16          }
    2.17          else
    2.18              init_ac_timer(&vpit->pit_timer, pit_timer_fn, vpit, d->processor);
    2.19 @@ -250,6 +252,12 @@ void vmx_hooks_assist(struct vcpu *d)
    2.20              vpit->period = 1000000;
    2.21          }
    2.22          vpit->vector = ((p->u.data >> 16) & 0xFF);
    2.23 +
    2.24 +        if( reinit && oldvec != vpit->vector){
    2.25 +            clear_bit(oldvec, intr);
    2.26 +            vpit->pending_intr_nr = 0;
    2.27 +        }
    2.28 +
    2.29          vpit->channel = ((p->u.data >> 24) & 0x3);
    2.30          vpit->first_injected = 0;
    2.31