* Re: PPC64
@ 2008-10-21 20:52 Hollis Blanchard
2008-10-21 22:04 ` PPC64 Pavel Roskin
2008-10-23 18:00 ` PPC64 Manoel
0 siblings, 2 replies; 28+ messages in thread
From: Hollis Blanchard @ 2008-10-21 20:52 UTC (permalink / raw)
To: Manoel; +Cc: grub-devel, Carlos Roberto do Nascimento Costa
Please CC me, since I'm no longer subscribed to grub-devel.
> From: Manoel <mrabran@linux.vnet.ibm.com>
> To: The development of GRUB 2 <grub-devel@gnu.org>
> Subject: Re: PPC64
> Date: Tue, 21 Oct 2008 14:43:25 -0200
>
> Hi Hollis,
>
> On Mon, 2008-10-20 at 14:32 -0500, Hollis Blanchard wrote:
> > On Mon, 2008-10-20 at 17:18 -0200, Manoel wrote:
> > >
> > > I'm working in a project to use grub2 to boot some ppc machines(p6 , p5
> > > and so on) and we had some difficulties with a grub modules problem.
> > > Grub fails to load modules.
> > >
> > > When debugging I noted that grub try to find the headerinfo modules
> > > struc (which is identified by the magic number 0x676d696d) in the
> > > address 0x2d000 (_end + gap aligned in 4k blocks).
> > > but this address does not contains the headerinfo.
> > >
> > > So i altered the source code such as the memory is searched to find the
> > > magic number. It is then found at address 0x38f4c and then grub find
> > > some modules (but fails after) has showed in attachment grub2.txt.
> >
> > ...
> > ../kern/dl.c:527: module at 0x3e0dc, size 0xc9c
> > ../kern/dl.c:556: relocating to 0x28720
> > ../kern/dl.c:513: flushing 0x4 bytes at 0x28190
> > ../kern/dl.c:513: flushing 0x14 bytes at 0x281d0
> > ../kern/dl.c:513: flushing 0x68 bytes at 0x28220
> > ../kern/dl.c:513: flushing 0x410 bytes at 0x282c0
> > ../kern/dl.c:570: module name: amiga
> > ../kern/dl.c:571: init function: 0x282c0
> > ../kern/dl.c:527: module at 0x3ed84, size 0xe28
> > ../kern/dl.c:556: relocating to 0x280a0
> > ../kern/dl.c:513: flushing 0x4 bytes at 0x27a30
> > ../kern/dl.c:513: flushing 0x14 bytes at 0x27a70
> > ../kern/dl.c:513: flushing 0xfc bytes at 0x27ac0
> > ../kern/dl.c:513: flushing 0x458 bytes at 0x27bf0
> > ../kern/dl.c:570: module name: apple
> > ../kern/dl.c:571: init function: 0x27bf0
> > ../kern/dl.c:527: module at 0x3fbb8, size 0xeca4
> > ../kern/dl.c:556: relocating to 0x27940
> >
> > Notice how much larger that last module is than the ones before it.
> > That's a bit suspicious... do you have any modules that size?
> >
>
> I'd like to address this issue later but their size are really messed
> up. Grub can find the modules (how you can see by the modules names)
> though. The modules should have 7k at most but grub identified them has
> having about 50k.
That is really strange. I wonder if you have an ABI issue like
sizeof(long)... how is the grub-mkimage tool compiled? Please make sure
it's 32-bit. The grub binary that executes at boot should also 32-bit.
> I'm also curious why we must have a GAP between _end and the modules.
> Why do not put the modules right after the _end address.
We put the modules into a separate PT_LOAD ELF segment, and these must
be aligned.
One other possibility is that your firmware doesn't like the way
grub-mkimage throws out the section table on the ELF file. You could try
changing that behavior.
I suppose you could also try to extend the existing PT_LOAD segment
instead of creating a new one, but architecturally creating a new
segment for the modules is much nicer.
> I need to look more into the source code but I noted the modules are
> allocated in address in a decrementing order. The next module is always
> loaded in a address below the previous module. I don't know if this
> memory is allocated by the OF or if Grub forces the address to load the
> modules this way.
> How I have said before that I will look at this issue after the modules
> header info location address issue is resolved.
>
> > > that address calculation led me to believe that I can tell where the
> > > struct will be on memory based in its place in the binary.
> > >
> > > I also noted that basemod ( indicates where the modules sections begin)
> > > used by grub_mkelfimage is the same calculated by grub (_end + GAP). but
> > > it seems to not store it on the necessary address.
> > >
> > > using hexedit I could see that in the address 0xCC98 (in the file
> > > generated by grub_mkelfimage) is stored the struct header info.
> >
> > Well, hmm. Given the readelf output below, file offset 0xcc98 should be
> > loaded right at 0x2d000. Since you can see the magic number there
> > (correct?), I can't explain why the ELF loaded places it at 0x38f4c.
>
> Yes, the magic number is exactly at the address 0xcc98 on the file
> generated by the grub_mkelfimage. How can you tell the address it should
> appear in memory based on its address in file? Maybe it's only valid in
> some old OF version?
Look at the segment list again:
> Program Headers:
> Type Offset VirtAddr PhysAddr FileSiz MemSiz Flg Align
> LOAD 0x0000b4 0x00010000 0x00010000 0x0cbe4 0x14098 RWE 0x10
> GNU_STACK 0x00cc98 0x00000000 0x00000000 0x00000 0x00000 RWE 0x4
> LOAD 0x00cc98 0x0002d000 0x0002d000 0x5c1c8 0x5c1c8 RWE 0x4
> NOTE 0x068e60 0x00000000 0x00000000 0x0002c 0x00000 R 0x4
Offset tells you where in the file each segment begins. FileSiz is how
many bytes to read from the file. VirtAddr/PhysAddr is where in memory
to copy it, and MemSiz is how many bytes the segment will occupy in
memory. (If MemSiz > FileSiz, the trailing bytes are zero.)
0x38f4c, where you found the header, is about 50KB inside the second
LOAD segment (which was added by grub-mkimage and contains the modules).
Either the firmware's ELF loader did something bad loading the file, or
grub-mkimage did something bad constructing the file.
Since you said you can manually verify that file offset 0xcc98 does in
fact contain the magic number, and we can all see that it *should* be
loaded at 0x2d000, that makes it seem like the loader did something
wrong.
Can you report the bug to the firmware team, supply the broken binary,
and see if they'll take a look at it?
By the way, what filesystem is GRUB located on, and how big is the
partition? Historically IBM firmware has had bugs loading from many
filesystems, but I think FAT12 is OK as long as it's on a small
partition.
> > Can you report what memory firmware is using on this system? IIRC you
> > can decode it from the "available" properties in the memory nodes.
> >
> I couldn't find any apparently useful information in the memory nodes
> properties. I have attached it anyway, I have also attached the "/" node
> properties.
I didn't get these.
You'll need to refer to the PowerPC and CHRP bindings to IEEE 1275 to
interpret the /memory/available properties. I don't remember the field
widths off the top of my head, but they are basically a list of <base,
length> pairs that denote regions of memory available to applications.
I was just wondering if maybe firmware was occupying the memory
specified in the ELF header for the modules segment, and was doing
something stupid after that.
--
Hollis Blanchard
IBM Linux Technology Center
^ permalink raw reply [flat|nested] 28+ messages in thread
* Re: PPC64
2008-10-21 20:52 PPC64 Hollis Blanchard
@ 2008-10-21 22:04 ` Pavel Roskin
2008-10-21 22:40 ` PPC64 Hollis Blanchard
2008-10-23 18:00 ` PPC64 Manoel
1 sibling, 1 reply; 28+ messages in thread
From: Pavel Roskin @ 2008-10-21 22:04 UTC (permalink / raw)
To: The development of GRUB 2, Hollis Blanchard
Cc: Manoel, Carlos Roberto do Nascimento Costa
[-- Attachment #1: Type: text/plain, Size: 1664 bytes --]
Hello!
I just want to post some PowerPC related information in this thread
without delving deep into this discussion.
GRUB_MOD_GAP is needed to work around a bug on PowerMac G3 (Blue&White).
Without the gap, images created by grub-mkimage would not load.
OpenFirmware would report: "CLAIM failed".
I believe grub-mkimage doesn't generate valid ELF files, but they are
"good enough" for OpenFirmware. But only with the gap.
I have never tried compiling GRUB on 64-bit PowerPC. However, I tried
cross-compiling it on x86_64 for PowerPC and found a bug in
grub-mkimage, which I fixed. Look for GRUB_TARGET_SIZEOF_LONG in
ChangeLog.
Once this bug is fixed, it should be safe to remove all references
host_m32 from configure.ac. However, I left it in place because I
didn't have a 64-bit PowerPC to test.
util/ieee1275/grub-install.in is not suitable for PowerPC. It assumes
that /boot is on the HFS boot partition. It's not the case for Fedora
and perhaps any distro. The HFS boot partition is not mounted and
should be accessed by hfstools. The modules should be installed
under /boot/grub. The path to /boot/grub should be embedded into the
core image. We have support for embedding the default module path now.
We need a better script that would not put all modules on the short HFS
boot partition. Considering that the SPARC port is defunct, I would
just rewrite util/ieee1275/grub-install.in.
I'm attaching two scripts I'm using to test PowerPC grub on x86_64. One
is building the tools for the host architecture, the other builds them
for PowerPC and uses qemu to run them. The paths should be adjusted,
obviously.
--
Regards,
Pavel Roskin
[-- Attachment #2: grub-ppc --]
[-- Type: application/x-shellscript, Size: 307 bytes --]
[-- Attachment #3: grub-ppc-native --]
[-- Type: application/x-shellscript, Size: 432 bytes --]
^ permalink raw reply [flat|nested] 28+ messages in thread
* Re: PPC64
2008-10-21 22:04 ` PPC64 Pavel Roskin
@ 2008-10-21 22:40 ` Hollis Blanchard
2008-10-23 5:25 ` PPC64 Pavel Roskin
0 siblings, 1 reply; 28+ messages in thread
From: Hollis Blanchard @ 2008-10-21 22:40 UTC (permalink / raw)
To: Pavel Roskin
Cc: The development of GRUB 2, Carlos Roberto do Nascimento Costa,
Manoel
On Tue, 2008-10-21 at 18:04 -0400, Pavel Roskin wrote:
>
> util/ieee1275/grub-install.in is not suitable for PowerPC.
It worked great for me. :)
> It assumes that /boot is on the HFS boot partition.
I documented the partitioning assumptions it uses:
http://grub.enbug.org/TestingOnPowerPC
> It's not the case for Fedora
> and perhaps any distro. The HFS boot partition is not mounted and
> should be accessed by hfstools. The modules should be installed
> under /boot/grub. The path to /boot/grub should be embedded into the
> core image. We have support for embedding the default module path now.
> We need a better script that would not put all modules on the short HFS
> boot partition. Considering that the SPARC port is defunct, I would
> just rewrite util/ieee1275/grub-install.in.
The "boot partition" is an unnecessary hack instituted by a particularly
opinionated ybin developer, and a great inconvenience. It's ridiculous
to have scripts to copy and convert yaboot.conf files into a "secret"
partition, especially since the bootloader is perfectly capable of
discovering files at run time (unlike lilo, where the ybin model came
from). Also, have you looked at those scripts? <shudder>
On IBM POWER servers, there is no HFS partition at all. Instead, there
is a "raw" partition onto which you dd an ELF file. Firmware loads the
whole thing into memory and jumps at offset 0. Traditionally, yaboot is
installed there, and when it runs it does a shoddy job of trying to walk
the (DOS) partition table, searching for /etc/yaboot.conf.
Once GRUB replaces yaboot/ybin we can happily wave both of these
anachronisms goodbye. Firmware on both systems is fully capable of
loading ELF files from a filesystem, and since it's on a filesystem
there is no need to embed anything or search anywhere: all files
(grub.cfg and the modules) should be placed adjacent to the executable.
As for embedding the path in the executable itself, that's a nice idea
until you copy the executable to another system or move your hard disk
to another system where devices have different Open Firmware paths and
aliases. Another big pain point is building bootable CDs, since these
also unfortunately cannot make assumptions about the Open Firmware
devices available.
Just put all the files in the same directory on a real filesystem and be
happy. I know I am. :)
--
Hollis Blanchard
IBM Linux Technology Center
^ permalink raw reply [flat|nested] 28+ messages in thread
* Re: PPC64
2008-10-21 22:40 ` PPC64 Hollis Blanchard
@ 2008-10-23 5:25 ` Pavel Roskin
2008-10-23 15:06 ` PPC64 Hollis Blanchard
0 siblings, 1 reply; 28+ messages in thread
From: Pavel Roskin @ 2008-10-23 5:25 UTC (permalink / raw)
To: The development of GRUB 2, Hollis Blanchard
Cc: Manoel, Carlos Roberto do Nascimento Costa
Quoting Hollis Blanchard <hollisb@us.ibm.com>:
> On Tue, 2008-10-21 at 18:04 -0400, Pavel Roskin wrote:
>>
>> util/ieee1275/grub-install.in is not suitable for PowerPC.
>
> It worked great for me. :)
OK, I should have said that it's not suitable as a drop-in replacement
for yaboot on PowerMACs.
>> It assumes that /boot is on the HFS boot partition.
>
> I documented the partitioning assumptions it uses:
> http://grub.enbug.org/TestingOnPowerPC
Actually, that page doesn't mention grub-install at all. It suggests
merging all modules with the core and installing it on the boot
partition.
>> It's not the case for Fedora
>> and perhaps any distro. The HFS boot partition is not mounted and
>> should be accessed by hfstools. The modules should be installed
>> under /boot/grub. The path to /boot/grub should be embedded into the
>> core image. We have support for embedding the default module path now.
>> We need a better script that would not put all modules on the short HFS
>> boot partition. Considering that the SPARC port is defunct, I would
>> just rewrite util/ieee1275/grub-install.in.
>
> The "boot partition" is an unnecessary hack instituted by a particularly
> opinionated ybin developer, and a great inconvenience. It's ridiculous
> to have scripts to copy and convert yaboot.conf files into a "secret"
> partition, especially since the bootloader is perfectly capable of
> discovering files at run time (unlike lilo, where the ybin model came
> from). Also, have you looked at those scripts? <shudder>
I don't quite understand what you mean here. I don't care where
yaboot looks for its configuration files. I mean that GRUB should not
rely on the kernel support for HFS and that the HFS boot partition
should be used sparingly (it's a separate question whether yaboot does
the best effort, but yaboot is small).
> On IBM POWER servers, there is no HFS partition at all. Instead, there
> is a "raw" partition onto which you dd an ELF file. Firmware loads the
> whole thing into memory and jumps at offset 0. Traditionally, yaboot is
> installed there, and when it runs it does a shoddy job of trying to walk
> the (DOS) partition table, searching for /etc/yaboot.conf.
>
> Once GRUB replaces yaboot/ybin we can happily wave both of these
> anachronisms goodbye. Firmware on both systems is fully capable of
> loading ELF files from a filesystem, and since it's on a filesystem
> there is no need to embed anything or search anywhere: all files
> (grub.cfg and the modules) should be placed adjacent to the executable.
Actually, I would prefer all files that don't have to be on HFS or on
the raw partition to be on the native partition, so that they can be
easily accessed. That includes grub.cfg.
> As for embedding the path in the executable itself, that's a nice idea
> until you copy the executable to another system or move your hard disk
> to another system where devices have different Open Firmware paths and
> aliases. Another big pain point is building bootable CDs, since these
> also unfortunately cannot make assumptions about the Open Firmware
> devices available.
We can use UUIDs now. That should alleviate most issues.
> Just put all the files in the same directory on a real filesystem and be
> happy. I know I am. :)
I'm afraid I'm missing something.
Anyway, I think it's too much to ask from users to change the existing
partitioning or mount points. GRUB can be more compatible with both
its i386 implementation and with yaboot by keeping modules in
/boot/grub on ext2 or another native filesystem and placing the
minimal core to the machine specific boot partition (whether it's HFS
or raw or something else).
The goal of my previous message was to list the issues I ran into.
Inability to use grub-install as is was one of them, and it has not
been addressed.
--
Regards,
Pavel Roskin
^ permalink raw reply [flat|nested] 28+ messages in thread
* Re: PPC64
2008-10-23 5:25 ` PPC64 Pavel Roskin
@ 2008-10-23 15:06 ` Hollis Blanchard
2008-10-23 16:52 ` PPC64 Pavel Roskin
0 siblings, 1 reply; 28+ messages in thread
From: Hollis Blanchard @ 2008-10-23 15:06 UTC (permalink / raw)
To: Pavel Roskin
Cc: The development of GRUB 2, Carlos Roberto do Nascimento Costa,
Manoel
On Thu, 2008-10-23 at 01:25 -0400, Pavel Roskin wrote:
> Quoting Hollis Blanchard <hollisb@us.ibm.com>:
> > On IBM POWER servers, there is no HFS partition at all. Instead, there
> > is a "raw" partition onto which you dd an ELF file. Firmware loads the
> > whole thing into memory and jumps at offset 0. Traditionally, yaboot is
> > installed there, and when it runs it does a shoddy job of trying to walk
> > the (DOS) partition table, searching for /etc/yaboot.conf.
> >
> > Once GRUB replaces yaboot/ybin we can happily wave both of these
> > anachronisms goodbye. Firmware on both systems is fully capable of
> > loading ELF files from a filesystem, and since it's on a filesystem
> > there is no need to embed anything or search anywhere: all files
> > (grub.cfg and the modules) should be placed adjacent to the executable.
>
> Actually, I would prefer all files that don't have to be on HFS or on
> the raw partition to be on the native partition, so that they can be
> easily accessed. That includes grub.cfg.
FWIW, I ran for years with an HFS partition "natively" mounted
on /boot/grub, and I never experienced any instability. Do you have
reason (other than hearsay) to mistrust the Linux HFS driver?
> > As for embedding the path in the executable itself, that's a nice idea
> > until you copy the executable to another system or move your hard disk
> > to another system where devices have different Open Firmware paths and
> > aliases. Another big pain point is building bootable CDs, since these
> > also unfortunately cannot make assumptions about the Open Firmware
> > devices available.
>
> We can use UUIDs now. That should alleviate most issues.
Agreed.
> > Just put all the files in the same directory on a real filesystem and be
> > happy. I know I am. :)
>
> I'm afraid I'm missing something.
>
> Anyway, I think it's too much to ask from users to change the existing
> partitioning or mount points. GRUB can be more compatible with both
> its i386 implementation and with yaboot by keeping modules in
> /boot/grub on ext2 or another native filesystem and placing the
> minimal core to the machine specific boot partition (whether it's HFS
> or raw or something else).
Actually I don't remember if I had to change the partitioning scheme at
all: isn't GRUB + modules small enough to fit into the typical "ybin
boot partition"?
I don't think asking the user to add an entry to /etc/fstab is an
onerous restriction. After all, they are trying to replace their
distribution's bootloader in the first place, so they almost certainly
have some familiarity with the boot process. Once distributions use
GRUB2 of course, no user intervention would be required.
My basic point is that requiring grub-install and this mystical "hidden
partition in the mist" is just silly. It's completely unnecessary on
systems with filesystem support in firmware, and it's silly to
artificially limit those systems by imposing historical x86 restrictions
onto them.
--
Hollis Blanchard
IBM Linux Technology Center
^ permalink raw reply [flat|nested] 28+ messages in thread
* Re: PPC64
2008-10-23 15:06 ` PPC64 Hollis Blanchard
@ 2008-10-23 16:52 ` Pavel Roskin
0 siblings, 0 replies; 28+ messages in thread
From: Pavel Roskin @ 2008-10-23 16:52 UTC (permalink / raw)
To: The development of GRUB 2, Hollis Blanchard
Cc: Manoel, Carlos Roberto do Nascimento Costa
On Thu, 2008-10-23 at 10:06 -0500, Hollis Blanchard wrote:
> On Thu, 2008-10-23 at 01:25 -0400, Pavel Roskin wrote:
> > Actually, I would prefer all files that don't have to be on HFS or on
> > the raw partition to be on the native partition, so that they can be
> > easily accessed. That includes grub.cfg.
>
> FWIW, I ran for years with an HFS partition "natively" mounted
> on /boot/grub, and I never experienced any instability. Do you have
> reason (other than hearsay) to mistrust the Linux HFS driver?
HFS support is marked experimental in Linux 2.6.27, unlike HFSPLUS. I'm
not sure about the quality of fsck.hfs. However, it's not that I
distrust any drivers or utilities. The HFS driver may be missing from
the kernel. It doesn't even have to be a Linux kernel.
> > Anyway, I think it's too much to ask from users to change the existing
> > partitioning or mount points. GRUB can be more compatible with both
> > its i386 implementation and with yaboot by keeping modules in
> > /boot/grub on ext2 or another native filesystem and placing the
> > minimal core to the machine specific boot partition (whether it's HFS
> > or raw or something else).
>
> Actually I don't remember if I had to change the partitioning scheme at
> all: isn't GRUB + modules small enough to fit into the typical "ybin
> boot partition"?
It would fit. But it's better to keep modules and grub.cfg on a
filesystem that is easier to access.
> I don't think asking the user to add an entry to /etc/fstab is an
> onerous restriction. After all, they are trying to replace their
> distribution's bootloader in the first place, so they almost certainly
> have some familiarity with the boot process. Once distributions use
> GRUB2 of course, no user intervention would be required.
>
> My basic point is that requiring grub-install and this mystical "hidden
> partition in the mist" is just silly. It's completely unnecessary on
> systems with filesystem support in firmware, and it's silly to
> artificially limit those systems by imposing historical x86 restrictions
> onto them.
I can imagine that there are some real issues why the HFS boot partition
is not mounted. HFS may lack some security mechanisms that other
filesystems have. It may not have a good fsck. Anyway, whatever the
reasons, I don't think switching from yaboot to GRUB would change those
reasons. For GRUB to be a compelling replacement, it would be
beneficial if it could fit the existing systems.
--
Regards,
Pavel Roskin
^ permalink raw reply [flat|nested] 28+ messages in thread
* Re: PPC64
2008-10-21 20:52 PPC64 Hollis Blanchard
2008-10-21 22:04 ` PPC64 Pavel Roskin
@ 2008-10-23 18:00 ` Manoel
2008-10-23 19:08 ` PPC64 Hollis Blanchard
1 sibling, 1 reply; 28+ messages in thread
From: Manoel @ 2008-10-23 18:00 UTC (permalink / raw)
To: The development of GRUB 2
Cc: Carlos Roberto do Nascimento Costa, Hollis Blanchard
On Tue, 2008-10-21 at 15:52 -0500, Hollis Blanchard wrote:
> Please CC me, since I'm no longer subscribed to grub-devel.
>
> > From: Manoel <mrabran@linux.vnet.ibm.com>
> > To: The development of GRUB 2 <grub-devel@gnu.org>
> > Subject: Re: PPC64
> > Date: Tue, 21 Oct 2008 14:43:25 -0200
> >
> > Hi Hollis,
> >
> > On Mon, 2008-10-20 at 14:32 -0500, Hollis Blanchard wrote:
> > > On Mon, 2008-10-20 at 17:18 -0200, Manoel wrote:
> > > >
> > > > I'm working in a project to use grub2 to boot some ppc machines(p6 , p5
> > > > and so on) and we had some difficulties with a grub modules problem.
> > > > Grub fails to load modules.
> > > >
> > > > When debugging I noted that grub try to find the headerinfo modules
> > > > struc (which is identified by the magic number 0x676d696d) in the
> > > > address 0x2d000 (_end + gap aligned in 4k blocks).
> > > > but this address does not contains the headerinfo.
> > > >
> > > > So i altered the source code such as the memory is searched to find the
> > > > magic number. It is then found at address 0x38f4c and then grub find
> > > > some modules (but fails after) has showed in attachment grub2.txt.
> > >
> > > ...
> > > ../kern/dl.c:527: module at 0x3e0dc, size 0xc9c
> > > ../kern/dl.c:556: relocating to 0x28720
> > > ../kern/dl.c:513: flushing 0x4 bytes at 0x28190
> > > ../kern/dl.c:513: flushing 0x14 bytes at 0x281d0
> > > ../kern/dl.c:513: flushing 0x68 bytes at 0x28220
> > > ../kern/dl.c:513: flushing 0x410 bytes at 0x282c0
> > > ../kern/dl.c:570: module name: amiga
> > > ../kern/dl.c:571: init function: 0x282c0
> > > ../kern/dl.c:527: module at 0x3ed84, size 0xe28
> > > ../kern/dl.c:556: relocating to 0x280a0
> > > ../kern/dl.c:513: flushing 0x4 bytes at 0x27a30
> > > ../kern/dl.c:513: flushing 0x14 bytes at 0x27a70
> > > ../kern/dl.c:513: flushing 0xfc bytes at 0x27ac0
> > > ../kern/dl.c:513: flushing 0x458 bytes at 0x27bf0
> > > ../kern/dl.c:570: module name: apple
> > > ../kern/dl.c:571: init function: 0x27bf0
> > > ../kern/dl.c:527: module at 0x3fbb8, size 0xeca4
> > > ../kern/dl.c:556: relocating to 0x27940
> > >
> > > Notice how much larger that last module is than the ones before it.
> > > That's a bit suspicious... do you have any modules that size?
> > >
> >
> > I'd like to address this issue later but their size are really messed
> > up. Grub can find the modules (how you can see by the modules names)
> > though. The modules should have 7k at most but grub identified them has
> > having about 50k.
>
> That is really strange. I wonder if you have an ABI issue like
> sizeof(long)... how is the grub-mkimage tool compiled? Please make sure
> it's 32-bit. The grub binary that executes at boot should also 32-bit.
They are all 32-bit. I'll look deeper in this issue later.
>
> > I'm also curious why we must have a GAP between _end and the modules.
> > Why do not put the modules right after the _end address.
>
> We put the modules into a separate PT_LOAD ELF segment, and these must
> be aligned.
>
> One other possibility is that your firmware doesn't like the way
> grub-mkimage throws out the section table on the ELF file. You could try
> changing that behavior.
>
> I suppose you could also try to extend the existing PT_LOAD segment
> instead of creating a new one, but architecturally creating a new
> segment for the modules is much nicer.
>
I talked with some folks at #pppc64 on freenode an they suggest that the
OF is loading things in the wrong place could a problem with my
load-base:
real-base c00000 c00000
virt-base ffffffff ffffffff
real-size 1000000 1000000
virt-size ffffffff ffffffff
load-base 4000 4000
they suggested to change load-base from 4000 to 200000 but I hava yet to
try it. They also said that the note section can override load-base
(and maybe we have some problem there?)
I'm now reading PARP documentation to learn more about OF behavior. I
thought these machine were CHRP but they are actually PARP (is that
right?). Son only today I was able to get the correct documentation.
> > I need to look more into the source code but I noted the modules are
> > allocated in address in a decrementing order. The next module is always
> > loaded in a address below the previous module. I don't know if this
> > memory is allocated by the OF or if Grub forces the address to load the
> > modules this way.
> > How I have said before that I will look at this issue after the modules
> > header info location address issue is resolved.
> >
> > > > that address calculation led me to believe that I can tell where the
> > > > struct will be on memory based in its place in the binary.
> > > >
> > > > I also noted that basemod ( indicates where the modules sections begin)
> > > > used by grub_mkelfimage is the same calculated by grub (_end + GAP). but
> > > > it seems to not store it on the necessary address.
> > > >
> > > > using hexedit I could see that in the address 0xCC98 (in the file
> > > > generated by grub_mkelfimage) is stored the struct header info.
> > >
> > > Well, hmm. Given the readelf output below, file offset 0xcc98 should be
> > > loaded right at 0x2d000. Since you can see the magic number there
> > > (correct?), I can't explain why the ELF loaded places it at 0x38f4c.
> >
> > Yes, the magic number is exactly at the address 0xcc98 on the file
> > generated by the grub_mkelfimage. How can you tell the address it should
> > appear in memory based on its address in file? Maybe it's only valid in
> > some old OF version?
>
> Look at the segment list again:
> > Program Headers:
> > Type Offset VirtAddr PhysAddr FileSiz MemSiz Flg Align
> > LOAD 0x0000b4 0x00010000 0x00010000 0x0cbe4 0x14098 RWE 0x10
> > GNU_STACK 0x00cc98 0x00000000 0x00000000 0x00000 0x00000 RWE 0x4
> > LOAD 0x00cc98 0x0002d000 0x0002d000 0x5c1c8 0x5c1c8 RWE 0x4
> > NOTE 0x068e60 0x00000000 0x00000000 0x0002c 0x00000 R 0x4
>
NOTE 0x068e60 0x00000000 0x00000000 0x0002c 0x00000 R 0x4
this line look somehow wrong. NOTE will be loaded at the address 0?
and will occupy no memory? that is the same as don't having NOTE at all
right?
> Offset tells you where in the file each segment begins. FileSiz is how
> many bytes to read from the file. VirtAddr/PhysAddr is where in memory
> to copy it, and MemSiz is how many bytes the segment will occupy in
> memory. (If MemSiz > FileSiz, the trailing bytes are zero.)
>
> 0x38f4c, where you found the header, is about 50KB inside the second
> LOAD segment (which was added by grub-mkimage and contains the modules).
> Either the firmware's ELF loader did something bad loading the file, or
> grub-mkimage did something bad constructing the file.
>
> Since you said you can manually verify that file offset 0xcc98 does in
> fact contain the magic number, and we can all see that it *should* be
> loaded at 0x2d000, that makes it seem like the loader did something
> wrong.
>
> Can you report the bug to the firmware team, supply the broken binary,
> and see if they'll take a look at it?
>
I'll do that.
> By the way, what filesystem is GRUB located on, and how big is the
> partition? Historically IBM firmware has had bugs loading from many
> filesystems, but I think FAT12 is OK as long as it's on a small
> partition.
>
We are doing boot through network so we can test easier, and so far we
are only concerned about the initial parts (to find and load modules).
> > > Can you report what memory firmware is using on this system? IIRC you
> > > can decode it from the "available" properties in the memory nodes.
> > >
> > I couldn't find any apparently useful information in the memory nodes
> > properties. I have attached it anyway, I have also attached the "/" node
> > properties.
>
> I didn't get these.
>
I got documentation about the CHRP binding and it tells about a
memory-controller node, but it doesn't exist (maybe cause it is actually
PARP). I'll try to find something about it in PARP documentation.
> You'll need to refer to the PowerPC and CHRP bindings to IEEE 1275 to
> interpret the /memory/available properties. I don't remember the field
> widths off the top of my head, but they are basically a list of <base,
> length> pairs that denote regions of memory available to applications.
>
> I was just wondering if maybe firmware was occupying the memory
> specified in the ELF header for the modules segment, and was doing
> something stupid after that.
>
look likes it, maybe it cant load the section where it should then it
loads it elsewhere, but even so, grub should be able to load all modules
once I find where it starts.
Grub is able to successfully load some modules (first 6) and then
crashes when getting the module name of the 7th one.
Forcing grub to stop in the 6th module they appear listed in the lsmod
command (but I can't tell about it's functionality).
Looking better at the booting the size problem only occurs in the last
module (which crashes grub). So either mkelfimage is doing something
wrong or OF is corrupting the address where its size is stored.
I'll look more into int after the header address issue is done.
--
Best Regards,
Manoel Abranches <mrabran@linux.vnet.ibm.com>
IBM Linux Technology Center Brasil
^ permalink raw reply [flat|nested] 28+ messages in thread* Re: PPC64
2008-10-23 18:00 ` PPC64 Manoel
@ 2008-10-23 19:08 ` Hollis Blanchard
2008-10-24 12:10 ` PPC64 Manoel
2008-10-24 21:53 ` PPC64 Manoel
0 siblings, 2 replies; 28+ messages in thread
From: Hollis Blanchard @ 2008-10-23 19:08 UTC (permalink / raw)
To: Manoel; +Cc: The development of GRUB 2, Carlos Roberto do Nascimento Costa
On Thu, 2008-10-23 at 16:00 -0200, Manoel wrote:
>
> I talked with some folks at #pppc64 on freenode an they suggest that
> the
> OF is loading things in the wrong place could a problem with my
> load-base:
>
> real-base c00000 c00000
> virt-base ffffffff ffffffff
> real-size 1000000 1000000
> virt-size ffffffff ffffffff
> load-base 4000 4000
>
> they suggested to change load-base from 4000 to 200000 but I hava yet
> to try it. They also said that the note section can override
> load-base (and maybe we have some problem there?)
It's possible. See below.
> I'm now reading PARP documentation to learn more about OF behavior. I
> thought these machine were CHRP but they are actually PARP (is that
> right?). Son only today I was able to get the correct documentation.
PAPR was based on the older CHRP specification.
> > Look at the segment list again:
> > > Program Headers:
> > > Type Offset VirtAddr PhysAddr FileSiz MemSiz Flg Align
> > > LOAD 0x0000b4 0x00010000 0x00010000 0x0cbe4 0x14098 RWE 0x10
> > > GNU_STACK 0x00cc98 0x00000000 0x00000000 0x00000 0x00000 RWE 0x4
> > > LOAD 0x00cc98 0x0002d000 0x0002d000 0x5c1c8 0x5c1c8 RWE 0x4
> > > NOTE 0x068e60 0x00000000 0x00000000 0x0002c 0x00000 R 0x4
> >
> NOTE 0x068e60 0x00000000 0x00000000 0x0002c 0x00000 R 0x4
> this line look somehow wrong. NOTE will be loaded at the address 0?
> and will occupy no memory? that is the same as don't having NOTE at
> all right?
NOTE is interpreted by the loader (firmware), but not actually loaded
into memory. This is a binary structure that can be used to set some of
the environment variables you mention above.
The NOTE segment (segment, not section) is created by
util/elf/grub-mkimage.c . You can see that load-base is set to 0x4000 in
that code. Since your text starts at 0x10000, that means your binary can
be at most 0xc000 bytes (48KB) large before it overlaps the text area.
That isn't necessarily a problem; firmware is probably using memmove()
(which handles overlapping areas) to load the segments into place.
It's probably worth trying a different load-base to see if that could be
the problem here.
--
Hollis Blanchard
IBM Linux Technology Center
^ permalink raw reply [flat|nested] 28+ messages in thread
* Re: PPC64
2008-10-23 19:08 ` PPC64 Hollis Blanchard
@ 2008-10-24 12:10 ` Manoel
2008-10-24 14:51 ` PPC64 Hollis Blanchard
2008-10-24 21:53 ` PPC64 Manoel
1 sibling, 1 reply; 28+ messages in thread
From: Manoel @ 2008-10-24 12:10 UTC (permalink / raw)
To: Hollis Blanchard
Cc: The development of GRUB 2, Carlos Roberto do Nascimento Costa
I changed the load-base to 0x200000 in the note segment that mkelfimage
creates. After that grub2 found the modules info header in the correct
position (as stated in the program header) and was able to load all
modules correctly.
Maybe the Open Firmware detected the overlapping and tried to load the
segment in another place, and for some reason the data write was
corrupted.
Sounds like a OF's bug and I'll report it as you suggested. To me the
correct behavior would be load things in place and correctly even with
overlapping memory.
And about the note section, what is the point in create it with
hardcoded variables? I don't see a reason to have this note segment
unless the user want to use different variables values than the
configured in OF.
Thanks for the help so far, it was very useful.
On Thu, 2008-10-23 at 14:08 -0500, Hollis Blanchard wrote:
> On Thu, 2008-10-23 at 16:00 -0200, Manoel wrote:
> >
> > I talked with some folks at #pppc64 on freenode an they suggest that
> > the
> > OF is loading things in the wrong place could a problem with my
> > load-base:
> >
> > real-base c00000 c00000
> > virt-base ffffffff ffffffff
> > real-size 1000000 1000000
> > virt-size ffffffff ffffffff
> > load-base 4000 4000
> >
> > they suggested to change load-base from 4000 to 200000 but I hava yet
> > to try it. They also said that the note section can override
> > load-base (and maybe we have some problem there?)
>
> It's possible. See below.
>
> > I'm now reading PARP documentation to learn more about OF behavior. I
> > thought these machine were CHRP but they are actually PARP (is that
> > right?). Son only today I was able to get the correct documentation.
>
> PAPR was based on the older CHRP specification.
>
> > > Look at the segment list again:
> > > > Program Headers:
> > > > Type Offset VirtAddr PhysAddr FileSiz MemSiz Flg Align
> > > > LOAD 0x0000b4 0x00010000 0x00010000 0x0cbe4 0x14098 RWE 0x10
> > > > GNU_STACK 0x00cc98 0x00000000 0x00000000 0x00000 0x00000 RWE 0x4
> > > > LOAD 0x00cc98 0x0002d000 0x0002d000 0x5c1c8 0x5c1c8 RWE 0x4
> > > > NOTE 0x068e60 0x00000000 0x00000000 0x0002c 0x00000 R 0x4
> > >
> > NOTE 0x068e60 0x00000000 0x00000000 0x0002c 0x00000 R 0x4
> > this line look somehow wrong. NOTE will be loaded at the address 0?
> > and will occupy no memory? that is the same as don't having NOTE at
> > all right?
>
> NOTE is interpreted by the loader (firmware), but not actually loaded
> into memory. This is a binary structure that can be used to set some of
> the environment variables you mention above.
>
> The NOTE segment (segment, not section) is created by
> util/elf/grub-mkimage.c . You can see that load-base is set to 0x4000 in
> that code. Since your text starts at 0x10000, that means your binary can
> be at most 0xc000 bytes (48KB) large before it overlaps the text area.
> That isn't necessarily a problem; firmware is probably using memmove()
> (which handles overlapping areas) to load the segments into place.
>
> It's probably worth trying a different load-base to see if that could be
> the problem here.
>
--
Best Regards,
Manoel Abranches <mrabran@linux.vnet.ibm.com>
IBM Linux Technology Center Brasil
^ permalink raw reply [flat|nested] 28+ messages in thread
* Re: PPC64
2008-10-24 12:10 ` PPC64 Manoel
@ 2008-10-24 14:51 ` Hollis Blanchard
0 siblings, 0 replies; 28+ messages in thread
From: Hollis Blanchard @ 2008-10-24 14:51 UTC (permalink / raw)
To: Manoel; +Cc: The development of GRUB 2, Carlos Roberto do Nascimento Costa
Traditionally, firmware has refused to load an ELF file without a NOTE
segment. I feel like I heard that actually changed recently (maybe in
the p5 timeframe), but I never investigated further. You could easily
test by running grub-mkimage without the -n switch.
--
Hollis Blanchard
IBM Linux Technology Center
On Fri, 2008-10-24 at 10:10 -0200, Manoel wrote:
> I changed the load-base to 0x200000 in the note segment that mkelfimage
> creates. After that grub2 found the modules info header in the correct
> position (as stated in the program header) and was able to load all
> modules correctly.
> Maybe the Open Firmware detected the overlapping and tried to load the
> segment in another place, and for some reason the data write was
> corrupted.
> Sounds like a OF's bug and I'll report it as you suggested. To me the
> correct behavior would be load things in place and correctly even with
> overlapping memory.
>
> And about the note section, what is the point in create it with
> hardcoded variables? I don't see a reason to have this note segment
> unless the user want to use different variables values than the
> configured in OF.
>
>
> Thanks for the help so far, it was very useful.
> On Thu, 2008-10-23 at 14:08 -0500, Hollis Blanchard wrote:
> > On Thu, 2008-10-23 at 16:00 -0200, Manoel wrote:
> > >
> > > I talked with some folks at #pppc64 on freenode an they suggest that
> > > the
> > > OF is loading things in the wrong place could a problem with my
> > > load-base:
> > >
> > > real-base c00000 c00000
> > > virt-base ffffffff ffffffff
> > > real-size 1000000 1000000
> > > virt-size ffffffff ffffffff
> > > load-base 4000 4000
> > >
> > > they suggested to change load-base from 4000 to 200000 but I hava yet
> > > to try it. They also said that the note section can override
> > > load-base (and maybe we have some problem there?)
> >
> > It's possible. See below.
> >
> > > I'm now reading PARP documentation to learn more about OF behavior. I
> > > thought these machine were CHRP but they are actually PARP (is that
> > > right?). Son only today I was able to get the correct documentation.
> >
> > PAPR was based on the older CHRP specification.
> >
> > > > Look at the segment list again:
> > > > > Program Headers:
> > > > > Type Offset VirtAddr PhysAddr FileSiz MemSiz Flg Align
> > > > > LOAD 0x0000b4 0x00010000 0x00010000 0x0cbe4 0x14098 RWE 0x10
> > > > > GNU_STACK 0x00cc98 0x00000000 0x00000000 0x00000 0x00000 RWE 0x4
> > > > > LOAD 0x00cc98 0x0002d000 0x0002d000 0x5c1c8 0x5c1c8 RWE 0x4
> > > > > NOTE 0x068e60 0x00000000 0x00000000 0x0002c 0x00000 R 0x4
> > > >
> > > NOTE 0x068e60 0x00000000 0x00000000 0x0002c 0x00000 R 0x4
> > > this line look somehow wrong. NOTE will be loaded at the address 0?
> > > and will occupy no memory? that is the same as don't having NOTE at
> > > all right?
> >
> > NOTE is interpreted by the loader (firmware), but not actually loaded
> > into memory. This is a binary structure that can be used to set some of
> > the environment variables you mention above.
> >
> > The NOTE segment (segment, not section) is created by
> > util/elf/grub-mkimage.c . You can see that load-base is set to 0x4000 in
> > that code. Since your text starts at 0x10000, that means your binary can
> > be at most 0xc000 bytes (48KB) large before it overlaps the text area.
> > That isn't necessarily a problem; firmware is probably using memmove()
> > (which handles overlapping areas) to load the segments into place.
> >
> > It's probably worth trying a different load-base to see if that could be
> > the problem here.
> >
^ permalink raw reply [flat|nested] 28+ messages in thread
* Re: PPC64
2008-10-23 19:08 ` PPC64 Hollis Blanchard
2008-10-24 12:10 ` PPC64 Manoel
@ 2008-10-24 21:53 ` Manoel
2008-10-27 17:19 ` PPC64 Pavel Roskin
1 sibling, 1 reply; 28+ messages in thread
From: Manoel @ 2008-10-24 21:53 UTC (permalink / raw)
To: Hollis Blanchard
Cc: The development of GRUB 2, Carlos Roberto do Nascimento Costa
Changing the load-base worked in the P5 machine but when I tested in the
P6 machine I got the following message:
Relocation overflow
In function grub_arch_dl_relocate_symbols.
It means that I'm lacking memory?
On Thu, 2008-10-23 at 14:08 -0500, Hollis Blanchard wrote:
> On Thu, 2008-10-23 at 16:00 -0200, Manoel wrote:
> >
> > I talked with some folks at #pppc64 on freenode an they suggest that
> > the
> > OF is loading things in the wrong place could a problem with my
> > load-base:
> >
> > real-base c00000 c00000
> > virt-base ffffffff ffffffff
> > real-size 1000000 1000000
> > virt-size ffffffff ffffffff
> > load-base 4000 4000
> >
> > they suggested to change load-base from 4000 to 200000 but I hava yet
> > to try it. They also said that the note section can override
> > load-base (and maybe we have some problem there?)
>
> It's possible. See below.
>
> > I'm now reading PARP documentation to learn more about OF behavior. I
> > thought these machine were CHRP but they are actually PARP (is that
> > right?). Son only today I was able to get the correct documentation.
>
> PAPR was based on the older CHRP specification.
>
> > > Look at the segment list again:
> > > > Program Headers:
> > > > Type Offset VirtAddr PhysAddr FileSiz MemSiz Flg Align
> > > > LOAD 0x0000b4 0x00010000 0x00010000 0x0cbe4 0x14098 RWE 0x10
> > > > GNU_STACK 0x00cc98 0x00000000 0x00000000 0x00000 0x00000 RWE 0x4
> > > > LOAD 0x00cc98 0x0002d000 0x0002d000 0x5c1c8 0x5c1c8 RWE 0x4
> > > > NOTE 0x068e60 0x00000000 0x00000000 0x0002c 0x00000 R 0x4
> > >
> > NOTE 0x068e60 0x00000000 0x00000000 0x0002c 0x00000 R 0x4
> > this line look somehow wrong. NOTE will be loaded at the address 0?
> > and will occupy no memory? that is the same as don't having NOTE at
> > all right?
>
> NOTE is interpreted by the loader (firmware), but not actually loaded
> into memory. This is a binary structure that can be used to set some of
> the environment variables you mention above.
>
> The NOTE segment (segment, not section) is created by
> util/elf/grub-mkimage.c . You can see that load-base is set to 0x4000 in
> that code. Since your text starts at 0x10000, that means your binary can
> be at most 0xc000 bytes (48KB) large before it overlaps the text area.
> That isn't necessarily a problem; firmware is probably using memmove()
> (which handles overlapping areas) to load the segments into place.
>
> It's probably worth trying a different load-base to see if that could be
> the problem here.
>
--
Best Regards,
Manoel Abranches <mrabran@linux.vnet.ibm.com>
IBM Linux Technology Center Brazil
^ permalink raw reply [flat|nested] 28+ messages in thread
* Re: PPC64
2008-10-24 21:53 ` PPC64 Manoel
@ 2008-10-27 17:19 ` Pavel Roskin
2008-11-04 16:05 ` PPC64 Manoel
0 siblings, 1 reply; 28+ messages in thread
From: Pavel Roskin @ 2008-10-27 17:19 UTC (permalink / raw)
To: The development of GRUB 2
Cc: Carlos Roberto do Nascimento Costa, Hollis Blanchard
On Fri, 2008-10-24 at 19:53 -0200, Manoel wrote:
> Changing the load-base worked in the P5 machine but when I tested in the
> P6 machine I got the following message:
> Relocation overflow
> In function grub_arch_dl_relocate_symbols.
> It means that I'm lacking memory?
No. Look at the code. For R_PPC_REL24, delta is shifted by 6 bits left
and right and should stay the same. It's a 32-bit signed integer. The
overflow would happen for positive numbers that exceed (0x7fffffff>>6)
or 0x01ffffff. A similar limit exists for negative numbers. I suggest
that you add some print statements to find out what's happening.
--
Regards,
Pavel Roskin
^ permalink raw reply [flat|nested] 28+ messages in thread
* Re: PPC64
2008-10-27 17:19 ` PPC64 Pavel Roskin
@ 2008-11-04 16:05 ` Manoel
2008-11-04 16:12 ` PPC64 Hollis Blanchard
0 siblings, 1 reply; 28+ messages in thread
From: Manoel @ 2008-11-04 16:05 UTC (permalink / raw)
To: The development of GRUB 2
Cc: Carlos Roberto do Nascimento Costa, Hollis Blanchard
I was able to solve this thanks to Hollis and Segher.
What was need was a flag to gcc ( -mlong-call) so that gcc puts indirect
branches instead of direct branches when needed to prevent the 32mb
limitation (as stated at gcc manpages).
My doubt is where is the best place to put this flag so that it will be
passed to all gcc calls by default?
On Mon, 2008-10-27 at 13:19 -0400, Pavel Roskin wrote:
> On Fri, 2008-10-24 at 19:53 -0200, Manoel wrote:
> > Changing the load-base worked in the P5 machine but when I tested in the
> > P6 machine I got the following message:
> > Relocation overflow
> > In function grub_arch_dl_relocate_symbols.
> > It means that I'm lacking memory?
>
> No. Look at the code. For R_PPC_REL24, delta is shifted by 6 bits left
> and right and should stay the same. It's a 32-bit signed integer. The
> overflow would happen for positive numbers that exceed (0x7fffffff>>6)
> or 0x01ffffff. A similar limit exists for negative numbers. I suggest
> that you add some print statements to find out what's happening.
>
^ permalink raw reply [flat|nested] 28+ messages in thread
* Re: PPC64
2008-11-04 16:05 ` PPC64 Manoel
@ 2008-11-04 16:12 ` Hollis Blanchard
2008-11-04 18:18 ` PPC64 mlongcall gcc flag Manoel
0 siblings, 1 reply; 28+ messages in thread
From: Hollis Blanchard @ 2008-11-04 16:12 UTC (permalink / raw)
To: Manoel; +Cc: The development of GRUB 2, Carlos Roberto do Nascimento Costa
On Tue, 2008-11-04 at 14:05 -0200, Manoel wrote:
> I was able to solve this thanks to Hollis and Segher.
>
> What was need was a flag to gcc ( -mlong-call) so that gcc puts indirect
> branches instead of direct branches when needed to prevent the 32mb
> limitation (as stated at gcc manpages).
>
> My doubt is where is the best place to put this flag so that it will be
> passed to all gcc calls by default?
You don't want it on all gcc calls; you only want it when building the
modules.
--
Hollis Blanchard
IBM Linux Technology Center
^ permalink raw reply [flat|nested] 28+ messages in thread
* PPC64 mlongcall gcc flag
2008-11-04 16:12 ` PPC64 Hollis Blanchard
@ 2008-11-04 18:18 ` Manoel
2008-11-04 18:21 ` Manoel
` (2 more replies)
0 siblings, 3 replies; 28+ messages in thread
From: Manoel @ 2008-11-04 18:18 UTC (permalink / raw)
To: The development of GRUB 2
Cc: Carlos Roberto do Nascimento Costa, Hollis Blanchard
I did this patch to add a gcc flag to the modules compilation. Is that
the correct place to put this flag?
Also I would like to know what the command "cursor-on" and "cursor-off"
do in OLPC firmware (they dont exist in PowerPC firmware).
How can I attain the same funcionality in PowerPC machine? Or is it
unnecessary in PowerPC firmware?
--
Best Regards,
Manoel Abranches <mrabran@linux.vnet.ibm.com>
IBM Linux Technology Center Brazil
^ permalink raw reply [flat|nested] 28+ messages in thread* Re: PPC64 mlongcall gcc flag
2008-11-04 18:18 ` PPC64 mlongcall gcc flag Manoel
@ 2008-11-04 18:21 ` Manoel
2008-11-04 19:16 ` Robert Millan
2008-11-04 23:48 ` Pavel Roskin
2 siblings, 0 replies; 28+ messages in thread
From: Manoel @ 2008-11-04 18:21 UTC (permalink / raw)
To: The development of GRUB 2
Cc: Carlos Roberto do Nascimento Costa, Hollis Blanchard
[-- Attachment #1: Type: text/plain, Size: 438 bytes --]
sorry, forgot the patch.
On Tue, 2008-11-04 at 16:18 -0200, Manoel wrote:
> I did this patch to add a gcc flag to the modules compilation. Is that
> the correct place to put this flag?
>
> Also I would like to know what the command "cursor-on" and "cursor-off"
> do in OLPC firmware (they dont exist in PowerPC firmware).
> How can I attain the same functionality in PowerPC machine? Or is it
> unnecessary in PowerPC firmware?
>
>
[-- Attachment #2: flag.patch --]
[-- Type: text/x-patch, Size: 548 bytes --]
Index: Makefile.in
===================================================================
--- Makefile.in (revision 1893)
+++ Makefile.in (working copy)
@@ -65,7 +65,7 @@
CPPFLAGS = @CPPFLAGS@ -I$(builddir) -I$(builddir)/include -I$(srcdir)/include -Wall -W \
-DGRUB_LIBDIR=\"$(pkglibdir)\"
TARGET_CC = @TARGET_CC@
-TARGET_CFLAGS = @TARGET_CFLAGS@
+TARGET_CFLAGS = @TARGET_CFLAGS@ -mlongcall
TARGET_CPPFLAGS = @TARGET_CPPFLAGS@ -I$(builddir) -I$(builddir)/include -I$(srcdir)/include \
-Wall -W
TARGET_LDFLAGS = @TARGET_LDFLAGS@
static void
^ permalink raw reply [flat|nested] 28+ messages in thread
* Re: PPC64 mlongcall gcc flag
2008-11-04 18:18 ` PPC64 mlongcall gcc flag Manoel
2008-11-04 18:21 ` Manoel
@ 2008-11-04 19:16 ` Robert Millan
2008-11-04 23:48 ` Pavel Roskin
2 siblings, 0 replies; 28+ messages in thread
From: Robert Millan @ 2008-11-04 19:16 UTC (permalink / raw)
To: The development of GRUB 2
Cc: Carlos Roberto do Nascimento Costa, Hollis Blanchard
On Tue, Nov 04, 2008 at 04:18:05PM -0200, Manoel wrote:
> I did this patch to add a gcc flag to the modules compilation. Is that
> the correct place to put this flag?
>
> Also I would like to know what the command "cursor-on" and "cursor-off"
> do in OLPC firmware (they dont exist in PowerPC firmware).
> How can I attain the same funcionality in PowerPC machine? Or is it
> unnecessary in PowerPC firmware?
They enable and disable display cursor, respectively. If you find how your
particular flavour of OFW does this, you could add a bit of code to
grub_ofconsole_setcursor() and have that work there too.
--
Robert Millan
The DRM opt-in fallacy: "Your data belongs to us. We will decide when (and
how) you may access your data; but nobody's threatening your freedom: we
still allow you to remove your data and not access it at all."
^ permalink raw reply [flat|nested] 28+ messages in thread
* Re: PPC64 mlongcall gcc flag
2008-11-04 18:18 ` PPC64 mlongcall gcc flag Manoel
2008-11-04 18:21 ` Manoel
2008-11-04 19:16 ` Robert Millan
@ 2008-11-04 23:48 ` Pavel Roskin
2008-11-05 9:43 ` Robert Millan
2008-11-05 17:25 ` Hollis Blanchard
2 siblings, 2 replies; 28+ messages in thread
From: Pavel Roskin @ 2008-11-04 23:48 UTC (permalink / raw)
To: The development of GRUB 2, Manoel
Cc: Carlos Roberto do Nascimento Costa, Hollis Blanchard
On Tue, 2008-11-04 at 16:18 -0200, Manoel wrote:
> I did this patch to add a gcc flag to the modules compilation. Is that
> the correct place to put this flag?
It's a wrong place. It breaks compilation of i386:
cc1: error: unrecognized command line option "-mlongcall"
This option should added in configure for PowerPC targets only. There
is already code for adding flags to TARGET_CFLAGS for i386, so that
would be the natural place to do it for PowerPC as well:
Index: configure.ac
===================================================================
--- configure.ac (revision 1893)
+++ configure.ac (working copy)
@@ -291,6 +291,11 @@
TARGET_CFLAGS="$TARGET_CFLAGS -malign-jumps=1 -malign-loops=1 -malign-functions=1"
fi
fi
+
+ # Force long calls on PowerPC.
+ if test "x$target_cpu" = xpowerpc; then
+ TARGET_CFLAGS="$TARGET_CFLAGS -mlongcall"
+ fi
fi
if test "x$target_m32" = x1; then
Don't forget to run autogen.sh to regenerate configure from configure.ac
if you want to test it.
However, it would be nice to have a better explanation why "-mlongcall"
is needed. If it's only needed for modules and has significant
overhead, we may want to introduce MODULE_CFLAGS, which would only be
used for modules.
By the way, I tried cross-compiling for PowerPC with and without
"-mlongcall" with gcc 4.2.4. With "-mlongcall", the size of all modules
combined is 426424 bytes. Without "-mlongcall", the size of all modules
combined is 354464 bytes. That's a significant difference for a
bootloader and should be avoided if possible.
Maybe there is a way to keep the modules and the core in the first 32
megabytes?
--
Regards,
Pavel Roskin
^ permalink raw reply [flat|nested] 28+ messages in thread* Re: PPC64 mlongcall gcc flag
2008-11-04 23:48 ` Pavel Roskin
@ 2008-11-05 9:43 ` Robert Millan
2008-11-05 15:35 ` Pavel Roskin
2008-11-05 17:25 ` Hollis Blanchard
1 sibling, 1 reply; 28+ messages in thread
From: Robert Millan @ 2008-11-05 9:43 UTC (permalink / raw)
To: The development of GRUB 2
Cc: Manoel, Carlos Roberto do Nascimento Costa, Hollis Blanchard
On Tue, Nov 04, 2008 at 06:48:26PM -0500, Pavel Roskin wrote:
> Index: configure.ac
> ===================================================================
> --- configure.ac (revision 1893)
> +++ configure.ac (working copy)
> @@ -291,6 +291,11 @@
> TARGET_CFLAGS="$TARGET_CFLAGS -malign-jumps=1 -malign-loops=1 -malign-functions=1"
> fi
> fi
> +
> + # Force long calls on PowerPC.
> + if test "x$target_cpu" = xpowerpc; then
> + TARGET_CFLAGS="$TARGET_CFLAGS -mlongcall"
> + fi
> fi
IIRC we had a case/esac stanza for $target_cpu already. Shouldn't this be added
there instead?
--
Robert Millan
The DRM opt-in fallacy: "Your data belongs to us. We will decide when (and
how) you may access your data; but nobody's threatening your freedom: we
still allow you to remove your data and not access it at all."
^ permalink raw reply [flat|nested] 28+ messages in thread
* Re: PPC64 mlongcall gcc flag
2008-11-05 9:43 ` Robert Millan
@ 2008-11-05 15:35 ` Pavel Roskin
0 siblings, 0 replies; 28+ messages in thread
From: Pavel Roskin @ 2008-11-05 15:35 UTC (permalink / raw)
To: The development of GRUB 2
Cc: Manoel, Carlos Roberto do Nascimento Costa, Hollis Blanchard
On Wed, 2008-11-05 at 10:43 +0100, Robert Millan wrote:
> On Tue, Nov 04, 2008 at 06:48:26PM -0500, Pavel Roskin wrote:
> > Index: configure.ac
> > ===================================================================
> > --- configure.ac (revision 1893)
> > +++ configure.ac (working copy)
> > @@ -291,6 +291,11 @@
> > TARGET_CFLAGS="$TARGET_CFLAGS -malign-jumps=1 -malign-loops=1 -malign-functions=1"
> > fi
> > fi
> > +
> > + # Force long calls on PowerPC.
> > + if test "x$target_cpu" = xpowerpc; then
> > + TARGET_CFLAGS="$TARGET_CFLAGS -mlongcall"
> > + fi
> > fi
>
> IIRC we had a case/esac stanza for $target_cpu already. Shouldn't this be added
> there instead?
I would prefer that we handle similar flags in the same place. It's
more reliable (especially in context of further changes) than grouping
changes in different flags by conditions.
The real question is of course how to avoid or limit -mlongcall, as it
makes the modules bigger. We should not need more that 32 Mb for code.
--
Regards,
Pavel Roskin
^ permalink raw reply [flat|nested] 28+ messages in thread
* Re: PPC64 mlongcall gcc flag
2008-11-04 23:48 ` Pavel Roskin
2008-11-05 9:43 ` Robert Millan
@ 2008-11-05 17:25 ` Hollis Blanchard
2008-11-05 19:27 ` Manoel
2008-11-06 15:12 ` Robert Millan
1 sibling, 2 replies; 28+ messages in thread
From: Hollis Blanchard @ 2008-11-05 17:25 UTC (permalink / raw)
To: Pavel Roskin
Cc: The development of GRUB 2, Carlos Roberto do Nascimento Costa,
Manoel
On Tue, 2008-11-04 at 18:48 -0500, Pavel Roskin wrote:
>
> However, it would be nice to have a better explanation why "-mlongcall"
> is needed. If it's only needed for modules and has significant
> overhead, we may want to introduce MODULE_CFLAGS, which would only be
> used for modules.
It absolutely should only be used for modules.
It's needed because a PowerPC branch instruction can only target +/-
32MB. -mlongcall replaces the direct branch with an indirect one (using
mtctr/bctrl instructions). This can target the full 32-bit address
space.
> By the way, I tried cross-compiling for PowerPC with and without
> "-mlongcall" with gcc 4.2.4. With "-mlongcall", the size of all modules
> combined is 426424 bytes. Without "-mlongcall", the size of all modules
> combined is 354464 bytes. That's a significant difference for a
> bootloader and should be avoided if possible.
To be fair, if we are that worried about footprint, why do we have a
runtime ELF linker in a bootloader?
At any rate, the point of having dynamically loadable modules is so you
can only load the ones you need. On that scale I think the size increase
is less of an issue.
> Maybe there is a way to keep the modules and the core in the first 32
> megabytes?
Actually I'm confused about something here Manoel.
Module memory is allocated by grub_malloc(), but as you can see at
http://svn.savannah.gnu.org/viewvc/trunk/grub2/kern/ieee1275/init.c?revision=1806&root=grub&view=markup the GRUB heap capped at 4MB (I don't mean size, I mean the end of the heap). So how are your modules appearing in memory above 32MB?
--
Hollis Blanchard
IBM Linux Technology Center
^ permalink raw reply [flat|nested] 28+ messages in thread
* Re: PPC64 mlongcall gcc flag
2008-11-05 17:25 ` Hollis Blanchard
@ 2008-11-05 19:27 ` Manoel
2008-11-06 15:12 ` Robert Millan
1 sibling, 0 replies; 28+ messages in thread
From: Manoel @ 2008-11-05 19:27 UTC (permalink / raw)
To: Hollis Blanchard
Cc: The development of GRUB 2, Pavel Roskin,
Carlos Roberto do Nascimento Costa
[-- Attachment #1: Type: text/plain, Size: 2900 bytes --]
On Wed, 2008-11-05 at 11:25 -0600, Hollis Blanchard wrote:
> On Tue, 2008-11-04 at 18:48 -0500, Pavel Roskin wrote:
> >
> > However, it would be nice to have a better explanation why "-mlongcall"
> > is needed. If it's only needed for modules and has significant
> > overhead, we may want to introduce MODULE_CFLAGS, which would only be
> > used for modules.
>
> It absolutely should only be used for modules.
>
> It's needed because a PowerPC branch instruction can only target +/-
> 32MB. -mlongcall replaces the direct branch with an indirect one (using
> mtctr/bctrl instructions). This can target the full 32-bit address
> space.
>
> > By the way, I tried cross-compiling for PowerPC with and without
> > "-mlongcall" with gcc 4.2.4. With "-mlongcall", the size of all modules
> > combined is 426424 bytes. Without "-mlongcall", the size of all modules
> > combined is 354464 bytes. That's a significant difference for a
> > bootloader and should be avoided if possible.
>
> To be fair, if we are that worried about footprint, why do we have a
> runtime ELF linker in a bootloader?
>
> At any rate, the point of having dynamically loadable modules is so you
> can only load the ones you need. On that scale I think the size increase
> is less of an issue.
>
> > Maybe there is a way to keep the modules and the core in the first 32
> > megabytes?
>
> Actually I'm confused about something here Manoel.
>
> Module memory is allocated by grub_malloc(), but as you can see at
> ihttp://svn.savannah.gnu.org/viewvc/trunk/grub2/kern/ieee1275/init.c?revision=1806&root=grub&view=markup the GRUB heap capped at 4MB (I don't mean size, I mean the end of the heap). So how are your modules appearing in memory above 32MB?
>
I'm not sure why ( I didnt look at that part of the source code yet).
If I understand correctly the heap should only use address in the range
0x - 0x400000 (0 - 4mb).
The total modules size until the moment of failure (reallocation
overflow) is around 120 kb , then it shouldn't be a lack of memory
problem.
In the attachment we can see that the modules are relocated in a
decreasing order of address.
the firsts modules are relocated in the address range 0x2a990->0x262f0
(in small steps). Then relocated to the address range 0x8ab0->0x4830
(small steps again).
Note that grub jumps from the address 0x262f0 to 0x8ab0., probably
because grub itself is using this address space(grub is linked at
0x10000).
until there all is ok.
but then it tries to relocate to the address 0x208f6b0 and the
"relocation overflow" problem happens.
In the P5 machine the behavior is very similar but the address 0x1c6f6b0
is used and all goes fine.
could it be a bug in the grub memory manager?
Attached is the debug information of the modules relocation in both P5
and P6.
--
Best Regards,
Manoel Abranches <mrabran@linux.vnet.ibm.com>
IBM Linux Technology Center Brazil
[-- Attachment #2: grub_loading_modules_P5 --]
[-- Type: text/plain, Size: 5920 bytes --]
../kern/dl.c:527: module at 0x2c018, size 0xa84
../kern/dl.c:556: relocating to 0x2a990
../kern/dl.c:513: flushing 0x14 bytes at 0x2a450
../kern/dl.c:513: flushing 0x58 bytes at 0x2a4a0
../kern/dl.c:513: flushing 0x410 bytes at 0x2a530
../kern/dl.c:570: module name: acorn
../kern/dl.c:571: init function: 0x2a910
../kern/dl.c:527: module at 0x2caa8, size 0xe28
../kern/dl.c:556: relocating to 0x2a340
../kern/dl.c:513: flushing 0x88 bytes at 0x29b70
../kern/dl.c:513: flushing 0x6b8 bytes at 0x29c30
../kern/dl.c:570: module name: fshelp
../kern/dl.c:571: init function: 0x0
../kern/dl.c:527: module at 0x2d8dc, size 0x1758
../kern/dl.c:556: relocating to 0x299f0
../kern/dl.c:513: flushing 0x4 bytes at 0x28d60
../kern/dl.c:513: flushing 0x20 bytes at 0x28da0
../kern/dl.c:513: flushing 0x7c bytes at 0x28df0
../kern/dl.c:513: flushing 0xad8 bytes at 0x28ea0
../kern/dl.c:570: module name: affs
../kern/dl.c:571: init function: 0x29934
../kern/dl.c:527: module at 0x2f040, size 0x2374
../kern/dl.c:556: relocating to 0x28c70
../kern/dl.c:513: flushing 0x4 bytes at 0x27100
../kern/dl.c:513: flushing 0x20 bytes at 0x27140
../kern/dl.c:513: flushing 0x1c bytes at 0x27190
../kern/dl.c:513: flushing 0x1a20 bytes at 0x271e0
../kern/dl.c:570: module name: afs
../kern/dl.c:571: init function: 0x28bbc
../kern/dl.c:527: module at 0x313c0, size 0xb4c
../kern/dl.c:556: relocating to 0x27010
../kern/dl.c:513: flushing 0x4 bytes at 0x26af0
../kern/dl.c:513: flushing 0x14 bytes at 0x26b30
../kern/dl.c:513: flushing 0x54 bytes at 0x26b80
../kern/dl.c:513: flushing 0x3a4 bytes at 0x26c10
../kern/dl.c:570: module name: amiga
../kern/dl.c:571: init function: 0x26f70
../kern/dl.c:527: module at 0x31f18, size 0xcd0
../kern/dl.c:556: relocating to 0x269e0
../kern/dl.c:513: flushing 0x4 bytes at 0x26400
../kern/dl.c:513: flushing 0x14 bytes at 0x26440
../kern/dl.c:513: flushing 0xfc bytes at 0x26490
../kern/dl.c:513: flushing 0x3d0 bytes at 0x265c0
../kern/dl.c:570: module name: apple
../kern/dl.c:571: init function: 0x2694c
../kern/dl.c:527: module at 0x32bf4, size 0xe6d8
../kern/dl.c:556: relocating to 0x262f0
../kern/dl.c:513: flushing 0x69c bytes at 0x24970
../kern/dl.c:513: flushing 0x42 bytes at 0x25040
../kern/dl.c:513: flushing 0x4 bytes at 0x250c0
../kern/dl.c:513: flushing 0xc90 bytes at 0x25100
../kern/dl.c:513: flushing 0x4b8 bytes at 0x25dc0
../kern/dl.c:513: flushing 0x7358 bytes at 0x8c90
../kern/dl.c:570: module name: normal
../kern/dl.c:571: init function: 0xc180
../kern/dl.c:527: module at 0x412d8, size 0xa48
../kern/dl.c:556: relocating to 0x8ab0
../kern/dl.c:513: flushing 0x90 bytes at 0x8630
../kern/dl.c:513: flushing 0x34c bytes at 0x86f0
../kern/dl.c:570: module name: blocklist
../kern/dl.c:571: init function: 0x871c
../kern/dl.c:527: module at 0x41d2c, size 0x5a8
../kern/dl.c:556: relocating to 0x84b0
../kern/dl.c:513: flushing 0x38 bytes at 0x8310
../kern/dl.c:513: flushing 0xbc bytes at 0x8380
../kern/dl.c:570: module name: boot
../kern/dl.c:571: init function: 0x83ac
../kern/dl.c:527: module at 0x422e0, size 0x9d4
../kern/dl.c:556: relocating to 0x81b0
../kern/dl.c:513: flushing 0x20 bytes at 0x7c40
../kern/dl.c:513: flushing 0x8 bytes at 0x7c90
../kern/dl.c:513: flushing 0x488 bytes at 0x7cd0
../kern/dl.c:570: module name: bufio
../kern/dl.c:571: init function: 0x0
../kern/dl.c:527: module at 0x42cc0, size 0x2328
../kern/dl.c:556: relocating to 0x7b40
../kern/dl.c:513: flushing 0x114 bytes at 0x6090
../kern/dl.c:513: flushing 0xe0 bytes at 0x61e0
../kern/dl.c:513: flushing 0x70 bytes at 0x62f0
../kern/dl.c:513: flushing 0x1758 bytes at 0x6390
../kern/dl.c:570: module name: gzio
../kern/dl.c:571: init function: 0x0
../kern/dl.c:527: module at 0x44ff4, size 0x89c
../kern/dl.c:556: relocating to 0x5f90
../kern/dl.c:513: flushing 0x4c bytes at 0x5cd0
../kern/dl.c:513: flushing 0x1b0 bytes at 0x5d50
../kern/dl.c:570: module name: cat
../kern/dl.c:571: init function: 0x5d7c
../kern/dl.c:527: module at 0x4589c, size 0x9d8
../kern/dl.c:556: relocating to 0x5b70
../kern/dl.c:513: flushing 0xd0 bytes at 0x5760
../kern/dl.c:513: flushing 0x27c bytes at 0x5860
../kern/dl.c:570: module name: cmp
../kern/dl.c:571: init function: 0x588c
../kern/dl.c:527: module at 0x46280, size 0x8c8
../kern/dl.c:556: relocating to 0x5600
../kern/dl.c:513: flushing 0xa0 bytes at 0x5320
../kern/dl.c:513: flushing 0x1a0 bytes at 0x53f0
../kern/dl.c:570: module name: configfile
../kern/dl.c:571: init function: 0x5434
../kern/dl.c:527: module at 0x46b54, size 0xffc
../kern/dl.c:556: relocating to 0x5100
../kern/dl.c:513: flushing 0x4 bytes at 0x4920
../kern/dl.c:513: flushing 0x20 bytes at 0x4960
../kern/dl.c:513: flushing 0x70 bytes at 0x49b0
../kern/dl.c:513: flushing 0x660 bytes at 0x4a50
../kern/dl.c:570: module name: cpio
../kern/dl.c:571: init function: 0x506c
../kern/dl.c:527: module at 0x47b5c, size 0x8b4
../kern/dl.c:556: relocating to 0x4830
../kern/dl.c:513: flushing 0x400 bytes at 0x4030
../kern/dl.c:513: flushing 0x54 bytes at 0x4480
../kern/dl.c:513: flushing 0x2a8 bytes at 0x4510
../kern/dl.c:570: module name: crc
../kern/dl.c:571: init function: 0x453c
../kern/dl.c:527: module at 0x4841c, size 0x1eb8
../kern/dl.c:556: relocating to 0x1c6f6b0
../kern/dl.c:513: flushing 0x8 bytes at 0x1c6e4f0
../kern/dl.c:513: flushing 0x8 bytes at 0x1c6e530
../kern/dl.c:513: flushing 0x20 bytes at 0x1c6e570
../kern/dl.c:513: flushing 0x148 bytes at 0x1c6e5c0
../kern/dl.c:513: flushing 0x58 bytes at 0x1c6e740
../kern/dl.c:513: flushing 0xe88 bytes at 0x1c6e7d0
../kern/dl.c:570: module name: raid
../kern/dl.c:571: init function: 0x1c6f278
../kern/dl.c:527: module at 0x4a2e0, size 0x85c
../kern/dl.c:556: relocating to 0x1c6e240
../kern/dl.c:513: flushing 0xc bytes at 0x1c6dee0
../kern/dl.c:513: flushing 0x64 bytes at 0x1c6df20
../kern/dl.c:513: flushing 0x208 bytes at 0x1c6dfc0
../kern/dl.c:570: module name: dm_nv
../kern/dl.c:571: init function: 0x1c6dfec
[-- Attachment #3: grub_loading_modules_P6 --]
[-- Type: text/plain, Size: 5263 bytes --]
../kern/dl.c:527: module at 0x2c018, size 0xa84
../kern/dl.c:556: relocating to 0x2a990
../kern/dl.c:513: flushing 0x14 bytes at 0x2a450
../kern/dl.c:513: flushing 0x58 bytes at 0x2a4a0
../kern/dl.c:513: flushing 0x410 bytes at 0x2a530
../kern/dl.c:570: module name: acorn
../kern/dl.c:571: init function: 0x2a910
../kern/dl.c:527: module at 0x2caa8, size 0xe28
../kern/dl.c:556: relocating to 0x2a340
../kern/dl.c:513: flushing 0x88 bytes at 0x29b70
../kern/dl.c:513: flushing 0x6b8 bytes at 0x29c30
../kern/dl.c:570: module name: fshelp
../kern/dl.c:571: init function: 0x0
../kern/dl.c:527: module at 0x2d8dc, size 0x1758
../kern/dl.c:556: relocating to 0x299f0
../kern/dl.c:513: flushing 0x4 bytes at 0x28d60
../kern/dl.c:513: flushing 0x20 bytes at 0x28da0
../kern/dl.c:513: flushing 0x7c bytes at 0x28df0
../kern/dl.c:513: flushing 0xad8 bytes at 0x28ea0
../kern/dl.c:570: module name: affs
../kern/dl.c:571: init function: 0x29934
../kern/dl.c:527: module at 0x2f040, size 0x2374
../kern/dl.c:556: relocating to 0x28c70
../kern/dl.c:513: flushing 0x4 bytes at 0x27100
../kern/dl.c:513: flushing 0x20 bytes at 0x27140
../kern/dl.c:513: flushing 0x1c bytes at 0x27190
../kern/dl.c:513: flushing 0x1a20 bytes at 0x271e0
../kern/dl.c:570: module name: afs
../kern/dl.c:571: init function: 0x28bbc
../kern/dl.c:527: module at 0x313c0, size 0xb4c
../kern/dl.c:556: relocating to 0x27010
../kern/dl.c:513: flushing 0x4 bytes at 0x26af0
../kern/dl.c:513: flushing 0x14 bytes at 0x26b30
../kern/dl.c:513: flushing 0x54 bytes at 0x26b80
../kern/dl.c:513: flushing 0x3a4 bytes at 0x26c10
../kern/dl.c:570: module name: amiga
../kern/dl.c:571: init function: 0x26f70
../kern/dl.c:527: module at 0x31f18, size 0xcd0
../kern/dl.c:556: relocating to 0x269e0
../kern/dl.c:513: flushing 0x4 bytes at 0x26400
../kern/dl.c:513: flushing 0x14 bytes at 0x26440
../kern/dl.c:513: flushing 0xfc bytes at 0x26490
../kern/dl.c:513: flushing 0x3d0 bytes at 0x265c0
../kern/dl.c:570: module name: apple
../kern/dl.c:571: init function: 0x2694c
../kern/dl.c:527: module at 0x32bf4, size 0xe6d8
../kern/dl.c:556: relocating to 0x262f0
../kern/dl.c:513: flushing 0x69c bytes at 0x24970
../kern/dl.c:513: flushing 0x42 bytes at 0x25040
../kern/dl.c:513: flushing 0x4 bytes at 0x250c0
../kern/dl.c:513: flushing 0xc90 bytes at 0x25100
../kern/dl.c:513: flushing 0x4b8 bytes at 0x25dc0
../kern/dl.c:513: flushing 0x7358 bytes at 0x8c90
../kern/dl.c:570: module name: normal
../kern/dl.c:571: init function: 0xc180
../kern/dl.c:527: module at 0x412d8, size 0xa48
../kern/dl.c:556: relocating to 0x8ab0
../kern/dl.c:513: flushing 0x90 bytes at 0x8630
../kern/dl.c:513: flushing 0x34c bytes at 0x86f0
../kern/dl.c:570: module name: blocklist
../kern/dl.c:571: init function: 0x871c
../kern/dl.c:527: module at 0x41d2c, size 0x5a8
../kern/dl.c:556: relocating to 0x84b0
../kern/dl.c:513: flushing 0x38 bytes at 0x8310
../kern/dl.c:513: flushing 0xbc bytes at 0x8380
../kern/dl.c:570: module name: boot
../kern/dl.c:571: init function: 0x83ac
../kern/dl.c:527: module at 0x422e0, size 0x9d4
../kern/dl.c:556: relocating to 0x81b0
../kern/dl.c:513: flushing 0x20 bytes at 0x7c40
../kern/dl.c:513: flushing 0x8 bytes at 0x7c90
../kern/dl.c:513: flushing 0x488 bytes at 0x7cd0
../kern/dl.c:570: module name: bufio
../kern/dl.c:571: init function: 0x0
../kern/dl.c:527: module at 0x42cc0, size 0x2328
../kern/dl.c:556: relocating to 0x7b40
../kern/dl.c:513: flushing 0x114 bytes at 0x6090
../kern/dl.c:513: flushing 0xe0 bytes at 0x61e0
../kern/dl.c:513: flushing 0x70 bytes at 0x62f0
../kern/dl.c:513: flushing 0x1758 bytes at 0x6390
../kern/dl.c:570: module name: gzio
../kern/dl.c:571: init function: 0x0
../kern/dl.c:527: module at 0x44ff4, size 0x89c
../kern/dl.c:556: relocating to 0x5f90
../kern/dl.c:513: flushing 0x4c bytes at 0x5cd0
../kern/dl.c:513: flushing 0x1b0 bytes at 0x5d50
../kern/dl.c:570: module name: cat
../kern/dl.c:571: init function: 0x5d7c
../kern/dl.c:527: module at 0x4589c, size 0x9d8
../kern/dl.c:556: relocating to 0x5b70
../kern/dl.c:513: flushing 0xd0 bytes at 0x5760
../kern/dl.c:513: flushing 0x27c bytes at 0x5860
../kern/dl.c:570: module name: cmp
../kern/dl.c:571: init function: 0x588c
../kern/dl.c:527: module at 0x46280, size 0x8c8
../kern/dl.c:556: relocating to 0x5600
../kern/dl.c:513: flushing 0xa0 bytes at 0x5320
../kern/dl.c:513: flushing 0x1a0 bytes at 0x53f0
../kern/dl.c:570: module name: configfile
../kern/dl.c:571: init function: 0x5434
../kern/dl.c:527: module at 0x46b54, size 0xffc
../kern/dl.c:556: relocating to 0x5100
../kern/dl.c:513: flushing 0x4 bytes at 0x4920
../kern/dl.c:513: flushing 0x20 bytes at 0x4960
../kern/dl.c:513: flushing 0x70 bytes at 0x49b0
../kern/dl.c:513: flushing 0x660 bytes at 0x4a50
../kern/dl.c:570: module name: cpio
../kern/dl.c:571: init function: 0x506c
../kern/dl.c:527: module at 0x47b5c, size 0x8b4
../kern/dl.c:556: relocating to 0x4830
../kern/dl.c:513: flushing 0x400 bytes at 0x4030
../kern/dl.c:513: flushing 0x54 bytes at 0x4480
../kern/dl.c:513: flushing 0x2a8 bytes at 0x4510
../kern/dl.c:570: module name: crc
../kern/dl.c:571: init function: 0x453c
../kern/dl.c:527: module at 0x4841c, size 0x1eb8
../kern/dl.c:556: relocating to 0x208f6b0
Relocation overflow
Aborted. Press any key to exit.
^ permalink raw reply [flat|nested] 28+ messages in thread
* Re: PPC64 mlongcall gcc flag
2008-11-05 17:25 ` Hollis Blanchard
2008-11-05 19:27 ` Manoel
@ 2008-11-06 15:12 ` Robert Millan
2008-11-06 17:42 ` Manoel
1 sibling, 1 reply; 28+ messages in thread
From: Robert Millan @ 2008-11-06 15:12 UTC (permalink / raw)
To: The development of GRUB 2
Cc: Manoel, Pavel Roskin, Carlos Roberto do Nascimento Costa
On Wed, Nov 05, 2008 at 11:25:15AM -0600, Hollis Blanchard wrote:
>
> Module memory is allocated by grub_malloc(), but as you can see at
> http://svn.savannah.gnu.org/viewvc/trunk/grub2/kern/ieee1275/init.c?revision=1806&root=grub&view=markup the GRUB heap capped at 4MB (I don't mean size, I mean the end of the heap).
It's not really capped at 4 MB. It will cap it only when an heuristic tells it
there's still enough room for heap:
/* Avoid claiming anything above HEAP_MAX_ADDR, if possible. */
if ((addr < HEAP_MAX_ADDR) && /* if it's too late, don't bother */
(addr + len > HEAP_MAX_ADDR) && /* if it wasn't available anyway, don't bother */
(total + (HEAP_MAX_ADDR - addr) > HEAP_MIN_SIZE)) /* only limit ourselves when we can afford to */
Argueably, this is not my best piece of code... today I'd have implemented a
payload relocator (like the one used by loader/i386/pc/multiboot.c) just so we
can happily use everything in /memory/available as heap.
And I'd even advice doing the same for powerpc (sharing code with i386 if
possible).
--
Robert Millan
The DRM opt-in fallacy: "Your data belongs to us. We will decide when (and
how) you may access your data; but nobody's threatening your freedom: we
still allow you to remove your data and not access it at all."
^ permalink raw reply [flat|nested] 28+ messages in thread* Re: PPC64 mlongcall gcc flag
2008-11-06 15:12 ` Robert Millan
@ 2008-11-06 17:42 ` Manoel
0 siblings, 0 replies; 28+ messages in thread
From: Manoel @ 2008-11-06 17:42 UTC (permalink / raw)
To: The development of GRUB 2
Cc: Hollis Blanchard, Pavel Roskin,
Carlos Roberto do Nascimento Costa, Segher Boessenkool
Humm..we should do something to prevent memory to be allocated above
32mb (actually things can be above 32mb...but they cant be at a large
offset since the PowerPC branch instruction works with offsets not
absolute address).
The thing is I was able to load the modules in P6 by changing the link
address to 0x200000.
Previously I had changed the load-base (from 0x4000 to 0x200000) address
since I was having trouble with memory overlapping and OF failed to put
the segments at the correct address. With it things worked in P5 but not
in P6 (with "relocated overflow"). That was resolved by passing
mlongcall flag to gcc (that changes a indirect branch to a direct
branch).
Now I changed back the load-base address to 0x4000 e put the grub link
address to 0x200000(same that yaboot use) and I was able to boot the P6
machine without using the mlongcall flag.
That must be a coincidence though, by changing the memory layout things
were allocated at a different place. The better solution would be to
guarantee things are allocated within the direct branch range.
On Thu, 2008-11-06 at 16:12 +0100, Robert Millan wrote:
> On Wed, Nov 05, 2008 at 11:25:15AM -0600, Hollis Blanchard wrote:
> >
> > Module memory is allocated by grub_malloc(), but as you can see at
> > http://svn.savannah.gnu.org/viewvc/trunk/grub2/kern/ieee1275/init.c?revision=1806&root=grub&view=markup the GRUB heap capped at 4MB (I don't mean size, I mean the end of the heap).
>
> It's not really capped at 4 MB. It will cap it only when an heuristic tells it
> there's still enough room for heap:
>
> /* Avoid claiming anything above HEAP_MAX_ADDR, if possible. */
> if ((addr < HEAP_MAX_ADDR) && /* if it's too late, don't bother */
> (addr + len > HEAP_MAX_ADDR) && /* if it wasn't available anyway, don't bother */
> (total + (HEAP_MAX_ADDR - addr) > HEAP_MIN_SIZE)) /* only limit ourselves when we can afford to */
>
> Argueably, this is not my best piece of code... today I'd have implemented a
> payload relocator (like the one used by loader/i386/pc/multiboot.c) just so we
> can happily use everything in /memory/available as heap.
>
> And I'd even advice doing the same for powerpc (sharing code with i386 if
> possible).
>
--
Best Regards,
Manoel Abranches <mrabran@linux.vnet.ibm.com>
IBM Linux Technology Center Brazil
^ permalink raw reply [flat|nested] 28+ messages in thread
* Re: PPC64
@ 2008-10-27 8:04 rubisher
0 siblings, 0 replies; 28+ messages in thread
From: rubisher @ 2008-10-27 8:04 UTC (permalink / raw)
To: grub-devel; +Cc: mrabran, crncosta, grub-devel
---------- Initial header -----------
From : grub-devel-bounces+rubisher=scarlet.be@gnu.org
To : "Manoel" mrabran@linux.vnet.ibm.com
CC : "The development of GRUB 2" grub-devel@gnu.org,"Carlos Roberto
do Nascimento Costa" crncosta@linux.vnet.ibm.com
Date : Thu, 23 Oct 2008 14:08:55 -0500
Subject : Re: PPC64
> On Thu, 2008-10-23 at 16:00 -0200, Manoel wrote:
> >
[snip]
>
> PAPR was based on the older CHRP specification.
>
mmm, from my aix boot: '# lscfg -vp' report me:
[snip]
Model Architecture: chrp
[snip]
Hth,
r.
ps: I would like to help more but not enough time right now.
[snip]
---
More than 2000 Scarlet customers don't pay a subscription anymore!
Join and surf free of charge! >> http://www.scarlet.be/nl/mgm
^ permalink raw reply [flat|nested] 28+ messages in thread
* PPC64
@ 2008-10-20 19:18 Manoel
2008-10-20 19:32 ` PPC64 Hollis Blanchard
0 siblings, 1 reply; 28+ messages in thread
From: Manoel @ 2008-10-20 19:18 UTC (permalink / raw)
To: grub-devel; +Cc: Carlos Roberto do Nascimento Costa, Hollis Blanchard
[-- Attachment #1: Type: text/plain, Size: 2266 bytes --]
I'm working in a project to use grub2 to boot some ppc machines(p6 , p5
and so on) and we had some difficulties with a grub modules problem.
Grub fails to load modules.
When debugging I noted that grub try to find the headerinfo modules
struc (which is identified by the magic number 0x676d696d) in the
address 0x2d000 (_end + gap aligned in 4k blocks).
but this address does not contains the headerinfo.
So i altered the source code such as the memory is searched to find the
magic number. It is then found at address 0x38f4c and then grub find
some modules (but fails after) has showed in attachment grub2.txt.
that address calculation led me to believe that I can tell where the
struct will be on memory based in its place in the binary.
I also noted that basemod ( indicates where the modules sections begin)
used by grub_mkelfimage is the same calculated by grub (_end + GAP). but
it seems to not store it on the necessary address.
using hexedit I could see that in the address 0xCC98 (in the file
generated by grub_mkelfimage) is stored the struct header info.
so in resume.
address where grub tries to find the header 0x2d000.
address where it is actually stored 0x38f4c.
address where it is in the generated file 0xCC98.
So my doubts are:
How this address calculation works?
How can I know where the struct will be in memory based in its address
in the binary?
It really works or only in some old OpenFirmare version?
I followed the wiki tutorial in the process.
That is the exit of the command: "readelf -l" (binary + modules):
Elf file type is EXEC (Executable file)
Entry point 0x10000
There are 4 program headers, starting at offset 52
Program Headers:
Type Offset VirtAddr PhysAddr FileSiz MemSiz Flg Align
LOAD 0x0000b4 0x00010000 0x00010000 0x0cbe4 0x14098 RWE 0x10
GNU_STACK 0x00cc98 0x00000000 0x00000000 0x00000 0x00000 RWE 0x4
LOAD 0x00cc98 0x0002d000 0x0002d000 0x5c1c8 0x5c1c8 RWE 0x4
NOTE 0x068e60 0x00000000 0x00000000 0x0002c 0x00000 R 0x4
the exit of "readelf -a" is showed in attachment readelf.txt
If you could help me, I will appreciate it. Thanks in advance!
Best regards.
Abranches, Manoel R.
[-- Attachment #2: grub2.txt --]
[-- Type: text/plain, Size: 3402 bytes --]
cursor-on, unknown wordWelcome to GRUB!
search= 0x38f4c
end =0x24098
gap =0x8000
align=0x1000
base_mod=0x2d000
modinfo = 0x2d000
modinfo->magic = 0x3063ffff
modinfo = 0x38f4c
modinfo->magic = 0x676d696d
../kern/dl.c:527: module at 0x38f64, size 0xbc0
../kern/dl.c:556: relocating to 0x2b8f0
../kern/dl.c:513: flushing 0x14 bytes at 0x2b350
../kern/dl.c:513: flushing 0x69 bytes at 0x2b3a0
../kern/dl.c:513: flushing 0x460 bytes at 0x2b440
../kern/dl.c:570: module name: acorn
../kern/dl.c:571: init function: 0x2b440
../kern/dl.c:527: module at 0x39b30, size 0xefc
../kern/dl.c:556: relocating to 0x2b240
../kern/dl.c:513: flushing 0x97 bytes at 0x2aa30
../kern/dl.c:513: flushing 0x6ec bytes at 0x2ab00
../kern/dl.c:570: module name: fshelp
../kern/dl.c:571: init function: 0x0
../kern/dl.c:527: module at 0x3aa38, size 0x1aa4
../kern/dl.c:556: relocating to 0x2a8b0
../kern/dl.c:513: flushing 0x4 bytes at 0x29af0
../kern/dl.c:513: flushing 0x20 bytes at 0x29b30
../kern/dl.c:513: flushing 0x89 bytes at 0x29b80
../kern/dl.c:513: flushing 0xbf4 bytes at 0x29c40
../kern/dl.c:570: module name: affs
../kern/dl.c:571: init function: 0x29c40
../kern/dl.c:527: module at 0x3c4e8, size 0x1be8
../kern/dl.c:556: relocating to 0x29a20
../kern/dl.c:513: flushing 0x4 bytes at 0x287f0
../kern/dl.c:513: flushing 0x20 bytes at 0x28830
../kern/dl.c:513: flushing 0x28 bytes at 0x28880
../kern/dl.c:513: flushing 0x4 bytes at 0x288e0
../kern/dl.c:513: flushing 0x108c bytes at 0x28920
../kern/dl.c:570: module name: afs
../kern/dl.c:571: init function: 0x28920
../kern/dl.c:527: module at 0x3e0dc, size 0xc9c
../kern/dl.c:556: relocating to 0x28720
../kern/dl.c:513: flushing 0x4 bytes at 0x28190
../kern/dl.c:513: flushing 0x14 bytes at 0x281d0
../kern/dl.c:513: flushing 0x68 bytes at 0x28220
../kern/dl.c:513: flushing 0x410 bytes at 0x282c0
../kern/dl.c:570: module name: amiga
../kern/dl.c:571: init function: 0x282c0
../kern/dl.c:527: module at 0x3ed84, size 0xe28
../kern/dl.c:556: relocating to 0x280a0
../kern/dl.c:513: flushing 0x4 bytes at 0x27a30
../kern/dl.c:513: flushing 0x14 bytes at 0x27a70
../kern/dl.c:513: flushing 0xfc bytes at 0x27ac0
../kern/dl.c:513: flushing 0x458 bytes at 0x27bf0
../kern/dl.c:570: module name: apple
../kern/dl.c:571: init function: 0x27bf0
../kern/dl.c:527: module at 0x3fbb8, size 0xeca4
../kern/dl.c:556: relocating to 0x27940
DEFAULT CATCH!, exception-handler=fff00300
at %SRR0: 0000000000013f88 %SRR1: 0000000000003002
Open Firmware exception handler entered from non-OF code
Client's Fix Pt Regs:
00 0000000000000010 00000000018dff50 0000000000000000 0000000065765b1b
04 000000000001a944 0000000000000000 0000000000003002 0000000000000010
08 00000000018dfe08 000000000001a944 000000000000000a 0000000065765b1b
0c 0000000000000000 0000000000000000 0000000000000000 0000000000000000
10 0000000000000000 0000000000000000 0000000000000000 0000000000000000
14 0000000000c00000 0000000000000008 0000000000000000 0000000000000000
18 0000000000000000 000000000001af4c 000000000001a944 000000000003fbb8
1c 0000000000000007 000000000004881c 0000000000027940 000000000003fbb8
Special Regs:
%IV: 00000300 %CR: 24000048 %XER: 00000000 %DSISR: 08000000
%SRR0: 0000000000013f88 %SRR1: 0000000000003002
%LR: 000000000001291c %CTR: 0000000000017930
%DAR: 0000000065765b1b
Virtual PID = 0
PFW: Unable to send error log!
ofdbg
0 >
[-- Attachment #3: readelf.txt --]
[-- Type: text/plain, Size: 1578 bytes --]
ELF Header:
Magic: 7f 45 4c 46 01 02 01 00 00 00 00 00 00 00 00 00
Class: ELF32
Data: 2's complement, big endian
Version: 1 (current)
OS/ABI: UNIX - System V
ABI Version: 0
Type: EXEC (Executable file)
Machine: PowerPC
Version: 0x1
Entry point address: 0x10000
Start of program headers: 52 (bytes into file)
Start of section headers: 0 (bytes into file)
Flags: 0x0
Size of this header: 52 (bytes)
Size of program headers: 32 (bytes)
Number of program headers: 4
Size of section headers: 40 (bytes)
Number of section headers: 0
Section header string table index: 0 <corrupt: out of range>
There are no sections in this file.
There are no sections in this file.
Program Headers:
Type Offset VirtAddr PhysAddr FileSiz MemSiz Flg Align
LOAD 0x0000b4 0x00010000 0x00010000 0x0cbe4 0x14098 RWE 0x10
GNU_STACK 0x00cc98 0x00000000 0x00000000 0x00000 0x00000 RWE 0x4
LOAD 0x00cc98 0x0002d000 0x0002d000 0x5c1c8 0x5c1c8 RWE 0x4
NOTE 0x068e60 0x00000000 0x00000000 0x0002c 0x00000 R 0x4
There is no dynamic section in this file.
There are no relocations in this file.
There are no unwind sections in this file.
No version information found in this file.
^ permalink raw reply [flat|nested] 28+ messages in thread* Re: PPC64
2008-10-20 19:18 PPC64 Manoel
@ 2008-10-20 19:32 ` Hollis Blanchard
2008-10-21 16:43 ` PPC64 Manoel
0 siblings, 1 reply; 28+ messages in thread
From: Hollis Blanchard @ 2008-10-20 19:32 UTC (permalink / raw)
To: Manoel; +Cc: grub-devel, Carlos Roberto do Nascimento Costa
On Mon, 2008-10-20 at 17:18 -0200, Manoel wrote:
>
> I'm working in a project to use grub2 to boot some ppc machines(p6 , p5
> and so on) and we had some difficulties with a grub modules problem.
> Grub fails to load modules.
>
> When debugging I noted that grub try to find the headerinfo modules
> struc (which is identified by the magic number 0x676d696d) in the
> address 0x2d000 (_end + gap aligned in 4k blocks).
> but this address does not contains the headerinfo.
>
> So i altered the source code such as the memory is searched to find the
> magic number. It is then found at address 0x38f4c and then grub find
> some modules (but fails after) has showed in attachment grub2.txt.
...
../kern/dl.c:527: module at 0x3e0dc, size 0xc9c
../kern/dl.c:556: relocating to 0x28720
../kern/dl.c:513: flushing 0x4 bytes at 0x28190
../kern/dl.c:513: flushing 0x14 bytes at 0x281d0
../kern/dl.c:513: flushing 0x68 bytes at 0x28220
../kern/dl.c:513: flushing 0x410 bytes at 0x282c0
../kern/dl.c:570: module name: amiga
../kern/dl.c:571: init function: 0x282c0
../kern/dl.c:527: module at 0x3ed84, size 0xe28
../kern/dl.c:556: relocating to 0x280a0
../kern/dl.c:513: flushing 0x4 bytes at 0x27a30
../kern/dl.c:513: flushing 0x14 bytes at 0x27a70
../kern/dl.c:513: flushing 0xfc bytes at 0x27ac0
../kern/dl.c:513: flushing 0x458 bytes at 0x27bf0
../kern/dl.c:570: module name: apple
../kern/dl.c:571: init function: 0x27bf0
../kern/dl.c:527: module at 0x3fbb8, size 0xeca4
../kern/dl.c:556: relocating to 0x27940
Notice how much larger that last module is than the ones before it.
That's a bit suspicious... do you have any modules that size?
> that address calculation led me to believe that I can tell where the
> struct will be on memory based in its place in the binary.
>
> I also noted that basemod ( indicates where the modules sections begin)
> used by grub_mkelfimage is the same calculated by grub (_end + GAP). but
> it seems to not store it on the necessary address.
>
> using hexedit I could see that in the address 0xCC98 (in the file
> generated by grub_mkelfimage) is stored the struct header info.
Well, hmm. Given the readelf output below, file offset 0xcc98 should be
loaded right at 0x2d000. Since you can see the magic number there
(correct?), I can't explain why the ELF loaded places it at 0x38f4c.
Can you report what memory firmware is using on this system? IIRC you
can decode it from the "available" properties in the memory nodes.
> so in resume.
>
> address where grub tries to find the header 0x2d000.
> address where it is actually stored 0x38f4c.
> address where it is in the generated file 0xCC98.
>
> So my doubts are:
> How this address calculation works?
> How can I know where the struct will be in memory based in its address
> in the binary?
> It really works or only in some old OpenFirmare version?
>
>
> I followed the wiki tutorial in the process.
>
> That is the exit of the command: "readelf -l" (binary + modules):
>
> Elf file type is EXEC (Executable file)
> Entry point 0x10000
> There are 4 program headers, starting at offset 52
>
> Program Headers:
> Type Offset VirtAddr PhysAddr FileSiz MemSiz Flg Align
> LOAD 0x0000b4 0x00010000 0x00010000 0x0cbe4 0x14098 RWE 0x10
> GNU_STACK 0x00cc98 0x00000000 0x00000000 0x00000 0x00000 RWE 0x4
> LOAD 0x00cc98 0x0002d000 0x0002d000 0x5c1c8 0x5c1c8 RWE 0x4
> NOTE 0x068e60 0x00000000 0x00000000 0x0002c 0x00000 R 0x4
>
>
> the exit of "readelf -a" is showed in attachment readelf.txt
>
> If you could help me, I will appreciate it. Thanks in advance!
> Best regards.
> Abranches, Manoel R.
--
Hollis Blanchard
IBM Linux Technology Center
^ permalink raw reply [flat|nested] 28+ messages in thread
* Re: PPC64
2008-10-20 19:32 ` PPC64 Hollis Blanchard
@ 2008-10-21 16:43 ` Manoel
0 siblings, 0 replies; 28+ messages in thread
From: Manoel @ 2008-10-21 16:43 UTC (permalink / raw)
To: The development of GRUB 2
[-- Attachment #1: Type: text/plain, Size: 5391 bytes --]
Hi Hollis,
On Mon, 2008-10-20 at 14:32 -0500, Hollis Blanchard wrote:
> On Mon, 2008-10-20 at 17:18 -0200, Manoel wrote:
> >
> > I'm working in a project to use grub2 to boot some ppc machines(p6 , p5
> > and so on) and we had some difficulties with a grub modules problem.
> > Grub fails to load modules.
> >
> > When debugging I noted that grub try to find the headerinfo modules
> > struc (which is identified by the magic number 0x676d696d) in the
> > address 0x2d000 (_end + gap aligned in 4k blocks).
> > but this address does not contains the headerinfo.
> >
> > So i altered the source code such as the memory is searched to find the
> > magic number. It is then found at address 0x38f4c and then grub find
> > some modules (but fails after) has showed in attachment grub2.txt.
>
> ...
> ../kern/dl.c:527: module at 0x3e0dc, size 0xc9c
> ../kern/dl.c:556: relocating to 0x28720
> ../kern/dl.c:513: flushing 0x4 bytes at 0x28190
> ../kern/dl.c:513: flushing 0x14 bytes at 0x281d0
> ../kern/dl.c:513: flushing 0x68 bytes at 0x28220
> ../kern/dl.c:513: flushing 0x410 bytes at 0x282c0
> ../kern/dl.c:570: module name: amiga
> ../kern/dl.c:571: init function: 0x282c0
> ../kern/dl.c:527: module at 0x3ed84, size 0xe28
> ../kern/dl.c:556: relocating to 0x280a0
> ../kern/dl.c:513: flushing 0x4 bytes at 0x27a30
> ../kern/dl.c:513: flushing 0x14 bytes at 0x27a70
> ../kern/dl.c:513: flushing 0xfc bytes at 0x27ac0
> ../kern/dl.c:513: flushing 0x458 bytes at 0x27bf0
> ../kern/dl.c:570: module name: apple
> ../kern/dl.c:571: init function: 0x27bf0
> ../kern/dl.c:527: module at 0x3fbb8, size 0xeca4
> ../kern/dl.c:556: relocating to 0x27940
>
> Notice how much larger that last module is than the ones before it.
> That's a bit suspicious... do you have any modules that size?
>
I'd like to address this issue later but their size are really messed
up. Grub can find the modules (how you can see by the modules names)
though. The modules should have 7k at most but grub identified them has
having about 50k.
I'm also curious why we must have a GAP between _end and the modules.
Why do not put the modules right after the _end address.
I need to look more into the source code but I noted the modules are
allocated in address in a decrementing order. The next module is always
loaded in a address below the previous module. I don't know if this
memory is allocated by the OF or if Grub forces the address to load the
modules this way.
How I have said before that I will look at this issue after the modules
header info location address issue is resolved.
> > that address calculation led me to believe that I can tell where the
> > struct will be on memory based in its place in the binary.
> >
> > I also noted that basemod ( indicates where the modules sections begin)
> > used by grub_mkelfimage is the same calculated by grub (_end + GAP). but
> > it seems to not store it on the necessary address.
> >
> > using hexedit I could see that in the address 0xCC98 (in the file
> > generated by grub_mkelfimage) is stored the struct header info.
>
> Well, hmm. Given the readelf output below, file offset 0xcc98 should be
> loaded right at 0x2d000. Since you can see the magic number there
> (correct?), I can't explain why the ELF loaded places it at 0x38f4c.
Yes, the magic number is exactly at the address 0xcc98 on the file
generated by the grub_mkelfimage. How can you tell the address it should
appear in memory based on its address in file? Maybe it's only valid in
some old OF version?
>
> Can you report what memory firmware is using on this system? IIRC you
> can decode it from the "available" properties in the memory nodes.
>
I couldn't find any apparently useful information in the memory nodes
properties. I have attached it anyway, I have also attached the "/" node
properties.
The OF version we are using is that below:
PowerPC Firmware
Version SF240_299
> > so in resume.
> >
> > address where grub tries to find the header 0x2d000.
> > address where it is actually stored 0x38f4c.
> > address where it is in the generated file 0xCC98.
> >
> > So my doubts are:
> > How this address calculation works?
> > How can I know where the struct will be in memory based in its address
> > in the binary?
> > It really works or only in some old OpenFirmare version?
> >
> >
> > I followed the wiki tutorial in the process.
> >
> > That is the exit of the command: "readelf -l" (binary + modules):
> >
> > Elf file type is EXEC (Executable file)
> > Entry point 0x10000
> > There are 4 program headers, starting at offset 52
> >
> > Program Headers:
> > Type Offset VirtAddr PhysAddr FileSiz MemSiz Flg Align
> > LOAD 0x0000b4 0x00010000 0x00010000 0x0cbe4 0x14098 RWE 0x10
> > GNU_STACK 0x00cc98 0x00000000 0x00000000 0x00000 0x00000 RWE 0x4
> > LOAD 0x00cc98 0x0002d000 0x0002d000 0x5c1c8 0x5c1c8 RWE 0x4
> > NOTE 0x068e60 0x00000000 0x00000000 0x0002c 0x00000 R 0x4
> >
> >
> > the exit of "readelf -a" is showed in attachment readelf.txt
> >
> > If you could help me, I will appreciate it. Thanks in advance!
> > Best regards.
> > Abranches, Manoel R.
>
--
Best Regards,
Manoel Abranches <mrabran@linux.vnet.ibm.com>
IBM Linux Technology Center Brasil
[-- Attachment #2: OF-memory-properties.txt --]
[-- Type: text/plain, Size: 356 bytes --]
name memory
device_type memory
reg 00000000 00000000 00000000 08000000
available 00000000 00004000 00000000 00bfc000 00000000 01c00000 00000000 06400000
#address-cells 00000001
#size-cells 00000000
ibm,associativity 00000004 00000000 00000000 00000000 000000
[-- Attachment #3: OF-properties.txt --]
[-- Type: text/plain, Size: 4195 bytes --]
0 > .properties
ibm,model-class E5
ibm,pci-full-cfg 00000001
ibm,extended-clock-frequency
00000000 1f78a400
clock-frequency 1f78a400
device_type chrp
#address-cells 00000002
#size-cells 00000002
ibm,max-boot-devices 00000005
ibm,fw-bytes-per-boot-device
00000100
ibm,extended-address
ibm,lpar-capable
ibm,converged-loc-codes
ibm,eeh-default 00000001
ibm,partition-no 00000009
ibm,partition-name 706f7765 72706163 6b2d7465 73743200
ibm,platform-hardware-notification
00000001 504f5745 52355f30 30334230 33303100
ibm,aix-diagnostics
name IBM,9133-55A
model IBM,9133-55A
compatible IBM,9133-55A
ibm,aix-uid 02a1b3d6
system-id IBM,0306301FH
ibm,drc-indexes 00000208 80000001 80000002 80000003 80000004 80000005 80000006 80000007
20000001 20000002 20000003 20000004 20000005 20000006 20000007 20000008
20000009 2000000a 2000000b 2000000c 2000000d 2000000e 2000000f 20000010
20000011 20000012 20000013 20000014 20000015 20000016 20000017 20000018
20000019 2000001a 2000001b 2000001c 2000001d 2000001e 2000001f 20000020
20000021 20000022 20000023 20000024 20000025 20000026 20000027 20000028
20000029 2000002a 2000002b 2000002c 2000002d 2000002e 2000002f 20000030
20000031 20000032 20000033 20000034 20000035 20000036 20000037 20000038
... 00000824bytes total
ibm,drc-types 00000208 4d454d00 4d454d00 4d454d00 4d454d00 4d454d00 4d454d00 4d454d00
50484200 50484200 50484200 50484200 50484200 50484200 50484200 50484200
50484200 50484200 50484200 50484200 50484200 50484200 50484200 50484200
50484200 50484200 50484200 50484200 50484200 50484200 50484200 50484200
50484200 50484200 50484200 50484200 50484200 50484200 50484200 50484200
50484200 50484200 50484200 50484200 50484200 50484200 50484200 50484200
50484200 50484200 50484200 50484200 50484200 50484200 50484200 50484200
50484200 50484200 50484200 50484200 50484200 50484200 50484200 50484200
... 00000825bytes total
ibm,drc-names 00000208 4c4d4232 004c4d42 33004c4d 4234004c 4d423500 4c4d4236 004c4d42
37004c4d 42380050 48422031 00504842 20320050 48422033 00504842 20340050
48422035 00504842 20360050 48422037 00504842 20380050 48422039 00504842
20313000 50484220 31310050 48422031 32005048 42203133 00504842 20313400
50484220 31350050 48422031 36005048 42203137 00504842 20313800 50484220
31390050 48422032 30005048 42203231 00504842 20323200 50484220 32330050
48422032 34005048 42203235 00504842 20323600 50484220 32370050 48422032
38005048 42203239 00504842 20333000 50484220 33310050 48422033 32005048
... 00000fd0bytes total
ibm,drc-power-domains 00000208 ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff
ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff
ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff
ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff
ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff
ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff
ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff
ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff
... 00000824bytes total
^ permalink raw reply [flat|nested] 28+ messages in thread
end of thread, other threads:[~2008-11-06 17:46 UTC | newest]
Thread overview: 28+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-10-21 20:52 PPC64 Hollis Blanchard
2008-10-21 22:04 ` PPC64 Pavel Roskin
2008-10-21 22:40 ` PPC64 Hollis Blanchard
2008-10-23 5:25 ` PPC64 Pavel Roskin
2008-10-23 15:06 ` PPC64 Hollis Blanchard
2008-10-23 16:52 ` PPC64 Pavel Roskin
2008-10-23 18:00 ` PPC64 Manoel
2008-10-23 19:08 ` PPC64 Hollis Blanchard
2008-10-24 12:10 ` PPC64 Manoel
2008-10-24 14:51 ` PPC64 Hollis Blanchard
2008-10-24 21:53 ` PPC64 Manoel
2008-10-27 17:19 ` PPC64 Pavel Roskin
2008-11-04 16:05 ` PPC64 Manoel
2008-11-04 16:12 ` PPC64 Hollis Blanchard
2008-11-04 18:18 ` PPC64 mlongcall gcc flag Manoel
2008-11-04 18:21 ` Manoel
2008-11-04 19:16 ` Robert Millan
2008-11-04 23:48 ` Pavel Roskin
2008-11-05 9:43 ` Robert Millan
2008-11-05 15:35 ` Pavel Roskin
2008-11-05 17:25 ` Hollis Blanchard
2008-11-05 19:27 ` Manoel
2008-11-06 15:12 ` Robert Millan
2008-11-06 17:42 ` Manoel
-- strict thread matches above, loose matches on Subject: below --
2008-10-27 8:04 PPC64 rubisher
2008-10-20 19:18 PPC64 Manoel
2008-10-20 19:32 ` PPC64 Hollis Blanchard
2008-10-21 16:43 ` PPC64 Manoel
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.