Gianluca Guida
2009-Aug-01 00:28 UTC
[Xen-devel] [PATCH] 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(-) diff --git a/arch/x86/xen/enlighten.c b/arch/x86/xen/enlighten.c index e099e44..b542d76 100644 --- a/arch/x86/xen/enlighten.c +++ b/arch/x86/xen/enlighten.c @@ -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); diff --git a/arch/x86/xen/mmu.c b/arch/x86/xen/mmu.c index 8c53fc9..10acb23 100644 --- a/arch/x86/xen/mmu.c +++ b/arch/x86/xen/mmu.c @@ -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; diff --git a/arch/x86/xen/xen-ops.h b/arch/x86/xen/xen-ops.h index 82ba25c..1c51314 100644 --- a/arch/x86/xen/xen-ops.h +++ b/arch/x86/xen/xen-ops.h @@ -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); -- 1.5.6.5 _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel