KVM: i8259: initialize IMR to 0xff on reset
PATCH 1/1 KVM: i8259: initialize IMR to 0xff on reset
Otherwise, a wily interrupt can slip through while the guest isn't prepared for it (and while the irq base is zero).
--- arch/x86/kvm/i8259.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)
arch/x86/kvm/i8259.c +1 -1
@@ -275,7 +275,7 @@ void kvm_pic_reset(struct kvm_kpic_state *s) s->last_irr =0 ; s->irr =0 ; - s->imr =0 ; + s->imr =0xff ; s->isr =0 ; s->isr_ack =0xff ; s->priority_add =0 ;
Signature · 1 line
1.7.1
arch/x86/kvm/i8259.c void kvm_pic_reset(struct kvm_kpic_state *s) · line 281
Quoted 11 lines · Avi Kivity
Otherwise, a wily interrupt can slip through while the guest isn't prepared for it (and while the irq base is zero).
s->last_irr = 0; s->irr = 0;arch/x86/kvm/i8259.c +1
-1- s->imr =0 ; + s->imr =0xff ; s->isr =0 ; s->isr_ack =0xff ; s->priority_add =0 ;
For some reason, this bug only shows on the non-atomic-injection branch (specifically, the KVM_REQ_EVENT part).
Signature · 1 line
error compiling committee.c: too many arguments to function
Paolo Bonzini
maintainerQuoted 13 lines · Avi Kivity
Otherwise, a wily interrupt can slip through while the guest isn't prepared for it (and while the irq base is zero).
Signed-off-by Avi Kivity<[email protected]>--- arch/x86/kvm/i8259.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)arch/x86/kvm/i8259.c +0
-0
arch/x86/kvm/i8259.c void kvm_pic_reset(struct kvm_kpic_state *s) · line 281
Quoted 8 lines
arch/x86/kvm/i8259.c +1
-1@@ -275,7 +275,7 @@ void kvm_pic_reset(struct kvm_kpic_state *s) s->last_irr =0 ; s->irr =0 ; - s->imr =0 ; + s->imr =0xff ; s->isr =0 ; s->isr_ack =0xff ; s->priority_add =0 ;
Sounds sane, but the datasheet says explicitly that upon reset "The Interrupt Mask Register is cleared"... (FWIW, I checked because it looked like QEMU and Xen also had the same behavior of setting IMR to zero).
Paolo
Quoted 15 lines · Paolo Bonzini
Quoted 14 lines · Avi Kivity
Otherwise, a wily interrupt can slip through while the guest isn't prepared for it (and while the irq base is zero).
Signed-off-by Avi Kivity<[email protected]>--- arch/x86/kvm/i8259.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)arch/x86/kvm/i8259.c +0
-0@@ -275,7 +275,7 @@ void kvm_pic_reset(struct kvm_kpic_state *s)
Quoted 9 lines
arch/x86/kvm/i8259.c void kvm_pic_reset(struct kvm_kpic_state *s) · line 281
Quoted 7 lines
arch/x86/kvm/i8259.c +1
-1s->last_irr =0 ; s->irr =0 ; - s->imr =0 ; + s->imr =0xff ; s->isr =0 ; s->isr_ack =0xff ; s->priority_add =0 ;Sounds sane, but the datasheet says explicitly that upon reset "The Interrupt Mask Register is cleared"... (FWIW, I checked because it looked like QEMU and Xen also had the same behavior of setting IMR to zero).
Hm, right.
Reading the spec, the correct approach is not to do a full reset on ICW1(D4=1), instead just do what the spec says (which is different from reset). I'll try it out.
Signature · 1 line
error compiling committee.c: too many arguments to function