From mboxrd@z Thu Jan 1 00:00:00 1970 From: "Yang, Sheng" Subject: Re: [PATCH 3/8] KVM: Handle device assignment to guests Date: Thu, 17 Jul 2008 10:29:34 +0800 Message-ID: <200807171029.34395.sheng.yang@intel.com> References: <1216214225-18030-1-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" Content-Transfer-Encoding: 7bit Cc: "Han, Weidong" , "Avi Kivity" , "Ben-Ami Yassour" , amit.shah@qumranet.com, muli@il.ibm.com, anthony@codemonkey.ws To: kvm@vger.kernel.org Return-path: Received: from mga09.intel.com ([134.134.136.24]:55273 "EHLO mga09.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752738AbYGQC1x (ORCPT ); Wed, 16 Jul 2008 22:27:53 -0400 In-Reply-To: <0122C7C995D32147B66BF4F440D30163015DC7E7@pdsmsx415.ccr.corp.intel.com> Content-Disposition: inline Sender: kvm-owner@vger.kernel.org List-ID: On Thursday 17 July 2008 10:09:57 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. > I am working on the MSI support now. -- regards Yang, Sheng