From mboxrd@z Thu Jan 1 00:00:00 1970 From: Avi Kivity Subject: Re: [PATCH 3/8] KVM: Handle device assignment to guests Date: Thu, 17 Jul 2008 09:02:32 +0300 Message-ID: <487EE078.8020001@qumranet.com> References: <1216214225-18030-1-git-send-email-benami@il.ibm.com> <1216214225-18030-2-git-send-email-benami@il.ibm.com> <1216214225-18030-3-git-send-email-benami@il.ibm.com> <1216214225-18030-4-git-send-email-benami@il.ibm.com> <487E0E10.4000009@qumranet.com> <0122C7C995D32147B66BF4F440D30163015DC7E7@pdsmsx415.ccr.corp.intel.com> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Cc: Ben-Ami Yassour , amit.shah@qumranet.com, kvm@vger.kernel.org, muli@il.ibm.com, anthony@codemonkey.ws To: "Han, Weidong" Return-path: Received: from il.qumranet.com ([212.179.150.194]:49044 "EHLO il.qumranet.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752654AbYGQGCe (ORCPT ); Thu, 17 Jul 2008 02:02:34 -0400 In-Reply-To: <0122C7C995D32147B66BF4F440D30163015DC7E7@pdsmsx415.ccr.corp.intel.com> Sender: kvm-owner@vger.kernel.org List-ID: Han, Weidong wrote: > Avi Kivity wrote: > >>> +static void kvm_pci_pt_work_fn(struct work_struct *work) +{ >>> + struct kvm_pci_pt_dev_list *match; >>> + struct kvm_pci_pt_work *int_work; >>> + int source; >>> + unsigned long flags; >>> + int guest_irq; >>> + int host_irq; >>> + >>> + int_work = container_of(work, struct kvm_pci_pt_work, work); + >>> + source = int_work->source ? KVM_PT_SOURCE_IRQ_ACK : >>> KVM_PT_SOURCE_IRQ; + + /* This is taken to safely inject irq >>> > inside > >>> the guest. When + * the interrupt injection (or the ioapic code) >>> uses a + * finer-grained lock, update this >>> + */ >>> + mutex_lock(&int_work->kvm->lock); >>> + read_lock_irqsave(&kvm_pci_pt_lock, flags); >>> + match = >>> > kvm_find_pci_pt_dev(&int_work->kvm->arch.pci_pt_dev_head, > >>> NULL, + int_work->irq, source); >>> + if (!match) { >>> + printk(KERN_ERR "%s: no matching device assigned to >>> > guest " > >>> + "found for irq %d, source = %d!\n", >>> + __func__, int_work->irq, int_work->source); >>> + read_unlock_irqrestore(&kvm_pci_pt_lock, flags); + >>> > goto out; > >>> + } >>> + guest_irq = match->pt_dev.guest.irq; >>> + host_irq = match->pt_dev.host.irq; >>> + read_unlock_irqrestore(&kvm_pci_pt_lock, flags); >>> + >>> + if (source == KVM_PT_SOURCE_IRQ) >>> + kvm_set_irq(int_work->kvm, guest_irq, 1); >>> + else { >>> + kvm_set_irq(int_work->kvm, int_work->irq, 0); >>> + enable_irq(host_irq); >>> + } >>> +out: >>> + mutex_unlock(&int_work->kvm->lock); >>> + kvm_put_kvm(int_work->kvm); >>> +} >>> >>> + >>> +/* FIXME: Implement the OR logic needed to make shared interrupts >>> on + * this line behave properly + */ >>> >>> >> Isn't this a showstopper? There is no easy way for a user to avoid >> sharing, especially as we have only three pci irqs at present. >> >> > > Currently it's not easy to avoid sharing. I think we can support MSI for > assgined device to solve sharing problem. > MSI is definitely the right direction, but we also need to support the OR logic for guests that do not support MSI. -- I have a truly marvellous patch that fixes the bug which this signature is too narrow to contain.