grub-devel
[Top][All Lists]
Advanced

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

[PATCH] Incorrect initrd minimum address calculation


From: Colin Watson
Subject: [PATCH] Incorrect initrd minimum address calculation
Date: Sat, 13 Oct 2012 09:41:43 +0100
User-agent: Mutt/1.5.21 (2010-09-15)

One of my colleagues asked me to look into this bug, which showed Ubuntu
unable to boot as a guest within Windows Azure:

  https://bugs.launchpad.net/bugs/1055686

Although there was some speculation that this might be a bug in the
virtual hardware platform, I was unconvinced.  Debugging output from
GRUB indicated that this was a problem with allocating physical memory,
and dmesg output from Linux showed that there should have been enough
sufficiently low memory for the kernel and initrd.  The usable lines
from E820 output were:

  BIOS-e820: [mem 0x0000000000000000-0x000000000009fbff] usable
  BIOS-e820: [mem 0x0000000000100000-0x0000000003feffff] usable
  BIOS-e820: [mem 0x0000000040000000-0x00000000abffffff] usable

I looked hard at how GRUB allocates memory for the initrd.  The maximum
address is capped to 0x37FFFFFF, thereby excluding the
0x40000000-0xABFFFFFF range that's available on this system, so the
effective available range per E820 data is 0x100000-0x3FEFFFF, minus
what's already been allocated for the kernel.  The minimum address is
then taken as the target physical address of the kernel (here,
0x1000000) plus its required init space (here, 0x134F000) plus the
initrd size.  But the initrd is going to be allocated *above* this
address.  Why does it need to add the initrd size?  The effect of this
calculation is to limit the initrd size to about 15MB when it should be
limited to about 30MB.

What do you think of this patch?

2012-10-13  Colin Watson  <address@hidden>

        * grub-core/loader/i386/linux.c (grub_cmd_initrd): Don't add the
        initrd size to addr_min, since the initrd will be allocated
        after this address.

=== modified file 'grub-core/loader/i386/linux.c'
--- grub-core/loader/i386/linux.c       2012-10-05 12:09:19 +0000
+++ grub-core/loader/i386/linux.c       2012-10-13 08:33:56 +0000
@@ -1101,8 +1101,7 @@ grub_cmd_initrd (grub_command_t cmd __at
      worse than that of Linux 2.3.xx, so avoid the last 64kb.  */
   addr_max -= 0x10000;
 
-  addr_min = (grub_addr_t) prot_mode_target + prot_init_space
-             + page_align (size);
+  addr_min = (grub_addr_t) prot_mode_target + prot_init_space;
 
   /* Put the initrd as high as possible, 4KiB aligned.  */
   addr = (addr_max - size) & ~0xFFF;

Thanks,

-- 
Colin Watson                                       address@hidden



reply via email to

[Prev in Thread] Current Thread [Next in Thread]