mirror of
https://github.com/xen-project/xen.git
synced 2026-10-30 03:00:05 +01:00
Create P2M map during Mini-OS boot (fixes 'xm dump-core').
Signed-off-by: Grzegorz Milos <gm281@cam.ac.uk>
This commit is contained in:
1 parent
84e23d3ec9
commit
5fca0f03a3
4 files changed
+50
No files matched your search
@@ -130,3 +130,7 @@ map_frames(unsigned long* frames, unsigned long n)
|
||||
return (void*) __va(frames[0] << PAGE_SHIFT);
|
||||
}
|
||||
|
||||
void arch_init_p2m(unsigned long max_pfn)
|
||||
{
|
||||
printk("Warn: p2m map not implemented.\n");
|
||||
}
|
||||
@@ -402,6 +402,49 @@ void *map_frames(unsigned long *f, unsigned long n)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void arch_init_p2m(unsigned long max_pfn)
|
||||
{
|
||||
#define L1_P2M_SHIFT 10
|
||||
#define L2_P2M_SHIFT 20
|
||||
#define L3_P2M_SHIFT 30
|
||||
#define L1_P2M_ENTRIES (1 << L1_P2M_SHIFT)
|
||||
#define L2_P2M_ENTRIES (1 << (L2_P2M_SHIFT - L1_P2M_SHIFT))
|
||||
#define L3_P2M_ENTRIES (1 << (L3_P2M_SHIFT - L2_P2M_SHIFT))
|
||||
#define L1_P2M_MASK (L1_P2M_ENTRIES - 1)
|
||||
#define L2_P2M_MASK (L2_P2M_ENTRIES - 1)
|
||||
#define L3_P2M_MASK (L3_P2M_ENTRIES - 1)
|
||||
|
||||
unsigned long *l1_list, *l2_list, *l3_list;
|
||||
unsigned long pfn;
|
||||
|
||||
l3_list = (unsigned long *)alloc_page();
|
||||
for(pfn=0; pfn<max_pfn; pfn++)
|
||||
{
|
||||
if(!(pfn % (L1_P2M_ENTRIES * L2_P2M_ENTRIES)))
|
||||
{
|
||||
l2_list = (unsigned long*)alloc_page();
|
||||
if((pfn >> L3_P2M_SHIFT) > 0)
|
||||
{
|
||||
printk("Error: Too many pfns.\n");
|
||||
do_exit();
|
||||
}
|
||||
l3_list[(pfn >> L2_P2M_SHIFT)] = virt_to_mfn(l2_list);
|
||||
}
|
||||
if(!(pfn % (L1_P2M_ENTRIES)))
|
||||
{
|
||||
l1_list = (unsigned long*)alloc_page();
|
||||
l2_list[(pfn >> L1_P2M_SHIFT) & L2_P2M_MASK] =
|
||||
virt_to_mfn(l1_list);
|
||||
}
|
||||
|
||||
l1_list[pfn & L1_P2M_MASK] = pfn_to_mfn(pfn);
|
||||
}
|
||||
HYPERVISOR_shared_info->arch.pfn_to_mfn_frame_list_list =
|
||||
virt_to_mfn(l3_list);
|
||||
HYPERVISOR_shared_info->arch.max_pfn = max_pfn;
|
||||
}
|
||||
|
||||
void arch_init_mm(unsigned long* start_pfn_p, unsigned long* max_pfn_p)
|
||||
{
|
||||
|
||||
|
||||
@@ -55,6 +55,7 @@ static __inline__ int get_order(unsigned long size)
|
||||
|
||||
void arch_init_demand_mapping_area(unsigned long max_pfn);
|
||||
void arch_init_mm(unsigned long* start_pfn_p, unsigned long* max_pfn_p);
|
||||
void arch_init_p2m(unsigned long max_pfn_p);
|
||||
|
||||
void *map_frames(unsigned long *f, unsigned long n);
|
||||
|
||||
|
||||
@@ -379,6 +379,8 @@ void init_mm(void)
|
||||
init_page_allocator(PFN_PHYS(start_pfn), PFN_PHYS(max_pfn));
|
||||
printk("MM: done\n");
|
||||
|
||||
arch_init_p2m(max_pfn);
|
||||
|
||||
arch_init_demand_mapping_area(max_pfn);
|
||||
}
|
||||
|
||||
|
||||