Skip to contentSkip to conversation

Claim on IEEE1275

DISCUSSION Marco Gerards 2 participants 9 messages Dec 28, 2004 – Jan 2, 2005

lore
Share & tools
lore
#0 lore raw

Hi,

Some minutes ago I have committed a patch that removes the stack initialization code. This seems to work perfectly fine for both the PegasosII and the newworld mac. This was required for loading linux on the PegasosII. Without this change linux crashed when decompressing itself. It's ok for me to restore this code when the problem is found. But at the moment this seems like a fine fix.

Only one problem remains for loading linux on the PegasosII. The grub_claimmap call fails because the map fails. I think this is because the firmware already maps the memory.

Hollis, is the map call really required? We can better go back to using grub_ieee1275_claim if it is not. If it is required, do you have an idea of how to detect this?

Thanks,
Marco

#1 lore raw
Quoted 7 lines · Marco Gerards

Some minutes ago I have committed a patch that removes the stack initialization code. This seems to work perfectly fine for both the PegasosII and the newworld mac. This was required for loading linux on the PegasosII. Without this change linux crashed when decompressing itself. It's ok for me to restore this code when the problem is found. But at the moment this seems like a fine fix.

I would still like to have some idea of the problem we're avoiding. We *were* using an 8KB stack (which seems like a lot). Now we use whatever firmware gave us. Firmware is required by spec (8.2.2 of the PowerPC IEEE1275 binding) to give us at least a 32KB stack, but of course we cannot guarantee that all implementations do this correctly. It is possible that Linux's gunzip code requires a stack greater than 8KB, and that would be good to know (and comment). Would you mind testing the old code with larger stack sizes and see if that matters?

I said earlier that I didn't think the old stack initialization code was correct, but now I think it may be ok. I have never seen use of the "la" mnemonic, but it might do what we want here.

Quoted 3 lines

Only one problem remains for loading linux on the PegasosII. The grub_claimmap call fails because the map fails. I think this is because the firmware already maps the memory.

You can verify this by consulting the "translations" property of /chosen/mmu if I recall correctly.

Quoted 3 lines

Hollis, is the map call really required? We can better go back to using grub_ieee1275_claim if it is not. If it is required, do you have an idea of how to detect this?

It is certainly required: how would you like it if you claimed some memory to write to but it was never mapped?

There is a "real-mode?" configuration variable, but I think that just specifies OF's translation mode, independent of the client's mode (see the IEEE1275 PowerPC and CHRP bindings). Knowing the value of that variable might be interesting but I wouldn't recommend changing it, as Apple firmware in particular is known to die a horrible death by mucking with one of those settings (I'm pretty sure it's "real-mode?").

-Hollis

#2 lore raw
Quoted 9 lines · Hollis Blanchard
Quoted 7 lines · Marco Gerards

Some minutes ago I have committed a patch that removes the stack initialization code. This seems to work perfectly fine for both the PegasosII and the newworld mac. This was required for loading linux on the PegasosII. Without this change linux crashed when decompressing itself. It's ok for me to restore this code when the problem is found. But at the moment this seems like a fine fix.

Quoted 9 lines

I would still like to have some idea of the problem we're avoiding. We *were* using an 8KB stack (which seems like a lot). Now we use whatever firmware gave us. Firmware is required by spec (8.2.2 of the PowerPC IEEE1275 binding) to give us at least a 32KB stack, but of course we cannot guarantee that all implementations do this correctly. It is possible that Linux's gunzip code requires a stack greater than 8KB, and that would be good to know (and comment). Would you mind testing the old code with larger stack sizes and see if that matters?

I've done that before I removed it. It did not help. Perhaps the problem is caused because stack is in .bss and it is not executable?

Quoted 3 lines

I said earlier that I didn't think the old stack initialization code was correct, but now I think it may be ok. I have never seen use of the "la" mnemonic, but it might do what we want here.

Ok. Hopefully Johan can comment on that, he wrote that code.

Quoted 6 lines
Quoted 3 lines

Only one problem remains for loading linux on the PegasosII. The grub_claimmap call fails because the map fails. I think this is because the firmware already maps the memory.

You can verify this by consulting the "translations" property of /chosen/mmu if I recall correctly.

Ok.

Quoted 6 lines
Quoted 3 lines

Hollis, is the map call really required? We can better go back to using grub_ieee1275_claim if it is not. If it is required, do you have an idea of how to detect this?

It is certainly required: how would you like it if you claimed some memory to write to but it was never mapped?

I assume it is mapped by claim. Anyway, yaboot does not use map and neither does linux, as it seems.

Quoted 6 lines

There is a "real-mode?" configuration variable, but I think that just specifies OF's translation mode, independent of the client's mode (see the IEEE1275 PowerPC and CHRP bindings). Knowing the value of that variable might be interesting but I wouldn't recommend changing it, as Apple firmware in particular is known to die a horrible death by mucking with one of those settings (I'm pretty sure it's "real-mode?").

On my powerbook it is set to false, while it is set to true on the pegasos. So what do you suggest? Using map when it is set to false?

Thanks,
Marco

