* [PATCH] KVM: PCIPT: VT-d: Check if context mapping succeed or not
@ 2008-06-23 14:53 Han, Weidong
2008-06-23 19:35 ` Muli Ben-Yehuda
0 siblings, 1 reply; 2+ messages in thread
From: Han, Weidong @ 2008-06-23 14:53 UTC (permalink / raw)
To: amit.shah; +Cc: kvm, Muli Ben-Yehuda, Ben-Ami Yassour1
>From 3898ee02c07054af2867ed49cd7973016aab2132 Mon Sep 17 00:00:00 2001
From: Weidong Han <weidong.han@intel.com>
Date: Mon, 23 Jun 2008 16:45:56 +0800
Subject: [PATCH] Check if context mapping succeed or not
If context mapping fails, return error. And also, don't need to restore
back host linux iommu domain for detached device in
kvm_iommu_unmap_guest().
Signed-off-by: Weidong Han <weidong.han@intel.com>
---
arch/x86/kvm/vtd.c | 18 +++++++-----------
1 files changed, 7 insertions(+), 11 deletions(-)
diff --git a/arch/x86/kvm/vtd.c b/arch/x86/kvm/vtd.c
index be775cd..7bbd353 100644
--- a/arch/x86/kvm/vtd.c
+++ b/arch/x86/kvm/vtd.c
@@ -104,12 +104,17 @@ found:
printk(KERN_ERR "kvm_iommu_map_guest: domain ==
NULL\n");
else
printk("kvm_iommu_map_guest: domain = %p\n",
kvm->arch.domain);
-
+
if (kvm_iommu_map_memslots(kvm)) {
kvm_iommu_unmap_memslots(kvm);
return -EFAULT;
}
- kvm_intel_iommu_context_mapping(kvm->arch.domain, pdev);
+
+ if (kvm_intel_iommu_context_mapping(kvm->arch.domain, pdev)) {
+ printk(KERN_ERR "Domain context map for %s failed",
+ pci_name(pdev));
+ return -EFAULT;
+ }
return 0;
}
EXPORT_SYMBOL_GPL(kvm_iommu_map_guest);
@@ -153,7 +158,6 @@ static int kvm_iommu_unmap_memslots(struct kvm *kvm)
int kvm_iommu_unmap_guest(struct kvm *kvm)
{
- struct dmar_domain *domain;
struct kvm_pci_pt_dev_list *entry;
struct pci_dev *pdev = NULL;
@@ -181,14 +185,6 @@ found:
/* detach kvm dmar domain */
kvm_intel_iommu_detach_dev(kvm->arch.domain,
pdev->bus->number, pdev->devfn);
-
- /* now restore back linux iommu domain */
- domain = kvm_intel_iommu_find_domain(pdev);
- if (domain)
- kvm_intel_iommu_context_mapping(domain, pdev);
- else
- printk(KERN_DEBUG
- "kvm_iommu_unmap_guest: domain ==
NULL\n");
}
kvm_iommu_unmap_memslots(kvm);
kvm_intel_iommu_domain_exit(kvm->arch.domain);
--
1.5.1
^ permalink raw reply related [flat|nested] 2+ messages in thread* Re: [PATCH] KVM: PCIPT: VT-d: Check if context mapping succeed or not
2008-06-23 14:53 [PATCH] KVM: PCIPT: VT-d: Check if context mapping succeed or not Han, Weidong
@ 2008-06-23 19:35 ` Muli Ben-Yehuda
0 siblings, 0 replies; 2+ messages in thread
From: Muli Ben-Yehuda @ 2008-06-23 19:35 UTC (permalink / raw)
To: Han, Weidong; +Cc: amit.shah, kvm, Ben-Ami Yassour1
Hi Weidong,
Minor comments below.
On Mon, Jun 23, 2008 at 10:53:17PM +0800, Han, Weidong wrote:
> printk("kvm_iommu_map_guest: domain = %p\n",
> kvm->arch.domain);
> -
> +
This patch is line-wrapped, and there's some uneeded whitespace above.
> if (kvm_iommu_map_memslots(kvm)) {
> kvm_iommu_unmap_memslots(kvm);
> return -EFAULT;
> }
> - kvm_intel_iommu_context_mapping(kvm->arch.domain, pdev);
> +
> + if (kvm_intel_iommu_context_mapping(kvm->arch.domain, pdev)) {
> + printk(KERN_ERR "Domain context map for %s failed",
> + pci_name(pdev));
> + return -EFAULT;
> + }
Why not return the return value from kvm_intel_iommu_context_mapping()
directly? It will make debugging a little bit easier.
Cheers,
Muli
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2008-06-23 19:35 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-06-23 14:53 [PATCH] KVM: PCIPT: VT-d: Check if context mapping succeed or not Han, Weidong
2008-06-23 19:35 ` Muli Ben-Yehuda
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox