FreeBSD Bugzilla – Attachment 237693 Details for
Bug 267361
EINVAL accessing fpcsr for armv7 process on arm64 kernel
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
Patch adapted for 13.1
0001-arm64-Implement-cpu_ptrace.patch (text/plain), 3.44 KB, created by
Olivier Houchard
on 2022-10-28 17:08:28 UTC
(
hide
)
Description:
Patch adapted for 13.1
Filename:
MIME Type:
Creator:
Olivier Houchard
Created:
2022-10-28 17:08:28 UTC
Size:
3.44 KB
patch
obsolete
>From 44aa3d772e43c98fd932248628722430402639d8 Mon Sep 17 00:00:00 2001 >From: Olivier Houchard <cognet@FreeBSD.org> >Date: Thu, 27 Oct 2022 23:25:59 +0200 >Subject: [PATCH] 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. > >This is an adaptation of commit d78c2cd831d346b94c00c72b5a94a1a4f0dd3e53. > >PR: 267361 >MFC After: 1 week >--- > sys/arm64/arm64/freebsd32_machdep.c | 8 ++------ > sys/arm64/arm64/ptrace_machdep.c | 30 +++++++++++++++++++++++++++++ > sys/arm64/include/ptrace.h | 10 ++++++++++ > sys/arm64/include/vfp.h | 5 +++++ > 4 files changed, 47 insertions(+), 6 deletions(-) > >diff --git a/sys/arm64/arm64/freebsd32_machdep.c b/sys/arm64/arm64/freebsd32_machdep.c >index 9d7b5effac0c..7fad089c0090 100644 >--- a/sys/arm64/arm64/freebsd32_machdep.c >+++ b/sys/arm64/arm64/freebsd32_machdep.c >@@ -57,10 +57,6 @@ extern void freebsd32_sendsig(sig_t catcher, ksiginfo_t *ksi, sigset_t *mask); > */ > #define UC32_COPY_SIZE offsetof(ucontext32_t, uc_link) > >-#ifdef VFP >-static void get_fpcontext32(struct thread *td, mcontext32_vfp_t *); >-#endif >- > /* > * Stubs for machine dependent 32-bits system calls. > */ >@@ -123,7 +119,7 @@ freebsd32_sysarch(struct thread *td, struct freebsd32_sysarch_args *uap) > } > > #ifdef VFP >-static void >+void > get_fpcontext32(struct thread *td, mcontext32_vfp_t *mcp) > { > struct pcb *curpcb; >@@ -151,7 +147,7 @@ get_fpcontext32(struct thread *td, mcontext32_vfp_t *mcp) > critical_exit(); > } > >-static void >+void > set_fpcontext32(struct thread *td, mcontext32_vfp_t *mcp) > { > struct pcb *pcb; >diff --git a/sys/arm64/arm64/ptrace_machdep.c b/sys/arm64/arm64/ptrace_machdep.c >index 144ff29aff47..a32827bf7b57 100644 >--- a/sys/arm64/arm64/ptrace_machdep.c >+++ b/sys/arm64/arm64/ptrace_machdep.c >@@ -47,6 +47,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 >+} >+ > int > ptrace_set_pc(struct thread *td, u_long addr) > { >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_ */ >diff --git a/sys/arm64/include/vfp.h b/sys/arm64/include/vfp.h >index 9808b3a8d831..c20665591093 100644 >--- a/sys/arm64/include/vfp.h >+++ b/sys/arm64/include/vfp.h >@@ -97,4 +97,9 @@ int is_fpu_kern_thread(u_int); > > #endif > >+#ifdef COMPAT_FREEBSD32 >+void get_fpcontext32(struct thread *td, mcontext32_vfp_t *mcp); >+void set_fpcontext32(struct thread *td, mcontext32_vfp_t *mcp); >+#endif >+ > #endif /* !_MACHINE_VFP_H_ */ >-- >2.30.1 >
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 267361
: 237693