From: Marcelo Tosatti <mtosatti@redhat.com>
To: Avi Kivity <avi@qumranet.com>
Cc: kvm-devel <kvm@vger.kernel.org>
Subject: Re: KVM: fix i8259 reset irq acking
Date: Thu, 14 Aug 2008 20:53:25 -0300 [thread overview]
Message-ID: <20080814235325.GA14844@dmt.cnet> (raw)
In-Reply-To: <48A2BA22.70805@qumranet.com>
On Wed, Aug 13, 2008 at 01:40:34PM +0300, Avi Kivity wrote:
> Marcelo Tosatti wrote:
>> The irq ack during pic reset has three problems:
>>
>> - Ignores slave/master PIC, using gsi 0-8 for both.
>> - Generates an ACK even if the APIC is in control.
>> - Depends upon IMR being clear, which is broken if the irq was masked
>> at the time it was generated.
>>
>> The last one causes the BIOS to hang after the first reboot of Windows
>> installation, since PIT interrupts stop.
>>
>> Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
>>
>>
>> diff --git a/arch/x86/kvm/i8259.c b/arch/x86/kvm/i8259.c
>> index de70499..2b42d48 100644
>> --- a/arch/x86/kvm/i8259.c
>> +++ b/arch/x86/kvm/i8259.c
>> @@ -195,14 +195,18 @@ int kvm_pic_read_irq(struct kvm *kvm)
>> void kvm_pic_reset(struct kvm_kpic_state *s)
>> {
>> - int irq;
>> + int irq, irqbase;
>> struct kvm *kvm = s->pics_state->irq_request_opaque;
>> - for (irq = 0; irq < PIC_NUM_PINS; irq++) {
>> - if (!(s->imr & (1 << irq)) && (s->irr & (1 << irq) ||
>> - s->isr & (1 << irq)))
>> - kvm_notify_acked_irq(kvm, irq);
>> - }
>> + if (s == &s->pics_state->pics[0])
>> + irqbase = 0;
>> + else
>> + irqbase = 8;
>> +
>> + if (!kvm_lapic_enabled(kvm->vcpus[0]))
>>
>
> What if the lapic is enabled and passes through PIC interrupts in EXTINT
> mode?
>
> btw, this will oops if we have no vcpu 0.
True. How's this:
The irq ack during pic reset has three problems:
- Ignores slave/master PIC, using gsi 0-8 for both.
- Generates an ACK even if the APIC is in control.
- Depends upon IMR being clear, which is broken if the irq was masked
at the time it was generated.
The last one causes the BIOS to hang after the first reboot of
Windows
installation, since PIT interrupts stop.
Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
diff --git a/arch/x86/kvm/i8259.c b/arch/x86/kvm/i8259.c
index de70499..59a2201 100644
--- a/arch/x86/kvm/i8259.c
+++ b/arch/x86/kvm/i8259.c
@@ -195,13 +195,23 @@ int kvm_pic_read_irq(struct kvm *kvm)
void kvm_pic_reset(struct kvm_kpic_state *s)
{
- int irq;
+ int irq, irqbase;
struct kvm *kvm = s->pics_state->irq_request_opaque;
+ struct kvm_vcpu *vcpu0 = kvm->vcpus[0];
+
+ if (s == &s->pics_state->pics[0])
+ irqbase = 0;
+ else
+ irqbase = 8;
for (irq = 0; irq < PIC_NUM_PINS; irq++) {
- if (!(s->imr & (1 << irq)) && (s->irr & (1 << irq) ||
- s->isr & (1 << irq)))
- kvm_notify_acked_irq(kvm, irq);
+ union ioapic_redir_entry entry;
+ entry = kvm->arch.vioapic->redirtbl[irq+irqbase];
+ if ((vcpu0 && !kvm_lapic_enabled(vcpu0)) ||
+ entry.fields.delivery_mode == IOAPIC_EXTINT) {
+ if (s->irr & (1 << irq) || s->isr & (1 << irq))
+ kvm_notify_acked_irq(kvm, irq+irqbase);
+ }
}
s->last_irr = 0;
s->irr = 0;
next prev parent reply other threads:[~2008-08-14 23:54 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-07-31 17:15 KVM: fix i8259 reset irq acking Marcelo Tosatti
2008-08-13 10:40 ` Avi Kivity
2008-08-14 23:53 ` Marcelo Tosatti [this message]
2008-08-17 6:22 ` Avi Kivity
2008-08-17 7:42 ` Avi Kivity
2008-08-17 14:36 ` Avi Kivity
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20080814235325.GA14844@dmt.cnet \
--to=mtosatti@redhat.com \
--cc=avi@qumranet.com \
--cc=kvm@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox