powerpc/ptrace: Give ptrace(2) access to SPE registers when available

SPE registers are already exported in core dumps with the VMX note, so use
the same interface for live access.

Instead of simply guarding out in #ifndef __SPE__ the cpu_feature check, I
chose to keep the check and check against PPC_FEATURE_SPE, on the off-chance
someone decides to run a SPE kernel on a non-SPE device (which is possible,
though highly unlikely, and would be no different from running a MPC85XX
kernel in that instance).
This commit is contained in:
Justin Hibbits 2019-11-22 04:34:46 +00:00
parent 14eff785e8
commit e988a68e5a
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=354990

View file

@ -40,6 +40,12 @@ __FBSDID("$FreeBSD$");
#include <machine/md_var.h>
#include <machine/pcb.h>
#ifdef __SPE__
#define PPC_FEATURE_VECTOR PPC_FEATURE_HAS_SPE
#else
#define PPC_FEATURE_VECTOR PPC_FEATURE_HAS_ALTIVEC
#endif
int
cpu_ptrace(struct thread *td, int req, void *addr, int data)
{
@ -58,7 +64,7 @@ cpu_ptrace(struct thread *td, int req, void *addr, int data)
error = EINVAL;
switch (req) {
case PT_GETVRREGS:
if (!(cpu_features & PPC_FEATURE_HAS_ALTIVEC))
if (!(cpu_features & PPC_FEATURE_VECTOR))
break;
if (pcb->pcb_flags & PCB_VEC) {
@ -68,7 +74,7 @@ cpu_ptrace(struct thread *td, int req, void *addr, int data)
error = copyout(&vec, addr, sizeof(vec));
break;
case PT_SETVRREGS:
if (!(cpu_features & PPC_FEATURE_HAS_ALTIVEC))
if (!(cpu_features & PPC_FEATURE_VECTOR))
break;
error = copyin(addr, &vec, sizeof(vec));
if (error == 0) {