powerpc/ptrace: Expose DEXCR and HDEXCR registers to ptrace
authorBenjamin Gray <bgray@linux.ibm.com>
Mon, 19 Jun 2023 07:36:26 +0000 (17:36 +1000)
committerMichael Ellerman <mpe@ellerman.id.au>
Mon, 19 Jun 2023 07:36:26 +0000 (17:36 +1000)
commit884ad5c52da253e5d38f947cd8d1d9412a47429c
tree48ecae3a0bdfe4a4ae24769b9231c118263db676
parentbe98fcf7c10dea74e9c3e2cd0018e47bdee67442
powerpc/ptrace: Expose DEXCR and HDEXCR registers to ptrace

The DEXCR register is of interest when ptracing processes. Currently it
is static, but eventually will be dynamically controllable by a process.
If a process can control its own, then it is useful for it to be
ptrace-able to (e.g., for checkpoint-restore functionality).

It is also relevant to core dumps (the NPHIE aspect in particular),
which use the ptrace mechanism (or is it the other way around?) to
decide what to dump. The HDEXCR is useful here too, as the NPHIE aspect
may be set in the HDEXCR without being set in the DEXCR. Although the
HDEXCR is per-cpu and we don't track it in the task struct (it's useless
in normal operation), it would be difficult to imagine why a hypervisor
would set it to different values within a guest. A hypervisor cannot
safely set NPHIE differently at least, as that would break programs.

Expose a read-only view of the userspace DEXCR and HDEXCR to ptrace.
The HDEXCR is always readonly, and is useful for diagnosing the core
dumps (as the HDEXCR may set NPHIE without the DEXCR setting it).

Signed-off-by: Benjamin Gray <bgray@linux.ibm.com>
Reviewed-by: Russell Currey <ruscur@russell.cc>
[mpe: Use lower_32_bits() rather than open coding]
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Link: https://msgid.link/20230616034846.311705-7-bgray@linux.ibm.com
arch/powerpc/include/uapi/asm/elf.h
arch/powerpc/kernel/ptrace/ptrace-decl.h
arch/powerpc/kernel/ptrace/ptrace-view.c
include/uapi/linux/elf.h