diff options
author | Sheng Yang <sheng@linux.intel.com> | 2009-03-12 09:45:39 -0400 |
---|---|---|
committer | Avi Kivity <avi@redhat.com> | 2009-06-10 04:48:29 -0400 |
commit | e56d532f20c890a06bbe7cd479f4201e3a03cd73 (patch) | |
tree | 6c8b1a019a77bf2081ac7482eea322f5b0a636e8 /include/linux/kvm.h | |
parent | 386eb6e8b3caface8a0514da70a47c05cabb5b96 (diff) |
KVM: Device assignment framework rework
After discussion with Marcelo, we decided to rework device assignment framework
together. The old problems are kernel logic is unnecessary complex. So Marcelo
suggest to split it into a more elegant way:
1. Split host IRQ assign and guest IRQ assign. And userspace determine the
combination. Also discard msi2intx parameter, userspace can specific
KVM_DEV_IRQ_HOST_MSI | KVM_DEV_IRQ_GUEST_INTX in assigned_irq->flags to
enable MSI to INTx convertion.
2. Split assign IRQ and deassign IRQ. Import two new ioctls:
KVM_ASSIGN_DEV_IRQ and KVM_DEASSIGN_DEV_IRQ.
This patch also fixed the reversed _IOR vs _IOW in definition(by deprecated the
old interface).
[avi: replace homemade bitcount() by hweight_long()]
Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
Signed-off-by: Sheng Yang <sheng@linux.intel.com>
Signed-off-by: Avi Kivity <avi@redhat.com>
Diffstat (limited to 'include/linux/kvm.h')
-rw-r--r-- | include/linux/kvm.h | 26 |
1 files changed, 17 insertions, 9 deletions
diff --git a/include/linux/kvm.h b/include/linux/kvm.h index 640835ed2708..644e3a9f47db 100644 --- a/include/linux/kvm.h +++ b/include/linux/kvm.h | |||
@@ -412,6 +412,7 @@ struct kvm_trace_rec { | |||
412 | #ifdef __KVM_HAVE_MSIX | 412 | #ifdef __KVM_HAVE_MSIX |
413 | #define KVM_CAP_DEVICE_MSIX 28 | 413 | #define KVM_CAP_DEVICE_MSIX 28 |
414 | #endif | 414 | #endif |
415 | #define KVM_CAP_ASSIGN_DEV_IRQ 29 | ||
415 | /* Another bug in KVM_SET_USER_MEMORY_REGION fixed: */ | 416 | /* Another bug in KVM_SET_USER_MEMORY_REGION fixed: */ |
416 | #define KVM_CAP_JOIN_MEMORY_REGIONS_WORKS 30 | 417 | #define KVM_CAP_JOIN_MEMORY_REGIONS_WORKS 30 |
417 | 418 | ||
@@ -485,8 +486,10 @@ struct kvm_irq_routing { | |||
485 | #define KVM_ASSIGN_PCI_DEVICE _IOR(KVMIO, 0x69, \ | 486 | #define KVM_ASSIGN_PCI_DEVICE _IOR(KVMIO, 0x69, \ |
486 | struct kvm_assigned_pci_dev) | 487 | struct kvm_assigned_pci_dev) |
487 | #define KVM_SET_GSI_ROUTING _IOW(KVMIO, 0x6a, struct kvm_irq_routing) | 488 | #define KVM_SET_GSI_ROUTING _IOW(KVMIO, 0x6a, struct kvm_irq_routing) |
489 | /* deprecated, replaced by KVM_ASSIGN_DEV_IRQ */ | ||
488 | #define KVM_ASSIGN_IRQ _IOR(KVMIO, 0x70, \ | 490 | #define KVM_ASSIGN_IRQ _IOR(KVMIO, 0x70, \ |
489 | struct kvm_assigned_irq) | 491 | struct kvm_assigned_irq) |
492 | #define KVM_ASSIGN_DEV_IRQ _IOW(KVMIO, 0x70, struct kvm_assigned_irq) | ||
490 | #define KVM_REINJECT_CONTROL _IO(KVMIO, 0x71) | 493 | #define KVM_REINJECT_CONTROL _IO(KVMIO, 0x71) |
491 | #define KVM_DEASSIGN_PCI_DEVICE _IOW(KVMIO, 0x72, \ | 494 | #define KVM_DEASSIGN_PCI_DEVICE _IOW(KVMIO, 0x72, \ |
492 | struct kvm_assigned_pci_dev) | 495 | struct kvm_assigned_pci_dev) |
@@ -494,6 +497,7 @@ struct kvm_irq_routing { | |||
494 | _IOW(KVMIO, 0x73, struct kvm_assigned_msix_nr) | 497 | _IOW(KVMIO, 0x73, struct kvm_assigned_msix_nr) |
495 | #define KVM_ASSIGN_SET_MSIX_ENTRY \ | 498 | #define KVM_ASSIGN_SET_MSIX_ENTRY \ |
496 | _IOW(KVMIO, 0x74, struct kvm_assigned_msix_entry) | 499 | _IOW(KVMIO, 0x74, struct kvm_assigned_msix_entry) |
500 | #define KVM_DEASSIGN_DEV_IRQ _IOW(KVMIO, 0x75, struct kvm_assigned_irq) | ||
497 | 501 | ||
498 | /* | 502 | /* |
499 | * ioctls for vcpu fds | 503 | * ioctls for vcpu fds |
@@ -584,6 +588,8 @@ struct kvm_debug_guest { | |||
584 | #define KVM_TRC_STLB_INVAL (KVM_TRC_HANDLER + 0x18) | 588 | #define KVM_TRC_STLB_INVAL (KVM_TRC_HANDLER + 0x18) |
585 | #define KVM_TRC_PPC_INSTR (KVM_TRC_HANDLER + 0x19) | 589 | #define KVM_TRC_PPC_INSTR (KVM_TRC_HANDLER + 0x19) |
586 | 590 | ||
591 | #define KVM_DEV_ASSIGN_ENABLE_IOMMU (1 << 0) | ||
592 | |||
587 | struct kvm_assigned_pci_dev { | 593 | struct kvm_assigned_pci_dev { |
588 | __u32 assigned_dev_id; | 594 | __u32 assigned_dev_id; |
589 | __u32 busnr; | 595 | __u32 busnr; |
@@ -594,6 +600,17 @@ struct kvm_assigned_pci_dev { | |||
594 | }; | 600 | }; |
595 | }; | 601 | }; |
596 | 602 | ||
603 | #define KVM_DEV_IRQ_HOST_INTX (1 << 0) | ||
604 | #define KVM_DEV_IRQ_HOST_MSI (1 << 1) | ||
605 | #define KVM_DEV_IRQ_HOST_MSIX (1 << 2) | ||
606 | |||
607 | #define KVM_DEV_IRQ_GUEST_INTX (1 << 8) | ||
608 | #define KVM_DEV_IRQ_GUEST_MSI (1 << 9) | ||
609 | #define KVM_DEV_IRQ_GUEST_MSIX (1 << 10) | ||
610 | |||
611 | #define KVM_DEV_IRQ_HOST_MASK 0x00ff | ||
612 | #define KVM_DEV_IRQ_GUEST_MASK 0xff00 | ||
613 | |||
597 | struct kvm_assigned_irq { | 614 | struct kvm_assigned_irq { |
598 | __u32 assigned_dev_id; | 615 | __u32 assigned_dev_id; |
599 | __u32 host_irq; | 616 | __u32 host_irq; |
@@ -609,15 +626,6 @@ struct kvm_assigned_irq { | |||
609 | }; | 626 | }; |
610 | }; | 627 | }; |
611 | 628 | ||
612 | #define KVM_DEV_ASSIGN_ENABLE_IOMMU (1 << 0) | ||
613 | |||
614 | #define KVM_DEV_IRQ_ASSIGN_MSI_ACTION KVM_DEV_IRQ_ASSIGN_ENABLE_MSI | ||
615 | #define KVM_DEV_IRQ_ASSIGN_ENABLE_MSI (1 << 0) | ||
616 | |||
617 | #define KVM_DEV_IRQ_ASSIGN_MSIX_ACTION (KVM_DEV_IRQ_ASSIGN_ENABLE_MSIX |\ | ||
618 | KVM_DEV_IRQ_ASSIGN_MASK_MSIX) | ||
619 | #define KVM_DEV_IRQ_ASSIGN_ENABLE_MSIX (1 << 1) | ||
620 | #define KVM_DEV_IRQ_ASSIGN_MASK_MSIX (1 << 2) | ||
621 | 629 | ||
622 | struct kvm_assigned_msix_nr { | 630 | struct kvm_assigned_msix_nr { |
623 | __u32 assigned_dev_id; | 631 | __u32 assigned_dev_id; |