Skip to content

Commit 10348f5

Browse files
committed
powerpc: Check return value of instance-to-package OF call
On PA-Semi firmware, the instance-to-package callback doesn't seem to be implemented. We didn't check for error, however, thus subsequently passed the -1 value returned into stdout_node to thins like prom_getprop etc... Thus caused the firmware to load values around 0 (physical) internally as node structures. It somewhat "worked" as long as we had a NULL in the right place (address 8) at the beginning of the kernel, we didn't "see" the bug. But commit 5c0484e "powerpc: Endian safe trampoline" changed the kernel entry point causing that old bug to now cause a crash early during boot. This fixes booting on PA-Semi board by properly checking the return value from instance-to-package. Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org> Tested-by: Olof Johansson <olof@lixom.net> ---
1 parent f991db1 commit 10348f5

File tree

1 file changed

+13
-9
lines changed

1 file changed

+13
-9
lines changed

arch/powerpc/kernel/prom_init.c

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1986,19 +1986,23 @@ static void __init prom_init_stdout(void)
19861986
/* Get the full OF pathname of the stdout device */
19871987
memset(path, 0, 256);
19881988
call_prom("instance-to-path", 3, 1, prom.stdout, path, 255);
1989-
stdout_node = call_prom("instance-to-package", 1, 1, prom.stdout);
1990-
val = cpu_to_be32(stdout_node);
1991-
prom_setprop(prom.chosen, "/chosen", "linux,stdout-package",
1992-
&val, sizeof(val));
19931989
prom_printf("OF stdout device is: %s\n", of_stdout_device);
19941990
prom_setprop(prom.chosen, "/chosen", "linux,stdout-path",
19951991
path, strlen(path) + 1);
19961992

1997-
/* If it's a display, note it */
1998-
memset(type, 0, sizeof(type));
1999-
prom_getprop(stdout_node, "device_type", type, sizeof(type));
2000-
if (strcmp(type, "display") == 0)
2001-
prom_setprop(stdout_node, path, "linux,boot-display", NULL, 0);
1993+
/* instance-to-package fails on PA-Semi */
1994+
stdout_node = call_prom("instance-to-package", 1, 1, prom.stdout);
1995+
if (stdout_node != PROM_ERROR) {
1996+
val = cpu_to_be32(stdout_node);
1997+
prom_setprop(prom.chosen, "/chosen", "linux,stdout-package",
1998+
&val, sizeof(val));
1999+
2000+
/* If it's a display, note it */
2001+
memset(type, 0, sizeof(type));
2002+
prom_getprop(stdout_node, "device_type", type, sizeof(type));
2003+
if (strcmp(type, "display") == 0)
2004+
prom_setprop(stdout_node, path, "linux,boot-display", NULL, 0);
2005+
}
20022006
}
20032007

20042008
static int __init prom_find_machine_type(void)

0 commit comments

Comments
 (0)