xen: find a better location for the real-mode trampoline
PATCH 1/1 xen: find a better location for the real-mode trampoline
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.
--- xen/arch/x86/boot/head.S | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-)
xen/arch/x86/boot/head.S +12 -9
@@ -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! */
Signature · 1 line
1.8.0
Quoted 10 lines
Quoted 1 line
Quoted 1 line · Paolo Bonzini
On some machines, the location at
0x40edoes 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,
0x413is actually a better source than0x40eto 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.
I think if anything we really should make this a minimum calculation of all three (sanity checked) values, rather than throwing the other sources out. It's just not certain enough that we can trust all multiboot implementations.
Of course, ideally we'd consult the memory map, but the E820 one is unavailable at that point (and getting at it would create a chicken-and-egg problem).
Jan
Quoted 46 lines
Signed-off-by Paolo Bonzini <[email protected]>--- xen/arch/x86/boot/head.S | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-)xen/arch/x86/boot/head.S +12
-9@@ -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! */Signature · 7 lines
1.8.0 _______________________________________________ Xen-devel mailing list [email protected] http://lists.xen.org/xen-devel
Quoted 11 lines · Jan Beulich
Quoted 10 lines
Quoted 1 line
Quoted 1 line · Paolo Bonzini
On some machines, the location at
0x40edoes 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,
0x413is actually a better source than0x40eto 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.
Quoted 8 lines
I think if anything we really should make this a minimum calculation of all three (sanity checked) values, rather than throwing the other sources out. It's just not certain enough that we can trust all multiboot implementations.
Of course, ideally we'd consult the memory map, but the E820 one is unavailable at that point (and getting at it would create a chicken-and-egg problem).
Can we scan the memory for the possible EBDA regions? There is an "EBDA" type header in those regions, if I recall?
Quoted 58 lines
Jan
Quoted 46 lines
Signed-off-by Paolo Bonzini <[email protected]>--- xen/arch/x86/boot/head.S | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-)xen/arch/x86/boot/head.S +12
-9@@ -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! */Signature · 7 lines
1.8.0 _______________________________________________ Xen-devel mailing list [email protected] http://lists.xen.org/xen-devel_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
Quoted 18 lines
Quoted 1 line
Quoted 1 line · Konrad Rzeszutek Wilk
Quoted 16 lines · Jan Beulich
Quoted 10 lines
Quoted 1 line
Quoted 1 line · Paolo Bonzini
On some machines, the location at
0x40edoes 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,
0x413is actually a better source than0x40eto 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.I think if anything we really should make this a minimum calculation of all three (sanity checked) values, rather than throwing the other sources out. It's just not certain enough that we can trust all multiboot implementations.
Quoted 6 lines
Quoted 3 lines
Of course, ideally we'd consult the memory map, but the E820 one is unavailable at that point (and getting at it would create a chicken-and-egg problem).
Can we scan the memory for the possible EBDA regions? There is an "EBDA" type header in those regions, if I recall?
I don't think there are any signatures - the value at (real mode) 0040:000e has to be relied upon.
Jan
Quoted 12 lines
Quoted 11 lines
Quoted 2 lines · Jan Beulich
Quoted 1 line · Paolo Bonzini
On some machines, the location at
0x40edoes 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,
0x413is actually a better source than0x40eto 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.
Quoted 4 lines
I think if anything we really should make this a minimum calculation of all three (sanity checked) values, rather than throwing the other sources out. It's just not certain enough that we can trust all multiboot implementations.
I never saw a response from you on this one - were you intending to follow up, or did you (silently) expect us to sort this out?
Jan
Quoted 60 lines
Of course, ideally we'd consult the memory map, but the E820 one is unavailable at that point (and getting at it would create a chicken-and-egg problem).
Jan
Quoted 46 lines
Signed-off-by Paolo Bonzini <[email protected]>--- xen/arch/x86/boot/head.S | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-)xen/arch/x86/boot/head.S +12
-9@@ -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! */Signature · 7 lines
1.8.0 _______________________________________________ Xen-devel mailing list [email protected] http://lists.xen.org/xen-devel_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
Il 18/12/2012 14:07, Jan Beulich ha scritto:
Quoted 12 lines
Quoted 12 lines
Quoted 11 lines
Quoted 2 lines · Jan Beulich
Quoted 1 line · Paolo Bonzini
On some machines, the location at
0x40edoes 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,
0x413is actually a better source than0x40eto 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.
Quoted 8 lines
Quoted 4 lines
I think if anything we really should make this a minimum calculation of all three (sanity checked) values, rather than throwing the other sources out. It's just not certain enough that we can trust all multiboot implementations.
I never saw a response from you on this one - were you intending to follow up, or did you (silently) expect us to sort this out?
No, just busy. I agree that checking all three is best. However, there is at least one known case where 0x40e doesn't work, so 0x413 and multiboot should be enough.
Paolo
Quoted 19 lines
Quoted 1 line
Quoted 1 line · Paolo Bonzini
Il 18/12/2012 14:07, Jan Beulich ha scritto:
Quoted 17 lines
Quoted 16 lines
Quoted 11 lines
Quoted 2 lines · Jan Beulich
Quoted 1 line · Paolo Bonzini
On some machines, the location at
0x40edoes 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,
0x413is actually a better source than0x40eto 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.I think if anything we really should make this a minimum calculation of all three (sanity checked) values, rather than throwing the other sources out. It's just not certain enough that we can trust all multiboot implementations.
Quoted 7 lines
Quoted 3 lines
I never saw a response from you on this one - were you intending to follow up, or did you (silently) expect us to sort this out?
No, just busy. I agree that checking all three is best. However, there is at least one known case where
0x40edoesn't work, so0x413and multiboot should be enough.
Can you provide more detail about this specific case? In particular, what value 0x40e in fact has there?
Jan
Il 18/12/2012 14:27, Jan Beulich ha scritto:
Quoted 23 lines
Quoted 23 lines
Quoted 1 line
Quoted 1 line · Paolo Bonzini
Il 18/12/2012 14:07, Jan Beulich ha scritto:
Quoted 20 lines
Quoted 12 lines
Quoted 11 lines
Quoted 2 lines · Jan Beulich
Quoted 1 line · Paolo Bonzini
On some machines, the location at
0x40edoes 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,
0x413is actually a better source than0x40eto 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.Quoted 4 lines
I think if anything we really should make this a minimum calculation of all three (sanity checked) values, rather than throwing the other sources out. It's just not certain enough that we can trust all multiboot implementations.
I never saw a response from you on this one - were you intending to follow up, or did you (silently) expect us to sort this out?
Quoted 6 lines
Quoted 3 lines
No, just busy. I agree that checking all three is best. However, there is at least one known case where
0x40edoesn't work, so0x413and multiboot should be enough.Can you provide more detail about this specific case? In particular, what value
0x40ein fact has there?
Sure. 0x40e did point to the beginning of the EBDA (around 635k), but an option ROM was reserving memory below there by lowering 0x413. That's the "on some machines" in the commit message.
Paolo
Quoted 29 lines
Quoted 1 line
Quoted 1 line · Paolo Bonzini
Il 18/12/2012 14:27, Jan Beulich ha scritto:
Quoted 27 lines
Quoted 26 lines
Quoted 1 line
Quoted 1 line · Paolo Bonzini
Il 18/12/2012 14:07, Jan Beulich ha scritto:
Quoted 12 lines
Quoted 12 lines
Quoted 11 lines
Quoted 2 lines · Jan Beulich
Quoted 1 line · Paolo Bonzini
On some machines, the location at
0x40edoes 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,
0x413is actually a better source than0x40eto 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.Quoted 8 lines
Quoted 4 lines
I think if anything we really should make this a minimum calculation of all three (sanity checked) values, rather than throwing the other sources out. It's just not certain enough that we can trust all multiboot implementations.
I never saw a response from you on this one - were you intending to follow up, or did you (silently) expect us to sort this out?
No, just busy. I agree that checking all three is best. However, there is at least one known case where
0x40edoesn't work, so0x413and multiboot should be enough.
Quoted 6 lines
Quoted 2 lines
Can you provide more detail about this specific case? In particular, what value
0x40ein fact has there?Sure.
0x40edid point to the beginning of the EBDA (around 635k), but an option ROM was reserving memory below there by lowering0x413. That's the "on some machines" in the commit message.
That wouldn't preclude the suggested sanity-checked-minimum solution.
Jan
Il 18/12/2012 14:36, Jan Beulich ha scritto:
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 3 lines
Quoted 3 lines
No, just busy. I agree that checking all three is best. However, there is at least one known case where
0x40edoesn't work, so0x413and multiboot should be enough.
Quoted 8 lines
Quoted 6 lines
Quoted 6 lines
Quoted 2 lines
Quoted 2 lines
Can you provide more detail about this specific case? In particular, what value
0x40ein fact has there?Sure.
0x40edid point to the beginning of the EBDA (around 635k), but an option ROM was reserving memory below there by lowering0x413. That's the "on some machines" in the commit message.That wouldn't preclude the suggested sanity-checked-minimum solution.
Yes, on the other hand [0x413] should always be less than or equal to [0x40e] << 6. Otherwise for example DOS would not work on that system.
Paolo