All of lore.kernel.org
 help / color / mirror / Atom feed
From: Avi Kivity <avi@redhat.com>
To: kvm@vger.kernel.org
Cc: linux-kernel@vger.kernel.org
Subject: [PATCH 30/38] KVM: enable PCI multiple-segments for pass-through device
Date: Tue, 16 Feb 2010 12:35:28 +0200	[thread overview]
Message-ID: <1266316536-28936-31-git-send-email-avi@redhat.com> (raw)
In-Reply-To: <1266316536-28936-1-git-send-email-avi@redhat.com>

From: Zhai, Edwin <edwin.zhai@intel.com>

Enable optional parameter (default 0) - PCI segment (or domain) besides
BDF, when assigning PCI device to guest.

Signed-off-by: Zhai Edwin <edwin.zhai@intel.com>
Acked-by: Chris Wright <chrisw@sous-sol.org>
Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
---
 arch/x86/kvm/x86.c       |    1 +
 include/linux/kvm.h      |    4 +++-
 include/linux/kvm_host.h |    1 +
 virt/kvm/assigned-dev.c  |    4 +++-
 virt/kvm/iommu.c         |    9 ++++++---
 5 files changed, 14 insertions(+), 5 deletions(-)

diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
index d47ceda..0bf3df5 100644
--- a/arch/x86/kvm/x86.c
+++ b/arch/x86/kvm/x86.c
@@ -1569,6 +1569,7 @@ int kvm_dev_ioctl_check_extension(long ext)
 	case KVM_CAP_HYPERV:
 	case KVM_CAP_HYPERV_VAPIC:
 	case KVM_CAP_HYPERV_SPIN:
+	case KVM_CAP_PCI_SEGMENT:
 		r = 1;
 		break;
 	case KVM_CAP_COALESCED_MMIO:
