From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with archive (Exim 4.43) id 1IHcud-0005Yr-RT for mharc-grub-devel@gnu.org; Sun, 05 Aug 2007 06:00:39 -0400 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1IHcub-0005Va-LJ for grub-devel@gnu.org; Sun, 05 Aug 2007 06:00:37 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1IHcua-0005SA-3F for grub-devel@gnu.org; Sun, 05 Aug 2007 06:00:37 -0400 Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1IHcuZ-0005Rv-Ng for grub-devel@gnu.org; Sun, 05 Aug 2007 06:00:35 -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 1IHcuW-0007kc-4b for grub-devel@gnu.org; Sun, 05 Aug 2007 06:00:34 -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 1IHcu4-0003PL-Tx for grub-devel@gnu.org; Sun, 05 Aug 2007 12:00:05 +0200 Received: from rmh by aragorn with local (Exim 4.63) (envelope-from ) id 1IHcxU-0006mA-3p for grub-devel@gnu.org; Sun, 05 Aug 2007 12:03:36 +0200 Date: Sun, 5 Aug 2007 12:03:36 +0200 From: Robert Millan To: grub-devel@gnu.org Message-ID: <20070805100336.GA25997@aragorn> References: <20070702181635.GA23110@aragorn> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="VS++wcV0S1rZb1Fb" Content-Disposition: inline In-Reply-To: <20070702181635.GA23110@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. Subject: updated regression diff (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: Sun, 05 Aug 2007 10:00:37 -0000 --VS++wcV0S1rZb1Fb Content-Type: text/plain; charset=us-ascii Content-Disposition: inline On Mon, Jul 02, 2007 at 08:16:35PM +0200, Robert Millan wrote: > [...] I'm attaching a reverse diff of the commit, such that when applied > to HEAD makes GRUB work again (verified) [1]. This patch broke. I'm updating it to HEAD. Removed some cosmetical changes to make it less error-prone. -- Robert Millan I know my rights; I want my phone call! What use is a phone call, if you are unable to speak? (as seen on /.) --VS++wcV0S1rZb1Fb Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="regression.diff" -2007-02-21 Hollis Blanchard - - * kern/powerpc/ieee1275/init.c (HEAP_SIZE): Removed. - (HEAP_LIMIT): New macro. - (grub_claim_heap): Claim memory up to `heaplimit'. - -2007-02-21 Hollis Blanchard - - * conf/powerpc-ieee1275.rmk (kernel_elf_LDFLAGS): Link at 64KB. - * kern/powerpc/ieee1275/init.c (_end): Add declaration. - (_start): Likewise. - (grub_arch_modules_addr): Return address after `_end'. - * util/powerpc/ieee1275/grub-mkimage.c: Include grub/misc.h. - (load_modules): Use new parameter as `p_paddr' and `p_vaddr'. - (add_segments): Calculate `_end' from phdr size and location. - (ALIGN_UP): Moved to ... - * include/grub/misc.h: here. - * include/grub/powerpc/ieee1275/kernel.h (GRUB_IEEE1275_MOD_ALIGN): - New macro. - (GRUB_IEEE1275_MODULE_BASE): Removed. diff -ur grub2-bad/conf/powerpc-ieee1275.mk grub2-good/conf/powerpc-ieee1275.mk --- grub2-bad/conf/powerpc-ieee1275.mk 2007-02-22 00:22:20.000000000 +0100 +++ grub2-good/conf/powerpc-ieee1275.mk 2006-12-13 23:34:04.000000000 +0100 @@ -468,7 +468,7 @@ kernel_elf_CFLAGS = $(COMMON_CFLAGS) kernel_elf_ASFLAGS = $(COMMON_ASFLAGS) kernel_elf_LDFLAGS = $(COMMON_LDFLAGS) -static-libgcc -lgcc \ - -Wl,-N,-S,-Ttext,0x10000,-Bstatic + -Wl,-N,-S,-Ttext,0x200000,-Bstatic # Scripts. sbin_SCRIPTS = grub-install diff -ur grub2-bad/conf/powerpc-ieee1275.rmk grub2-good/conf/powerpc-ieee1275.rmk --- grub2-bad/conf/powerpc-ieee1275.rmk 2007-02-22 00:22:20.000000000 +0100 +++ grub2-good/conf/powerpc-ieee1275.rmk 2006-12-13 23:30:19.000000000 +0100 @@ -74,7 +74,7 @@ kernel_elf_CFLAGS = $(COMMON_CFLAGS) kernel_elf_ASFLAGS = $(COMMON_ASFLAGS) kernel_elf_LDFLAGS = $(COMMON_LDFLAGS) -static-libgcc -lgcc \ - -Wl,-N,-S,-Ttext,0x10000,-Bstatic + -Wl,-N,-S,-Ttext,0x200000,-Bstatic # Scripts. sbin_SCRIPTS = grub-install diff -ur grub2-bad/include/grub/powerpc/ieee1275/kernel.h grub2-good/include/grub/powerpc/ieee1275/kernel.h --- grub2-bad/include/grub/powerpc/ieee1275/kernel.h 2007-02-22 00:22:20.000000000 +0100 +++ grub2-good/include/grub/powerpc/ieee1275/kernel.h 2006-04-23 15:37:36.000000000 +0200 @@ -22,9 +22,10 @@ #include -#define GRUB_IEEE1275_MOD_ALIGN 0x1000 - void EXPORT_FUNC (grub_reboot) (void); void EXPORT_FUNC (grub_halt) (void); +/* Where grub-mkimage places the core modules in memory. */ +#define GRUB_IEEE1275_MODULE_BASE 0x00300000 + #endif /* ! GRUB_KERNEL_MACHINE_HEADER */ diff -ur grub2-bad/kern/powerpc/ieee1275/init.c grub2-good/kern/powerpc/ieee1275/init.c --- grub2-bad/kern/powerpc/ieee1275/init.c 2007-02-22 00:27:36.000000000 +0100 +++ grub2-good/kern/powerpc/ieee1275/init.c 2007-02-13 04:49:43.000000000 +0100 @@ -34,10 +34,7 @@ #include #include -#define HEAP_LIMIT (4<<20) /* 4 MiB */ - -extern char _start[]; -extern char _end[]; +#define HEAP_SIZE (8<<20) /* 8 MiB */ void grub_exit (void) @@ -114,27 +111,29 @@ } /* Claim some available memory in the first /memory node. */ -static void grub_claim_heap (unsigned long heaplimit) +static void grub_claim_heap (unsigned long heapsize) { + 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 (len) - { - /* 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_mm_init_region ((void *) (grub_addr_t) addr, len); - } - + /* Limit heap to `heapsize'. */ + if (total + len > heapsize) + len = heapsize - total; + + /* 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_mm_init_region ((void *) (grub_addr_t) addr, len); + + total += len; + if (total >= heapsize) + return 1; return 0; } @@ -148,7 +147,7 @@ int actual; grub_console_init (); - grub_claim_heap (HEAP_LIMIT); + grub_claim_heap (HEAP_SIZE); grub_ofdisk_init (); /* Process commandline. */ @@ -206,5 +205,5 @@ grub_addr_t grub_arch_modules_addr (void) { - return ALIGN_UP(_end, GRUB_IEEE1275_MOD_ALIGN); + return GRUB_IEEE1275_MODULE_BASE; } diff -ur grub2-bad/util/powerpc/ieee1275/grub-mkimage.c grub2-good/util/powerpc/ieee1275/grub-mkimage.c --- grub2-bad/util/powerpc/ieee1275/grub-mkimage.c 2007-02-22 00:22:20.000000000 +0100 +++ grub2-good/util/powerpc/ieee1275/grub-mkimage.c 2006-09-26 06:24:38.000000000 +0200 @@ -97,8 +98,7 @@ } void -load_modules (grub_addr_t modbase, Elf32_Phdr *phdr, const char *dir, - char *mods[], FILE *out) +load_modules (Elf32_Phdr *phdr, const char *dir, char *mods[], FILE *out) { char *module_img; struct grub_util_path_list *path_list; @@ -152,8 +152,8 @@ phdr->p_type = grub_cpu_to_be32 (PT_LOAD); phdr->p_flags = grub_cpu_to_be32 (PF_R | PF_W | PF_X); phdr->p_align = grub_cpu_to_be32 (sizeof (long)); - phdr->p_vaddr = grub_cpu_to_be32 (modbase); - phdr->p_paddr = grub_cpu_to_be32 (modbase); + phdr->p_vaddr = grub_cpu_to_be32 (GRUB_IEEE1275_MODULE_BASE); + phdr->p_paddr = grub_cpu_to_be32 (GRUB_IEEE1275_MODULE_BASE); phdr->p_filesz = grub_cpu_to_be32 (total_module_size); phdr->p_memsz = grub_cpu_to_be32 (total_module_size); } @@ -166,7 +166,6 @@ Elf32_Phdr *phdr; FILE *in; char *kernel_path; - grub_addr_t grub_end = 0; off_t phdroff; int i; @@ -184,7 +183,6 @@ for (i = 0; i < grub_be_to_cpu16 (ehdr.e_phnum); i++) { char *segment_img; - grub_size_t segment_end; phdr = phdrs + i; @@ -196,13 +194,6 @@ grub_util_info ("copying segment %d, type %d", i, grub_be_to_cpu32 (phdr->p_type)); - /* Locate _end. */ - segment_end = grub_be_to_cpu32 (phdr->p_paddr) - + grub_be_to_cpu32 (phdr->p_memsz); - grub_util_info ("segment %u end 0x%lx", i, segment_end); - if (segment_end > grub_end) - grub_end = segment_end; - /* Read segment data and write it to new file. */ segment_img = xmalloc (grub_be_to_cpu32 (phdr->p_filesz)); @@ -216,11 +207,6 @@ if (mods[0] != NULL) { - grub_addr_t modbase; - - /* Place modules just after grub segment. */ - modbase = ALIGN_UP(grub_end, GRUB_IEEE1275_MOD_ALIGN); - /* Construct new segment header for modules. */ phdr = phdrs + grub_be_to_cpu16 (ehdr.e_phnum); ehdr.e_phnum = grub_cpu_to_be16 (grub_be_to_cpu16 (ehdr.e_phnum) + 1); @@ -229,7 +215,7 @@ phdr->p_offset = grub_cpu_to_be32 (ALIGN_UP (grub_util_get_fp_size (out), sizeof (long))); - load_modules (modbase, phdr, dir, mods, out); + load_modules (phdr, dir, mods, out); } if (chrp) --VS++wcV0S1rZb1Fb--