[PATCH] arm64: smp: Prevent raw_smp_processor_id() recursion
Catalin Marinas
catalin.marinas at arm.com
Thu Dec 1 09:27:20 PST 2016
On Thu, Dec 01, 2016 at 05:16:50PM +0000, Robin Murphy wrote:
> On 01/12/16 15:55, Robin Murphy wrote:
> > Under CONFIG_DEBUG_PREEMPT=y, this_cpu_ptr() ends up calling back into
> > raw_smp_processor_id(), resulting in some hilariously catastrophic
> > infinite recursion. In the normal case, we have:
> >
> > #define this_cpu_ptr(ptr) raw_cpu_ptr(ptr)
> >
> > and everything is dandy. However for CONFIG_DEBUG_PREEMPT, this_cpu_ptr()
> > is defined in terms of my_cpu_offset, wherein the fun begins:
> >
> > #define my_cpu_offset per_cpu_offset(smp_processor_id())
> > ...
> > #define smp_processor_id() debug_smp_processor_id()
> > ...
> > notrace unsigned int debug_smp_processor_id(void)
> > {
> > return check_preemption_disabled("smp_processor_id", "");
> > ...
> > notrace static unsigned int check_preemption_disabled(const char *what1,
> > const char *what2)
> > {
> > int this_cpu = raw_smp_processor_id();
> >
> > and bang. Use raw_cpu_ptr() directly to avoid that.
> >
> > Reported-by: Marek Szyprowski <m.szyprowski at samsung.com>
> > Acked-by: Will Deacon <will.deacon at arm.com>
> > Signed-off-by: Robin Murphy <robin.murphy at arm.com>
>
> I wasn't sure whether commit IDs on for-next/core are stable, but if
> they are, this could also have:
>
> Fixes: 57c82954e77f ("arm64: make cpu number a percpu variable")
It depends on which branch is pulled into next. I keep the for-next/core
stable at this stage, so I'll include the Fixes like as well. Thanks.
--
Catalin
More information about the linux-arm-kernel
mailing list