Skip to contentSkip to conversation

Xen: Properly setup uninitialized P2M entries.

PATCH New Gianluca Guida 1 participant 1 message Aug 1, 2009

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Xen: Properly setup uninitialized P2M entries.

P2M entries higher than xen_start_info->nr_pages allocated by the domain builder are uninitialized. Set them to INVALID_P2M_ENTRY.

---
 arch/x86/xen/enlighten.c |    3 +++
 arch/x86/xen/mmu.c       |   13 +++++++++++++
 arch/x86/xen/xen-ops.h   |    1 +
 3 files changed, 17 insertions(+), 0 deletions(-)
arch/x86/xen/enlighten.c +3 -0
index e099e44..b542d76 100644
@@ -1091,6 +1091,9 @@ asmlinkage void __init xen_start_kernel(void)
 	/* set the limit of our address space */
 	xen_reserve_top();
 
+	/* fixup p2m entries uninitialized by domain builder */
+	xen_fix_mfn_list();
+
 #ifdef CONFIG_X86_32
 	/* set up basic CPUID stuff */
 	cpu_detect(&new_cpu_data);
arch/x86/xen/mmu.c +13 -0
index 8c53fc9..10acb23 100644
@@ -235,6 +235,19 @@ void __init xen_build_dynamic_phys_to_machine(void)
 	xen_build_mfn_list_list();
 }
 
+/*
+ * P2M entries higher than xen_start_info->nr_pages allocated by the
+ * domain builder are uninitialized. Set them to INVALID_P2M_ENTRY.
+ */
+void __init xen_fix_mfn_list(void)
+{
+	unsigned idx;
+	unsigned long max_pfn = min(MAX_DOMAIN_PAGES, xen_start_info->nr_pages);
+
+	for (idx = p2m_index(max_pfn); idx < P2M_ENTRIES_PER_PAGE; idx++)
+		p2m_top[p2m_top_index(max_pfn)][idx] = INVALID_P2M_ENTRY;
+}
+
 unsigned long get_phys_to_machine(unsigned long pfn)
 {
 	unsigned topidx, idx;
arch/x86/xen/xen-ops.h +1 -0
index 82ba25c..1c51314 100644
@@ -41,6 +41,7 @@ void xen_enable_syscall(void);
 void xen_vcpu_restore(void);
 
 void __init xen_build_dynamic_phys_to_machine(void);
+void __init xen_fix_mfn_list(void);
 
 void xen_init_irq_ops(void);
 void xen_setup_timer(int cpu);
Signature · 1 line
1.5.6.5