All of lore.kernel.org
 help / color / mirror / Atom feed
From: Hongyan Xia <hongyax@amazon.com>
To: <xen-devel@lists.xenproject.org>
Cc: "Andrew Cooper" <andrew.cooper3@citrix.com>,
	"Wei Liu" <wl@xen.org>, "Jan Beulich" <jbeulich@suse.com>,
	"Roger Pau Monné" <roger.pau@citrix.com>
Subject: [Xen-devel] [PATCH v2 34/55] x86/smpboot: clone_mapping should have one exit path
Date: Mon, 30 Sep 2019 11:33:26 +0100	[thread overview]
Message-ID: <a9f3fe6aa0e54b3f8d0494f86cf8e0822fe9ce12.1569833766.git.hongyax@amazon.com> (raw)
In-Reply-To: <cover.1569833766.git.hongyax@amazon.com>

From: Wei Liu <wei.liu2@citrix.com>

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

No functional change.

Signed-off-by: Wei Liu <wei.liu2@citrix.com>
---
 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 55b99644af..716dc1512d 100644
--- a/xen/arch/x86/smpboot.c
+++ b/xen/arch/x86/smpboot.c
@@ -667,6 +667,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
@@ -674,11 +675,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);
@@ -707,7 +714,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);
         }
     }
@@ -716,7 +726,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));
@@ -730,7 +743,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));
     }
@@ -746,7 +762,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));
     }
@@ -767,7 +786,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@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel

  parent reply	other threads:[~2019-09-30 10:35 UTC|newest]

