Re: [PATCH] Check for breakpoint in text_poke to eliminate bug_on

From: Mathieu Desnoyers
Date: Sun Apr 20 2008 - 16:25:43 EST


* Pekka Paalanen (pq@xxxxxx) wrote:
> On Sun, 20 Apr 2008 15:44:40 -0400
> Mathieu Desnoyers <mathieu.desnoyers@xxxxxxxxxx> wrote:
>
> > Can you test this new version ? The check was buggy when it fell on a
> > code boundary : the addr - 1 wan't always a valid address.
> >
>
> Sorry, still the same. Btw. I had to apply your patch by hand on top of
> your previous patch, and it ended up as just
>
> --- a/arch/x86/kernel/alternative.c
> +++ b/arch/x86/kernel/alternative.c
> @@ -520,11 +520,6 @@ void *__kprobes text_poke(void *addr, const void *opcode, size_t len)
> struct page *pages[2];
> int i;
>
> - if (*((uint8_t *)addr - 1) != BREAKPOINT_INSTRUCTION) {
> - BUG_ON(len > sizeof(long));
> - BUG_ON((((long)addr + len - 1) & ~(sizeof(long) - 1))
> - - ((long)addr & ~(sizeof(long) - 1)));
> - }
> if (!core_kernel_text((unsigned long)addr)) {
>
> Now I took a log of echo 0, echo 1 cycle with 2.6.24-gentoo-r1-trace
> kernel:
> [ 203.448534] CPU 1 is now offline
> [ 203.448975] SMP alternatives: switching to UP code
> [ 217.888298] SMP alternatives: switching to SMP code
> [ 217.889285] Booting processor 1/2 APIC 0x1
> [ 217.901404] Initializing CPU#1
> [ 217.982081] Calibrating delay using timer specific routine.. 3991.35 BogoMIPS (lpj=6650167)
> [ 217.982088] CPU: L1 I cache: 32K, L1 D cache: 32K
> [ 217.982089] CPU: L2 cache: 4096K
> [ 217.982091] CPU: Physical Processor ID: 0
> [ 217.982092] CPU: Processor Core ID: 1
> [ 217.982593] Intel(R) Core(TM)2 Duo CPU T7300 @ 2.00GHz stepping 0a
> [ 217.982644] Switched to high resolution mode on CPU 1
>
> And the failing log from the latest try is:
>
> [ 87.064970] CPU 1 is now offline
> [ 87.065311] lockdep: fixing up alternatives.
> [ 87.065694] SMP alternatives: switching to UP code
> [ 97.192213] lockdep: fixing up alternatives.
> [ 97.192532] SMP alternatives: switching to SMP code
> [ 97.203495] Booting processor 1/1 ip 6000
> and it hangs and reboots.
>
> Does it make sense to bisect on sched-devel/latest?
> I think I could try that after a sleep&work cycle.
> Luckily this bug is easy to reproduce.
>

Yup. I was able to successfully cycle cpu hotplug with 2.6.25 mainline
with the equivalent of the text_poke patches I sent to you, therefore I
guess it rules out text_poke as a cause of your crash. A bisection of
sched-devel/latest seems appropriate.

Mathieu

>
> Thanks.
>
> --
> Pekka Paalanen
> http://www.iki.fi/pq/

--
Mathieu Desnoyers
Computer Engineering Ph.D. Student, Ecole Polytechnique de Montreal
OpenPGP key fingerprint: 8CD5 52C3 8E3C 4140 715F BA06 3F25 A8FE 3BAE 9A68
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/