All of lore.kernel.org
 help / color / mirror / Atom feed
From: Hongyan Xia <hx242@xen.org>
To: xen-devel@lists.xenproject.org
Cc: julien@xen.org, Jan Beulich <jbeulich@suse.com>
Subject: [PATCH v7 09/15] efi: use new page table APIs in copy_mapping
Date: Fri, 29 May 2020 12:11:53 +0100	[thread overview]
Message-ID: <0259b645c81ecc3879240e30760b0e7641a2b602.1590750232.git.hongyxia@amazon.com> (raw)
In-Reply-To: <cover.1590750232.git.hongyxia@amazon.com>
In-Reply-To: <cover.1590750232.git.hongyxia@amazon.com>

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

After inspection ARM doesn't have alloc_xen_pagetable so this function
is x86 only, which means it is safe for us to change.

Signed-off-by: Wei Liu <wei.liu2@citrix.com>
Signed-off-by: Hongyan Xia <hongyxia@amazon.com>

---
Changed in v7:
- hoist l3 variables out of the loop to avoid repetitive mappings.
---
 xen/common/efi/boot.c | 34 ++++++++++++++++++++++++----------
 1 file changed, 24 insertions(+), 10 deletions(-)

diff --git a/xen/common/efi/boot.c b/xen/common/efi/boot.c
index a6f84c945a..2599ae50d2 100644
--- a/xen/common/efi/boot.c
+++ b/xen/common/efi/boot.c
@@ -6,6 +6,7 @@
 #include <xen/compile.h>
 #include <xen/ctype.h>
 #include <xen/dmi.h>
+#include <xen/domain_page.h>
 #include <xen/init.h>
 #include <xen/keyhandler.h>
 #include <xen/lib.h>
@@ -1442,29 +1443,42 @@ static __init void copy_mapping(unsigned long mfn, unsigned long end,
                                                  unsigned long emfn))
 {
     unsigned long next;
+    l3_pgentry_t *l3src = NULL, *l3dst = NULL;
 
     for ( ; mfn < end; mfn = next )
     {
         l4_pgentry_t l4e = efi_l4_pgtable[l4_table_offset(mfn << PAGE_SHIFT)];
-        l3_pgentry_t *l3src, *l3dst;
         unsigned long va = (unsigned long)mfn_to_virt(mfn);
 
+        if ( !((mfn << PAGE_SHIFT) & ((1UL << L4_PAGETABLE_SHIFT) - 1)) )
+        {
+            UNMAP_DOMAIN_PAGE(l3src);
+            UNMAP_DOMAIN_PAGE(l3dst);
+        }
         next = mfn + (1UL << (L3_PAGETABLE_SHIFT - PAGE_SHIFT));
         if ( !is_valid(mfn, min(next, end)) )
             continue;
-        if ( !(l4e_get_flags(l4e) & _PAGE_PRESENT) )
+        if ( !l3dst )
         {
-            l3dst = alloc_xen_pagetable();
-            BUG_ON(!l3dst);
-            clear_page(l3dst);
-            efi_l4_pgtable[l4_table_offset(mfn << PAGE_SHIFT)] =
-                l4e_from_paddr(virt_to_maddr(l3dst), __PAGE_HYPERVISOR);
+            if ( !(l4e_get_flags(l4e) & _PAGE_PRESENT) )
+            {
+                mfn_t l3mfn;
+
+                l3dst = alloc_map_clear_xen_pt(&l3mfn);
+                BUG_ON(!l3dst);
+                efi_l4_pgtable[l4_table_offset(mfn << PAGE_SHIFT)] =
+                    l4e_from_mfn(l3mfn, __PAGE_HYPERVISOR);
+            }
+            else
+                l3dst = map_l3t_from_l4e(l4e);
         }
-        else
-            l3dst = l4e_to_l3e(l4e);
-        l3src = l4e_to_l3e(idle_pg_table[l4_table_offset(va)]);
+        if ( !l3src )
+            l3src = map_l3t_from_l4e(idle_pg_table[l4_table_offset(va)]);
         l3dst[l3_table_offset(mfn << PAGE_SHIFT)] = l3src[l3_table_offset(va)];
     }
+
+    unmap_domain_page(l3src);
+    unmap_domain_page(l3dst);
 }
 
 static bool __init ram_range_valid(unsigned long smfn, unsigned long emfn)
-- 
2.24.1.AMZN



  parent reply	other threads:[~2020-05-29 11:13 UTC|newest]

Thread overview: 32+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-05-29 11:11 [PATCH v7 00/15] switch to domheap for Xen page tables Hongyan Xia
2020-05-29 11:11 ` [PATCH v7 01/15] x86/mm: map_pages_to_xen would better have one exit path Hongyan Xia
2020-05-29 11:11 ` [PATCH v7 02/15] x86/mm: make sure there is one exit path for modify_xen_mappings Hongyan Xia
2020-05-29 11:11 ` [PATCH v7 03/15] x86/mm: rewrite virt_to_xen_l*e Hongyan Xia
2020-07-14 10:47   ` Jan Beulich
2020-07-27  9:09     ` Hongyan Xia
2020-07-27 19:31       ` Jan Beulich
2020-05-29 11:11 ` [PATCH v7 04/15] x86/mm: switch to new APIs in map_pages_to_xen Hongyan Xia
2020-07-14 11:52   ` Jan Beulich
2020-05-29 11:11 ` [PATCH v7 05/15] x86/mm: switch to new APIs in modify_xen_mappings Hongyan Xia
2020-07-14 11:55   ` Jan Beulich
2020-05-29 11:11 ` [PATCH v7 06/15] x86_64/mm: introduce pl2e in paging_init Hongyan Xia
2020-07-14 12:02   ` Jan Beulich
2020-05-29 11:11 ` [PATCH v7 07/15] x86_64/mm: switch to new APIs " Hongyan Xia
2020-07-14 12:03   ` Jan Beulich
2020-05-29 11:11 ` [PATCH v7 08/15] x86_64/mm: switch to new APIs in setup_m2p_table Hongyan Xia
2020-07-14 12:32   ` Jan Beulich
2020-07-14 12:33   ` Jan Beulich
2020-05-29 11:11 ` Hongyan Xia [this message]
2020-07-14 12:42   ` [PATCH v7 09/15] efi: use new page table APIs in copy_mapping Jan Beulich
2020-07-27 12:45     ` Hongyan Xia
2020-07-27 13:45       ` Hongyan Xia
2020-07-27 19:33       ` Jan Beulich
2020-05-29 11:11 ` [PATCH v7 10/15] efi: switch to new APIs in EFI code Hongyan Xia
2020-07-15 13:06   ` Jan Beulich
2020-05-29 11:11 ` [PATCH v7 11/15] x86/smpboot: add exit path for clone_mapping() Hongyan Xia
2020-05-29 11:11 ` [PATCH v7 12/15] x86/smpboot: switch clone_mapping() to new APIs Hongyan Xia
2020-07-15 13:11   ` Jan Beulich
2020-05-29 11:11 ` [PATCH v7 13/15] x86/mm: drop old page table APIs Hongyan Xia
2020-05-29 11:11 ` [PATCH v7 14/15] x86: switch to use domheap page for page tables Hongyan Xia
2020-07-15 13:16   ` Jan Beulich
2020-05-29 11:11 ` [PATCH v7 15/15] x86/mm: drop _new suffix for page table APIs Hongyan Xia

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=0259b645c81ecc3879240e30760b0e7641a2b602.1590750232.git.hongyxia@amazon.com \
    --to=hx242@xen.org \
    --cc=jbeulich@suse.com \
    --cc=julien@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.