Received: from mailman by lists.gnu.org with archive (Exim 4.43) id 1K3bFX-0002ss-D4 for mharc-grub-devel@gnu.org; Tue, 03 Jun 2008 14:28:47 -0400 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1K3bFV-0002sZ-Vi for grub-devel@gnu.org; Tue, 03 Jun 2008 14:28:45 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1K3bFR-0002pe-7C for grub-devel@gnu.org; Tue, 03 Jun 2008 14:28:44 -0400 Received: from [199.232.76.173] (port=39184 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1K3bFR-0002pX-4R for grub-devel@gnu.org; Tue, 03 Jun 2008 14:28:41 -0400 Received: from ti-out-0910.google.com ([209.85.142.187]:64768) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1K3bFQ-00024k-Oo for grub-devel@gnu.org; Tue, 03 Jun 2008 14:28:41 -0400 Received: by ti-out-0910.google.com with SMTP id u5so705684tia.10 for ; Tue, 03 Jun 2008 11:28:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:message-id:date:from:to:subject:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; bh=4pr9NPVJUohQ96Zi0Xb4Q/9EVd2Vy1eOWams7D6YFI0=; b=hOb7dnpvlkk5BMl+iPLbdFBHnvtrtd8or7jprjhQJE+N77GVo+kkfIDP25OI0PvYIhWDjTos+RLJUAO1weqDKy5PquImQNc14px0aTPD4pkSGPPoDXsNa0BgAjeIAl6i2GyDvjrtE5g3MHpuCUtbLqitqUI3hVV7XCmwqWThiXI= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:date:from:to:subject:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; b=PBAPaOMnZUxbdTwsDM9LaF8sc3JoU7q/FjXFqf8OBFGLi2MLP0tAYYBPBi4e2o1vjSy9PuF9b6KQzCkCwlFvouQllQ+oV/WYFJYta3kBkhKEwV7ok9/+kHLEjc2hxEybCEC740lE5MhFq14EsSeepcGMLUQDiT/gpQwVY4UqK/c= Received: by 10.110.109.12 with SMTP id h12mr1759852tic.34.1212517716634; Tue, 03 Jun 2008 11:28:36 -0700 (PDT) Received: by 10.110.16.5 with HTTP; Tue, 3 Jun 2008 11:28:36 -0700 (PDT) Message-ID: Date: Wed, 4 Jun 2008 02:28:36 +0800 From: Bean To: "The development of GRUB 2" In-Reply-To: <48457141.3020405@isaac.cedarswampstudios.org> MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline References: <4840123A.5020003@isaac.cedarswampstudios.org> <48402B87.6060201@isaac.cedarswampstudios.org> <20080530192626.GA29768@thorin> <48406B3F.1070704@isaac.cedarswampstudios.org> <20080531093501.GA6619@thorin> <48419F91.3070408@isaac.cedarswampstudios.org> <20080531192640.GA25920@thorin> <4841C728.5070008@isaac.cedarswampstudios.org> <48457141.3020405@isaac.cedarswampstudios.org> X-detected-kernel: by monty-python.gnu.org: Linux 2.6 (newer, 2) Subject: Re: macbook EFI experiences X-BeenThere: grub-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list Reply-To: The development of GRUB 2 List-Id: The development of GRUB 2 List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 03 Jun 2008 18:28:46 -0000 On Wed, Jun 4, 2008 at 12:28 AM, Isaac Dupree wrote: > Bean wrote: >> >> Hi, >> >> The problem with initrd is that it can't allocate enough memory. >> Please try the following patch, it will show some info that could be >> be useful in debugging. > > linux (hd0,4)/vmlinuz > [Linux-EFI, setup=0x2a00, size=0x1d2798] > initrd (hd0,4)/initrd.img > 679000 1ffeffff 832 Hi, I figure it out now, there is some problem with the initrd allocation algorithm, the following patch should fix it: diff --git a/loader/i386/efi/linux.c b/loader/i386/efi/linux.c index ee3fb99..8d0e0c2 100644 --- a/loader/i386/efi/linux.c +++ b/loader/i386/efi/linux.c @@ -601,7 +604,7 @@ grub_rescue_cmd_initrd (int argc, char *argv[]) lh = (struct linux_kernel_header *) real_mode_mem; - addr_max = grub_cpu_to_le32 (lh->initrd_addr_max); + addr_max = (grub_cpu_to_le32 (lh->initrd_addr_max) << 10); if (linux_mem_size != 0 && linux_mem_size < addr_max) addr_max = linux_mem_size; @@ -612,7 +615,8 @@ grub_rescue_cmd_initrd (int argc, char *argv[]) addr_max -= 0x10000; /* Usually, the compression ratio is about 50%. */ - addr_min = (grub_addr_t) prot_mode_mem + ((prot_mode_pages * 3) << 12); + addr_min = (grub_addr_t) prot_mode_mem + ((prot_mode_pages * 3) << 12) + + page_align (size); /* Find the highest address to put the initrd. */ mmap_size = find_mmap_size (); @@ -625,8 +629,6 @@ grub_rescue_cmd_initrd (int argc, char *argv[]) desc = NEXT_MEMORY_DESCRIPTOR (desc, desc_size)) { if (desc->type == GRUB_EFI_CONVENTIONAL_MEMORY - && desc->physical_start >= addr_min - && desc->physical_start + size < addr_max && desc->num_pages >= initrd_pages) { grub_efi_physical_address_t physical_end; @@ -635,6 +637,9 @@ grub_rescue_cmd_initrd (int argc, char *argv[]) if (physical_end > addr_max) physical_end = addr_max; + if (physical_end < addr_min) + continue; + if (physical_end > addr) addr = physical_end - page_align (size); } -- Bean