From mboxrd@z Thu Jan 1 00:00:00 1970 From: Paolo Bonzini Subject: [PATCH] xen: find a better location for the real-mode trampoline Date: Thu, 29 Nov 2012 18:34:21 +0100 Message-ID: <1354210461-9739-1-git-send-email-pbonzini@redhat.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org To: xen-devel@lists.xen.org List-Id: xen-devel@lists.xenproject.org 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. But it is even better to fetch the information from the multiboot structure, where the boot loader has placed the data for us already. Signed-off-by: Paolo Bonzini --- xen/arch/x86/boot/head.S | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/xen/arch/x86/boot/head.S b/xen/arch/x86/boot/head.S index 7efa155..1790462 100644 --- a/xen/arch/x86/boot/head.S +++ b/xen/arch/x86/boot/head.S @@ -78,16 +78,19 @@ __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. + * Prefer to get this information from the multiboot + * structure, if available. + */ + mov 4(%ebx),%eax /* kb of low memory */ + testb $1,(%ebx) /* test MBI_MEMLIMITS */ + jnz 1f + + movzwl 0x413,%eax /* base memory size in kb */ 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