History

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.

Jason Wessel committed 14 years ago

Commit 456ca7f1 parent 78724b81 file · +28 −24Browse files

Showing the changes to drivers/misc (1 of 1 file). Show all

Unified · Split

drivers/misc/kgdbts.c+28−24
@@ -885,6 +885,22 @@ static void run_singlestep_break_test(void) · 884 unmodified lines
885885 kgdbts_break_test();
886886 }
887887
888+static void test_debug_rodata(void)
889+{
890+#ifdef CONFIG_DEBUG_RODATA
891+ /* Until there is an api to write to read-only text segments, use
892+ * HW breakpoints for the remainder of any tests, else print a
893+ * failure message if hw breakpoints do not work.
894+ */
895+ if (!(arch_kgdb_ops.flags & KGDB_HW_BREAKPOINT && hwbreaks_ok)) {
896+ eprintk("kgdbts: HW breakpoints BROKEN, ending tests\n");
897+ return;
898+ }
899+ force_hwbrks = 1;
900+ v1printk("kgdbts:Using HW breakpoints for SW breakpoint tests\n");
901+#endif /* CONFIG_DEBUG_RODATA */
902+}
903+
888904 static void kgdbts_run_tests(void)
889905 {
890906 char *ptr;
@@ -907,6 +923,18 @@ static void kgdbts_run_tests(void) · 16 unmodified lines
907923 if (ptr)
908924 sstep_test = simple_strtol(ptr+1, NULL, 10);
909925
926+ /* All HW break point tests */
927+ if (arch_kgdb_ops.flags & KGDB_HW_BREAKPOINT) {
928+ hwbreaks_ok = 1;
929+ v1printk("kgdbts:RUN hw breakpoint test\n");
930+ run_breakpoint_test(1);
931+ v1printk("kgdbts:RUN hw write breakpoint test\n");
932+ run_hw_break_test(1);
933+ v1printk("kgdbts:RUN access write breakpoint test\n");
934+ run_hw_break_test(0);
935+ }
936+ test_debug_rodata();
937+
910938 /* required internal KGDB tests */
911939 v1printk("kgdbts:RUN plant and detach test\n");
912940 run_plant_and_detach_test(0);
@@ -924,35 +952,11 @@ static void kgdbts_run_tests(void) · 11 unmodified lines
924952
925953 /* ===Optional tests=== */
926954
927− /* All HW break point tests */
928− if (arch_kgdb_ops.flags & KGDB_HW_BREAKPOINT) {
929− hwbreaks_ok = 1;
930− v1printk("kgdbts:RUN hw breakpoint test\n");
931− run_breakpoint_test(1);
932− v1printk("kgdbts:RUN hw write breakpoint test\n");
933− run_hw_break_test(1);
934− v1printk("kgdbts:RUN access write breakpoint test\n");
935− run_hw_break_test(0);
936− }
937−
938955 if (nmi_sleep) {
939956 v1printk("kgdbts:RUN NMI sleep %i seconds test\n", nmi_sleep);
940957 run_nmi_sleep_test(nmi_sleep);
941958 }
942959
943−#ifdef CONFIG_DEBUG_RODATA
944− /* Until there is an api to write to read-only text segments, use
945− * HW breakpoints for the remainder of any tests, else print a
946− * failure message if hw breakpoints do not work.
947− */
948− if (!(arch_kgdb_ops.flags & KGDB_HW_BREAKPOINT && hwbreaks_ok)) {
949− eprintk("kgdbts: HW breakpoints do not work,"
950− "skipping remaining tests\n");
951− return;
952− }
953− force_hwbrks = 1;
954−#endif /* CONFIG_DEBUG_RODATA */
955−
956960 /* If the do_fork test is run it will be the last test that is
957961 * executed because a kernel thread will be spawned at the very
958962 * end to unregister the debug hooks.

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t