diff options
author | Benjamin Gray <bgray@linux.ibm.com> | 2023-06-19 17:36:25 +1000 |
---|---|---|
committer | Michael Ellerman <mpe@ellerman.id.au> | 2023-06-19 17:36:26 +1000 |
commit | 5bcba4e6c13f0c889da1f9e67ee10accd9ca4c19 (patch) | |
tree | da6844eb74b2f2a374adf652893f3b6b56f5e952 /arch/powerpc/kernel | |
parent | 0ffd60b782ed79349baf28dd3259c872f39274e9 (diff) | |
download | linux-stable-5bcba4e6c13f0c889da1f9e67ee10accd9ca4c19.tar.gz linux-stable-5bcba4e6c13f0c889da1f9e67ee10accd9ca4c19.tar.bz2 linux-stable-5bcba4e6c13f0c889da1f9e67ee10accd9ca4c19.zip |
powerpc/dexcr: Handle hashchk exception
Recognise and pass the appropriate signal to the user program when a
hashchk instruction triggers. This is independent of allowing
configuration of DEXCR[NPHIE], as a hypervisor can enforce this aspect
regardless of the kernel.
The signal mirrors how ARM reports their similar check failure. For
example, their FPAC handler in arch/arm64/kernel/traps.c do_el0_fpac()
does this. When we fail to read the instruction that caused the fault
we send a segfault, similar to how emulate_math() does it.
Signed-off-by: Benjamin Gray <bgray@linux.ibm.com>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Link: https://msgid.link/20230616034846.311705-5-bgray@linux.ibm.com
Diffstat (limited to 'arch/powerpc/kernel')
-rw-r--r-- | arch/powerpc/kernel/traps.c | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/arch/powerpc/kernel/traps.c b/arch/powerpc/kernel/traps.c index 9bdd79aa51cf..e59ec6d32d37 100644 --- a/arch/powerpc/kernel/traps.c +++ b/arch/powerpc/kernel/traps.c @@ -1516,6 +1516,22 @@ static void do_program_check(struct pt_regs *regs) return; } } + + if (cpu_has_feature(CPU_FTR_DEXCR_NPHIE) && user_mode(regs)) { + ppc_inst_t insn; + + if (get_user_instr(insn, (void __user *)regs->nip)) { + _exception(SIGSEGV, regs, SEGV_MAPERR, regs->nip); + return; + } + + if (ppc_inst_primary_opcode(insn) == 31 && + get_xop(ppc_inst_val(insn)) == OP_31_XOP_HASHCHK) { + _exception(SIGILL, regs, ILL_ILLOPN, regs->nip); + return; + } + } + _exception(SIGTRAP, regs, TRAP_BRKPT, regs->nip); return; } |