Skip to content

Commit 4ef333b

Browse files
amitdanielkachhapwilldeacon
authored andcommitted
arm64: traps: Allow force_signal_inject to pass esr error code
Some error signal need to pass proper ARM esr error code to userspace to better identify the cause of the signal. So the function force_signal_inject is extended to pass this as a parameter. The existing code is not affected by this change. Signed-off-by: Amit Daniel Kachhap <amit.kachhap@arm.com> Reviewed-by: Dave Martin <Dave.Martin@arm.com> Link: https://lore.kernel.org/r/20200914083656.21428-3-amit.kachhap@arm.com Signed-off-by: Will Deacon <will@kernel.org>
1 parent 9339693 commit 4ef333b

3 files changed

Lines changed: 10 additions & 10 deletions

File tree

arch/arm64/include/asm/traps.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ struct undef_hook {
2424

2525
void register_undef_hook(struct undef_hook *hook);
2626
void unregister_undef_hook(struct undef_hook *hook);
27-
void force_signal_inject(int signal, int code, unsigned long address);
27+
void force_signal_inject(int signal, int code, unsigned long address, unsigned int err);
2828
void arm64_notify_segfault(unsigned long addr);
2929
void arm64_force_sig_fault(int signo, int code, void __user *addr, const char *str);
3030
void arm64_force_sig_mceerr(int code, void __user *addr, short lsb, const char *str);

arch/arm64/kernel/fpsimd.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -312,7 +312,7 @@ static void fpsimd_save(void)
312312
* re-enter user with corrupt state.
313313
* There's no way to recover, so kill it:
314314
*/
315-
force_signal_inject(SIGKILL, SI_KERNEL, 0);
315+
force_signal_inject(SIGKILL, SI_KERNEL, 0, 0);
316316
return;
317317
}
318318

@@ -936,7 +936,7 @@ void do_sve_acc(unsigned int esr, struct pt_regs *regs)
936936
{
937937
/* Even if we chose not to use SVE, the hardware could still trap: */
938938
if (unlikely(!system_supports_sve()) || WARN_ON(is_compat_task())) {
939-
force_signal_inject(SIGILL, ILL_ILLOPC, regs->pc);
939+
force_signal_inject(SIGILL, ILL_ILLOPC, regs->pc, 0);
940940
return;
941941
}
942942

arch/arm64/kernel/traps.c

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -412,7 +412,7 @@ static int call_undef_hook(struct pt_regs *regs)
412412
return fn ? fn(regs, instr) : 1;
413413
}
414414

415-
void force_signal_inject(int signal, int code, unsigned long address)
415+
void force_signal_inject(int signal, int code, unsigned long address, unsigned int err)
416416
{
417417
const char *desc;
418418
struct pt_regs *regs = current_pt_regs();
@@ -438,7 +438,7 @@ void force_signal_inject(int signal, int code, unsigned long address)
438438
signal = SIGKILL;
439439
}
440440

441-
arm64_notify_die(desc, regs, signal, code, (void __user *)address, 0);
441+
arm64_notify_die(desc, regs, signal, code, (void __user *)address, err);
442442
}
443443

444444
/*
@@ -455,7 +455,7 @@ void arm64_notify_segfault(unsigned long addr)
455455
code = SEGV_ACCERR;
456456
mmap_read_unlock(current->mm);
457457

458-
force_signal_inject(SIGSEGV, code, addr);
458+
force_signal_inject(SIGSEGV, code, addr, 0);
459459
}
460460

461461
void do_undefinstr(struct pt_regs *regs)
@@ -468,14 +468,14 @@ void do_undefinstr(struct pt_regs *regs)
468468
return;
469469

470470
BUG_ON(!user_mode(regs));
471-
force_signal_inject(SIGILL, ILL_ILLOPC, regs->pc);
471+
force_signal_inject(SIGILL, ILL_ILLOPC, regs->pc, 0);
472472
}
473473
NOKPROBE_SYMBOL(do_undefinstr);
474474

475475
void do_bti(struct pt_regs *regs)
476476
{
477477
BUG_ON(!user_mode(regs));
478-
force_signal_inject(SIGILL, ILL_ILLOPC, regs->pc);
478+
force_signal_inject(SIGILL, ILL_ILLOPC, regs->pc, 0);
479479
}
480480
NOKPROBE_SYMBOL(do_bti);
481481

@@ -528,7 +528,7 @@ static void user_cache_maint_handler(unsigned int esr, struct pt_regs *regs)
528528
__user_cache_maint("ic ivau", address, ret);
529529
break;
530530
default:
531-
force_signal_inject(SIGILL, ILL_ILLOPC, regs->pc);
531+
force_signal_inject(SIGILL, ILL_ILLOPC, regs->pc, 0);
532532
return;
533533
}
534534

@@ -581,7 +581,7 @@ static void mrs_handler(unsigned int esr, struct pt_regs *regs)
581581
sysreg = esr_sys64_to_sysreg(esr);
582582

583583
if (do_emulate_mrs(regs, sysreg, rt) != 0)
584-
force_signal_inject(SIGILL, ILL_ILLOPC, regs->pc);
584+
force_signal_inject(SIGILL, ILL_ILLOPC, regs->pc, 0);
585585
}
586586

587587
static void wfi_handler(unsigned int esr, struct pt_regs *regs)

0 commit comments

Comments
 (0)