}
 
 /*
- * The D-flag (Debug mask) is set (masked) upon debug exception entry.
- * Kprobes needs to clear (unmask) D-flag -ONLY- in case of recursive
- * probe i.e. when probe hit from kprobe handler context upon
- * executing the pre/post handlers. In this case we return with
- * D-flag clear so that single-stepping can be carried-out.
- *
- * Leave D-flag set in all other cases.
+ * When PSTATE.D is set (masked), then software step exceptions can not be
+ * generated.
+ * SPSR's D bit shows the value of PSTATE.D immediately before the
+ * exception was taken. PSTATE.D is set while entering into any exception
+ * mode, however software clears it for any normal (none-debug-exception)
+ * mode in the exception entry. Therefore, when we are entering into kprobe
+ * breakpoint handler from any normal mode then SPSR.D bit is already
+ * cleared, however it is set when we are entering from any debug exception
+ * mode.
+ * Since we always need to generate single step exception after a kprobe
+ * breakpoint exception therefore we need to clear it unconditionally, when
+ * we become sure that the current breakpoint exception is for kprobe.
  */
 static void __kprobes
 spsr_set_debug_flag(struct pt_regs *regs, int mask)
 
                set_ss_context(kcb, slot);      /* mark pending ss */
 
-               if (kcb->kprobe_status == KPROBE_REENTER)
-                       spsr_set_debug_flag(regs, 0);
-               else
-                       WARN_ON(regs->pstate & PSR_D_BIT);
+               spsr_set_debug_flag(regs, 0);
 
                /* IRQs and single stepping do not mix well. */
                kprobes_save_local_irqflag(kcb, regs);
                        BUG();
 
                kernel_disable_single_step();
-               if (kcb->kprobe_status == KPROBE_REENTER)
-                       spsr_set_debug_flag(regs, 1);
 
                if (kcb->kprobe_status == KPROBE_REENTER)
                        restore_previous_kprobe(kcb);
                kprobes_restore_local_irqflag(kcb, regs);
                kernel_disable_single_step();
 
-               if (kcb->kprobe_status == KPROBE_REENTER)
-                       spsr_set_debug_flag(regs, 1);
-
                post_kprobe_handler(kcb, regs);
        }