From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with archive (Exim 4.43) id 1IFbXd-000241-DL for mharc-grub-devel@gnu.org; Mon, 30 Jul 2007 16:08:33 -0400 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1IFbXb-0001yV-3A for grub-devel@gnu.org; Mon, 30 Jul 2007 16:08:31 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1IFbXZ-0001xr-Oj for grub-devel@gnu.org; Mon, 30 Jul 2007 16:08:30 -0400 Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1IFbXZ-0001xo-KG for grub-devel@gnu.org; Mon, 30 Jul 2007 16:08:29 -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 1IFbXZ-0002ny-6c for grub-devel@gnu.org; Mon, 30 Jul 2007 16:08:29 -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 1IFbXS-00042y-V0; Mon, 30 Jul 2007 22:08:24 +0200 Received: from rmh by aragorn with local (Exim 4.63) (envelope-from ) id 1IFbac-0007pg-VX; Mon, 30 Jul 2007 22:11:39 +0200 Date: Mon, 30 Jul 2007 22:11:38 +0200 From: Robert Millan To: Sven Luther Message-ID: <20070730201138.GA27359@aragorn> References: <1184099550.9495.76.camel@basalt> <20070713220829.GA20231@aragorn> <20070724195946.GA3336@aragorn> <20070725200805.GA17393@aragorn> <20070727080500.GA17986@aragorn> <20070727103310.GA1539@powerlinux.fr> <20070727191514.GA3461@aragorn> <20070729193011.GA7033@aragorn> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="0F1p//8PRICkK4MW" Content-Disposition: inline In-Reply-To: <20070729193011.GA7033@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: The development of GRUB 2 Subject: [PATCH] efika memory issues 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: Mon, 30 Jul 2007 20:08:31 -0000 --0F1p//8PRICkK4MW Content-Type: text/plain; charset=us-ascii Content-Disposition: inline On Sun, Jul 29, 2007 at 09:30:11PM +0200, Robert Millan wrote: > > Hi Sven, > > I have a pair of questions about the memory issue.. > > [...] Ok, after some discussion on IRC, and invaluable help by Sven in documenting smartfirmware behaviour, I came up with this patch. Please let me know what you think. If there are no objections I'll check it in in a few days. 2007-07-30 Robert Millan * include/grub/ieee1275/ieee1275.h (grub_ieee1275_flag): Add GRUB_IEEE1275_FLAG_EFIKA_SECRET_AVAILABLE_REGION flag. * kern/powerpc/ieee1275/cmain.c (grub_ieee1275_find_options): Set GRUB_IEEE1275_FLAG_EFIKA_SECRET_AVAILABLE_REGION flag when running on an Efika (SmartFirmware). * kern/powerpc/ieee1275/init.c (grub_claim_heap): Fail gracefuly when addr > heaplimit. Use grub_printf instead of grub_error for error reporting, since grub_error doesn't work at this point of execution. When GRUB_IEEE1275_FLAG_EFIKA_SECRET_AVAILABLE_REGION was set, release hardcoded 0x4000:0xffc000 region. -- 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. --0F1p//8PRICkK4MW Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="efika.diff" 2007-07-30 Robert Millan * include/grub/ieee1275/ieee1275.h (grub_ieee1275_flag): Add GRUB_IEEE1275_FLAG_EFIKA_SECRET_AVAILABLE_REGION flag. * kern/powerpc/ieee1275/cmain.c (grub_ieee1275_find_options): Set GRUB_IEEE1275_FLAG_EFIKA_SECRET_AVAILABLE_REGION flag when running on an Efika (SmartFirmware). * kern/powerpc/ieee1275/init.c (grub_claim_heap): Fail gracefuly when addr > heaplimit. Use grub_printf instead of grub_error for error reporting, since grub_error doesn't work at this point of execution. When GRUB_IEEE1275_FLAG_EFIKA_SECRET_AVAILABLE_REGION was set, release hardcoded 0x4000:0xffc000 region. Index: include/grub/ieee1275/ieee1275.h =================================================================== RCS file: /sources/grub/grub2/include/grub/ieee1275/ieee1275.h,v retrieving revision 1.7 diff -u -r1.7 ieee1275.h --- include/grub/ieee1275/ieee1275.h 22 Jul 2007 09:05:10 -0000 1.7 +++ include/grub/ieee1275/ieee1275.h 30 Jul 2007 19:52:32 -0000 @@ -82,6 +82,10 @@ /* CodeGen firmware does not correctly implement "output-device output" */ GRUB_IEEE1275_FLAG_BROKEN_OUTPUT, + + /* Efika version of CodeGen firmware has an available memory region that + is not represented in /memory/available. */ + GRUB_IEEE1275_FLAG_EFIKA_SECRET_AVAILABLE_REGION, }; extern int EXPORT_FUNC(grub_ieee1275_test_flag) (enum grub_ieee1275_flag flag); Index: kern/powerpc/ieee1275/cmain.c =================================================================== RCS file: /sources/grub/grub2/kern/powerpc/ieee1275/cmain.c,v retrieving revision 1.9 diff -u -r1.9 cmain.c --- kern/powerpc/ieee1275/cmain.c 22 Jul 2007 09:16:51 -0000 1.9 +++ kern/powerpc/ieee1275/cmain.c 30 Jul 2007 19:52:32 -0000 @@ -63,9 +63,14 @@ rc = grub_ieee1275_get_property (openprom, "SmartFirmware-version", 0, 0, 0); if (rc >= 0) { + char model[32]; grub_ieee1275_set_flag (GRUB_IEEE1275_FLAG_NO_PARTITION_0); grub_ieee1275_set_flag (GRUB_IEEE1275_FLAG_0_BASED_PARTITIONS); grub_ieee1275_set_flag (GRUB_IEEE1275_FLAG_BROKEN_OUTPUT); + + rc = grub_ieee1275_get_property (openprom, "model", &model, sizeof model, 0); + if ((rc >= 0) && !grub_strncmp (model, "EFIKA", 5)) + grub_ieee1275_set_flag (GRUB_IEEE1275_FLAG_EFIKA_SECRET_AVAILABLE_REGION); } } 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 30 Jul 2007 19:52:32 -0000 @@ -121,6 +121,12 @@ len -= 1; /* Required for some firmware. */ /* Don't claim anything above `heaplimit'. */ + if (addr > heaplimit) + { + grub_printf ("Cannot claim heap above limit (0x%llx > 0x%lx)\n", addr, heaplimit); + return GRUB_ERR_OUT_OF_MEMORY; + } + if (addr + len > heaplimit) len = heaplimit - addr; @@ -128,15 +134,19 @@ { /* Claim and use it. */ if (grub_claimmap (addr, len) < 0) - return grub_error (GRUB_ERR_OUT_OF_MEMORY, - "Failed to claim heap at 0x%llx, len 0x%llx\n", - addr, len); + { + grub_printf ("Failed to claim heap at 0x%llx, len 0x%llx\n", addr, len); + return GRUB_ERR_OUT_OF_MEMORY; + } grub_mm_init_region ((void *) (grub_addr_t) addr, len); } return 0; } + if (grub_ieee1275_test_flag (GRUB_IEEE1275_FLAG_EFIKA_SECRET_AVAILABLE_REGION)); + grub_ieee1275_release (0x4000, 0xffc000); + grub_available_iterate (heap_init); } --0F1p//8PRICkK4MW--