diff mbox series

[v2,28/55] efi: use new page table APIs in copy_mapping

Message ID 5629b76f1923c6ff4e79a9bc9905ebbaddba189b.1569833766.git.hongyax@amazon.com (mailing list archive)
State New, archived
Headers show
Series Switch to domheap for Xen PTEs | expand

Commit Message

Xia, Hongyan Sept. 30, 2019, 10:33 a.m. UTC
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>
---
XXX test this in gitlab ci to be sure.
---
 xen/common/efi/boot.c | 16 +++++++++++-----
 1 file changed, 11 insertions(+), 5 deletions(-)
diff mbox series

Patch

diff --git a/xen/common/efi/boot.c b/xen/common/efi/boot.c
index 79193784ff..62b5944e61 100644
--- a/xen/common/efi/boot.c
+++ b/xen/common/efi/boot.c
@@ -1440,16 +1440,22 @@  static __init void copy_mapping(unsigned long mfn, unsigned long end,
             continue;
         if ( !(l4e_get_flags(l4e) & _PAGE_PRESENT) )
         {
-            l3dst = alloc_xen_pagetable();
-            BUG_ON(!l3dst);
+            mfn_t l3t_mfn;
+
+            l3t_mfn = alloc_xen_pagetable_new();
+            BUG_ON(mfn_eq(l3t_mfn, INVALID_MFN));
+            l3dst = map_xen_pagetable_new(l3t_mfn);
             clear_page(l3dst);
             efi_l4_pgtable[l4_table_offset(mfn << PAGE_SHIFT)] =
-                l4e_from_paddr(virt_to_maddr(l3dst), __PAGE_HYPERVISOR);
+                l4e_from_mfn(l3t_mfn, __PAGE_HYPERVISOR);
         }
         else
-            l3dst = l4e_to_l3e(l4e);
-        l3src = l4e_to_l3e(idle_pg_table[l4_table_offset(va)]);
+            l3dst = map_xen_pagetable_new(l4e_get_mfn(l4e));
+        l3src = map_xen_pagetable_new(
+            l4e_get_mfn(idle_pg_table[l4_table_offset(va)]));
         l3dst[l3_table_offset(mfn << PAGE_SHIFT)] = l3src[l3_table_offset(va)];
+        UNMAP_XEN_PAGETABLE_NEW(l3src);
+        UNMAP_XEN_PAGETABLE_NEW(l3dst);
     }
 }