* [PATCH] powerpc/mpic: Check if cpu_possible() in mpic_physmask()
@ 2018-03-31 14:00 Michael Ellerman
2018-03-31 14:05 ` Michael Ellerman
0 siblings, 1 reply; 2+ messages in thread
From: Michael Ellerman @ 2018-03-31 14:00 UTC (permalink / raw)
To: linuxppc-dev; +Cc: npiggin
In mpic_physmask() we loop over all CPUs up to 32, then get the hard
SMP processor id of that CPU.
Currently that's possibly walking off the end of the paca array, but
in a future patch we will change the paca array to be an array of
pointers, and in that case we will get a NULL for missing CPUs and
oops. eg:
Unable to handle kernel paging request for data at address 0x88888888888888b8
Faulting instruction address: 0xc00000000004e380
Oops: Kernel access of bad area, sig: 11 [#1]
...
NIP .mpic_set_affinity+0x60/0x1a0
LR .irq_do_set_affinity+0x48/0x100
Fix it by checking the CPU is possible, this also fixes the code if
there are gaps in the CPU numbering which probably never happens on
mpic systems but who knows.
Debugged-by: Nicholas Piggin <npiggin@gmail.com>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
---
arch/powerpc/sysdev/mpic.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/arch/powerpc/sysdev/mpic.c b/arch/powerpc/sysdev/mpic.c
index 73067805300a..1d4e0ef658d3 100644
--- a/arch/powerpc/sysdev/mpic.c
+++ b/arch/powerpc/sysdev/mpic.c
@@ -626,7 +626,7 @@ static inline u32 mpic_physmask(u32 cpumask)
int i;
u32 mask = 0;
- for (i = 0; i < min(32, NR_CPUS); ++i, cpumask >>= 1)
+ for (i = 0; i < min(32, NR_CPUS) && cpu_possible(i); ++i, cpumask >>= 1)
mask |= (cpumask & 1) << get_hard_smp_processor_id(i);
return mask;
}
--
2.14.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: powerpc/mpic: Check if cpu_possible() in mpic_physmask()
2018-03-31 14:00 [PATCH] powerpc/mpic: Check if cpu_possible() in mpic_physmask() Michael Ellerman
@ 2018-03-31 14:05 ` Michael Ellerman
0 siblings, 0 replies; 2+ messages in thread
From: Michael Ellerman @ 2018-03-31 14:05 UTC (permalink / raw)
To: Michael Ellerman, linuxppc-dev; +Cc: npiggin
On Sat, 2018-03-31 at 14:00:24 UTC, Michael Ellerman wrote:
> In mpic_physmask() we loop over all CPUs up to 32, then get the hard
> SMP processor id of that CPU.
>
> Currently that's possibly walking off the end of the paca array, but
> in a future patch we will change the paca array to be an array of
> pointers, and in that case we will get a NULL for missing CPUs and
> oops. eg:
>
> Unable to handle kernel paging request for data at address 0x88888888888888b8
> Faulting instruction address: 0xc00000000004e380
> Oops: Kernel access of bad area, sig: 11 [#1]
> ...
> NIP .mpic_set_affinity+0x60/0x1a0
> LR .irq_do_set_affinity+0x48/0x100
>
> Fix it by checking the CPU is possible, this also fixes the code if
> there are gaps in the CPU numbering which probably never happens on
> mpic systems but who knows.
>
> Debugged-by: Nicholas Piggin <npiggin@gmail.com>
> Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Applied to powerpc next.
https://git.kernel.org/powerpc/c/0834d627fbea00c1444075eb3e448e
cheers
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2018-03-31 14:05 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-03-31 14:00 [PATCH] powerpc/mpic: Check if cpu_possible() in mpic_physmask() Michael Ellerman
2018-03-31 14:05 ` Michael Ellerman
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.