Skip to contentSkip to conversation

Clear the pending interrupt on shared page when PIC initialized

PATCH In review Jiang, Yunhong 2 participants 2 messages Sep 12, 2005

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Clear the pending interrupt on shared page when PIC initialized

When PIC is initialized and the irq base changed, the pending interrupt on shared page should be cleared.

Thanks
Yunhong Jiang

tools/ioemu/hw/i8259.c +8 -0
diff -r b187d5555866 -r 94a3235acaab tools/ioemu/hw/i8259.c
@@ -127,6 +127,13 @@
 
 /* pic[1] is connected to pin2 of pic[0] */
 #define CASCADE_IRQ 2
+static void clear_shared_page()
+{
+    extern shared_iopage_t *shared_page;
+    unsigned long *intr;
+    intr = (unsigned long *) &(shared_page->sp_global.pic_intr[0]);
+    memset(intr, 0, INTR_LEN);
+}
 
 static void shared_page_update()
 {
@@ -299,6 +306,7 @@
         if (val & 0x10) {
             /* init */
             pic_reset(s);
+            clear_shared_page();
             /* deassert a pending interrupt */
             cpu_reset_interrupt(cpu_single_env, CPU_INTERRUPT_HARD);
 
xen/arch/x86/vmx_intercept.c +0 -0
diff -r b187d5555866 -r 94a3235acaab xen/arch/x86/vmx_intercept.c
@@ -227,6 +227,7 @@
     u64 *intr = &(sp->sp_global.pic_intr[0]);
     struct vmx_virpit_t *vpit =
&(d->domain->arch.vmx_platform.vmx_pit);
     int rw_mode, reinit = 0;

+ int oldvec = 0;

     /* load init count*/
     if (p->state == STATE_IORESP_HOOK) { 
@@ -235,6 +236,7 @@
             VMX_DBG_LOG(DBG_LEVEL_1, "VMX_PIT: guest reset PIT with
channel %lx!\n", (unsigned long) ((p->u.data >> 24) & 0x3) );
             rem_ac_timer(&(vpit->pit_timer));
             reinit = 1;
+            oldvec = vpit->vector;
         }
         else
             init_ac_timer(&vpit->pit_timer, pit_timer_fn, vpit,
d->processor);
@@ -250,6 +252,12 @@
             vpit->period = 1000000;
         }
         vpit->vector = ((p->u.data >> 16) & 0xFF);

+
+ if( reinit && oldvec != vpit->vector){
+ clear_bit(oldvec, intr);
+ vpit->pending_intr_nr = 0;
+ }
+

         vpit->channel = ((p->u.data >> 24) & 0x3);
         vpit->first_injected = 0;

# HG changeset patch
# User [email protected]
# Node ID 94a3235acaabddf4eed05e677b683ab21ff2cd87
# Parent b187d555586684eb9e878e5d571c926bc4a11baa
Clear pending interrupt on shared page when pic initialized and irq base changed

tools/ioemu/hw/i8259.c +8 -0
diff -r b187d5555866 -r 94a3235acaab tools/ioemu/hw/i8259.c
@@ -127,6 +127,13 @@
 
 /* pic[1] is connected to pin2 of pic[0] */
 #define CASCADE_IRQ 2
+static void clear_shared_page()
+{
+    extern shared_iopage_t *shared_page;
+    unsigned long *intr;
+    intr = (unsigned long *) &(shared_page->sp_global.pic_intr[0]);
+    memset(intr, 0, INTR_LEN);
+}
 
 static void shared_page_update()
 {
@@ -299,6 +306,7 @@
         if (val & 0x10) {
             /* init */
             pic_reset(s);
+            clear_shared_page();
             /* deassert a pending interrupt */
             cpu_reset_interrupt(cpu_single_env, CPU_INTERRUPT_HARD);
 
xen/arch/x86/vmx_intercept.c +8 -0
diff -r b187d5555866 -r 94a3235acaab xen/arch/x86/vmx_intercept.c
@@ -227,6 +227,7 @@
     u64 *intr = &(sp->sp_global.pic_intr[0]);
     struct vmx_virpit_t *vpit = &(d->domain->arch.vmx_platform.vmx_pit);
     int rw_mode, reinit = 0;
+    int oldvec = 0;
 
     /* load init count*/
     if (p->state == STATE_IORESP_HOOK) { 
@@ -235,6 +236,7 @@
             VMX_DBG_LOG(DBG_LEVEL_1, "VMX_PIT: guest reset PIT with channel %lx!\n", (unsigned long) ((p->u.data >> 24) & 0x3) );
             rem_ac_timer(&(vpit->pit_timer));
             reinit = 1;
+            oldvec = vpit->vector;
         }
         else
             init_ac_timer(&vpit->pit_timer, pit_timer_fn, vpit, d->processor);
@@ -250,6 +252,12 @@
             vpit->period = 1000000;
         }
         vpit->vector = ((p->u.data >> 16) & 0xFF);
+
+        if( reinit && oldvec != vpit->vector){
+            clear_bit(oldvec, intr);
+            vpit->pending_intr_nr = 0;
+        }
+
         vpit->channel = ((p->u.data >> 24) & 0x3);
         vpit->first_injected = 0;
 

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel

#1 lore raw
Quoted 2 lines · Yunhong

When PIC is initialized and the irq base changed, the pending interrupt on shared page should be cleared.

For the i8259 device-model change -- ought we to be hooking off the cpu_interrupt/cpu_reset_interrupt functions rather than adding new hooks?

Also, are the patches to the PIT code directly related to the PIC patch or should they be split out with a separate explanation?

-- Keir