kgdbts: Fix kernel oops with CONFIG_DEBUG_RODATA
authorJason Wessel <jason.wessel@windriver.com>
Thu, 29 Mar 2012 11:55:44 +0000 (06:55 -0500)
committerLuis Henriques <luis.henriques@canonical.com>
Mon, 30 Apr 2012 18:15:01 +0000 (19:15 +0100)
commit7f0c517eec02413279e506f3aa6c8efd2e283758
treebfe2becd6e755ea0511179944266287957dd5c1e
parent1deaff3335a398729e39daec6008135c50d2fb12
kgdbts: Fix kernel oops with CONFIG_DEBUG_RODATA

BugLink: http://bugs.launchpad.net/bugs/981162

commit 456ca7ff24841bf2d2a2dfd690fe7d42ef70d932 upstream.

On x86 the kgdb test suite will oops when the kernel is compiled with
CONFIG_DEBUG_RODATA and you run the tests after boot time. This is
regression has existed since 2.6.26 by commit: b33cb815 (kgdbts: Use
HW breakpoints with CONFIG_DEBUG_RODATA).

The test suite can use hw breakpoints for all the tests, but it has to
execute the hardware breakpoint specific tests first in order to
determine that the hw breakpoints actually work.  Specifically the
very first test causes an oops:

# echo V1I1 > /sys/module/kgdbts/parameters/kgdbts
kgdb: Registered I/O driver kgdbts.
kgdbts:RUN plant and detach test

Entering kdb (current=0xffff880017aa9320, pid 1078) on processor 0 due to Keyboard Entry
[0]kdb> kgdbts: ERROR PUT: end of test buffer on 'plant_and_detach_test' line 1 expected OK got $E14#aa
WARNING: at drivers/misc/kgdbts.c:730 run_simple_test+0x151/0x2c0()
[...oops clipped...]

This commit re-orders the running of the tests and puts the RODATA
check into its own function so as to correctly avoid the kernel oops
by detecting and using the hw breakpoints.

Signed-off-by: Jason Wessel <jason.wessel@windriver.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Leann Ogasawara <leann.ogasawara@canonical.com>
Signed-off-by: Tim Gardner <tim.gardner@canonical.com>
drivers/misc/kgdbts.c