diff --git a/include/linux/kvm.h b/include/linux/kvm.h
index 4c4937e..dfa54be 100644
--- a/include/linux/kvm.h
+++ b/include/linux/kvm.h
@@ -500,6 +500,7 @@ struct kvm_ioeventfd {
 #define KVM_CAP_HYPERV 44
 #define KVM_CAP_HYPERV_VAPIC 45
 #define KVM_CAP_HYPERV_SPIN 46
+#define KVM_CAP_PCI_SEGMENT 47
 
 #ifdef KVM_CAP_IRQ_ROUTING
 
@@ -694,8 +695,9 @@ struct kvm_assigned_pci_dev {
 	__u32 busnr;
 	__u32 devfn;
 	__u32 flags;
+	__u32 segnr;
 	union {
-		__u32 reserved[12];
+		__u32 reserved[11];
 	};
 };
 
diff --git a/include/linux/kvm_host.h b/include/linux/kvm_host.h
index dfde04b..665c370 100644
--- a/include/linux/kvm_host.h
+++ b/include/linux/kvm_host.h
@@ -400,6 +400,7 @@ struct kvm_assigned_dev_kernel {
 	struct work_struct interrupt_work;
 	struct list_head list;
 	int assigned_dev_id;
+	int host_segnr;
 	int host_busnr;
 	int host_devfn;
 	unsigned int entries_nr;
diff --git a/virt/kvm/assigned-dev.c b/virt/kvm/assigned-dev.c
index f51e684..057e2cc 100644
--- a/virt/kvm/assigned-dev.c
+++ b/virt/kvm/assigned-dev.c
@@ -526,7 +526,8 @@ static int kvm_vm_ioctl_assign_device(struct kvm *kvm,
 		r = -ENOMEM;
 		goto out;
 	}
-	dev = pci_get_bus_and_slot(assigned_dev->busnr,
+	dev = pci_get_domain_bus_and_slot(assigned_dev->segnr,
+				   assigned_dev->busnr,
 				   assigned_dev->devfn);
 	if (!dev) {
 		printk(KERN_INFO "%s: host device not found\n", __func__);
@@ -548,6 +549,7 @@ static int kvm_vm_ioctl_assign_device(struct kvm *kvm,
 	pci_reset_function(dev);
 
 	match->assigned_dev_id = assigned_dev->assigned_dev_id;
+	match->host_segnr = assigned_dev->segnr;
 	match->host_busnr = assigned_dev->busnr;
 	match->host_devfn = assigned_dev->devfn;
 	match->flags = assigned_dev->flags;
diff --git a/virt/kvm/iommu.c b/virt/kvm/iommu.c
index 65a5143..80fd3ad 100644
--- a/virt/kvm/iommu.c
+++ b/virt/kvm/iommu.c
@@ -106,7 +106,8 @@ int kvm_assign_device(struct kvm *kvm,
 
 	r = iommu_attach_device(domain, &pdev->dev);
 	if (r) {
-		printk(KERN_ERR "assign device %x:%x.%x failed",
+		printk(KERN_ERR "assign device %x:%x:%x.%x failed",
+			pci_domain_nr(pdev->bus),
 			pdev->bus->number,
 			PCI_SLOT(pdev->devfn),
 			PCI_FUNC(pdev->devfn));
@@ -127,7 +128,8 @@ int kvm_assign_device(struct kvm *kvm,
 			goto out_unmap;
 	}
 
-	printk(KERN_DEBUG "assign device: host bdf = %x:%x:%x\n",
+	printk(KERN_DEBUG "assign device %x:%x:%x.%x\n",
+		assigned_dev->host_segnr,
 		assigned_dev->host_busnr,
 		PCI_SLOT(assigned_dev->host_devfn),
 		PCI_FUNC(assigned_dev->host_devfn));
@@ -154,7 +156,8 @@ int kvm_deassign_device(struct kvm *kvm,
 
 	iommu_detach_device(domain, &pdev->dev);
 
-	printk(KERN_DEBUG "deassign device: host bdf = %x:%x:%x\n",
+	printk(KERN_DEBUG "deassign device %x:%x:%x.%x\n",
+		assigned_dev->host_segnr,
 		assigned_dev->host_busnr,
 		PCI_SLOT(assigned_dev->host_devfn),
 		PCI_FUNC(assigned_dev->host_devfn));
-- 
1.6.5.3


  parent reply	other threads:[~2010-02-16 10:36 UTC|newest]

Thread overview: 39+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-02-16 10:34 [PATCH 00/38] KVM updates for the 2.6.34 merge window (batch 3/4) Avi Kivity
2010-02-16 10:34 ` [PATCH 01/38] KVM: export <asm/hyperv.h> Avi Kivity
2010-02-16 10:35 ` [PATCH 02/38] KVM: VMX: Remove emulation failure report Avi Kivity
2010-02-16 10:35 ` [PATCH 03/38] KVM: fix Hyper-V hypercall warnings and wrong mask value Avi Kivity
2010-02-16 10:35 ` [PATCH 04/38] KVM: fix cleanup_srcu_struct on vm destruction Avi Kivity
2010-02-16 10:35 ` [PATCH 05/38] KVM: x86: Use macros for x86_emulate_ops to avoid future mistakes Avi Kivity
2010-02-16 10:35 ` [PATCH 06/38] KVM: VMX: Fix exceptions of mov to dr Avi Kivity
2010-02-16 10:35 ` [PATCH 07/38] KVM: VMX: Fix emulation of DR4 and DR5 Avi Kivity
2010-02-16 10:35 ` [PATCH 08/38] KVM: VMX: Clean up DR6 emulation Avi Kivity
2010-02-16 10:35 ` [PATCH 09/38] KVM: SVM: Clean up and enhance mov dr emulation Avi Kivity
2010-02-16 10:35 ` [PATCH 10/38] KVM: SVM: Trap all debug register accesses Avi Kivity
2010-02-16 10:35 ` [PATCH 11/38] KVM: Fix kvm_coalesced_mmio_ring duplicate allocation Avi Kivity
2010-02-16 10:35 ` [PATCH 12/38] KVM: x86: fix checking of cr0 validity Avi Kivity
2010-02-16 10:35 ` [PATCH 13/38] KVM: Allow kvm_load_guest_fpu() even when !vcpu->fpu_active Avi Kivity
2010-02-16 10:35 ` [PATCH 14/38] KVM: Drop kvm_{load,put}_guest_fpu() exports Avi Kivity
2010-02-16 10:35 ` [PATCH 15/38] KVM: Activate fpu on clts Avi Kivity
2010-02-16 10:35 ` [PATCH 16/38] KVM: Add a helper for checking if the guest is in protected mode Avi Kivity
2010-02-16 10:35 ` [PATCH 17/38] KVM: Move cr0/cr4/efer related helpers to x86.h Avi Kivity
2010-02-16 10:35 ` [PATCH 18/38] KVM: Rename vcpu->shadow_efer to efer Avi Kivity
2010-02-16 10:35 ` [PATCH 19/38] KVM: Optimize kvm_read_cr[04]_bits() Avi Kivity
2010-02-16 10:35 ` [PATCH 20/38] KVM: trace guest fpu loads and unloads Avi Kivity
2010-02-16 10:35 ` [PATCH 21/38] KVM: MMU: Remove some useless code from alloc_mmu_pages() Avi Kivity
2010-02-16 10:35 ` [PATCH 22/38] KVM: PPC E500: Add register l1csr0 emulation Avi Kivity
2010-02-16 10:35 ` [PATCH 23/38] KVM: PPC: Add PVR/PIR init for E500 Avi Kivity
2010-02-16 10:35 ` [PATCH 24/38] KVM: PPC E500: fix tlbcfg emulation Avi Kivity
2010-02-16 10:35 ` [PATCH 25/38] KVM: VMX: Pass cr0.mp through to the guest when the fpu is active Avi Kivity
2010-02-16 10:35 ` [PATCH 26/38] KVM: mark segments accessed on HW task switch Avi Kivity
2010-02-16 10:35 ` [PATCH 27/38] KVM: Fix msr trace Avi Kivity
2010-02-16 10:35 ` [PATCH 28/38] KVM: Trace failed msr reads and writes Avi Kivity
2010-02-16 10:35 ` [PATCH 29/38] KVM: VMX: Remove redundant check in vm_need_virtualize_apic_accesses() Avi Kivity
2010-02-16 10:35 ` Avi Kivity [this message]
2010-02-16 10:35 ` [PATCH 31/38] KVM: fix load_guest_segment_descriptor() to return X86EMUL_* Avi Kivity
2010-02-16 10:35 ` [PATCH 32/38] KVM: fix kvm_fix_hypercall() " Avi Kivity
2010-02-16 10:35 ` [PATCH 33/38] KVM: VMX: Wire up .fpu_activate() callback Avi Kivity
2010-02-16 10:35 ` [PATCH 34/38] KVM: ia64: Fix string literal continuation lines Avi Kivity
2010-02-16 10:35 ` [PATCH 35/38] KVM: VMX: Remove redundant test in vmx_set_efer() Avi Kivity
2010-02-16 10:35 ` [PATCH 36/38] KVM: Introduce kvm_host_page_size Avi Kivity
2010-02-16 10:35 ` [PATCH 37/38] KVM: VMX: emulate accessed bit for EPT Avi Kivity
2010-02-16 10:35 ` [PATCH 38/38] KVM: Remove redundant reading of rax on OUT instructions Avi Kivity

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1266316536-28936-31-git-send-email-avi@redhat.com \
    --to=avi@redhat.com \
    --cc=kvm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.