Skip to content

Commit 611d2d3

Browse files
mrutland-armroxanan1996
authored andcommitted
arm64: consistently pass ESR_ELx to die()
BugLink: https://bugs.launchpad.net/bugs/2046008 commit 0f2cb92 upstream. Currently, bug_handler() and kasan_handler() call die() with '0' as the 'err' value, whereas die_kernel_fault() passes the ESR_ELx value. For consistency, this patch ensures we always pass the ESR_ELx value to die(). As this is only called for exceptions taken from kernel mode, there should be no user-visible change as a result of this patch. For UNDEFINED exceptions, I've had to modify do_undefinstr() and its callers to pass the ESR_ELx value. In all cases the ESR_ELx value had already been read and was available. Signed-off-by: Mark Rutland <[email protected]> Cc: Mark Brown <[email protected]> Cc: Alexandru Elisei <[email protected]> Cc: Amit Daniel Kachhap <[email protected]> Cc: James Morse <[email protected]> Cc: Will Deacon <[email protected]> Reviewed-by: Anshuman Khandual <[email protected]> Reviewed-by: Mark Brown <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Catalin Marinas <[email protected]> Signed-off-by: Jinjie Ruan <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]> Signed-off-by: Kamal Mostafa <[email protected]> Signed-off-by: Stefan Bader <[email protected]>
1 parent 29d1419 commit 611d2d3

File tree

3 files changed

+15
-15
lines changed

3 files changed

+15
-15
lines changed

arch/arm64/include/asm/exception.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ asmlinkage void call_on_irq_stack(struct pt_regs *regs,
5858
asmlinkage void asm_exit_to_user_mode(struct pt_regs *regs);
5959

6060
void do_mem_abort(unsigned long far, unsigned long esr, struct pt_regs *regs);
61-
void do_undefinstr(struct pt_regs *regs);
61+
void do_undefinstr(struct pt_regs *regs, unsigned long esr);
6262
void do_bti(struct pt_regs *regs);
6363
void do_debug_exception(unsigned long addr_if_watchpoint, unsigned long esr,
6464
struct pt_regs *regs);

arch/arm64/kernel/entry-common.c

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -371,11 +371,11 @@ static void noinstr el1_pc(struct pt_regs *regs, unsigned long esr)
371371
exit_to_kernel_mode(regs);
372372
}
373373

374-
static void noinstr el1_undef(struct pt_regs *regs)
374+
static void noinstr el1_undef(struct pt_regs *regs, unsigned long esr)
375375
{
376376
enter_from_kernel_mode(regs);
377377
local_daif_inherit(regs);
378-
do_undefinstr(regs);
378+
do_undefinstr(regs, esr);
379379
local_daif_mask();
380380
exit_to_kernel_mode(regs);
381381
}
@@ -417,7 +417,7 @@ asmlinkage void noinstr el1h_64_sync_handler(struct pt_regs *regs)
417417
break;
418418
case ESR_ELx_EC_SYS64:
419419
case ESR_ELx_EC_UNKNOWN:
420-
el1_undef(regs);
420+
el1_undef(regs, esr);
421421
break;
422422
case ESR_ELx_EC_BREAKPT_CUR:
423423
case ESR_ELx_EC_SOFTSTP_CUR:
@@ -554,11 +554,11 @@ static void noinstr el0_sp(struct pt_regs *regs, unsigned long esr)
554554
exit_to_user_mode(regs);
555555
}
556556

557-
static void noinstr el0_undef(struct pt_regs *regs)
557+
static void noinstr el0_undef(struct pt_regs *regs, unsigned long esr)
558558
{
559559
enter_from_user_mode(regs);
560560
local_daif_restore(DAIF_PROCCTX);
561-
do_undefinstr(regs);
561+
do_undefinstr(regs, esr);
562562
exit_to_user_mode(regs);
563563
}
564564

@@ -639,7 +639,7 @@ asmlinkage void noinstr el0t_64_sync_handler(struct pt_regs *regs)
639639
el0_pc(regs, esr);
640640
break;
641641
case ESR_ELx_EC_UNKNOWN:
642-
el0_undef(regs);
642+
el0_undef(regs, esr);
643643
break;
644644
case ESR_ELx_EC_BTI:
645645
el0_bti(regs);
@@ -755,7 +755,7 @@ asmlinkage void noinstr el0t_32_sync_handler(struct pt_regs *regs)
755755
case ESR_ELx_EC_CP14_MR:
756756
case ESR_ELx_EC_CP14_LS:
757757
case ESR_ELx_EC_CP14_64:
758-
el0_undef(regs);
758+
el0_undef(regs, esr);
759759
break;
760760
case ESR_ELx_EC_CP15_32:
761761
case ESR_ELx_EC_CP15_64:

arch/arm64/kernel/traps.c

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -486,7 +486,7 @@ void arm64_notify_segfault(unsigned long addr)
486486
force_signal_inject(SIGSEGV, code, addr, 0);
487487
}
488488

489-
void do_undefinstr(struct pt_regs *regs)
489+
void do_undefinstr(struct pt_regs *regs, unsigned long esr)
490490
{
491491
/* check for AArch32 breakpoint instructions */
492492
if (!aarch32_break_handler(regs))
@@ -496,7 +496,7 @@ void do_undefinstr(struct pt_regs *regs)
496496
return;
497497

498498
if (!user_mode(regs))
499-
die("Oops - Undefined instruction", regs, 0);
499+
die("Oops - Undefined instruction", regs, esr);
500500

501501
force_signal_inject(SIGILL, ILL_ILLOPC, regs->pc, 0);
502502
}
@@ -755,7 +755,7 @@ void do_cp15instr(unsigned long esr, struct pt_regs *regs)
755755
hook_base = cp15_64_hooks;
756756
break;
757757
default:
758-
do_undefinstr(regs);
758+
do_undefinstr(regs, esr);
759759
return;
760760
}
761761

@@ -770,7 +770,7 @@ void do_cp15instr(unsigned long esr, struct pt_regs *regs)
770770
* EL0. Fall back to our usual undefined instruction handler
771771
* so that we handle these consistently.
772772
*/
773-
do_undefinstr(regs);
773+
do_undefinstr(regs, esr);
774774
}
775775
NOKPROBE_SYMBOL(do_cp15instr);
776776
#endif
@@ -790,7 +790,7 @@ void do_sysinstr(unsigned long esr, struct pt_regs *regs)
790790
* back to our usual undefined instruction handler so that we handle
791791
* these consistently.
792792
*/
793-
do_undefinstr(regs);
793+
do_undefinstr(regs, esr);
794794
}
795795
NOKPROBE_SYMBOL(do_sysinstr);
796796

@@ -966,7 +966,7 @@ static int bug_handler(struct pt_regs *regs, unsigned long esr)
966966
{
967967
switch (report_bug(regs->pc, regs)) {
968968
case BUG_TRAP_TYPE_BUG:
969-
die("Oops - BUG", regs, 0);
969+
die("Oops - BUG", regs, esr);
970970
break;
971971

972972
case BUG_TRAP_TYPE_WARN:
@@ -1034,7 +1034,7 @@ static int kasan_handler(struct pt_regs *regs, unsigned long esr)
10341034
* This is something that might be fixed at some point in the future.
10351035
*/
10361036
if (!recover)
1037-
die("Oops - KASAN", regs, 0);
1037+
die("Oops - KASAN", regs, esr);
10381038

10391039
/* If thread survives, skip over the brk instruction and continue: */
10401040
arm64_skip_faulting_instruction(regs, AARCH64_INSN_SIZE);

0 commit comments

Comments
 (0)