Thread overview: 63+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-09-30 10:32 [Xen-devel] [PATCH v2 00/55] Switch to domheap for Xen PTEs Hongyan Xia
2019-09-30 10:32 ` [Xen-devel] [PATCH v2 01/55] x86/mm: defer clearing page in virt_to_xen_lXe Hongyan Xia
2019-09-30 15:05   ` Wei Liu
2019-09-30 10:32 ` [Xen-devel] [PATCH v2 02/55] x86: move some xen mm function declarations Hongyan Xia
2019-09-30 10:32 ` [Xen-devel] [PATCH v2 03/55] x86: introduce a new set of APIs to manage Xen page tables Hongyan Xia
2019-09-30 10:32 ` [Xen-devel] [PATCH v2 04/55] x86/mm: introduce l{1, 2}t local variables to map_pages_to_xen Hongyan Xia
2019-09-30 10:32 ` [Xen-devel] [PATCH v2 05/55] x86/mm: introduce l{1, 2}t local variables to modify_xen_mappings Hongyan Xia
2019-09-30 10:32 ` [Xen-devel] [PATCH v2 06/55] x86/mm: map_pages_to_xen should have one exit path Hongyan Xia
2019-09-30 10:32 ` [Xen-devel] [PATCH v2 07/55] x86/mm: add an end_of_loop label in map_pages_to_xen Hongyan Xia
2019-09-30 10:33 ` [Xen-devel] [PATCH v2 08/55] x86/mm: make sure there is one exit path for modify_xen_mappings Hongyan Xia
2019-09-30 10:33 ` [Xen-devel] [PATCH v2 09/55] x86/mm: add an end_of_loop label in modify_xen_mappings Hongyan Xia
2019-09-30 10:33 ` [Xen-devel] [PATCH v2 10/55] x86/mm: change pl2e to l2t in virt_to_xen_l2e Hongyan Xia
2019-09-30 10:33 ` [Xen-devel] [PATCH v2 11/55] x86/mm: change pl1e to l1t in virt_to_xen_l1e Hongyan Xia
2019-09-30 10:33 ` [Xen-devel] [PATCH v2 12/55] x86/mm: change pl3e to l3t in virt_to_xen_l3e Hongyan Xia
2019-09-30 10:33 ` [Xen-devel] [PATCH v2 13/55] x86/mm: rewrite virt_to_xen_l3e Hongyan Xia
2019-09-30 10:33 ` [Xen-devel] [PATCH v2 14/55] x86/mm: rewrite xen_to_virt_l2e Hongyan Xia
2019-09-30 10:33 ` [Xen-devel] [PATCH v2 15/55] x86/mm: rewrite virt_to_xen_l1e Hongyan Xia
2019-09-30 10:33 ` [Xen-devel] [PATCH v2 16/55] x86/mm: switch to new APIs in map_pages_to_xen Hongyan Xia
2019-09-30 10:33 ` [Xen-devel] [PATCH v2 17/55] x86/mm: drop lXe_to_lYe invocations " Hongyan Xia
2019-09-30 10:33 ` [Xen-devel] [PATCH v2 18/55] x86/mm: switch to new APIs in modify_xen_mappings Hongyan Xia
2019-09-30 10:33 ` [Xen-devel] [PATCH v2 19/55] x86/mm: drop lXe_to_lYe invocations from modify_xen_mappings Hongyan Xia
2019-09-30 10:33 ` [Xen-devel] [PATCH v2 20/55] x86/mm: switch to new APIs in arch_init_memory Hongyan Xia
2019-09-30 10:33 ` [Xen-devel] [PATCH v2 21/55] x86_64/mm: introduce pl2e in paging_init Hongyan Xia
2019-09-30 10:33 ` [Xen-devel] [PATCH v2 22/55] x86_64/mm: switch to new APIs " Hongyan Xia
2019-10-01 11:51   ` Wei Liu
2019-10-01 13:39     ` Hongyan Xia
2019-09-30 10:33 ` [Xen-devel] [PATCH v2 23/55] x86_64/mm: drop l4e_to_l3e invocation from paging_init Hongyan Xia
2019-09-30 10:33 ` [Xen-devel] [PATCH v2 24/55] x86_64/mm.c: remove code that serves no purpose in setup_m2p_table Hongyan Xia
2019-09-30 10:33 ` [Xen-devel] [PATCH v2 25/55] x86_64/mm: introduce pl2e " Hongyan Xia
2019-09-30 10:33 ` [Xen-devel] [PATCH v2 26/55] x86_64/mm: switch to new APIs " Hongyan Xia
2019-09-30 10:33 ` [Xen-devel] [PATCH v2 27/55] x86_64/mm: drop lXe_to_lYe invocations from setup_m2p_table Hongyan Xia
2019-09-30 10:33 ` [Xen-devel] [PATCH v2 28/55] efi: use new page table APIs in copy_mapping Hongyan Xia
2019-09-30 10:33 ` [Xen-devel] [PATCH v2 29/55] efi: avoid using global variable " Hongyan Xia
2019-09-30 10:33 ` [Xen-devel] [PATCH v2 30/55] efi: use new page table APIs in efi_init_memory Hongyan Xia
2019-09-30 10:33 ` [Xen-devel] [PATCH v2 31/55] efi: add emacs block to boot.c Hongyan Xia
2019-09-30 10:33 ` [Xen-devel] [PATCH v2 32/55] efi: switch EFI L4 table to use new APIs Hongyan Xia
2019-09-30 10:33 ` [Xen-devel] [PATCH v2 33/55] x86/smpboot: add emacs block Hongyan Xia
2019-09-30 10:33 ` Hongyan Xia [this message]
2019-09-30 10:33 ` [Xen-devel] [PATCH v2 35/55] x86/smpboot: switch pl3e to use new APIs in clone_mapping Hongyan Xia
2019-09-30 10:33 ` [Xen-devel] [PATCH v2 36/55] x86/smpboot: switch pl2e " Hongyan Xia
2019-09-30 10:33 ` [Xen-devel] [PATCH v2 37/55] x86/smpboot: switch pl1e " Hongyan Xia
2019-09-30 10:33 ` [Xen-devel] [PATCH v2 38/55] x86/smpboot: drop lXe_to_lYe invocations from cleanup_cpu_root_pgt Hongyan Xia
2019-09-30 10:33 ` [Xen-devel] [PATCH v2 39/55] x86: switch root_pgt to mfn_t and use new APIs Hongyan Xia
2019-10-01 13:54   ` Hongyan Xia
2019-10-01 15:20     ` Wei Liu
2019-10-01 15:31       ` Hongyan Xia
2019-09-30 10:33 ` [Xen-devel] [PATCH v2 40/55] x86/shim: map and unmap page tables in replace_va_mapping Hongyan Xia
2019-09-30 10:33 ` [Xen-devel] [PATCH v2 41/55] x86_64/mm: map and unmap page tables in m2p_mapped Hongyan Xia
2019-09-30 10:33 ` [Xen-devel] [PATCH v2 42/55] x86_64/mm: map and unmap page tables in share_hotadd_m2p_table Hongyan Xia
2019-09-30 10:33 ` [Xen-devel] [PATCH v2 43/55] x86_64/mm: map and unmap page tables in destroy_compat_m2p_mapping Hongyan Xia
2019-09-30 10:33 ` [Xen-devel] [PATCH v2 44/55] x86_64/mm: map and unmap page tables in destroy_m2p_mapping Hongyan Xia
2019-09-30 10:33 ` [Xen-devel] [PATCH v2 45/55] x86_64/mm: map and unmap page tables in setup_compat_m2p_table Hongyan Xia
2019-09-30 10:33 ` [Xen-devel] [PATCH v2 46/55] x86_64/mm: map and unmap page tables in cleanup_frame_table Hongyan Xia
2019-09-30 10:33 ` [Xen-devel] [PATCH v2 47/55] x86_64/mm: map and unmap page tables in subarch_init_memory Hongyan Xia
2019-09-30 10:33 ` [Xen-devel] [PATCH v2 48/55] x86_64/mm: map and unmap page tables in subarch_memory_op Hongyan Xia
2019-09-30 10:33 ` [Xen-devel] [PATCH v2 49/55] x86/smpboot: remove lXe_to_lYe in cleanup_cpu_root_pgt Hongyan Xia
2019-09-30 10:33 ` [Xen-devel] [PATCH v2 50/55] x86/pv: properly map and unmap page tables in mark_pv_pt_pages_rdonly Hongyan Xia
2019-09-30 10:33 ` [Xen-devel] [PATCH v2 51/55] x86/pv: properly map and unmap page table in dom0_construct_pv Hongyan Xia
2019-09-30 10:33 ` [Xen-devel] [PATCH v2 52/55] x86: remove lXe_to_lYe in __start_xen Hongyan Xia
2019-09-30 10:33 ` [Xen-devel] [PATCH v2 53/55] x86/mm: drop old page table APIs Hongyan Xia
2019-09-30 10:33 ` [Xen-devel] [PATCH v2 54/55] x86: switch to use domheap page for page tables Hongyan Xia
2019-09-30 10:33 ` [Xen-devel] [PATCH v2 55/55] x86/mm: drop _new suffix for page table APIs Hongyan Xia
2019-10-01 11:56 ` [Xen-devel] [PATCH v2 00/55] Switch to domheap for Xen PTEs Wei Liu

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=a9f3fe6aa0e54b3f8d0494f86cf8e0822fe9ce12.1569833766.git.hongyax@amazon.com \
    --to=hongyax@amazon.com \
    --cc=andrew.cooper3@citrix.com \
    --cc=jbeulich@suse.com \
    --cc=roger.pau@citrix.com \
    --cc=wl@xen.org \
    --cc=xen-devel@lists.xenproject.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.