* [PATCH] KVM: inject ExtINT interrupt before APIC interrupts
@ 2012-12-10 12:05 Gleb Natapov
2012-12-12 0:39 ` Zhang, Yang Z
0 siblings, 1 reply; 3+ messages in thread
From: Gleb Natapov @ 2012-12-10 12:05 UTC (permalink / raw)
To: kvm; +Cc: mtosatti, Yang Zhang
According to Intel SDM Volume 3 Section 10.8.1 "Interrupt Handling with
the Pentium 4 and Intel Xeon Processors" and Section 10.8.2 "Interrupt
Handling with the P6 Family and Pentium Processors" ExtINT interrupts are
sent directly to the processor core for handling. Currently KVM checks
APIC before it considers ExtINT interrupts for injection which is
backwards from the spec. Make code behave according to the SDM.
Signed-off-by: Gleb Natapov <gleb@redhat.com>
diff --git a/arch/x86/kvm/i8259.c b/arch/x86/kvm/i8259.c
index 848206d..cc31f7c 100644
--- a/arch/x86/kvm/i8259.c
+++ b/arch/x86/kvm/i8259.c
@@ -241,6 +241,8 @@ int kvm_pic_read_irq(struct kvm *kvm)
int irq, irq2, intno;
struct kvm_pic *s = pic_irqchip(kvm);
+ s->output = 0;
+
pic_lock(s);
irq = pic_get_irq(&s->pics[0]);
if (irq >= 0) {
diff --git a/arch/x86/kvm/irq.c b/arch/x86/kvm/irq.c
index 7e06ba1..ebd98d0 100644
--- a/arch/x86/kvm/irq.c
+++ b/arch/x86/kvm/irq.c
@@ -48,14 +48,10 @@ int kvm_cpu_has_interrupt(struct kvm_vcpu *v)
if (!irqchip_in_kernel(v->kvm))
return v->arch.interrupt.pending;
- if (kvm_apic_has_interrupt(v) == -1) { /* LAPIC */
- if (kvm_apic_accept_pic_intr(v)) {
- s = pic_irqchip(v->kvm); /* PIC */
- return s->output;
- } else
- return 0;
- }
- return 1;
+ if (kvm_apic_accept_pic_intr(v) && pic_irqchip(v->kvm)->output)
+ return pic_irqchip(v->kvm)->output; /* PIC */
+
+ return kvm_apic_has_interrupt(v) != -1; /* LAPIC */
}
EXPORT_SYMBOL_GPL(kvm_cpu_has_interrupt);
@@ -65,20 +61,14 @@ EXPORT_SYMBOL_GPL(kvm_cpu_has_interrupt);
int kvm_cpu_get_interrupt(struct kvm_vcpu *v)
{
struct kvm_pic *s;
- int vector;
if (!irqchip_in_kernel(v->kvm))
return v->arch.interrupt.nr;
- vector = kvm_get_apic_interrupt(v); /* APIC */
- if (vector == -1) {
- if (kvm_apic_accept_pic_intr(v)) {
- s = pic_irqchip(v->kvm);
- s->output = 0; /* PIC */
- vector = kvm_pic_read_irq(v->kvm);
- }
- }
- return vector;
+ if (kvm_apic_accept_pic_intr(v) && pic_irqchip(v->kvm)->output)
+ return kvm_pic_read_irq(v->kvm); /* PIC */
+
+ return kvm_get_apic_interrupt(v); /* APIC */
}
EXPORT_SYMBOL_GPL(kvm_cpu_get_interrupt);
--
Gleb.
^ permalink raw reply related [flat|nested] 3+ messages in thread
* RE: [PATCH] KVM: inject ExtINT interrupt before APIC interrupts
2012-12-10 12:05 [PATCH] KVM: inject ExtINT interrupt before APIC interrupts Gleb Natapov
@ 2012-12-12 0:39 ` Zhang, Yang Z
2012-12-14 1:06 ` Marcelo Tosatti
0 siblings, 1 reply; 3+ messages in thread
From: Zhang, Yang Z @ 2012-12-12 0:39 UTC (permalink / raw)
To: Gleb Natapov, kvm@vger.kernel.org; +Cc: mtosatti@redhat.com
Gleb Natapov wrote on 2012-12-10:
> According to Intel SDM Volume 3 Section 10.8.1 "Interrupt Handling with
> the Pentium 4 and Intel Xeon Processors" and Section 10.8.2 "Interrupt
> Handling with the P6 Family and Pentium Processors" ExtINT interrupts are
> sent directly to the processor core for handling. Currently KVM checks
> APIC before it considers ExtINT interrupts for injection which is
> backwards from the spec. Make code behave according to the SDM.
Ack.
> Signed-off-by: Gleb Natapov <gleb@redhat.com>
> diff --git a/arch/x86/kvm/i8259.c b/arch/x86/kvm/i8259.c
> index 848206d..cc31f7c 100644
> --- a/arch/x86/kvm/i8259.c
> +++ b/arch/x86/kvm/i8259.c
> @@ -241,6 +241,8 @@ int kvm_pic_read_irq(struct kvm *kvm)
> int irq, irq2, intno;
> struct kvm_pic *s = pic_irqchip(kvm);
> + s->output = 0;
> +
> pic_lock(s);
> irq = pic_get_irq(&s->pics[0]);
> if (irq >= 0) {
> diff --git a/arch/x86/kvm/irq.c b/arch/x86/kvm/irq.c
> index 7e06ba1..ebd98d0 100644
> --- a/arch/x86/kvm/irq.c
> +++ b/arch/x86/kvm/irq.c
> @@ -48,14 +48,10 @@ int kvm_cpu_has_interrupt(struct kvm_vcpu *v)
> if (!irqchip_in_kernel(v->kvm))
> return v->arch.interrupt.pending;
> - if (kvm_apic_has_interrupt(v) == -1) { /* LAPIC */
> - if (kvm_apic_accept_pic_intr(v)) {
> - s = pic_irqchip(v->kvm); /* PIC */
> - return s->output;
> - } else
> - return 0;
> - }
> - return 1;
> + if (kvm_apic_accept_pic_intr(v) && pic_irqchip(v->kvm)->output)
> + return pic_irqchip(v->kvm)->output; /* PIC */
> +
> + return kvm_apic_has_interrupt(v) != -1; /* LAPIC */
> }
> EXPORT_SYMBOL_GPL(kvm_cpu_has_interrupt);
> @@ -65,20 +61,14 @@ EXPORT_SYMBOL_GPL(kvm_cpu_has_interrupt);
> int kvm_cpu_get_interrupt(struct kvm_vcpu *v)
> {
> struct kvm_pic *s;
> - int vector;
>
> if (!irqchip_in_kernel(v->kvm))
> return v->arch.interrupt.nr;
> - vector = kvm_get_apic_interrupt(v); /* APIC */
> - if (vector == -1) {
> - if (kvm_apic_accept_pic_intr(v)) {
> - s = pic_irqchip(v->kvm);
> - s->output = 0; /* PIC */
> - vector = kvm_pic_read_irq(v->kvm);
> - }
> - }
> - return vector;
> + if (kvm_apic_accept_pic_intr(v) && pic_irqchip(v->kvm)->output)
> + return kvm_pic_read_irq(v->kvm); /* PIC */
> +
> + return kvm_get_apic_interrupt(v); /* APIC */
> }
> EXPORT_SYMBOL_GPL(kvm_cpu_get_interrupt);
> --
> Gleb.
Best regards,
Yang
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] KVM: inject ExtINT interrupt before APIC interrupts
2012-12-12 0:39 ` Zhang, Yang Z
@ 2012-12-14 1:06 ` Marcelo Tosatti
0 siblings, 0 replies; 3+ messages in thread
From: Marcelo Tosatti @ 2012-12-14 1:06 UTC (permalink / raw)
To: Zhang, Yang Z; +Cc: Gleb Natapov, kvm@vger.kernel.org
On Wed, Dec 12, 2012 at 12:39:02AM +0000, Zhang, Yang Z wrote:
> Gleb Natapov wrote on 2012-12-10:
> > According to Intel SDM Volume 3 Section 10.8.1 "Interrupt Handling with
> > the Pentium 4 and Intel Xeon Processors" and Section 10.8.2 "Interrupt
> > Handling with the P6 Family and Pentium Processors" ExtINT interrupts are
> > sent directly to the processor core for handling. Currently KVM checks
> > APIC before it considers ExtINT interrupts for injection which is
> > backwards from the spec. Make code behave according to the SDM.
> Ack.
Applied, thanks.
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2012-12-14 14:34 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-12-10 12:05 [PATCH] KVM: inject ExtINT interrupt before APIC interrupts Gleb Natapov
2012-12-12 0:39 ` Zhang, Yang Z
2012-12-14 1:06 ` Marcelo Tosatti
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox