From a76beb14123a69ca080f5a5425e28b786d62318d Mon Sep 17 00:00:00 2001 From: Alex Williamson Date: Mon, 9 Jul 2012 10:53:22 -0600 Subject: [PATCH 1/2] KVM: Fix device assignment threaded irq handler The kernel no longer allows us to pass NULL for the hard handler without also specifying IRQF_ONESHOT. IRQF_ONESHOT imposes latency in the exit path that we don't need for MSI interrupts. Long term we'd like to inject these interrupts from the hard handler when possible. In the short term, we can create dummy hard handlers that return us to the previous behavior. Credit to Michael for original patch. Fixes: https://bugzilla.kernel.org/show_bug.cgi?id=43328 Signed-off-by: Michael S. Tsirkin Signed-off-by: Alex Williamson Signed-off-by: Avi Kivity --- virt/kvm/assigned-dev.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/virt/kvm/assigned-dev.c b/virt/kvm/assigned-dev.c index b1e091ae2f37..23a41a9f8db9 100644 --- a/virt/kvm/assigned-dev.c +++ b/virt/kvm/assigned-dev.c @@ -334,6 +334,11 @@ static int assigned_device_enable_host_intx(struct kvm *kvm, } #ifdef __KVM_HAVE_MSI +static irqreturn_t kvm_assigned_dev_msi(int irq, void *dev_id) +{ + return IRQ_WAKE_THREAD; +} + static int assigned_device_enable_host_msi(struct kvm *kvm, struct kvm_assigned_dev_kernel *dev) { @@ -346,7 +351,7 @@ static int assigned_device_enable_host_msi(struct kvm *kvm, } dev->host_irq = dev->dev->irq; - if (request_threaded_irq(dev->host_irq, NULL, + if (request_threaded_irq(dev->host_irq, kvm_assigned_dev_msi, kvm_assigned_dev_thread_msi, 0, dev->irq_name, dev)) { pci_disable_msi(dev->dev); @@ -358,6 +363,11 @@ static int assigned_device_enable_host_msi(struct kvm *kvm, #endif #ifdef __KVM_HAVE_MSIX +static irqreturn_t kvm_assigned_dev_msix(int irq, void *dev_id) +{ + return IRQ_WAKE_THREAD; +} + static int assigned_device_enable_host_msix(struct kvm *kvm, struct kvm_assigned_dev_kernel *dev) { @@ -374,7 +384,8 @@ static int assigned_device_enable_host_msix(struct kvm *kvm, for (i = 0; i < dev->entries_nr; i++) { r = request_threaded_irq(dev->host_msix_entries[i].vector, - NULL, kvm_assigned_dev_thread_msix, + kvm_assigned_dev_msix, + kvm_assigned_dev_thread_msix, 0, dev->irq_name, dev); if (r) goto err; From 1dee7a3dc89fe8c7671aee012be8981a42aad45f Mon Sep 17 00:00:00 2001 From: Benjamin Herrenschmidt Date: Mon, 9 Jul 2012 22:48:17 +0000 Subject: [PATCH 2/2] powerpc/kvm: Fix "PR" KVM implementation of H_CEDE H_CEDE should enable the vcpu's MSR:EE bit. It does on "HV" KVM (it's burried in the assembly code though) and as far as I can tell, qemu does it as well. Signed-off-by: Benjamin Herrenschmidt Signed-off-by: Alexander Graf --- arch/powerpc/kvm/book3s_pr_papr.c | 1 + 1 file changed, 1 insertion(+) diff --git a/arch/powerpc/kvm/book3s_pr_papr.c b/arch/powerpc/kvm/book3s_pr_papr.c index 3ff9013d6e79..ee02b30878ed 100644 --- a/arch/powerpc/kvm/book3s_pr_papr.c +++ b/arch/powerpc/kvm/book3s_pr_papr.c @@ -241,6 +241,7 @@ int kvmppc_h_pr(struct kvm_vcpu *vcpu, unsigned long cmd) case H_PUT_TCE: return kvmppc_h_pr_put_tce(vcpu); case H_CEDE: + vcpu->arch.shared->msr |= MSR_EE; kvm_vcpu_block(vcpu); clear_bit(KVM_REQ_UNHALT, &vcpu->requests); vcpu->stat.halt_wakeup++;