From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with archive (Exim 4.43) id 1IDQVA-00087P-1q for mharc-grub-devel@gnu.org; Tue, 24 Jul 2007 15:57:00 -0400 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1IDQV8-00087I-4U for grub-devel@gnu.org; Tue, 24 Jul 2007 15:56:58 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1IDQV6-000876-NX for grub-devel@gnu.org; Tue, 24 Jul 2007 15:56:57 -0400 Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1IDQV6-000873-KQ for grub-devel@gnu.org; Tue, 24 Jul 2007 15:56:56 -0400 Received: from aybabtu.com ([69.60.117.155]) by monty-python.gnu.org with esmtps (TLS-1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1IDQV6-0001Kz-6S for grub-devel@gnu.org; Tue, 24 Jul 2007 15:56:56 -0400 Received: from [192.168.10.6] (helo=aragorn) by aybabtu.com with esmtps (TLS-1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.63) (envelope-from ) id 1IDQV3-0000TV-Qw; Tue, 24 Jul 2007 21:56:54 +0200 Received: from rmh by aragorn with local (Exim 4.63) (envelope-from ) id 1IDQXq-0000v8-Of; Tue, 24 Jul 2007 21:59:46 +0200 Date: Tue, 24 Jul 2007 21:59:46 +0200 From: Robert Millan To: The development of GRUB 2 Message-ID: <20070724195946.GA3336@aragorn> References: <1183565937.7721.41.camel@diesel> <20070710100444.GA5222@sahara.iti.upv.es> <20070710140823.GA8909@aragorn> <1184099550.9495.76.camel@basalt> <20070713220829.GA20231@aragorn> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="WIyZ46R2i8wDzkSu" Content-Disposition: inline In-Reply-To: <20070713220829.GA20231@aragorn> Organization: free as in freedom X-Message-Flag: Microsoft discourages use of Outlook. X-Debbugs-No-Ack: true User-Agent: Mutt/1.5.13 (2006-08-11) X-detected-kernel: Genre and OS details not recognized. Cc: Subject: Re: memory management issue (Re: another regression on Efika) 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, 24 Jul 2007 19:56:58 -0000 --WIyZ46R2i8wDzkSu Content-Type: text/plain; charset=us-ascii Content-Disposition: inline On Sat, Jul 14, 2007 at 12:08:30AM +0200, Robert Millan wrote: > On Tue, Jul 10, 2007 at 03:32:30PM -0500, Hollis Blanchard wrote: > > > > In short, whatever is causing these crashes is not only an Efika issue. > > > > I suspect Apple, or Apple powerbooks at least, are also affected. I got > > > > Sjoerd to try this on his powerbook, and he confirms this fixes for him. > > > > Paul also tried, with the same results. Not all the powerbooks are the > > > > very same model, there are different model revisions involved. > > > > > > The error Jordi was seeing before reverting your commits was very similar to > > > what I get on my Efika (something like "claim failed"). > > > > > > Hollis, do you still think this is a firmware bug? > > > > Could somebody please debug it and report back if it is really a GRUB > > issue? It could be as simple as adjusting the link address, or it could > > mean instrumenting grub_available_iterate() and checking that output > > with the contents of /memory/available. > > It turns out that grub_claim_heap() was asked to claim a region that starts > after the heap limit. The start address (0x19111e4) is correctly obtained > from /memory/available. > > Should heap limit be increased? The attached patch fixes the problem for Efika, although I'm not 1:1 sure of its correctness. It seems to me that heaplimit is meant to be used as a relative offset, not as an absolute memory address. This makes the current code fail when the start address in /memory/available is higher than heaplimit, and I don't think there's anything that can grant us this won't happen. From this POV, it's clear that moving from relative to absolute address is wrong. OTOH, your commit indicates (as per variable names, etc) that this change was done intentionally; so I have to assume there would be a reason for that. Please can you clarify? Btw, the attached patch doesn't fix the problem for Jordi (Mac). Maybe we're talking about two separate bugs after all. -- Robert Millan My spam trap is honeypot@aybabtu.com. Note: this address is only intended for spam harvesters. Writing to it will get you added to my black list. --WIyZ46R2i8wDzkSu Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="memory_fix.diff" Index: kern/powerpc/ieee1275/init.c =================================================================== RCS file: /sources/grub/grub2/kern/powerpc/ieee1275/init.c,v retrieving revision 1.31 diff -u -r1.31 init.c --- kern/powerpc/ieee1275/init.c 21 Jul 2007 23:32:27 -0000 1.31 +++ kern/powerpc/ieee1275/init.c 23 Jul 2007 19:49:44 -0000 @@ -115,14 +115,16 @@ /* Claim some available memory in the first /memory node. */ static void grub_claim_heap (unsigned long heaplimit) { + unsigned long total = 0; + auto int heap_init (grub_uint64_t addr, grub_uint64_t len); int heap_init (grub_uint64_t addr, grub_uint64_t len) { len -= 1; /* Required for some firmware. */ /* Don't claim anything above `heaplimit'. */ - if (addr + len > heaplimit) - len = heaplimit - addr; + if (total + len > heaplimit) + len = heaplimit - total; if (len) { @@ -134,6 +136,10 @@ grub_mm_init_region ((void *) (grub_addr_t) addr, len); } + total += len; + if (total >= heaplimit) + return 1; + return 0; } --WIyZ46R2i8wDzkSu--