From patchwork Tue Dec 1 14:36:33 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chris Lalancette X-Patchwork-Id: 63969 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 nB1EbP0U013481 for ; Tue, 1 Dec 2009 14:37:25 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753456AbZLAOhI (ORCPT ); Tue, 1 Dec 2009 09:37:08 -0500 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1753258AbZLAOhI (ORCPT ); Tue, 1 Dec 2009 09:37:08 -0500 Received: from mx1.redhat.com ([209.132.183.28]:47576 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753070AbZLAOhB (ORCPT ); Tue, 1 Dec 2009 09:37:01 -0500 Received: from int-mx03.intmail.prod.int.phx2.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.16]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id nB1Eb8Kx013208 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Tue, 1 Dec 2009 09:37:08 -0500 Received: from localhost.localdomain (ovpn01.gateway.prod.ext.phx2.redhat.com [10.5.9.1]) by int-mx03.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id nB1Eb36N002533; Tue, 1 Dec 2009 09:37:07 -0500 From: Chris Lalancette To: kvm@vger.kernel.org Cc: Chris Lalancette Subject: [PATCH 04/12] IOAPIC timer interrupt redirect. Date: Tue, 1 Dec 2009 15:36:33 +0100 Message-Id: <1259678201-11203-5-git-send-email-clalance@redhat.com> In-Reply-To: <1259678201-11203-1-git-send-email-clalance@redhat.com> References: <1259678201-11203-1-git-send-email-clalance@redhat.com> X-Scanned-By: MIMEDefang 2.67 on 10.5.11.16 Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org diff --git a/virt/kvm/ioapic.c b/virt/kvm/ioapic.c index 53f3166..fd52949 100644 --- a/virt/kvm/ioapic.c +++ b/virt/kvm/ioapic.c @@ -144,6 +144,15 @@ static void ioapic_write_indirect(struct kvm_ioapic *ioapic, u32 val) } } +static int ioapic_dest_multiple_cpus(struct kvm_lapic_irq *irqe) +{ + /* physical mode is always directed to 1 cpu */ + if (irqe->dest_mode == 0 || irqe->dest_id == 0) + return 0; + + return hweight_long(irqe->dest_id) != 1; +} + static int ioapic_deliver(struct kvm_ioapic *ioapic, int irq) { union kvm_ioapic_redirect_entry *entry = &ioapic->redirtbl[irq]; @@ -164,8 +173,10 @@ static int ioapic_deliver(struct kvm_ioapic *ioapic, int irq) irqe.shorthand = 0; #ifdef CONFIG_X86 - /* Always deliver PIT interrupt to vcpu 0 */ - if (irq == 0) { + /* if this is the PIT interrupt and the dest_id is multiple + * vcpus, re-write to go to vcpu 0 + */ + if (irq == 0 && ioapic_dest_multiple_cpus(&irqe)) { irqe.dest_mode = 0; /* Physical mode. */ /* need to read apic_id from apic register since * it can be rewritten */