* [PATCH] powerpc: Add missing error check to prom_find_boot_cpu()
@ 2017-01-23 19:42 Darren Stevens
2017-01-27 0:33 ` Michael Ellerman
0 siblings, 1 reply; 3+ messages in thread
From: Darren Stevens @ 2017-01-23 19:42 UTC (permalink / raw)
To: linuxppc-dev; +Cc: Christian Zigotzky, rtd, Pat Wall, aperez
[-- Attachment #1: Type: text/plain, Size: 178 bytes --]
AmigaOS...........: http://yam.ch/
Unix/MacOS/Windows: http://www.mozilla.com/thunderbird/
General information about MIME can be found at:
http://en.wikipedia.org/wiki/MIME
[-- Attachment #2: Type: text/plain, Size: 657 bytes --]
prom_init.c calls 'instance-to-package' twice, but the return
is not checked during prom_find_boot_cpu(). The result is then
passed to prom_getprop, which could be PROM_ERROR.
Add a return check to prevent this.
This was found on a pasemi system, where CFE doesn't have a working
'instance-to package' prom call.
Before Commit 5c0484e25ec0 ('powerpc: Endian safe trampoline') the
area around addr 0 as mostly 0's and this doesn't cause a problem.
Once the macro 'FIXUP_ENDIAN' has been added to head_64.S, the low
memory area now has non-zero values, which cause the prom_getprop
call to hang.
Signed-off-by: Darren Stevens <darren@stevens-zone.net>
---
[-- Attachment #3: prom_init.patch --]
[-- Type: text/plain, Size: 448 bytes --]
diff --git a/arch/powerpc/kernel/prom_init.c b/arch/powerpc/kernel/prom_init.c
index ec47a93..ac83eb0 100644
--- a/arch/powerpc/kernel/prom_init.c
+++ b/arch/powerpc/kernel/prom_init.c
@@ -2834,6 +2834,9 @@ static void __init prom_find_boot_cpu(void)
cpu_pkg = call_prom("instance-to-package", 1, 1, prom_cpu);
+ if (!PHANDLE_VALID(cpu_pkg))
+ return;
+
prom_getprop(cpu_pkg, "reg", &rval, sizeof(rval));
prom.cpu = be32_to_cpu(rval);
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: powerpc: Add missing error check to prom_find_boot_cpu()
2017-01-23 19:42 [PATCH] powerpc: Add missing error check to prom_find_boot_cpu() Darren Stevens
@ 2017-01-27 0:33 ` Michael Ellerman
2017-01-27 13:05 ` Darren Stevens
0 siblings, 1 reply; 3+ messages in thread
From: Michael Ellerman @ 2017-01-27 0:33 UTC (permalink / raw)
To: Darren Stevens, linuxppc-dev; +Cc: Pat Wall, rtd, aperez, Christian Zigotzky
On Mon, 2017-01-23 at 19:42:54 UTC, Darren Stevens wrote:
> prom_init.c calls 'instance-to-package' twice, but the return
> is not checked during prom_find_boot_cpu(). The result is then
> passed to prom_getprop, which could be PROM_ERROR.
> Add a return check to prevent this.
>
> This was found on a pasemi system, where CFE doesn't have a working
> 'instance-to package' prom call.
> Before Commit 5c0484e25ec0 ('powerpc: Endian safe trampoline') the
> area around addr 0 as mostly 0's and this doesn't cause a problem.
> Once the macro 'FIXUP_ENDIAN' has been added to head_64.S, the low
> memory area now has non-zero values, which cause the prom_getprop
> call to hang.
>
> Signed-off-by: Darren Stevens <darren@stevens-zone.net>
Applied to powerpc fixes, thanks.
https://git.kernel.org/powerpc/c/af2b7fa17eb92e52b65f96604448ff
cheers
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: powerpc: Add missing error check to prom_find_boot_cpu()
2017-01-27 0:33 ` Michael Ellerman
@ 2017-01-27 13:05 ` Darren Stevens
0 siblings, 0 replies; 3+ messages in thread
From: Darren Stevens @ 2017-01-27 13:05 UTC (permalink / raw)
To: Michael Ellerman; +Cc: linuxppc-dev, Pat Wall, rtd, aperez, Christian Zigotzky
Hello Michael
On 27/01/2017, Michael Ellerman wrote:
> On Mon, 2017-01-23 at 19:42:54 UTC, Darren Stevens wrote:
> Applied to powerpc fixes, thanks.
>
> https://git.kernel.org/powerpc/c/af2b7fa17eb92e52b65f96604448ff
Thanks, I was going to ask about backporting to 4.9 as it's a LTS now, but I
see from the above you've beaten me to it! Much appreciated.
I'm nearing the point where I will want to add the Nemo setup code to the
kernel, and I see 2 choices:
Continue as we do, with #ifdefs in the setup.c / pci.c files.
Create 2 new files setup-nemo.c and pci-nemo.c - I am assuming this would be
the prefered option?
Regards
Darren
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2017-01-27 13:05 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-01-23 19:42 [PATCH] powerpc: Add missing error check to prom_find_boot_cpu() Darren Stevens
2017-01-27 0:33 ` Michael Ellerman
2017-01-27 13:05 ` Darren Stevens
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.