git: f487dbef66a9 - stable/13 - arm64: Implement cpu_ptrace().
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Fri, 04 Nov 2022 23:51:12 UTC
The branch stable/13 has been updated by cognet: URL: https://cgit.FreeBSD.org/src/commit/?id=f487dbef66a93cff73b83935693518a685e16f5a commit f487dbef66a93cff73b83935693518a685e16f5a Author: Olivier Houchard <cognet@FreeBSD.org> AuthorDate: 2022-10-27 21:25:59 +0000 Commit: Olivier Houchard <cognet@FreeBSD.org> CommitDate: 2022-11-04 23:29:09 +0000 arm64: Implement cpu_ptrace(). Add a minimal implementation of cpu_ptrace() for arm64. It is only used to get/set VFP registers for 32bits binaries, as it is apparently what we use there, instead of the MI PT_GETFPREGS/PT_SETFPREGS. PR: 267361 MFC After: 1 week (cherry picked from commit d78c2cd831d346b94c00c72b5a94a1a4f0dd3e53) Signed-off-by: Olivier Houchard <cognet@FreeBSD.org> --- sys/arm64/arm64/ptrace_machdep.c | 30 ++++++++++++++++++++++++++++++ sys/arm64/include/ptrace.h | 10 ++++++++++ 2 files changed, 40 insertions(+) diff --git a/sys/arm64/arm64/ptrace_machdep.c b/sys/arm64/arm64/ptrace_machdep.c index 44ca58a49156..408c67a6c396 100644 --- a/sys/arm64/arm64/ptrace_machdep.c +++ b/sys/arm64/arm64/ptrace_machdep.c @@ -49,6 +49,36 @@ __FBSDID("$FreeBSD$"); #include <machine/armreg.h> +/* Only used to get/set 32bits VFP regs */ +int +cpu_ptrace(struct thread *td, int req, void *arg, int data) +{ +#if defined(VFP) && defined(COMPAT_FREEBSD32) + mcontext32_vfp_t vfp; + int error; + + if (!SV_CURPROC_FLAG(SV_ILP32)) + return (EINVAL); + switch (req) { + case PT_GETVFPREGS32: + get_fpcontext32(td, &vfp); + error = copyout(&vfp, arg, sizeof(vfp)); + break; + case PT_SETVFPREGS32: + error = copyin(arg, &vfp, sizeof(vfp)); + if (error == 0) + set_fpcontext32(td, &vfp); + break; + default: + error = EINVAL; + } + + return (error); +#else + return (EINVAL); +#endif +} + #if defined(VFP) && defined(COMPAT_FREEBSD32) static bool get_arm_vfp(struct regset *rs, struct thread *td, void *buf, size_t *sizep) diff --git a/sys/arm64/include/ptrace.h b/sys/arm64/include/ptrace.h index da23dbe43a4f..0705ee6daab0 100644 --- a/sys/arm64/include/ptrace.h +++ b/sys/arm64/include/ptrace.h @@ -1 +1,11 @@ /* $FreeBSD$ */ + +#ifndef _MACHINE_PTRACE_H_ +#define _MACHINE_PTRACE_H_ + +#define __HAVE_PTRACE_MACHDEP + +#define PT_GETVFPREGS32 (PT_FIRSTMACH + 0) +#define PT_SETVFPREGS32 (PT_FIRSTMACH + 1) + +#endif /* _MACHINE_PTRACE_H_ */