[Patch V4 13/16] xen: add explicit memblock_reserve() calls for special pages

From: Juergen Gross
Date: Mon Jun 08 2015 - 08:08:10 EST


Some special pages containing interfaces to xen are being reserved
implicitly only today. The memblock_reserve() call to reserve them is
meant to reserve the p2m list supplied by xen. It is just reserving
not only the p2m list itself, but some more pages up to the start of
the xen built page tables.

To be able to move the p2m list to another pfn range, which is needed
for support of huge RAM, this memblock_reserve() must be split up to
cover all affected reserved pages explicitly.

The affected pages are:
- start_info page
- xenstore ring
- console ring
- shared_info page

Signed-off-by: Juergen Gross <jgross@xxxxxxxx>
---
arch/x86/xen/enlighten.c | 1 +
arch/x86/xen/mmu.c | 11 +++++++++++
arch/x86/xen/xen-ops.h | 1 +
3 files changed, 13 insertions(+)

diff --git a/arch/x86/xen/enlighten.c b/arch/x86/xen/enlighten.c
index 46957ea..a29bcdb 100644
--- a/arch/x86/xen/enlighten.c
+++ b/arch/x86/xen/enlighten.c
@@ -1569,6 +1569,7 @@ asmlinkage __visible void __init xen_start_kernel(void)

xen_raw_console_write("mapping kernel into physical memory\n");
xen_setup_kernel_pagetable((pgd_t *)xen_start_info->pt_base, xen_start_info->nr_pages);
+ xen_reserve_special_pages();

/*
* Modify the cache mode translation tables to match Xen's PAT
diff --git a/arch/x86/xen/mmu.c b/arch/x86/xen/mmu.c
index 1982617..a286953 100644
--- a/arch/x86/xen/mmu.c
+++ b/arch/x86/xen/mmu.c
@@ -2084,6 +2084,17 @@ void __init xen_setup_kernel_pagetable(pgd_t *pgd, unsigned long max_pfn)
}
#endif /* CONFIG_X86_64 */

+void __init xen_reserve_special_pages(void)
+{
+ memblock_reserve(__pa(xen_start_info), PAGE_SIZE);
+ memblock_reserve(PFN_PHYS(mfn_to_pfn(xen_start_info->store_mfn)),
+ PAGE_SIZE);
+ if (!xen_initial_domain())
+ memblock_reserve(PFN_PHYS(mfn_to_pfn(
+ xen_start_info->console.domU.mfn)), PAGE_SIZE);
+ memblock_reserve(__pa(HYPERVISOR_shared_info), PAGE_SIZE);
+}
+
void __init xen_pt_check_e820(void)
{
if (xen_is_e820_reserved(xen_pt_base, xen_pt_size)) {
diff --git a/arch/x86/xen/xen-ops.h b/arch/x86/xen/xen-ops.h
index 553abd8..88bd15f 100644
--- a/arch/x86/xen/xen-ops.h
+++ b/arch/x86/xen/xen-ops.h
@@ -35,6 +35,7 @@ void xen_build_mfn_list_list(void);
void xen_setup_machphys_mapping(void);
void xen_setup_kernel_pagetable(pgd_t *pgd, unsigned long max_pfn);
void xen_reserve_top(void);
+void __init xen_reserve_special_pages(void);
void __init xen_pt_check_e820(void);

void xen_mm_pin_all(void);
--
2.1.4

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/