WARNING - OLD ARCHIVES

This is an archived copy of the Xen.org mailing list, which we have preserved to ensure that existing links to archives are not broken. The live archive, which contains the latest emails, can be found at http://lists.xen.org/
   
 
 
Xen 
 
Home Products Support Community News
 
   
 

xen-changelog

[Xen-changelog] [xen-unstable] VT-d: correct allocation failure checks

To: xen-changelog@xxxxxxxxxxxxxxxxxxx
Subject: [Xen-changelog] [xen-unstable] VT-d: correct allocation failure checks
From: Xen patchbot-unstable <patchbot-unstable@xxxxxxxxxxxxxxxxxxx>
Date: Wed, 22 Oct 2008 07:50:40 -0700
Delivery-date: Wed, 22 Oct 2008 07:52:08 -0700
Envelope-to: www-data@xxxxxxxxxxxxxxxxxxx
List-help: <mailto:xen-changelog-request@lists.xensource.com?subject=help>
List-id: BK change log <xen-changelog.lists.xensource.com>
List-post: <mailto:xen-changelog@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/mailman/listinfo/xen-changelog>, <mailto:xen-changelog-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/mailman/listinfo/xen-changelog>, <mailto:xen-changelog-request@lists.xensource.com?subject=unsubscribe>
Reply-to: xen-devel@xxxxxxxxxxxxxxxxxxx
Sender: xen-changelog-bounces@xxxxxxxxxxxxxxxxxxx
# HG changeset patch
# User Keir Fraser <keir.fraser@xxxxxxxxxx>
# Date 1224512379 -3600
# Node ID 2a25fd94c6f207d5b9066a1d765697a5a680fc42
# Parent  bf84c03c38eebc527786e96af4178f114a5bea41
VT-d: correct allocation failure checks

Checking the return value of map_domain_page() (and hence
map_vtd_domain_page()) against NULL is pointless, checking the return
value of alloc_domheap_page() (and thus alloc_pgtable_maddr()) is
mandatory, however.

Signed-off-by: Jan Beulich <jbeulich@xxxxxxxxxx>
---
 xen/drivers/passthrough/vtd/intremap.c |    2 +-
 xen/drivers/passthrough/vtd/iommu.c    |    6 ++----
 xen/drivers/passthrough/vtd/qinval.c   |    6 +++++-
 xen/drivers/passthrough/vtd/x86/vtd.c  |    8 +++++---
 4 files changed, 13 insertions(+), 9 deletions(-)

diff -r bf84c03c38ee -r 2a25fd94c6f2 xen/drivers/passthrough/vtd/intremap.c
--- a/xen/drivers/passthrough/vtd/intremap.c    Mon Oct 20 15:18:09 2008 +0100
+++ b/xen/drivers/passthrough/vtd/intremap.c    Mon Oct 20 15:19:39 2008 +0100
@@ -472,7 +472,7 @@ int intremap_setup(struct iommu *iommu)
         {
             dprintk(XENLOG_WARNING VTDPREFIX,
                     "Cannot allocate memory for ir_ctrl->iremap_maddr\n");
-            return -ENODEV;
+            return -ENOMEM;
         }
         ir_ctrl->iremap_index = -1;
     }
diff -r bf84c03c38ee -r 2a25fd94c6f2 xen/drivers/passthrough/vtd/iommu.c
--- a/xen/drivers/passthrough/vtd/iommu.c       Mon Oct 20 15:18:09 2008 +0100
+++ b/xen/drivers/passthrough/vtd/iommu.c       Mon Oct 20 15:19:39 2008 +0100
@@ -219,10 +219,10 @@ static u64 addr_to_dma_page_maddr(struct
             if ( !alloc )
                 break;
             maddr = alloc_pgtable_maddr();
+            if ( !maddr )
+                break;
             dma_set_pte_addr(*pte, maddr);
             vaddr = map_vtd_domain_page(maddr);
-            if ( !vaddr )
-                break;
 
             /*
              * high level table always sets r/w, last level
@@ -235,8 +235,6 @@ static u64 addr_to_dma_page_maddr(struct
         else
         {
             vaddr = map_vtd_domain_page(pte->val);
-            if ( !vaddr )
-                break;
         }
 
         if ( level == 2 )
diff -r bf84c03c38ee -r 2a25fd94c6f2 xen/drivers/passthrough/vtd/qinval.c
--- a/xen/drivers/passthrough/vtd/qinval.c      Mon Oct 20 15:18:09 2008 +0100
+++ b/xen/drivers/passthrough/vtd/qinval.c      Mon Oct 20 15:19:39 2008 +0100
@@ -428,7 +428,11 @@ int qinval_setup(struct iommu *iommu)
     {
         qi_ctrl->qinval_maddr = alloc_pgtable_maddr();
         if ( qi_ctrl->qinval_maddr == 0 )
-            panic("Cannot allocate memory for qi_ctrl->qinval_maddr\n");
+        {
+            dprintk(XENLOG_WARNING VTDPREFIX,
+                    "Cannot allocate memory for qi_ctrl->qinval_maddr\n");
+            return -ENOMEM;
+        }
         flush->context = flush_context_qi;
         flush->iotlb = flush_iotlb_qi;
     }
diff -r bf84c03c38ee -r 2a25fd94c6f2 xen/drivers/passthrough/vtd/x86/vtd.c
--- a/xen/drivers/passthrough/vtd/x86/vtd.c     Mon Oct 20 15:18:09 2008 +0100
+++ b/xen/drivers/passthrough/vtd/x86/vtd.c     Mon Oct 20 15:19:39 2008 +0100
@@ -41,17 +41,19 @@ u64 alloc_pgtable_maddr(void)
 {
     struct page_info *pg;
     u64 *vaddr;
+    unsigned long mfn;
 
     pg = alloc_domheap_page(NULL, 0);
-    vaddr = map_domain_page(page_to_mfn(pg));
-    if ( !vaddr )
+    if ( !pg )
         return 0;
+    mfn = page_to_mfn(pg);
+    vaddr = map_domain_page(mfn);
     memset(vaddr, 0, PAGE_SIZE);
 
     iommu_flush_cache_page(vaddr);
     unmap_domain_page(vaddr);
 
-    return page_to_maddr(pg);
+    return (u64)mfn << PAGE_SHIFT_4K;
 }
 
 void free_pgtable_maddr(u64 maddr)

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

<Prev in Thread] Current Thread [Next in Thread>
  • [Xen-changelog] [xen-unstable] VT-d: correct allocation failure checks, Xen patchbot-unstable <=