Skip to contentSkip to conversation

Call mask notifiers from pic.

PATCH Superseded Gleb Natapov 2 participants 2 messages Jul 14, 2010

Subsystems (3)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Call mask notifiers from pic.

If pit delivers interrupt while pic is masking it OS will never do EOI and ack notifier will not be called so when pit will be unmasked no pit interrupts will be delivered any more. Calling mask notifiers solves this issue.

arch/x86/kvm/i8259.c +9 -1
index 819b748..80d98cd 100644
@@ -363,10 +363,18 @@ static void pic_ioport_write(void *opaque, u32 addr, u32 val)
 		}
 	} else
 		switch (s->init_state) {
-		case 0:		/* normal mode */
+		case 0: { /* normal mode */
+			u8 imr_diff = s->imr ^ val;
 			s->imr = val;
+			for (irq = 0; irq < PIC_NUM_PINS/2; irq++)
+				if (imr_diff & (1 << irq))
+					kvm_fire_mask_notifiers(
+						s->pics_state->kvm,
+						SELECT_PIC(irq), irq,
+						!!(s->imr & (1 << irq)));
 			pic_update_irq(s->pics_state);
 			break;
+		}
 		case 1:
 			s->irq_base = val & 0xf8;
 			s->init_state = 2;

--
Gleb.

#1 lore raw
Quoted 14 lines · Gleb Natapov

If pit delivers interrupt while pic is masking it OS will never do EOI and ack notifier will not be called so when pit will be unmasked no pit interrupts will be delivered any more. Calling mask notifiers solves this issue.

arch/x86/kvm/i8259.c +0 -0
index 819b748..80d98cd 100644
@@ -363,10 +363,18 @@ static void pic_ioport_write(void *opaque, u32 addr, u32 val)
 		}
 	} else
 		switch (s->init_state) {

arch/x86/kvm/i8259.c static void pic_ioport_write(void *opaque, u32 addr, u32 val) · line 374

Quoted 10 lines
arch/x86/kvm/i8259.c +8 -1
-		case 0:		/* normal mode */
+		case 0: { /* normal mode */
+			u8 imr_diff = s->imr ^ val;
 			s->imr = val;
+			for (irq = 0; irq < PIC_NUM_PINS/2; irq++)
+				if (imr_diff & (1 << irq))
+					kvm_fire_mask_notifiers(
+						s->pics_state->kvm,
+						SELECT_PIC(irq), irq,
+						!!(s->imr & (1 << irq)));

irqchip/pin parameters are wrong for PIC_SLAVE.