idle_pg_table[] needs all slots populated before it is copied to create the
vcpu idle pagetables.  One missing slot is for MMCFG, which is now allocated
early.

Signed-off-by: Andrew Cooper <andrew.coop...@citrix.com>
---
 xen/arch/x86/setup.c     |  4 ++--
 xen/arch/x86/x86_64/mm.c | 15 +++++++++++++++
 2 files changed, 17 insertions(+), 2 deletions(-)

diff --git a/xen/arch/x86/setup.c b/xen/arch/x86/setup.c
index 64286f7..4aff5bd 100644
--- a/xen/arch/x86/setup.c
+++ b/xen/arch/x86/setup.c
@@ -1502,6 +1502,8 @@ void __init noreturn __start_xen(unsigned long mbi_p)
     if ( cpu_has_fsgsbase )
         set_in_cr4(X86_CR4_FSGSBASE);
 
+    arch_init_memory();
+
     cpu_smpboot_bsp();
 
     init_idle_domain();
@@ -1512,8 +1514,6 @@ void __init noreturn __start_xen(unsigned long mbi_p)
 
     early_time_init();
 
-    arch_init_memory();
-
     alternative_instructions();
 
     local_irq_enable();
diff --git a/xen/arch/x86/x86_64/mm.c b/xen/arch/x86/x86_64/mm.c
index 9b37da6..68eee30 100644
--- a/xen/arch/x86/x86_64/mm.c
+++ b/xen/arch/x86/x86_64/mm.c
@@ -831,6 +831,7 @@ static int extend_frame_table(struct mem_hotadd_info *info)
 void __init subarch_init_memory(void)
 {
     unsigned long i, n, v, m2p_start_mfn;
+    l4_pgentry_t *pl4e;
     l3_pgentry_t l3e;
     l2_pgentry_t l2e;
 
@@ -886,6 +887,20 @@ void __init subarch_init_memory(void)
         }
     }
 
+    /* Create an L3 table for the MMCFG region, or remap it NX. */
+    pl4e = &idle_pg_table[l4_table_offset(PCI_MCFG_VIRT_START)];
+    if ( !(l4e_get_flags(*pl4e) & _PAGE_PRESENT) )
+    {
+        l3_pgentry_t *l3t = alloc_xen_pagetable();
+
+        BUG_ON(!l3t);
+
+        clear_page(l3t);
+        *pl4e = l4e_from_paddr(virt_to_maddr(l3t), __PAGE_HYPERVISOR_RW);
+    }
+    else
+        l4e_add_flags(*pl4e, _PAGE_NX_BIT);
+
     /* Mark all of direct map NX if hardware supports it. */
     if ( !cpu_has_nx )
         return;
-- 
2.1.4


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

Reply via email to