From c2c7056af7647b523875d8b9850df6143d6eee11 Mon Sep 17 00:00:00 2001 From: Juergen Gross Date: Fri, 17 Jul 2015 06:51:30 +0200 Subject: [PATCH] xen: check for kernel memory conflicting with memory layout Checks whether the pre-allocated memory of the loaded kernel is in conflict with the target memory map. If this is the case, just panic instead of run into problems later, as there is nothing we can do to repair this situation. Signed-off-by: Juergen Gross Reviewed-by: David Vrabel Acked-by: Konrad Rzeszutek Wilk Signed-off-by: David Vrabel (cherry picked from commit 808fdb71936c41d46245f0e3aa6ec889cba70d97) Signed-off-by: Konrad Rzeszutek Wilk --- arch/x86/xen/setup.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/arch/x86/xen/setup.c b/arch/x86/xen/setup.c index 973d29441f96..9bd3f358f3d9 100644 --- a/arch/x86/xen/setup.c +++ b/arch/x86/xen/setup.c @@ -27,6 +27,7 @@ #include #include #include +#include #include "xen-ops.h" #include "vdso.h" #include "p2m.h" @@ -790,6 +791,17 @@ char * __init xen_memory_setup(void) sanitize_e820_map(e820.map, ARRAY_SIZE(e820.map), &e820.nr_map); + /* + * Check whether the kernel itself conflicts with the target E820 map. + * Failing now is better than running into weird problems later due + * to relocating (and even reusing) pages with kernel text or data. + */ + if (xen_is_e820_reserved(__pa_symbol(_text), + __pa_symbol(__bss_stop) - __pa_symbol(_text))) { + xen_raw_console_write("Xen hypervisor allocated kernel memory conflicts with E820 map\n"); + BUG(); + } + xen_reserve_xen_mfnlist(); /* -- 2.50.1