aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/misc
diff options
context:
space:
mode:
authorJason Wessel <jason.wessel@windriver.com>2008-05-28 13:49:57 -0400
committerJason Wessel <jason.wessel@windriver.com>2008-05-28 13:49:57 -0400
commitb33cb815b565a94c654a0fe8e62e36f5b4053888 (patch)
treecf0c5213903420338e71c44fc14322d34cc1c488 /drivers/misc
parent827e609b4581282b98bdf7666f6e93ff1bd1a63e (diff)
kgdbts: Use HW breakpoints with CONFIG_DEBUG_RODATA
Whenever CONFIG_DEBUG_RODATA is set in the kernel config many kernel text sections become read-only, and the use of software breakpoints in the kgdb tests will cause the kernel to fail to complete the start up. Until such time that there is an official API for modifying read-only text sections hardware breakpoints must be used to run the do_fork or sys_open tests or the tests get skipped. Also fix the duplicated include reported by: Huang Weiyi <weiyi.huang@gmail.com> Signed-off-by: Jason Wessel <jason.wessel@windriver.com>
Diffstat (limited to 'drivers/misc')
-rw-r--r--drivers/misc/kgdbts.c28
1 files changed, 24 insertions, 4 deletions
diff --git a/drivers/misc/kgdbts.c b/drivers/misc/kgdbts.c
index 2763ae086531..e4ff50b95a5e 100644
--- a/drivers/misc/kgdbts.c
+++ b/drivers/misc/kgdbts.c
@@ -102,7 +102,6 @@
102#include <linux/nmi.h> 102#include <linux/nmi.h>
103#include <linux/delay.h> 103#include <linux/delay.h>
104#include <linux/kthread.h> 104#include <linux/kthread.h>
105#include <linux/delay.h>
106 105
107#define v1printk(a...) do { \ 106#define v1printk(a...) do { \
108 if (verbose) \ 107 if (verbose) \
@@ -130,6 +129,8 @@ static int repeat_test;
130static int test_complete; 129static int test_complete;
131static int send_ack; 130static int send_ack;
132static int final_ack; 131static int final_ack;
132static int force_hwbrks;
133static int hwbreaks_ok;
133static int hw_break_val; 134static int hw_break_val;
134static int hw_break_val2; 135static int hw_break_val2;
135#if defined(CONFIG_ARM) || defined(CONFIG_MIPS) || defined(CONFIG_SPARC) 136#if defined(CONFIG_ARM) || defined(CONFIG_MIPS) || defined(CONFIG_SPARC)
@@ -233,12 +234,12 @@ static void break_helper(char *bp_type, char *arg, unsigned long vaddr)
233 234
234static void sw_break(char *arg) 235static void sw_break(char *arg)
235{ 236{
236 break_helper("Z0", arg, 0); 237 break_helper(force_hwbrks ? "Z1" : "Z0", arg, 0);
237} 238}
238 239
239static void sw_rem_break(char *arg) 240static void sw_rem_break(char *arg)
240{ 241{
241 break_helper("z0", arg, 0); 242 break_helper(force_hwbrks ? "z1" : "z0", arg, 0);
242} 243}
243 244
244static void hw_break(char *arg) 245static void hw_break(char *arg)
@@ -780,6 +781,8 @@ static void run_breakpoint_test(int is_hw_breakpoint)
780 return; 781 return;
781 782
782 eprintk("kgdbts: ERROR %s test failed\n", ts.name); 783 eprintk("kgdbts: ERROR %s test failed\n", ts.name);
784 if (is_hw_breakpoint)
785 hwbreaks_ok = 0;
783} 786}
784 787
785static void run_hw_break_test(int is_write_test) 788static void run_hw_break_test(int is_write_test)
@@ -797,9 +800,11 @@ static void run_hw_break_test(int is_write_test)
797 kgdb_breakpoint(); 800 kgdb_breakpoint();
798 hw_break_val_access(); 801 hw_break_val_access();
799 if (is_write_test) { 802 if (is_write_test) {
800 if (test_complete == 2) 803 if (test_complete == 2) {
801 eprintk("kgdbts: ERROR %s broke on access\n", 804 eprintk("kgdbts: ERROR %s broke on access\n",
802 ts.name); 805 ts.name);
806 hwbreaks_ok = 0;
807 }
803 hw_break_val_write(); 808 hw_break_val_write();
804 } 809 }
805 kgdb_breakpoint(); 810 kgdb_breakpoint();
@@ -808,6 +813,7 @@ static void run_hw_break_test(int is_write_test)
808 return; 813 return;
809 814
810 eprintk("kgdbts: ERROR %s test failed\n", ts.name); 815 eprintk("kgdbts: ERROR %s test failed\n", ts.name);
816 hwbreaks_ok = 0;
811} 817}
812 818
813static void run_nmi_sleep_test(int nmi_sleep) 819static void run_nmi_sleep_test(int nmi_sleep)
@@ -911,6 +917,7 @@ static void kgdbts_run_tests(void)
911 917
912 /* All HW break point tests */ 918 /* All HW break point tests */
913 if (arch_kgdb_ops.flags & KGDB_HW_BREAKPOINT) { 919 if (arch_kgdb_ops.flags & KGDB_HW_BREAKPOINT) {
920 hwbreaks_ok = 1;
914 v1printk("kgdbts:RUN hw breakpoint test\n"); 921 v1printk("kgdbts:RUN hw breakpoint test\n");
915 run_breakpoint_test(1); 922 run_breakpoint_test(1);
916 v1printk("kgdbts:RUN hw write breakpoint test\n"); 923 v1printk("kgdbts:RUN hw write breakpoint test\n");
@@ -924,6 +931,19 @@ static void kgdbts_run_tests(void)
924 run_nmi_sleep_test(nmi_sleep); 931 run_nmi_sleep_test(nmi_sleep);
925 } 932 }
926 933
934#ifdef CONFIG_DEBUG_RODATA
935 /* Until there is an api to write to read-only text segments, use
936 * HW breakpoints for the remainder of any tests, else print a
937 * failure message if hw breakpoints do not work.
938 */
939 if (!(arch_kgdb_ops.flags & KGDB_HW_BREAKPOINT && hwbreaks_ok)) {
940 eprintk("kgdbts: HW breakpoints do not work,"
941 "skipping remaining tests\n");
942 return;
943 }
944 force_hwbrks = 1;
945#endif /* CONFIG_DEBUG_RODATA */
946
927 /* If the do_fork test is run it will be the last test that is 947 /* If the do_fork test is run it will be the last test that is
928 * executed because a kernel thread will be spawned at the very 948 * executed because a kernel thread will be spawned at the very
929 * end to unregister the debug hooks. 949 * end to unregister the debug hooks.