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)
committerJason Wessel <jason.wessel@windriver.com>
Thu, 29 Mar 2012 22:41:24 +0000 (17:41 -0500)
commit456ca7ff24841bf2d2a2dfd690fe7d42ef70d932
tree979edc05aadcf59f7f9896ceb4d03b6586f3f19b
parent78724b8ef83fc2bcfbc0a72a7ad8a3ce5ad25e6a
kgdbts: Fix kernel oops with CONFIG_DEBUG_RODATA

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.

Cc: <stable@vger.kernel.org> # >= 2.6.26
Signed-off-by: Jason Wessel <jason.wessel@windriver.com>
drivers/misc/kgdbts.c