2 * This program is free software; you can redistribute it and/or modify it
3 * under the terms of the GNU General Public License as published by the
4 * Free Software Foundation; either version 2, or (at your option) any
7 * This program is distributed in the hope that it will be useful, but
8 * WITHOUT ANY WARRANTY; without even the implied warranty of
9 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
10 * General Public License for more details.
15 * Copyright (C) 2004 Amit S. Kale <amitkale@linsyssoft.com>
16 * Copyright (C) 2000-2001 VERITAS Software Corporation.
17 * Copyright (C) 2002 Andi Kleen, SuSE Labs
18 * Copyright (C) 2004 LinSysSoft Technologies Pvt. Ltd.
19 * Copyright (C) 2007 MontaVista Software, Inc.
20 * Copyright (C) 2007-2008 Jason Wessel, Wind River Systems, Inc.
22 /****************************************************************************
23 * Contributor: Lake Stevens Instrument Division$
24 * Written by: Glenn Engel $
25 * Updated by: Amit Kale<akale@veritas.com>
26 * Updated by: Tom Rini <trini@kernel.crashing.org>
27 * Updated by: Jason Wessel <jason.wessel@windriver.com>
28 * Modified for 386 by Jim Kingdon, Cygnus Support.
29 * Origianl kgdb, compatibility with 2.1.xx kernel by
30 * David Grothe <dave@gcom.com>
31 * Integrated into 2.2.5 kernel by Tigran Aivazian <tigran@sco.com>
32 * X86_64 changes from Andi Kleen's patch merged by Jim Houston
34 #include <linux/spinlock.h>
35 #include <linux/kdebug.h>
36 #include <linux/string.h>
37 #include <linux/kernel.h>
38 #include <linux/ptrace.h>
39 #include <linux/sched.h>
40 #include <linux/delay.h>
41 #include <linux/kgdb.h>
42 #include <linux/smp.h>
43 #include <linux/nmi.h>
44 #include <linux/hw_breakpoint.h>
45 #include <linux/uaccess.h>
46 #include <linux/memory.h>
48 #include <asm/text-patching.h>
49 #include <asm/debugreg.h>
50 #include <asm/apicdef.h>
53 #include <asm/switch_to.h>
55 struct dbg_reg_def_t dbg_reg_def
[DBG_MAX_REG_NUM
] =
58 { "ax", 4, offsetof(struct pt_regs
, ax
) },
59 { "cx", 4, offsetof(struct pt_regs
, cx
) },
60 { "dx", 4, offsetof(struct pt_regs
, dx
) },
61 { "bx", 4, offsetof(struct pt_regs
, bx
) },
62 { "sp", 4, offsetof(struct pt_regs
, sp
) },
63 { "bp", 4, offsetof(struct pt_regs
, bp
) },
64 { "si", 4, offsetof(struct pt_regs
, si
) },
65 { "di", 4, offsetof(struct pt_regs
, di
) },
66 { "ip", 4, offsetof(struct pt_regs
, ip
) },
67 { "flags", 4, offsetof(struct pt_regs
, flags
) },
68 { "cs", 4, offsetof(struct pt_regs
, cs
) },
69 { "ss", 4, offsetof(struct pt_regs
, ss
) },
70 { "ds", 4, offsetof(struct pt_regs
, ds
) },
71 { "es", 4, offsetof(struct pt_regs
, es
) },
73 { "ax", 8, offsetof(struct pt_regs
, ax
) },
74 { "bx", 8, offsetof(struct pt_regs
, bx
) },
75 { "cx", 8, offsetof(struct pt_regs
, cx
) },
76 { "dx", 8, offsetof(struct pt_regs
, dx
) },
77 { "si", 8, offsetof(struct pt_regs
, si
) },
78 { "di", 8, offsetof(struct pt_regs
, di
) },
79 { "bp", 8, offsetof(struct pt_regs
, bp
) },
80 { "sp", 8, offsetof(struct pt_regs
, sp
) },
81 { "r8", 8, offsetof(struct pt_regs
, r8
) },
82 { "r9", 8, offsetof(struct pt_regs
, r9
) },
83 { "r10", 8, offsetof(struct pt_regs
, r10
) },
84 { "r11", 8, offsetof(struct pt_regs
, r11
) },
85 { "r12", 8, offsetof(struct pt_regs
, r12
) },
86 { "r13", 8, offsetof(struct pt_regs
, r13
) },
87 { "r14", 8, offsetof(struct pt_regs
, r14
) },
88 { "r15", 8, offsetof(struct pt_regs
, r15
) },
89 { "ip", 8, offsetof(struct pt_regs
, ip
) },
90 { "flags", 4, offsetof(struct pt_regs
, flags
) },
91 { "cs", 4, offsetof(struct pt_regs
, cs
) },
92 { "ss", 4, offsetof(struct pt_regs
, ss
) },
100 int dbg_set_reg(int regno
, void *mem
, struct pt_regs
*regs
)
104 regno
== GDB_SS
|| regno
== GDB_FS
|| regno
== GDB_GS
||
106 regno
== GDB_SP
|| regno
== GDB_ORIG_AX
)
109 if (dbg_reg_def
[regno
].offset
!= -1)
110 memcpy((void *)regs
+ dbg_reg_def
[regno
].offset
, mem
,
111 dbg_reg_def
[regno
].size
);
115 char *dbg_get_reg(int regno
, void *mem
, struct pt_regs
*regs
)
117 if (regno
== GDB_ORIG_AX
) {
118 memcpy(mem
, ®s
->orig_ax
, sizeof(regs
->orig_ax
));
121 if (regno
>= DBG_MAX_REG_NUM
|| regno
< 0)
124 if (dbg_reg_def
[regno
].offset
!= -1)
125 memcpy(mem
, (void *)regs
+ dbg_reg_def
[regno
].offset
,
126 dbg_reg_def
[regno
].size
);
131 if (!user_mode(regs
))
132 *(unsigned long *)mem
= __KERNEL_DS
;
135 if (!user_mode(regs
))
136 *(unsigned long *)mem
= kernel_stack_pointer(regs
);
140 *(unsigned long *)mem
= 0xFFFF;
144 return dbg_reg_def
[regno
].name
;
148 * sleeping_thread_to_gdb_regs - Convert ptrace regs to GDB regs
149 * @gdb_regs: A pointer to hold the registers in the order GDB wants.
150 * @p: The &struct task_struct of the desired process.
152 * Convert the register values of the sleeping process in @p to
153 * the format that GDB expects.
154 * This function is called when kgdb does not have access to the
155 * &struct pt_regs and therefore it should fill the gdb registers
156 * @gdb_regs with what has been saved in &struct thread_struct
157 * thread field during switch_to.
159 void sleeping_thread_to_gdb_regs(unsigned long *gdb_regs
, struct task_struct
*p
)
161 #ifndef CONFIG_X86_32
162 u32
*gdb_regs32
= (u32
*)gdb_regs
;
164 gdb_regs
[GDB_AX
] = 0;
165 gdb_regs
[GDB_BX
] = 0;
166 gdb_regs
[GDB_CX
] = 0;
167 gdb_regs
[GDB_DX
] = 0;
168 gdb_regs
[GDB_SI
] = 0;
169 gdb_regs
[GDB_DI
] = 0;
170 gdb_regs
[GDB_BP
] = ((struct inactive_task_frame
*)p
->thread
.sp
)->bp
;
172 gdb_regs
[GDB_DS
] = __KERNEL_DS
;
173 gdb_regs
[GDB_ES
] = __KERNEL_DS
;
174 gdb_regs
[GDB_PS
] = 0;
175 gdb_regs
[GDB_CS
] = __KERNEL_CS
;
176 gdb_regs
[GDB_SS
] = __KERNEL_DS
;
177 gdb_regs
[GDB_FS
] = 0xFFFF;
178 gdb_regs
[GDB_GS
] = 0xFFFF;
180 gdb_regs32
[GDB_PS
] = 0;
181 gdb_regs32
[GDB_CS
] = __KERNEL_CS
;
182 gdb_regs32
[GDB_SS
] = __KERNEL_DS
;
183 gdb_regs
[GDB_R8
] = 0;
184 gdb_regs
[GDB_R9
] = 0;
185 gdb_regs
[GDB_R10
] = 0;
186 gdb_regs
[GDB_R11
] = 0;
187 gdb_regs
[GDB_R12
] = 0;
188 gdb_regs
[GDB_R13
] = 0;
189 gdb_regs
[GDB_R14
] = 0;
190 gdb_regs
[GDB_R15
] = 0;
192 gdb_regs
[GDB_PC
] = 0;
193 gdb_regs
[GDB_SP
] = p
->thread
.sp
;
196 static struct hw_breakpoint
{
201 struct perf_event
* __percpu
*pev
;
202 } breakinfo
[HBP_NUM
];
204 static unsigned long early_dr7
;
206 static void kgdb_correct_hw_break(void)
210 for (breakno
= 0; breakno
< HBP_NUM
; breakno
++) {
211 struct perf_event
*bp
;
212 struct arch_hw_breakpoint
*info
;
214 int cpu
= raw_smp_processor_id();
215 if (!breakinfo
[breakno
].enabled
)
218 set_debugreg(breakinfo
[breakno
].addr
, breakno
);
219 early_dr7
|= encode_dr7(breakno
,
220 breakinfo
[breakno
].len
,
221 breakinfo
[breakno
].type
);
222 set_debugreg(early_dr7
, 7);
225 bp
= *per_cpu_ptr(breakinfo
[breakno
].pev
, cpu
);
226 info
= counter_arch_bp(bp
);
227 if (bp
->attr
.disabled
!= 1)
229 bp
->attr
.bp_addr
= breakinfo
[breakno
].addr
;
230 bp
->attr
.bp_len
= breakinfo
[breakno
].len
;
231 bp
->attr
.bp_type
= breakinfo
[breakno
].type
;
232 info
->address
= breakinfo
[breakno
].addr
;
233 info
->len
= breakinfo
[breakno
].len
;
234 info
->type
= breakinfo
[breakno
].type
;
235 val
= arch_install_hw_breakpoint(bp
);
237 bp
->attr
.disabled
= 0;
240 hw_breakpoint_restore();
243 static int hw_break_reserve_slot(int breakno
)
247 struct perf_event
**pevent
;
252 for_each_online_cpu(cpu
) {
254 pevent
= per_cpu_ptr(breakinfo
[breakno
].pev
, cpu
);
255 if (dbg_reserve_bp_slot(*pevent
))
262 for_each_online_cpu(cpu
) {
266 pevent
= per_cpu_ptr(breakinfo
[breakno
].pev
, cpu
);
267 dbg_release_bp_slot(*pevent
);
272 static int hw_break_release_slot(int breakno
)
274 struct perf_event
**pevent
;
280 for_each_online_cpu(cpu
) {
281 pevent
= per_cpu_ptr(breakinfo
[breakno
].pev
, cpu
);
282 if (dbg_release_bp_slot(*pevent
))
284 * The debugger is responsible for handing the retry on
293 kgdb_remove_hw_break(unsigned long addr
, int len
, enum kgdb_bptype bptype
)
297 for (i
= 0; i
< HBP_NUM
; i
++)
298 if (breakinfo
[i
].addr
== addr
&& breakinfo
[i
].enabled
)
303 if (hw_break_release_slot(i
)) {
304 printk(KERN_ERR
"Cannot remove hw breakpoint at %lx\n", addr
);
307 breakinfo
[i
].enabled
= 0;
312 static void kgdb_remove_all_hw_break(void)
315 int cpu
= raw_smp_processor_id();
316 struct perf_event
*bp
;
318 for (i
= 0; i
< HBP_NUM
; i
++) {
319 if (!breakinfo
[i
].enabled
)
321 bp
= *per_cpu_ptr(breakinfo
[i
].pev
, cpu
);
322 if (!bp
->attr
.disabled
) {
323 arch_uninstall_hw_breakpoint(bp
);
324 bp
->attr
.disabled
= 1;
328 early_dr7
&= ~encode_dr7(i
, breakinfo
[i
].len
,
330 else if (hw_break_release_slot(i
))
331 printk(KERN_ERR
"KGDB: hw bpt remove failed %lx\n",
333 breakinfo
[i
].enabled
= 0;
338 kgdb_set_hw_break(unsigned long addr
, int len
, enum kgdb_bptype bptype
)
342 for (i
= 0; i
< HBP_NUM
; i
++)
343 if (!breakinfo
[i
].enabled
)
349 case BP_HARDWARE_BREAKPOINT
:
351 breakinfo
[i
].type
= X86_BREAKPOINT_EXECUTE
;
353 case BP_WRITE_WATCHPOINT
:
354 breakinfo
[i
].type
= X86_BREAKPOINT_WRITE
;
356 case BP_ACCESS_WATCHPOINT
:
357 breakinfo
[i
].type
= X86_BREAKPOINT_RW
;
364 breakinfo
[i
].len
= X86_BREAKPOINT_LEN_1
;
367 breakinfo
[i
].len
= X86_BREAKPOINT_LEN_2
;
370 breakinfo
[i
].len
= X86_BREAKPOINT_LEN_4
;
374 breakinfo
[i
].len
= X86_BREAKPOINT_LEN_8
;
380 breakinfo
[i
].addr
= addr
;
381 if (hw_break_reserve_slot(i
)) {
382 breakinfo
[i
].addr
= 0;
385 breakinfo
[i
].enabled
= 1;
391 * kgdb_disable_hw_debug - Disable hardware debugging while we in kgdb.
392 * @regs: Current &struct pt_regs.
394 * This function will be called if the particular architecture must
395 * disable hardware debugging while it is processing gdb packets or
396 * handling exception.
398 static void kgdb_disable_hw_debug(struct pt_regs
*regs
)
401 int cpu
= raw_smp_processor_id();
402 struct perf_event
*bp
;
404 /* Disable hardware debugging while we are in kgdb: */
405 set_debugreg(0UL, 7);
406 for (i
= 0; i
< HBP_NUM
; i
++) {
407 if (!breakinfo
[i
].enabled
)
410 early_dr7
&= ~encode_dr7(i
, breakinfo
[i
].len
,
414 bp
= *per_cpu_ptr(breakinfo
[i
].pev
, cpu
);
415 if (bp
->attr
.disabled
== 1)
417 arch_uninstall_hw_breakpoint(bp
);
418 bp
->attr
.disabled
= 1;
424 * kgdb_roundup_cpus - Get other CPUs into a holding pattern
425 * @flags: Current IRQ state
427 * On SMP systems, we need to get the attention of the other CPUs
428 * and get them be in a known state. This should do what is needed
429 * to get the other CPUs to call kgdb_wait(). Note that on some arches,
430 * the NMI approach is not used for rounding up all the CPUs. For example,
431 * in case of MIPS, smp_call_function() is used to roundup CPUs. In
432 * this case, we have to make sure that interrupts are enabled before
433 * calling smp_call_function(). The argument to this function is
434 * the flags that will be used when restoring the interrupts. There is
435 * local_irq_save() call before kgdb_roundup_cpus().
437 * On non-SMP systems, this is not called.
439 void kgdb_roundup_cpus(unsigned long flags
)
441 apic
->send_IPI_allbutself(APIC_DM_NMI
);
446 * kgdb_arch_handle_exception - Handle architecture specific GDB packets.
447 * @e_vector: The error vector of the exception that happened.
448 * @signo: The signal number of the exception that happened.
449 * @err_code: The error code of the exception that happened.
450 * @remcomInBuffer: The buffer of the packet we have read.
451 * @remcomOutBuffer: The buffer of %BUFMAX bytes to write a packet into.
452 * @linux_regs: The &struct pt_regs of the current process.
454 * This function MUST handle the 'c' and 's' command packets,
455 * as well packets to set / remove a hardware breakpoint, if used.
456 * If there are additional packets which the hardware needs to handle,
457 * they are handled here. The code should return -1 if it wants to
458 * process more packets, and a %0 or %1 if it wants to exit from the
461 int kgdb_arch_handle_exception(int e_vector
, int signo
, int err_code
,
462 char *remcomInBuffer
, char *remcomOutBuffer
,
463 struct pt_regs
*linux_regs
)
468 switch (remcomInBuffer
[0]) {
471 /* try to read optional parameter, pc unchanged if no parm */
472 ptr
= &remcomInBuffer
[1];
473 if (kgdb_hex2long(&ptr
, &addr
))
474 linux_regs
->ip
= addr
;
477 /* clear the trace bit */
478 linux_regs
->flags
&= ~X86_EFLAGS_TF
;
479 atomic_set(&kgdb_cpu_doing_single_step
, -1);
481 /* set the trace bit if we're stepping */
482 if (remcomInBuffer
[0] == 's') {
483 linux_regs
->flags
|= X86_EFLAGS_TF
;
484 atomic_set(&kgdb_cpu_doing_single_step
,
485 raw_smp_processor_id());
491 /* this means that we do not want to exit from the handler: */
496 single_step_cont(struct pt_regs
*regs
, struct die_args
*args
)
499 * Single step exception from kernel space to user space so
500 * eat the exception and continue the process:
502 printk(KERN_ERR
"KGDB: trap/step from kernel to user space, "
504 kgdb_arch_handle_exception(args
->trapnr
, args
->signr
,
505 args
->err
, "c", "", regs
);
507 * Reset the BS bit in dr6 (pointed by args->err) to
508 * denote completion of processing
510 (*(unsigned long *)ERR_PTR(args
->err
)) &= ~DR_STEP
;
515 static DECLARE_BITMAP(was_in_debug_nmi
, NR_CPUS
);
517 static int kgdb_nmi_handler(unsigned int cmd
, struct pt_regs
*regs
)
523 if (atomic_read(&kgdb_active
) != -1) {
524 /* KGDB CPU roundup */
525 cpu
= raw_smp_processor_id();
526 kgdb_nmicallback(cpu
, regs
);
527 set_bit(cpu
, was_in_debug_nmi
);
528 touch_nmi_watchdog();
535 cpu
= raw_smp_processor_id();
537 if (__test_and_clear_bit(cpu
, was_in_debug_nmi
))
548 static int __kgdb_notify(struct die_args
*args
, unsigned long cmd
)
550 struct pt_regs
*regs
= args
->regs
;
554 if (atomic_read(&kgdb_cpu_doing_single_step
) != -1) {
556 return single_step_cont(regs
, args
);
558 } else if (test_thread_flag(TIF_SINGLESTEP
))
559 /* This means a user thread is single stepping
560 * a system call which should be ignored
569 if (kgdb_handle_exception(args
->trapnr
, args
->signr
, cmd
, regs
))
572 /* Must touch watchdog before return to normal operation */
573 touch_nmi_watchdog();
577 int kgdb_ll_trap(int cmd
, const char *str
,
578 struct pt_regs
*regs
, long err
, int trap
, int sig
)
580 struct die_args args
= {
589 if (!kgdb_io_module_registered
)
592 return __kgdb_notify(&args
, cmd
);
596 kgdb_notify(struct notifier_block
*self
, unsigned long cmd
, void *ptr
)
601 local_irq_save(flags
);
602 ret
= __kgdb_notify(ptr
, cmd
);
603 local_irq_restore(flags
);
608 static struct notifier_block kgdb_notifier
= {
609 .notifier_call
= kgdb_notify
,
613 * kgdb_arch_init - Perform any architecture specific initialization.
615 * This function will handle the initialization of any architecture
616 * specific callbacks.
618 int kgdb_arch_init(void)
622 retval
= register_die_notifier(&kgdb_notifier
);
626 retval
= register_nmi_handler(NMI_LOCAL
, kgdb_nmi_handler
,
631 retval
= register_nmi_handler(NMI_UNKNOWN
, kgdb_nmi_handler
,
640 unregister_nmi_handler(NMI_LOCAL
, "kgdb");
642 unregister_die_notifier(&kgdb_notifier
);
647 static void kgdb_hw_overflow_handler(struct perf_event
*event
,
648 struct perf_sample_data
*data
, struct pt_regs
*regs
)
650 struct task_struct
*tsk
= current
;
653 for (i
= 0; i
< 4; i
++)
654 if (breakinfo
[i
].enabled
)
655 tsk
->thread
.debugreg6
|= (DR_TRAP0
<< i
);
658 void kgdb_arch_late(void)
661 struct perf_event_attr attr
;
662 struct perf_event
**pevent
;
665 * Pre-allocate the hw breakpoint structions in the non-atomic
666 * portion of kgdb because this operation requires mutexs to
669 hw_breakpoint_init(&attr
);
670 attr
.bp_addr
= (unsigned long)kgdb_arch_init
;
671 attr
.bp_len
= HW_BREAKPOINT_LEN_1
;
672 attr
.bp_type
= HW_BREAKPOINT_W
;
674 for (i
= 0; i
< HBP_NUM
; i
++) {
675 if (breakinfo
[i
].pev
)
677 breakinfo
[i
].pev
= register_wide_hw_breakpoint(&attr
, NULL
, NULL
);
678 if (IS_ERR((void * __force
)breakinfo
[i
].pev
)) {
679 printk(KERN_ERR
"kgdb: Could not allocate hw"
680 "breakpoints\nDisabling the kernel debugger\n");
681 breakinfo
[i
].pev
= NULL
;
685 for_each_online_cpu(cpu
) {
686 pevent
= per_cpu_ptr(breakinfo
[i
].pev
, cpu
);
687 pevent
[0]->hw
.sample_period
= 1;
688 pevent
[0]->overflow_handler
= kgdb_hw_overflow_handler
;
689 if (pevent
[0]->destroy
!= NULL
) {
690 pevent
[0]->destroy
= NULL
;
691 release_bp_slot(*pevent
);
698 * kgdb_arch_exit - Perform any architecture specific uninitalization.
700 * This function will handle the uninitalization of any architecture
701 * specific callbacks, for dynamic registration and unregistration.
703 void kgdb_arch_exit(void)
706 for (i
= 0; i
< 4; i
++) {
707 if (breakinfo
[i
].pev
) {
708 unregister_wide_hw_breakpoint(breakinfo
[i
].pev
);
709 breakinfo
[i
].pev
= NULL
;
712 unregister_nmi_handler(NMI_UNKNOWN
, "kgdb");
713 unregister_nmi_handler(NMI_LOCAL
, "kgdb");
714 unregister_die_notifier(&kgdb_notifier
);
719 * kgdb_skipexception - Bail out of KGDB when we've been triggered.
720 * @exception: Exception vector number
721 * @regs: Current &struct pt_regs.
723 * On some architectures we need to skip a breakpoint exception when
724 * it occurs after a breakpoint has been removed.
726 * Skip an int3 exception when it occurs after a breakpoint has been
727 * removed. Backtrack eip by 1 since the int3 would have caused it to
730 int kgdb_skipexception(int exception
, struct pt_regs
*regs
)
732 if (exception
== 3 && kgdb_isremovedbreak(regs
->ip
- 1)) {
739 unsigned long kgdb_arch_pc(int exception
, struct pt_regs
*regs
)
742 return instruction_pointer(regs
) - 1;
743 return instruction_pointer(regs
);
746 void kgdb_arch_set_pc(struct pt_regs
*regs
, unsigned long ip
)
751 int kgdb_arch_set_breakpoint(struct kgdb_bkpt
*bpt
)
754 char opc
[BREAK_INSTR_SIZE
];
756 bpt
->type
= BP_BREAKPOINT
;
757 err
= probe_kernel_read(bpt
->saved_instr
, (char *)bpt
->bpt_addr
,
761 err
= probe_kernel_write((char *)bpt
->bpt_addr
,
762 arch_kgdb_ops
.gdb_bpt_instr
, BREAK_INSTR_SIZE
);
766 * It is safe to call text_poke() because normal kernel execution
767 * is stopped on all cores, so long as the text_mutex is not locked.
769 if (mutex_is_locked(&text_mutex
))
771 text_poke((void *)bpt
->bpt_addr
, arch_kgdb_ops
.gdb_bpt_instr
,
773 err
= probe_kernel_read(opc
, (char *)bpt
->bpt_addr
, BREAK_INSTR_SIZE
);
776 if (memcmp(opc
, arch_kgdb_ops
.gdb_bpt_instr
, BREAK_INSTR_SIZE
))
778 bpt
->type
= BP_POKE_BREAKPOINT
;
783 int kgdb_arch_remove_breakpoint(struct kgdb_bkpt
*bpt
)
786 char opc
[BREAK_INSTR_SIZE
];
788 if (bpt
->type
!= BP_POKE_BREAKPOINT
)
791 * It is safe to call text_poke() because normal kernel execution
792 * is stopped on all cores, so long as the text_mutex is not locked.
794 if (mutex_is_locked(&text_mutex
))
796 text_poke((void *)bpt
->bpt_addr
, bpt
->saved_instr
, BREAK_INSTR_SIZE
);
797 err
= probe_kernel_read(opc
, (char *)bpt
->bpt_addr
, BREAK_INSTR_SIZE
);
798 if (err
|| memcmp(opc
, bpt
->saved_instr
, BREAK_INSTR_SIZE
))
803 return probe_kernel_write((char *)bpt
->bpt_addr
,
804 (char *)bpt
->saved_instr
, BREAK_INSTR_SIZE
);
807 struct kgdb_arch arch_kgdb_ops
= {
808 /* Breakpoint instruction: */
809 .gdb_bpt_instr
= { 0xcc },
810 .flags
= KGDB_HW_BREAKPOINT
,
811 .set_hw_breakpoint
= kgdb_set_hw_break
,
812 .remove_hw_breakpoint
= kgdb_remove_hw_break
,
813 .disable_hw_break
= kgdb_disable_hw_debug
,
814 .remove_all_hw_break
= kgdb_remove_all_hw_break
,
815 .correct_hw_break
= kgdb_correct_hw_break
,