From patchwork Sun Jan 25 01:31:51 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marcelo Tosatti X-Patchwork-Id: 3890 Received: from vger.kernel.org (vger.kernel.org [209.132.176.167]) by demeter.kernel.org (8.14.2/8.14.2) with ESMTP id n0P1WZ9l010089 for ; Sun, 25 Jan 2009 01:32:35 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752252AbZAYBc3 (ORCPT ); Sat, 24 Jan 2009 20:32:29 -0500 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1754212AbZAYBc3 (ORCPT ); Sat, 24 Jan 2009 20:32:29 -0500 Received: from mx2.redhat.com ([66.187.237.31]:45059 "EHLO mx2.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752252AbZAYBc2 (ORCPT ); Sat, 24 Jan 2009 20:32:28 -0500 Received: from int-mx2.corp.redhat.com (int-mx2.corp.redhat.com [172.16.27.26]) by mx2.redhat.com (8.13.8/8.13.8) with ESMTP id n0P1WRGp009811; Sat, 24 Jan 2009 20:32:27 -0500 Received: from ns3.rdu.redhat.com (ns3.rdu.redhat.com [10.11.255.199]) by int-mx2.corp.redhat.com (8.13.1/8.13.1) with ESMTP id n0P1WQ2J025443; Sat, 24 Jan 2009 20:32:27 -0500 Received: from amt.cnet (vpn-10-58.str.redhat.com [10.32.10.58]) by ns3.rdu.redhat.com (8.13.8/8.13.8) with ESMTP id n0P1WNtK028477; Sat, 24 Jan 2009 20:32:25 -0500 Received: from amt.cnet (amt.cnet [127.0.0.1]) by amt.cnet (Postfix) with ESMTP id 3B69E6801DF; Sat, 24 Jan 2009 23:32:00 -0200 (BRST) Received: (from marcelo@localhost) by amt.cnet (8.14.3/8.14.3/Submit) id n0P1Vpv3007184; Sat, 24 Jan 2009 23:31:51 -0200 Date: Sat, 24 Jan 2009 23:31:51 -0200 From: Marcelo Tosatti To: Beth Kon Cc: kvm@vger.kernel.org Subject: Re: [RFC][PATCH 1/2] Make irq0->inti2 override in BIOS configurable from userspace Message-ID: <20090125013150.GA7042@amt.cnet> References: <1232684977-4530-1-git-send-email-eak@us.ibm.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <1232684977-4530-1-git-send-email-eak@us.ibm.com> User-Agent: Mutt/1.5.18 (2008-05-17) X-Scanned-By: MIMEDefang 2.58 on 172.16.27.26 Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org Hi Beth, On Thu, Jan 22, 2009 at 10:29:36PM -0600, Beth Kon wrote: > This series of patches (nearly) resolves the irq0->inti2 override issue, and gets the hpet working on kvm with and > without the in-kernel irqchip (i.e., it disables userspace and in-kernel pit as needed). > > - irq0->inti2 > The resolution was to always use the override unless the kernel cannot do irq routing (i.e., compatibility with old > kernels). So qemu checks whether the kernel is capable of irq routing. If so, qemu tells kvm to route irq0 to > inti2 via the irq routing interface, and tells bios to add the irq0->inti2 override to the MADT interrupt source > override table, and to the mp table (for the non-acpi case). The only outstanding problem here is that when I set > acpi=off on the kernel boot line, the boot fails. Apparently linux does not like the way I implemented the override > for the mp table in rombios32.c. Since I am pressed for time at the moment, I'm putting this patch set out for comments > in hopes that someone else may immediately see the problem. Otherwise I'll keep looking into it as time permits. The mptable is not being initialized as you intented because irq0override is read from fw cfg after mptable initialization (oops). Also the kernel irq ack notifiers lack knowledge about the routing table, assuming identity mapping. See attached patches (qemu-kvm.c change avoids the creation of two routing entries for pin 2 pointing to different gsi's, 0 and 2). RHEL5 guests complain about "Invalid checksum", so there's still something wrong in either acpi or mptable setup. I'll try to look into this next week if nobody beats me. BIOS-e820: 00000000fffbc000 - 0000000100000000 (reserved) DMI 2.4 present. >>> ERROR: Invalid checksum No NUMA configuration found Great work Beth, thanks! diff --git a/arch/x86/kvm/i8259.c b/arch/x86/kvm/i8259.c index 179dcb0..9316037 100644 --- a/arch/x86/kvm/i8259.c +++ b/arch/x86/kvm/i8259.c @@ -49,7 +49,8 @@ static void pic_unlock(struct kvm_pic *s) spin_unlock(&s->lock); while (acks) { - kvm_notify_acked_irq(kvm, __ffs(acks)); + kvm_notify_acked_irq(kvm, SELECT_PIC(__ffs(acks)), + __ffs(acks)); acks &= acks - 1; } @@ -232,7 +233,7 @@ int kvm_pic_read_irq(struct kvm *kvm) } pic_update_irq(s); pic_unlock(s); - kvm_notify_acked_irq(kvm, irq); + kvm_notify_acked_irq(kvm, SELECT_PIC(irq), irq); return intno; } diff --git a/arch/x86/kvm/irq.h b/arch/x86/kvm/irq.h index 82579ee..9f59318 100644 --- a/arch/x86/kvm/irq.h +++ b/arch/x86/kvm/irq.h @@ -32,6 +32,8 @@ #include "lapic.h" #define PIC_NUM_PINS 16 +#define SELECT_PIC(irq) \ + ((irq) < 8 ? KVM_IRQCHIP_PIC_MASTER : KVM_IRQCHIP_PIC_SLAVE) struct kvm; struct kvm_vcpu; diff --git a/include/linux/kvm_host.h b/include/linux/kvm_host.h index ce285e0..c03a0a9 100644 --- a/include/linux/kvm_host.h +++ b/include/linux/kvm_host.h @@ -352,7 +352,7 @@ void kvm_unregister_irq_mask_notifier(struct kvm *kvm, int irq, void kvm_fire_mask_notifiers(struct kvm *kvm, int irq, bool mask); void kvm_set_irq(struct kvm *kvm, int irq_source_id, int irq, int level); -void kvm_notify_acked_irq(struct kvm *kvm, unsigned gsi); +void kvm_notify_acked_irq(struct kvm *kvm, unsigned irqchip, unsigned pin); void kvm_register_irq_ack_notifier(struct kvm *kvm, struct kvm_irq_ack_notifier *kian); void kvm_unregister_irq_ack_notifier(struct kvm_irq_ack_notifier *kian); diff --git a/virt/kvm/ioapic.c b/virt/kvm/ioapic.c index e85a2bc..1c986ac 100644 --- a/virt/kvm/ioapic.c +++ b/virt/kvm/ioapic.c @@ -293,20 +293,20 @@ void kvm_ioapic_set_irq(struct kvm_ioapic *ioapic, int irq, int level) } } -static void __kvm_ioapic_update_eoi(struct kvm_ioapic *ioapic, int gsi, +static void __kvm_ioapic_update_eoi(struct kvm_ioapic *ioapic, int pin, int trigger_mode) { union ioapic_redir_entry *ent; - ent = &ioapic->redirtbl[gsi]; + ent = &ioapic->redirtbl[pin]; - kvm_notify_acked_irq(ioapic->kvm, gsi); + kvm_notify_acked_irq(ioapic->kvm, KVM_IRQCHIP_IOAPIC, pin); if (trigger_mode == IOAPIC_LEVEL_TRIG) { ASSERT(ent->fields.trig_mode == IOAPIC_LEVEL_TRIG); ent->fields.remote_irr = 0; - if (!ent->fields.mask && (ioapic->irr & (1 << gsi))) - ioapic_service(ioapic, gsi); + if (!ent->fields.mask && (ioapic->irr & (1 << pin))) + ioapic_service(ioapic, pin); } } diff --git a/virt/kvm/irq_comm.c b/virt/kvm/irq_comm.c index a797fa5..0b4c69f 100644 --- a/virt/kvm/irq_comm.c +++ b/virt/kvm/irq_comm.c @@ -59,10 +59,19 @@ void kvm_set_irq(struct kvm *kvm, int irq_source_id, int irq, int level) e->set(e, kvm, !!(*irq_state)); } -void kvm_notify_acked_irq(struct kvm *kvm, unsigned gsi) +void kvm_notify_acked_irq(struct kvm *kvm, unsigned irqchip, unsigned pin) { + struct kvm_kernel_irq_routing_entry *e; struct kvm_irq_ack_notifier *kian; struct hlist_node *n; + unsigned gsi = -1; + + list_for_each_entry(e, &kvm->irq_routing, link) + if (e->irqchip.irqchip == irqchip && + e->irqchip.pin == pin) { + gsi = e->gsi; + break; + } hlist_for_each_entry(kian, n, &kvm->arch.irq_ack_notifier_list, link) if (kian->gsi == gsi) @@ -237,8 +246,6 @@ out: #define ROUTING_ENTRY1(irq) IOAPIC_ROUTING_ENTRY(irq) #ifdef CONFIG_X86 -#define SELECT_PIC(irq) \ - ((irq) < 8 ? KVM_IRQCHIP_PIC_MASTER : KVM_IRQCHIP_PIC_SLAVE) # define PIC_ROUTING_ENTRY(irq) \ { .gsi = irq, .type = KVM_IRQ_ROUTING_IRQCHIP, \ .u.irqchip.irqchip = SELECT_PIC(irq), .u.irqchip.pin = (irq) % 8 } Index: kvm-userspace.tip/bios/rombios32.c =================================================================== --- kvm-userspace.tip.orig/bios/rombios32.c +++ kvm-userspace.tip/bios/rombios32.c @@ -2299,14 +2299,14 @@ void rombios32_init(uint32_t *s3_resume_ if (bios_table_cur_addr != 0) { + irq0_override_probe(); + mptable_init(); uuid_probe(); smbios_init(); - irq0_override_probe(); - if (acpi_enabled) acpi_bios_init(); Index: kvm-userspace.tip/qemu/qemu-kvm.c =================================================================== --- kvm-userspace.tip.orig/qemu/qemu-kvm.c +++ kvm-userspace.tip/qemu/qemu-kvm.c @@ -817,7 +817,7 @@ int kvm_qemu_create_context(void) for (i = 0; i < 24; ++i) { if (i == 0) r = kvm_add_irq_route(kvm_context, i, KVM_IRQCHIP_IOAPIC, 2); - else + else if (i != 2) r = kvm_add_irq_route(kvm_context, i, KVM_IRQCHIP_IOAPIC, i); if (r < 0) return r;