]> xenbits.xensource.com Git - people/dariof/xen.git/commitdiff
xen/pvh: place the trampoline starting at MFN 1
authorRoger Pau Monne <roger.pau@citrix.com>
Wed, 17 Jan 2018 08:34:26 +0000 (08:34 +0000)
committerWei Liu <wei.liu2@citrix.com>
Thu, 18 Jan 2018 11:17:52 +0000 (11:17 +0000)
Since PVH guest jump straight into trampoline_setup trampoline_phys is
not initialized, thus the trampoline is relocated to address 0.

This works, but has the undesirable effect of having VA 0 mapped to
MFN 0, which means NULL pointed dereferences no longer trigger a page
fault.

In order to solve this, place the trampoline starting at MFN 1 and
reserve the memory used by it.

Signed-off-by: Roger Pau Monné <roger.pau@citrix.com>
Reviewed-by: Wei Liu <wei.liu2@citrix.com>
Acked-by: Jan Beulich <jbeulich@suse.com>
xen/arch/x86/boot/head.S
xen/arch/x86/mm.c

index 4fe5a776b135c8568a2e4bcca0fffd81b8b6037c..0f652cea110dc47c26e0336ef1923b7d4e364fc8 100644 (file)
@@ -411,6 +411,9 @@ __pvh_start:
         /* Skip bootloader setup and bios setup, go straight to trampoline */
         movb    $1, sym_esi(pvh_boot)
         movb    $1, sym_esi(skip_realmode)
+
+        /* Set trampoline_phys to use mfn 1 to avoid having a mapping at VA 0 */
+        movw    $0x1000, sym_esi(trampoline_phys)
         jmp     trampoline_setup
 
 #endif /* CONFIG_PVH_GUEST */
index 1147a1afb1bc31ce544d0c76022b48461a8dadf6..275e68c4176d6448b98fa289fbe69069d3b76d32 100644 (file)
@@ -292,9 +292,14 @@ void __init arch_init_memory(void)
     /*
      * 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.
+     * of 0 being a very common default value. Also reserve the RAM needed by
+     * the trampoline on PVH starting at MFN 1.
      */
-    for ( i = 0; i < (pvh_boot ? 1 : 0x100); i++ )
+    BUG_ON(pvh_boot && trampoline_phys != 0x1000);
+    for ( i = 0;
+          i < (pvh_boot ? (1 + PFN_UP(trampoline_end - trampoline_start))
+                        : 0x100);
+          i++ )
         share_xen_page_with_guest(mfn_to_page(_mfn(i)),
                                   dom_io, XENSHARE_writable);