Re: [PATCH 6/8] KVM: assigned dev: Preparation for mask support in userspace

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



 On 10/20/2010 10:26 AM, Sheng Yang wrote:
The feature wouldn't be enabled until later patch set msix_flags_enabled. It
would be enabled along with mask support in kernel.


diff --git a/arch/x86/include/asm/kvm_host.h b/arch/x86/include/asm/kvm_host.h
index e209078..2bb69ba 100644
--- a/arch/x86/include/asm/kvm_host.h
+++ b/arch/x86/include/asm/kvm_host.h
@@ -456,6 +456,8 @@ struct kvm_arch {
  	/* fields used by HYPER-V emulation */
  	u64 hv_guest_os_id;
  	u64 hv_hypercall;
+
+	bool msix_flags_enabled;
  };

In theory this should be in generic code, under #ifdef KVM_APIC_ARCHITECTURE. In practice x86 is fine since ia64 isn't actively developed.

@@ -666,11 +666,35 @@ msix_nr_out:
  	return r;
  }

+static void update_msix_mask(struct kvm_assigned_dev_kernel *assigned_dev,
+			     int index)
+{
+	int irq;
+	struct irq_desc *desc;
+
+	if (!assigned_dev->dev->msix_enabled ||
+	    !(assigned_dev->irq_requested_type&  KVM_DEV_IRQ_HOST_MSIX))
+		return;
+
+	irq = assigned_dev->host_msix_entries[index].vector;
+	BUG_ON(irq == 0);
+	desc = irq_to_desc(irq);
+	BUG_ON(!desc->msi_desc);
+
+	if (assigned_dev->guest_msix_entries[index].flags&
+			KVM_ASSIGNED_MSIX_MASK) {
+		desc->chip->mask(irq);
+		flush_work(&assigned_dev->interrupt_work);
+	} else
+		desc->chip->unmask(irq);
+}
+
  static int kvm_vm_ioctl_set_msix_entry(struct kvm *kvm,
  				       struct kvm_assigned_msix_entry *entry)
  {
  	int r = 0, i;
  	struct kvm_assigned_dev_kernel *adev;
+	bool entry_masked;

  	mutex_lock(&kvm->lock);

@@ -688,6 +712,21 @@ static int kvm_vm_ioctl_set_msix_entry(struct kvm *kvm,
  			adev->guest_msix_entries[i].entry = entry->entry;
  			adev->guest_msix_entries[i].vector = entry->gsi;
  			adev->host_msix_entries[i].entry = entry->entry;
+			if (!kvm->arch.msix_flags_enabled)
+				break;
+			entry_masked = adev->guest_msix_entries[i].flags&
+				KVM_ASSIGNED_MSIX_MASK;
+			if ((entry->flags&  KVM_MSIX_FLAG_MASK)&&
+					!entry_masked) {
+				adev->guest_msix_entries[i].flags |=
+					KVM_ASSIGNED_MSIX_MASK;
+				update_msix_mask(adev, i);
+			} else if (!(entry->flags&  KVM_MSIX_FLAG_MASK)&&
+					entry_masked) {
+				adev->guest_msix_entries[i].flags&=
+					~KVM_ASSIGNED_MSIX_MASK;
+				update_msix_mask(adev, i);
+			}
  			break;
  		}

I think you can fold these two functions together, will get rid of the extra if and be a little more readable.

--
error compiling committee.c: too many arguments to function

--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [KVM ARM]     [KVM ia64]     [KVM ppc]     [Virtualization Tools]     [Spice Development]     [Libvirt]     [Libvirt Users]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite Questions]     [Linux Kernel]     [Linux SCSI]     [XFree86]
  Powered by Linux