From c49338ef287c44113476d4c6ccaad7fa2924f8c7 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Roger=20Pau=20Monn=C3=A9?= Date: Mon, 12 Nov 2018 17:14:57 +0100 Subject: [PATCH] guest/pvh: special case the low 1MB MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit When running as a PVH guest Xen only special cases the trampoline code in the low 1MB, without also reserving the space used by the relocated metadata or the trampoline stack. Fix this by always reserving the low 1MB regardless of whether Xen is running as a guest or natively. Reported-by: Sergey Dyasli Signed-off-by: Roger Pau Monné Acked-by: Jan Beulich Reviewed-by: Wei Liu --- xen/arch/x86/mm.c | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/xen/arch/x86/mm.c b/xen/arch/x86/mm.c index 2c450cc208..16c7d88a8e 100644 --- a/xen/arch/x86/mm.c +++ b/xen/arch/x86/mm.c @@ -291,16 +291,13 @@ void __init arch_init_memory(void) BUG_ON(IS_ERR(dom_cow)); /* - * First 1MB of RAM is historically marked as I/O. If we booted PVH, - * reclaim the space. Irrespective, leave MFN 0 as special for the sake - * of 0 being a very common default value. Also reserve the RAM needed by - * the trampoline on PVH starting at MFN 1. + * First 1MB of RAM is historically marked as I/O. + * Note that apart from IO Xen also uses the low 1MB to store the AP boot + * trampoline and boot information metadata. Due to this always special + * case the low 1MB. */ BUG_ON(pvh_boot && trampoline_phys != 0x1000); - for ( i = 0; - i < (pvh_boot ? (1 + PFN_UP(trampoline_end - trampoline_start)) - : 0x100); - i++ ) + for ( i = 0; i < 0x100; i++ ) share_xen_page_with_guest(mfn_to_page(_mfn(i)), dom_io, SHARE_rw); /* Any areas not specified as RAM by the e820 map are considered I/O. */ -- 2.30.2