asmlinkage void asm_exit_to_user_mode(struct pt_regs *regs);
 
 void do_mem_abort(unsigned long far, unsigned long esr, struct pt_regs *regs);
-void do_undefinstr(struct pt_regs *regs);
+void do_undefinstr(struct pt_regs *regs, unsigned long esr);
 void do_bti(struct pt_regs *regs);
 void do_debug_exception(unsigned long addr_if_watchpoint, unsigned long esr,
                        struct pt_regs *regs);
 
        exit_to_kernel_mode(regs);
 }
 
-static void noinstr el1_undef(struct pt_regs *regs)
+static void noinstr el1_undef(struct pt_regs *regs, unsigned long esr)
 {
        enter_from_kernel_mode(regs);
        local_daif_inherit(regs);
-       do_undefinstr(regs);
+       do_undefinstr(regs, esr);
        local_daif_mask();
        exit_to_kernel_mode(regs);
 }
                break;
        case ESR_ELx_EC_SYS64:
        case ESR_ELx_EC_UNKNOWN:
-               el1_undef(regs);
+               el1_undef(regs, esr);
                break;
        case ESR_ELx_EC_BREAKPT_CUR:
        case ESR_ELx_EC_SOFTSTP_CUR:
        exit_to_user_mode(regs);
 }
 
-static void noinstr el0_undef(struct pt_regs *regs)
+static void noinstr el0_undef(struct pt_regs *regs, unsigned long esr)
 {
        enter_from_user_mode(regs);
        local_daif_restore(DAIF_PROCCTX);
-       do_undefinstr(regs);
+       do_undefinstr(regs, esr);
        exit_to_user_mode(regs);
 }
 
                el0_pc(regs, esr);
                break;
        case ESR_ELx_EC_UNKNOWN:
-               el0_undef(regs);
+               el0_undef(regs, esr);
                break;
        case ESR_ELx_EC_BTI:
                el0_bti(regs);
        case ESR_ELx_EC_CP14_MR:
        case ESR_ELx_EC_CP14_LS:
        case ESR_ELx_EC_CP14_64:
-               el0_undef(regs);
+               el0_undef(regs, esr);
                break;
        case ESR_ELx_EC_CP15_32:
        case ESR_ELx_EC_CP15_64:
 
        force_signal_inject(SIGSEGV, code, addr, 0);
 }
 
-void do_undefinstr(struct pt_regs *regs)
+void do_undefinstr(struct pt_regs *regs, unsigned long esr)
 {
        /* check for AArch32 breakpoint instructions */
        if (!aarch32_break_handler(regs))
                return;
 
        if (!user_mode(regs))
-               die("Oops - Undefined instruction", regs, 0);
+               die("Oops - Undefined instruction", regs, esr);
 
        force_signal_inject(SIGILL, ILL_ILLOPC, regs->pc, 0);
 }
                hook_base = cp15_64_hooks;
                break;
        default:
-               do_undefinstr(regs);
+               do_undefinstr(regs, esr);
                return;
        }
 
         * EL0. Fall back to our usual undefined instruction handler
         * so that we handle these consistently.
         */
-       do_undefinstr(regs);
+       do_undefinstr(regs, esr);
 }
 NOKPROBE_SYMBOL(do_cp15instr);
 #endif
         * back to our usual undefined instruction handler so that we handle
         * these consistently.
         */
-       do_undefinstr(regs);
+       do_undefinstr(regs, esr);
 }
 NOKPROBE_SYMBOL(do_sysinstr);
 
 {
        switch (report_bug(regs->pc, regs)) {
        case BUG_TRAP_TYPE_BUG:
-               die("Oops - BUG", regs, 0);
+               die("Oops - BUG", regs, esr);
                break;
 
        case BUG_TRAP_TYPE_WARN:
         * This is something that might be fixed at some point in the future.
         */
        if (!recover)
-               die("Oops - KASAN", regs, 0);
+               die("Oops - KASAN", regs, esr);
 
        /* If thread survives, skip over the brk instruction and continue: */
        arm64_skip_faulting_instruction(regs, AARCH64_INSN_SIZE);