[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Xen-devel] [RFC] x86/boot: Don't use BDA value if it's suspiciously small



On 26/08/16 10:09, Sylvain Munaut wrote:
If we have an multiboot value and the value we got from the BDA
seems too small, use the safe one

Signed-off-by: Sylvain Munaut <s.munaut@xxxxxxxxxxxxxxxxxxxx>
---
I need this when using linux-as-a-bootloader (i.e. kexec into Xen) because
the BDA is just zero at that point (not entirely sure why tbh).

Does Linux reclam and reuse the BDA by this point in its boot?


This is the simplest patch I could come up with and that shouldn't change
anything for system currently booting. But if the multiboot infos are
present, I'm not sure why not use that preferentially since the values
from the BDA / EBDA could just be random garbage while the multiboot header
has at least some minimal validation (checksum + magic).

If we have mutliboot memory information available (should be all of the time), we should use that in preference to peeking at the BDA/EBDA


An error message if no sane value ( i.e. > 64k at min ) can be found at
all could be printed too. Took me some time to trace this down and some
serial output would have been welcome :)

All of this code is rather hairy. Unfortunately, there is no good logging method available at this point.

~Andrew


Comments welcome wrt to what people think is best and I can re-spin this.

  xen/arch/x86/boot/head.S | 2 ++
  1 file changed, 2 insertions(+)

diff --git a/xen/arch/x86/boot/head.S b/xen/arch/x86/boot/head.S
index 85770e8..d79fcc5 100644
--- a/xen/arch/x86/boot/head.S
+++ b/xen/arch/x86/boot/head.S
@@ -108,6 +108,8 @@ __start:
          shl     $10-4,%edx
          cmp     %eax,%edx           /* compare with BDA value */
          cmovb   %edx,%eax           /* and use the smaller */
+        cmp     $0x1000,%eax        /* or if the BDA value is too small */
+        cmovb   %edx,%eax           /* (and probably not valid) */
2: /* Reserve 64kb for the trampoline */
          sub     $0x1000,%eax


_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxx
https://lists.xen.org/xen-devel

 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.