diff mbox series

[RFC,53/84] x86: remove lXe_to_lYe in __start_xen

Message ID 32ae1461fb4177b1586bb7e735da6d58bbee5462.1569489002.git.hongyax@amazon.com (mailing list archive)
State New, archived
Headers show
Series Remove direct map from Xen | expand

Commit Message

Xia, Hongyan Sept. 26, 2019, 9:46 a.m. UTC
From: Wei Liu <wei.liu2@citrix.com>

Properly map and unmap page tables where necessary.

Signed-off-by: Wei Liu <wei.liu2@citrix.com>
---
 xen/arch/x86/setup.c | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)
diff mbox series

Patch

diff --git a/xen/arch/x86/setup.c b/xen/arch/x86/setup.c
index 27981adc0b..1c90559288 100644
--- a/xen/arch/x86/setup.c
+++ b/xen/arch/x86/setup.c
@@ -1095,13 +1095,17 @@  void __init noreturn __start_xen(unsigned long mbi_p)
             pl4e = __va(__pa(idle_pg_table));
             for ( i = 0 ; i < L4_PAGETABLE_ENTRIES; i++, pl4e++ )
             {
+                l3_pgentry_t *l3t;
+
                 if ( !(l4e_get_flags(*pl4e) & _PAGE_PRESENT) )
                     continue;
                 *pl4e = l4e_from_intpte(l4e_get_intpte(*pl4e) +
                                         xen_phys_start);
-                pl3e = l4e_to_l3e(*pl4e);
+                pl3e = l3t = map_xen_pagetable_new(l4e_get_mfn(*pl4e));
                 for ( j = 0; j < L3_PAGETABLE_ENTRIES; j++, pl3e++ )
                 {
+                    l2_pgentry_t *l2t;
+
                     /* Not present, 1GB mapping, or already relocated? */
                     if ( !(l3e_get_flags(*pl3e) & _PAGE_PRESENT) ||
                          (l3e_get_flags(*pl3e) & _PAGE_PSE) ||
@@ -1109,7 +1113,7 @@  void __init noreturn __start_xen(unsigned long mbi_p)
                         continue;
                     *pl3e = l3e_from_intpte(l3e_get_intpte(*pl3e) +
                                             xen_phys_start);
-                    pl2e = l3e_to_l2e(*pl3e);
+                    pl2e = l2t = map_xen_pagetable_new(l3e_get_mfn(*pl3e));
                     for ( k = 0; k < L2_PAGETABLE_ENTRIES; k++, pl2e++ )
                     {
                         /* Not present, PSE, or already relocated? */
@@ -1120,7 +1124,9 @@  void __init noreturn __start_xen(unsigned long mbi_p)
                         *pl2e = l2e_from_intpte(l2e_get_intpte(*pl2e) +
                                                 xen_phys_start);
                     }
+                    UNMAP_XEN_PAGETABLE_NEW(l2t);
                 }
+                UNMAP_XEN_PAGETABLE_NEW(l3t);
             }
 
             /* The only data mappings to be relocated are in the Xen area. */