From mboxrd@z Thu Jan 1 00:00:00 1970 From: Jan Kiszka Subject: Re: [PATCH 2/3] KVM: Emulate MSI-X table in kernel Date: Mon, 17 Jan 2011 14:47:03 +0100 Message-ID: <4D344857.8020603@siemens.com> References: <1294309185-21417-1-git-send-email-sheng@linux.intel.com> <1294309185-21417-3-git-send-email-sheng@linux.intel.com> <4D343638.30004@redhat.com> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Cc: Sheng Yang , Marcelo Tosatti , "Michael S. Tsirkin" , kvm@vger.kernel.org To: Avi Kivity Return-path: Received: from david.siemens.de ([192.35.17.14]:22193 "EHLO david.siemens.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752316Ab1AQNrV (ORCPT ); Mon, 17 Jan 2011 08:47:21 -0500 In-Reply-To: <4D343638.30004@redhat.com> Sender: kvm-owner@vger.kernel.org List-ID: On 2011-01-17 13:29, Avi Kivity wrote: > On 01/06/2011 12:19 PM, Sheng Yang wrote: >> Then we can support mask bit operation of assigned devices now. >> >> >> >> +int kvm_assigned_device_update_msix_mask_bit(struct kvm *kvm, >> + int assigned_dev_id, int entry, bool mask) >> +{ >> + int r = -EFAULT; >> + struct kvm_assigned_dev_kernel *adev; >> + int i; >> + >> + if (!irqchip_in_kernel(kvm)) >> + return r; >> + >> + mutex_lock(&kvm->lock); >> + adev = kvm_find_assigned_dev(&kvm->arch.assigned_dev_head, >> + assigned_dev_id); >> + if (!adev) >> + goto out; >> + >> + for (i = 0; i< adev->entries_nr; i++) >> + if (adev->host_msix_entries[i].entry == entry) { >> + if (mask) >> + disable_irq_nosync( >> + adev->host_msix_entries[i].vector); > > Is it okay to call disable_irq_nosync() here? IIRC we don't check the > mask bit on irq delivery, so we may forward an interrupt to the guest > after the mask bit was set. > > What does pci say about the mask bit? when does it take effect? > > Another question is whether disable_irq_nosync() actually programs the > device mask bit, or not. If it does, then it's slow, and it may be > better to leave interrupts enabled but have an internal pending bit. If > it doesn't program the mask bit, it's fine. disable_irq* works lazily, only disabling the line in software. If an IRQ actually occurs, it is marked pending and the line is left masked on handler return (that's one reason why masking via PCI config space is slower at macro level). Jan -- Siemens AG, Corporate Technology, CT T DE IT 1 Corporate Competence Center Embedded Linux