From: Robert Millan <rmh@aybabtu.com>
To: grub-devel@gnu.org
Subject: another regression on Efika
Date: Mon, 2 Jul 2007 20:16:35 +0200 [thread overview]
Message-ID: <20070702181635.GA23110@aragorn> (raw)
[-- Attachment #1: Type: text/plain, Size: 1575 bytes --]
Hi,
I spotted another regression, caused by the following commits:
2007-02-21 Hollis Blanchard <hollis@penguinppc.org>
* 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 <hollis@penguinppc.org>
* 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.
They move GRUB from being able to initialise and fire up the menu (although
still unable to access disks), to abort with:
kern/mm.c: grub_error (GRUB_ERR_OUT_OF_MEMORY, "out of memory");
Unfortunately my limited expertise doesn't let me figure out what these changes
are doing. I'm attaching a reverse diff of the commit, such that when applied
to HEAD makes GRUB work again (verified) [1]. Perhaps someone can make sense
of it.
[1] Provided that the other regression caused by MacWorld hack is also fixed,
of course.
--
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.
[-- Attachment #2: memory.diff --]
[-- Type: text/x-diff, Size: 8605 bytes --]
-2007-02-21 Hollis Blanchard <hollis@penguinppc.org>
-
- * 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 <hollis@penguinppc.org>
-
- * 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
@@ -1004,4 +1004,3 @@
halt_mod_LDFLAGS = $(COMMON_LDFLAGS)
include $(srcdir)/conf/common.mk
-
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
@@ -127,4 +127,3 @@
halt_mod_LDFLAGS = $(COMMON_LDFLAGS)
include $(srcdir)/conf/common.mk
-
diff -ur grub2-bad/include/grub/misc.h grub2-good/include/grub/misc.h
--- grub2-bad/include/grub/misc.h 2007-02-22 00:22:20.000000000 +0100
+++ grub2-good/include/grub/misc.h 2006-10-14 17:24:52.000000000 +0200
@@ -26,8 +26,6 @@
#include <grub/symbol.h>
#include <grub/err.h>
-#define ALIGN_UP(addr, align) ((long)((char *)addr + align - 1) & ~(align - 1))
-
#define grub_dprintf(condition, fmt, args...) grub_real_dprintf(__FILE__, __LINE__, condition, fmt, ## args);
/* XXX: If grub_memmove is too slow, we must implement grub_memcpy. */
#define grub_memcpy(d,s,n) grub_memmove ((d), (s), (n))
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 <grub/symbol.h>
-#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 <grub/ieee1275/ofdisk.h>
#include <grub/ieee1275/ieee1275.h>
-#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
@@ -1,6 +1,6 @@
/*
* GRUB -- GRand Unified Bootloader
- * Copyright (C) 2004,2005,2006,2007 Free Software Foundation, Inc.
+ * Copyright (C) 2004,2005,2006 Free Software Foundation, Inc.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -27,12 +27,13 @@
#include <stdlib.h>
#include <string.h>
#include <grub/elf.h>
-#include <grub/misc.h>
#include <grub/util/misc.h>
#include <grub/util/resolve.h>
#include <grub/kernel.h>
#include <grub/machine/kernel.h>
+#define ALIGN_UP(addr, align) ((long)((char *)addr + align - 1) & ~(align - 1))
+
#define GRUB_IEEE1275_NOTE_NAME "PowerPC"
#define GRUB_IEEE1275_NOTE_TYPE 0x1275
@@ -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)
next reply other threads:[~2007-07-02 18:15 UTC|newest]
Thread overview: 35+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-07-02 18:16 Robert Millan [this message]
2007-07-02 21:14 ` another regression on Efika Robert Millan
2007-07-04 16:18 ` Hollis Blanchard
2007-07-10 10:04 ` Jordi Mallach
2007-07-10 14:08 ` memory management issue (Re: another regression on Efika) Robert Millan
2007-07-10 20:32 ` Hollis Blanchard
2007-07-13 22:08 ` Robert Millan
2007-07-24 19:59 ` Robert Millan
2007-07-25 17:51 ` Hollis Blanchard
2007-07-25 20:08 ` Robert Millan
2007-07-25 23:25 ` Hollis Blanchard
2007-07-27 8:05 ` Robert Millan
[not found] ` <20070727103310.GA1539@powerlinux.fr>
2007-07-27 19:15 ` Robert Millan
2007-07-29 19:30 ` Robert Millan
2007-07-30 20:11 ` [PATCH] efika memory issues Robert Millan
2007-07-30 22:35 ` Hollis Blanchard
2007-07-31 14:38 ` Robert Millan
2007-07-31 15:55 ` Hollis Blanchard
2007-07-31 19:42 ` Robert Millan
2007-08-01 17:34 ` Hollis Blanchard
2007-08-01 18:27 ` Robert Millan
2007-09-30 20:10 ` [PATCH] fix memory management on efika/pegasos Robert Millan
2007-10-01 18:18 ` Marcin Kurek
2007-10-01 22:25 ` Marcin Kurek
2007-10-02 19:42 ` Robert Millan
2007-10-03 23:38 ` Marcin Kurek
2007-10-04 20:47 ` Robert Millan
2007-07-10 14:10 ` OF disk naming scheme (Re: another regression on Efika) Robert Millan
2007-07-10 19:26 ` Jordi Mallach
2007-07-13 22:16 ` Robert Millan
2007-07-22 9:33 ` Robert Millan
2007-07-22 14:37 ` Marco Gerards
2007-07-22 20:25 ` Robert Millan
2007-08-12 14:56 ` proposed solution using "ofpathname -a" (Re: OF disk naming scheme) Robert Millan
2007-08-05 10:03 ` updated regression diff (Re: another regression on Efika) Robert Millan
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20070702181635.GA23110@aragorn \
--to=rmh@aybabtu.com \
--cc=grub-devel@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.