#3 lore raw
Quoted 8 lines · Marco Gerards
Quoted 6 lines
Quoted 3 lines

Hollis, is the map call really required? We can better go back to using grub_ieee1275_claim if it is not. If it is required, do you have an idea of how to detect this?

It is certainly required: how would you like it if you claimed some memory to write to but it was never mapped?

I assume it is mapped by claim.

If claim also called map, we would not have needed to add an explicit map call. See also the IEEE1275 description of "claim":
Claim does not automatically create an address translation for the
allocated resource.

	See 3.6.5.
Quoted 1 line

Anyway, yaboot does not use map and neither does linux, as it seems.

Linux does not because it terminates OF and takes over the MMU itself.

As for yaboot, it does not run on Old World Macintosh, and described in the thread starting at http://lists.gnu.org/archive/html/grub-devel/2004-09/msg00014.html, I needed to use map on Old World. If it is *only* needed on Old World, then we could add another flag to grub_ieee1275_flags.

Quoted 9 lines
Quoted 6 lines

There is a "real-mode?" configuration variable, but I think that just specifies OF's translation mode, independent of the client's mode (see the IEEE1275 PowerPC and CHRP bindings). Knowing the value of that variable might be interesting but I wouldn't recommend changing it, as Apple firmware in particular is known to die a horrible death by mucking with one of those settings (I'm pretty sure it's "real-mode?").

On my powerbook it is set to false, while it is set to true on the pegasos. So what do you suggest? Using map when it is set to false?

You said that both the PowerBook and the Pegasos work without the map call, so if the briQ works too then I think we should use the approach described above.

-Hollis

#4 lore raw
Quoted 5 lines · Hollis Blanchard

As for yaboot, it does not run on Old World Macintosh, and described in the thread starting at
http://lists.gnu.org/archive/html/grub-devel/2004-09/msg00014.html, I needed to use map on Old World. If it is *only* needed on Old World, then we could add another flag to grub_ieee1275_flags.

I agree.

Quoted 8 lines
Quoted 8 lines
Quoted 7 lines

There is a "real-mode?" configuration variable, but I think that just specifies OF's translation mode, independent of the client's mode (see the IEEE1275 PowerPC and CHRP bindings). Knowing the value of that variable might be interesting but I wouldn't recommend changing it, as Apple firmware in particular is known to die a horrible death by mucking with one of those settings (I'm pretty sure it's "real-mode?").

Quoted 6 lines
Quoted 2 lines

On my powerbook it is set to false, while it is set to true on the pegasos. So what do you suggest? Using map when it is set to false?

You said that both the PowerBook and the Pegasos work without the map call, so if the briQ works too then I think we should use the approach described above.

Right. When will you be able to test this?

Thanks,
Marco

#5 lore raw
Quoted 18 lines · Marco Gerards
Quoted 5 lines · Hollis Blanchard

As for yaboot, it does not run on Old World Macintosh, and described in the thread starting at
http://lists.gnu.org/archive/html/grub-devel/2004-09/msg00014.html, I needed to use map on Old World. If it is *only* needed on Old World, then we could add another flag to grub_ieee1275_flags.

I agree.

Quoted 8 lines
Quoted 8 lines
Quoted 7 lines

There is a "real-mode?" configuration variable, but I think that just specifies OF's translation mode, independent of the client's mode (see the IEEE1275 PowerPC and CHRP bindings). Knowing the value of that variable might be interesting but I wouldn't recommend changing it, as Apple firmware in particular is known to die a horrible death by mucking with one of those settings (I'm pretty sure it's "real-mode?").

Quoted 8 lines
Quoted 6 lines
Quoted 2 lines

On my powerbook it is set to false, while it is set to true on the pegasos. So what do you suggest? Using map when it is set to false?

You said that both the PowerBook and the Pegasos work without the map call, so if the briQ works too then I think we should use the approach described above.

Right. When will you be able to test this?

I will be able to check Friday.

-Hollis

#6 lore raw
In reply to Hollis Blanchard
Quoted 8 lines · Hollis Blanchard
Quoted 8 lines
Quoted 7 lines

There is a "real-mode?" configuration variable, but I think that just specifies OF's translation mode, independent of the client's mode (see the IEEE1275 PowerPC and CHRP bindings). Knowing the value of that variable might be interesting but I wouldn't recommend changing it, as Apple firmware in particular is known to die a horrible death by mucking with one of those settings (I'm pretty sure it's "real-mode?").

Quoted 4 lines
Quoted 2 lines

On my powerbook it is set to false, while it is set to true on the pegasos. So what do you suggest? Using map when it is set to false?

You said that both the PowerBook and the Pegasos work without the map call, so if the briQ works too then I think we should use the approach described above.

