xen-devel.lists.xenproject.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2] xen: find a better location for the real-mode trampoline
@ 2012-12-18 13:59 Paolo Bonzini
  0 siblings, 0 replies; only message in thread
From: Paolo Bonzini @ 2012-12-18 13:59 UTC (permalink / raw)
  To: xen-devel; +Cc: jbeulich

On some machines, the location at 0x40e does not point to the beginning
of the EBDA.  Rather, it points to the beginning of the BIOS-reserved
area of the EBDA, while the option ROMs place their data below that
segment.

For this reason, 0x413 is actually a better source than 0x40e to get
the location of the real-mode trampoline.  Xen was already using it
as a second source, and this patch keeps that working.  However, just
in case, let's also fetch the information from the multiboot structure,
where the boot loader should have placed it.  This way we don't
necessarily trust one of the BIOS or the multiboot loader more than
the other.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
 xen/arch/x86/boot/head.S | 24 +++++++++++++++---------
 1 file changed, 15 insertions(+), 9 deletions(-)

diff --git a/xen/arch/x86/boot/head.S b/xen/arch/x86/boot/head.S
index 7efa155..73e1c6a 100644
--- a/xen/arch/x86/boot/head.S
+++ b/xen/arch/x86/boot/head.S
@@ -78,16 +78,22 @@ __start:
         cmp     $0x2BADB002,%eax
         jne     not_multiboot
 
-        /* Set up trampoline segment 64k below EBDA */
-        movzwl  0x40e,%eax          /* EBDA segment */
-        cmp     $0xa000,%eax        /* sanity check (high) */
-        jae     0f
-        cmp     $0x4000,%eax        /* sanity check (low) */
-        jae     1f
-0:
-        movzwl  0x413,%eax          /* use base memory size on failure */
-        shl     $10-4,%eax
+        /* Set up trampoline segment just below end of base memory.
+         * Compare the value in the BDA with the information from the
+         * multiboot structure (if available) and use the smallest.
+         */
+        movzwl  0x413,%eax          /* base memory size in kb */
+        testb   $1,(%ebx)           /* test MBI_MEMLIMITS */
+        jz      1f                  /* not available? BDA value will be fine */
+        cmpw    $0x100,4(%ebx)      /* is the multiboot value too small?  */
+        jl      1f                  /* yes, do not use it */
+        cmpw    %ax,4(%ebx)         /* is the BDA value the smallest?  */
+        jge     1f                  /* yes, use it */
+        mov     4(%ebx),%eax
 1:
+        shl     $10-4,%eax          /* convert to a segment number */
+
+        /* Reserve 64kb for the trampoline */
         sub     $0x1000,%eax
 
         /* From arch/x86/smpboot.c: start_eip had better be page-aligned! */
-- 
1.8.0.2

^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2012-12-18 13:59 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-12-18 13:59 [PATCH v2] xen: find a better location for the real-mode trampoline Paolo Bonzini

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).