[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Xen-devel] [RFC PATCH 35/84] x86/smpboot: clone_mapping should have one exit path



From: Wei Liu <wei.liu2@xxxxxxxxxx>

We will soon need to clean up page table mappings in the exit path.

No functional change.

Signed-off-by: Wei Liu <wei.liu2@xxxxxxxxxx>
---
 xen/arch/x86/smpboot.c | 35 ++++++++++++++++++++++++++++-------
 1 file changed, 28 insertions(+), 7 deletions(-)

diff --git a/xen/arch/x86/smpboot.c b/xen/arch/x86/smpboot.c
index b086063486..8bee0c41e3 100644
--- a/xen/arch/x86/smpboot.c
+++ b/xen/arch/x86/smpboot.c
@@ -669,6 +669,7 @@ static int clone_mapping(const void *ptr, root_pgentry_t 
*rpt)
     l3_pgentry_t *pl3e;
     l2_pgentry_t *pl2e;
     l1_pgentry_t *pl1e;
+    int rc;
 
     /*
      * Sanity check 'linear'.  We only allow cloning from the Xen virtual
@@ -676,11 +677,17 @@ static int clone_mapping(const void *ptr, root_pgentry_t 
*rpt)
      */
     if ( root_table_offset(linear) > ROOT_PAGETABLE_LAST_XEN_SLOT ||
          root_table_offset(linear) < ROOT_PAGETABLE_FIRST_XEN_SLOT )
-        return -EINVAL;
+    {
+        rc = -EINVAL;
+        goto out;
+    }
 
     if ( linear < XEN_VIRT_START ||
          (linear >= XEN_VIRT_END && linear < DIRECTMAP_VIRT_START) )
-        return -EINVAL;
+    {
+        rc = -EINVAL;
+        goto out;
+    }
 
     pl3e = l4e_to_l3e(idle_pg_table[root_table_offset(linear)]) +
         l3_table_offset(linear);
@@ -709,7 +716,10 @@ static int clone_mapping(const void *ptr, root_pgentry_t 
*rpt)
             pl1e = l2e_to_l1e(*pl2e) + l1_table_offset(linear);
             flags = l1e_get_flags(*pl1e);
             if ( !(flags & _PAGE_PRESENT) )
-                return 0;
+            {
+                rc = 0;
+                goto out;
+            }
             pfn = l1e_get_pfn(*pl1e);
         }
     }
@@ -718,7 +728,10 @@ static int clone_mapping(const void *ptr, root_pgentry_t 
*rpt)
     {
         pl3e = alloc_xen_pagetable();
         if ( !pl3e )
-            return -ENOMEM;
+        {
+            rc = -ENOMEM;
+            goto out;
+        }
         clear_page(pl3e);
         l4e_write(&rpt[root_table_offset(linear)],
                   l4e_from_paddr(__pa(pl3e), __PAGE_HYPERVISOR));
@@ -732,7 +745,10 @@ static int clone_mapping(const void *ptr, root_pgentry_t 
*rpt)
     {
         pl2e = alloc_xen_pagetable();
         if ( !pl2e )
-            return -ENOMEM;
+        {
+            rc = -ENOMEM;
+            goto out;
+        }
         clear_page(pl2e);
         l3e_write(pl3e, l3e_from_paddr(__pa(pl2e), __PAGE_HYPERVISOR));
     }
@@ -748,7 +764,10 @@ static int clone_mapping(const void *ptr, root_pgentry_t 
*rpt)
     {
         pl1e = alloc_xen_pagetable();
         if ( !pl1e )
-            return -ENOMEM;
+        {
+            rc = -ENOMEM;
+            goto out;
+        }
         clear_page(pl1e);
         l2e_write(pl2e, l2e_from_paddr(__pa(pl1e), __PAGE_HYPERVISOR));
     }
@@ -769,7 +788,9 @@ static int clone_mapping(const void *ptr, root_pgentry_t 
*rpt)
     else
         l1e_write(pl1e, l1e_from_pfn(pfn, flags));
 
-    return 0;
+    rc = 0;
+ out:
+    return rc;
 }
 
 DEFINE_PER_CPU(root_pgentry_t *, root_pgt);
-- 
2.17.1


_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxxx
https://lists.xenproject.org/mailman/listinfo/xen-devel

 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.