#define BREAK_INSTR_SIZE       4
 #define BUFMAX                 ((NUMREGBYTES * 2) + 512)
 #define OUTBUFMAX              ((NUMREGBYTES * 2) + 512)
+
+#define BREAK_INSTR            0x7d821008      /* twge r2, r2 */
+
 static inline void arch_kgdb_breakpoint(void)
 {
-       asm(".long 0x7d821008"); /* twge r2, r2 */
+       asm(stringify_in_c(.long BREAK_INSTR));
 }
 #define CACHE_FLUSH_IS_SAFE    1
 #define DBG_MAX_REG_NUM     70
 
 #include <asm/processor.h>
 #include <asm/machdep.h>
 #include <asm/debug.h>
+#include <asm/code-patching.h>
 #include <linux/slab.h>
 
 /*
        if (kgdb_handle_exception(1, SIGTRAP, 0, regs) != 0)
                return 0;
 
-       if (*(u32 *) (regs->nip) == *(u32 *) (&arch_kgdb_ops.gdb_bpt_instr))
+       if (*(u32 *)regs->nip == BREAK_INSTR)
                regs->nip += BREAK_INSTR_SIZE;
 
        return 1;
        return -1;
 }
 
+int kgdb_arch_set_breakpoint(struct kgdb_bkpt *bpt)
+{
+       int err;
+       unsigned int instr;
+       unsigned int *addr = (unsigned int *)bpt->bpt_addr;
+
+       err = probe_kernel_address(addr, instr);
+       if (err)
+               return err;
+
+       err = patch_instruction(addr, BREAK_INSTR);
+       if (err)
+               return -EFAULT;
+
+       *(unsigned int *)bpt->saved_instr = instr;
+
+       return 0;
+}
+
+int kgdb_arch_remove_breakpoint(struct kgdb_bkpt *bpt)
+{
+       int err;
+       unsigned int instr = *(unsigned int *)bpt->saved_instr;
+       unsigned int *addr = (unsigned int *)bpt->bpt_addr;
+
+       err = patch_instruction(addr, instr);
+       if (err)
+               return -EFAULT;
+
+       return 0;
+}
+
 /*
  * Global data
  */
-struct kgdb_arch arch_kgdb_ops = {
-#ifdef __LITTLE_ENDIAN__
-       .gdb_bpt_instr = {0x08, 0x10, 0x82, 0x7d},
-#else
-       .gdb_bpt_instr = {0x7d, 0x82, 0x10, 0x08},
-#endif
-};
+struct kgdb_arch arch_kgdb_ops;
 
 static int kgdb_not_implemented(struct pt_regs *regs)
 {