The briQ works without the map, and fails just like the Pegasos with it (which shouldn't be surprising given their firmware was written by the same people).

I've tested this patch (attached to prevent line-wrapping) on the briQ, but there's some other problem (not caused by the patch) that hangs after "boot". I'm not going to test Old World now, as there are some more fundamental problems there.

The real issue may be that Apple firmware (on your PowerBook) returns success when a mapping is requested for an existing translation, but Codegen firmware (on the briQ and Pegasos) returns an error. It would be interesting to re-implement the "suspend" command we talked about a while ago and examine the processor node's "translations" property.

-Hollis

2005-01-01 Hollis Blanchard <[email protected]>
* boot/powerpc/ieee1275/cmain.c (cmain): Set the GRUB_IEEE1275_MAP_CLAIM bit in grub_ieee1275_flags.
* include/grub/powerpc/ieee1275/ieee1275.h (GRUB_IEEE1275_MAP_CLAIM):
New constant.
* kern/powerpc/ieee1275/openfw.c (grub_claimmap): Only call grub_map
if the
GRUB_IEEE1275_MAP_CLAIM bit is set in grub_ieee1275_flags.

? .vimrc
? build
? cscope.in.out
? cscope.out
? cscope.po.out
? map-claim.diff
Index: boot/powerpc/ieee1275/cmain.c
===================================================================
RCS file: /cvsroot/grub/grub2/boot/powerpc/ieee1275/cmain.c,v retrieving revision 1.5

powerpc/ieee1275/cmain.c +2 -1
diff -u -p -r1.5 cmain.c
@@ -56,7 +56,8 @@ cmain (uint32_t r3, uint32_t r4 __attrib
 
       grub_ieee1275_entry_fn = (intptr_t (*)(void *)) r3;
 
-      grub_ieee1275_flags = GRUB_IEEE1275_NO_PARTITION_0;
+      grub_ieee1275_flags = GRUB_IEEE1275_NO_PARTITION_0
+			    | GRUB_IEEE1275_MAP_CLAIM;
 
       /* Old World Open Firmware may use 4M-5M without claiming it.  */
       grub_ieee1275_claim (0x00400000, 0x00100000, 0, 0);

Index: include/grub/powerpc/ieee1275/ieee1275.h
===================================================================
RCS file: /cvsroot/grub/grub2/include/grub/powerpc/ieee1275/ieee1275.h,v retrieving revision 1.10

grub/powerpc/ieee1275/ieee1275.h +2 -0
diff -u -p -r1.10 ieee1275.h
@@ -69,6 +69,8 @@ extern grub_uint32_t grub_ieee1275_flags
 
 /* Old World firmware fails seek when "dev:0" is opened.  */
 #define GRUB_IEEE1275_NO_PARTITION_0 0x1
+/* Is "map" required after "claim"?  */
+#define GRUB_IEEE1275_MAP_CLAIM 0x2
 
 
 

Index: kern/powerpc/ieee1275/openfw.c
===================================================================
RCS file: /cvsroot/grub/grub2/kern/powerpc/ieee1275/openfw.c,v retrieving revision 1.6

powerpc/ieee1275/openfw.c +3 -1
diff -u -p -r1.6 openfw.c
@@ -189,7 +189,9 @@ grub_claimmap (grub_addr_t addr, grub_si
 {
   if (grub_ieee1275_claim (addr, size, 0, 0))
     return -1;
-  if (grub_map (addr, addr, size, 0x00))
+
+  if ((grub_ieee1275_flags & GRUB_IEEE1275_MAP_CLAIM)
+      && grub_map (addr, addr, size, 0x00))
     {
       grub_ieee1275_release (addr, size);
       return -1;
#7 lore raw
Quoted 2 lines · Hollis Blanchard

I've tested this patch (attached to prevent line-wrapping) on the briQ, but there's some other problem (not caused by the patch) that hangs after "boot". I'm not going to test Old World now, as there are some more fundamental problems there.

It has been pointed out to me that a simpler fix would just be to ignore map failures. That sounds better to me... we *are* supposed to use map, but the first 32 MB or so are probably already mapped anyways on most systems.

Likely the error occurs because "map" is meaningless in real-mode, and Codegen chose to return an error in this case. I was told an implementation in real-mode *may* provide an mmu node, so things seem rather open-ended in this situation.

The patch I sent earlier may get us into trouble if we want to load things on New World that happen to fall outside the already-mapped region (like large ramdisks). I think a better plan would be:
1) only call map in virtual mode
2) *and* ignore map errors. We could report them as warnings in a verbose mode for remote debugging.

-Hollis

#8 lore raw
Quoted 10 lines · Hollis Blanchard

It has been pointed out to me that a simpler fix would just be to ignore map failures. That sounds better to me... we *are* supposed to use map, but the first 32 MB or so are probably already mapped anyways on most systems.

Likely the error occurs because "map" is meaningless in real-mode, and Codegen chose to return an error in this case. I was told an implementation in real-mode *may* provide an mmu node, so things seem rather open-ended in this situation.

Quoted 4 lines

The patch I sent earlier may get us into trouble if we want to load things on New World that happen to fall outside the already-mapped region (like large ramdisks). I think a better plan would be:
1) only call map in virtual mode

Right.

Quoted 2 lines

2) *and* ignore map errors. We could report them as warnings in a verbose mode for remote debugging.

Ignore them in claimmap you mean, right? But doesn't #1 fix the problem already?

--
Marco