All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] AMD IOMMU: Destroy passthru guests when IO pagetable allcation fails
@ 2009-08-14 12:49 Wei Wang2
  0 siblings, 0 replies; only message in thread
From: Wei Wang2 @ 2009-08-14 12:49 UTC (permalink / raw)
  To: xen-devel

[-- Attachment #1: Type: text/plain, Size: 615 bytes --]

Hi,
This patch destroys passthru guests if IO pagetable allocation cannot be 
satisfied to prevent potential system crash. Please apply this patch to both 
3.4-testing and xen-unstable.
Thanks,
Wei

Signed-off-by: Wei Wang <wei.wang2@amd.com>
Acked-by: Wei Huang <wei.huang2@amd.com>

AMD GmbH, Germany
Operating System Research Center

Legal Information:
Advanced Micro Devices GmbH
Karl-Hammerschmidt-Str. 34
85609 Dornach b. München

Geschäftsführer: Jochen Polster, Thomas M. McCoy, Giuliano Meroni
Sitz: Dornach, Gemeinde Aschheim, Landkreis München
Registergericht München, HRB Nr. 43632

[-- Attachment #2: iopt.patch --]
[-- Type: text/x-diff, Size: 2420 bytes --]

diff -r 71d6d6f2ecd6 xen/drivers/passthrough/amd/iommu_map.c
--- a/xen/drivers/passthrough/amd/iommu_map.c	Fri Aug 07 09:54:43 2009 +0100
+++ b/xen/drivers/passthrough/amd/iommu_map.c	Wed Aug 12 13:20:21 2009 +0200
@@ -426,7 +426,10 @@ static u64 iommu_l2e_from_pfn(struct pag
             {
                 table = alloc_amd_iommu_pgtable();
                 if ( table == NULL )
+                {
+                    printk("AMD-Vi: Cannot allocate I/O page table\n");
                     return 0;
+                }
                 next_table_maddr = page_to_maddr(table);
                 amd_iommu_set_page_directory_entry(
                     (u32 *)pde, next_table_maddr, level - 1);
@@ -462,6 +465,7 @@ int amd_iommu_map_page(struct domain *d,
     {
         spin_unlock(&hd->mapping_lock);
         amd_iov_error("Invalid IO pagetable entry gfn = %lx\n", gfn);
+        domain_crash(d);
         return -EFAULT;
     }
     set_iommu_l1e_present(iommu_l2e, gfn, (u64)mfn << PAGE_SHIFT, iw, ir);
@@ -494,6 +498,7 @@ int amd_iommu_unmap_page(struct domain *
     {
         spin_unlock(&hd->mapping_lock);
         amd_iov_error("Invalid IO pagetable entry gfn = %lx\n", gfn);
+        domain_crash(d);
         return -EFAULT;
     }
 
@@ -535,6 +540,7 @@ int amd_iommu_reserve_domain_unity_map(
             spin_unlock(&hd->mapping_lock);
             amd_iov_error("Invalid IO pagetable entry phys_addr = %lx\n",
                           phys_addr);
+            domain_crash(domain);
             return -EFAULT;
         }
 
@@ -583,6 +589,7 @@ int amd_iommu_sync_p2m(struct domain *d)
             spin_unlock(&d->page_alloc_lock);
             spin_unlock(&hd->mapping_lock);
             amd_iov_error("Invalid IO pagetable entry gfn = %lx\n", gfn);
+            domain_crash(d);
             return -EFAULT;
         }
 
diff -r 71d6d6f2ecd6 xen/include/asm-x86/hvm/svm/amd-iommu-proto.h
--- a/xen/include/asm-x86/hvm/svm/amd-iommu-proto.h	Fri Aug 07 09:54:43 2009 +0100
+++ b/xen/include/asm-x86/hvm/svm/amd-iommu-proto.h	Wed Aug 12 13:20:21 2009 +0200
@@ -131,8 +131,10 @@ static inline struct page_info* alloc_am
     void *vaddr;
 
     pg = alloc_domheap_page(NULL, 0);
+    if ( pg == NULL )
+        return 0;
     vaddr = map_domain_page(page_to_mfn(pg));
-    if ( !vaddr )
+    if ( vaddr == NULL )
         return 0;
     memset(vaddr, 0, PAGE_SIZE);
     unmap_domain_page(vaddr);

[-- Attachment #3: Type: text/plain, Size: 138 bytes --]

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xensource.com
http://lists.xensource.com/xen-devel

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2009-08-14 12:49 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-08-14 12:49 [PATCH] AMD IOMMU: Destroy passthru guests when IO pagetable allcation fails Wei Wang2

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.