diff --git a/sys/arm/arm/elf_machdep.c b/sys/arm/arm/elf_machdep.c --- a/sys/arm/arm/elf_machdep.c +++ b/sys/arm/arm/elf_machdep.c @@ -145,19 +145,9 @@ } void -elf32_dump_thread(struct thread *td, void *dst, size_t *off) +elf32_dump_thread(struct thread *td __unused, void *dst __unused, + size_t *off __unused) { -#ifdef VFP - mcontext_vfp_t vfp; - - if (dst != NULL) { - get_vfpcontext(td, &vfp); - *off = elf32_populate_note(NT_ARM_VFP, &vfp, dst, sizeof(vfp), - NULL); - } else - *off = elf32_populate_note(NT_ARM_VFP, NULL, NULL, sizeof(vfp), - NULL); -#endif } bool diff --git a/sys/arm/arm/ptrace_machdep.c b/sys/arm/arm/ptrace_machdep.c --- a/sys/arm/arm/ptrace_machdep.c +++ b/sys/arm/arm/ptrace_machdep.c @@ -28,12 +28,45 @@ __FBSDID("$FreeBSD$"); #include +#include #include #include +#include #ifdef VFP #include #endif +#ifdef VFP +static bool +get_arm_vfp(struct regset *rs, struct thread *td, void *buf, size_t *sizep) +{ + if (buf != NULL) { + KASSERT(*sizep == sizeof(mcontext_vfp_t), + ("%s: invalid size", __func__)); + get_vfpcontext(td, buf); + } + *sizep = sizeof(mcontext_vfp_t); + return (true); +} + +static bool +set_arm_vfp(struct regset *rs, struct thread *td, void *buf, + size_t size) +{ + KASSERT(size == sizeof(mcontext_vfp_t), ("%s: invalid size", __func__)); + set_vfpcontext(td, buf); + return (true); +} + +static struct regset regset_arm_vfp = { + .note = NT_ARM_VFP, + .size = sizeof(mcontext_vfp_t), + .get = get_arm_vfp, + .set = set_arm_vfp, +}; +ELF_REGSET(regset_arm_vfp); +#endif + int cpu_ptrace(struct thread *td, int req, void *addr, int data) { diff --git a/sys/arm64/arm64/elf32_machdep.c b/sys/arm64/arm64/elf32_machdep.c --- a/sys/arm64/arm64/elf32_machdep.c +++ b/sys/arm64/arm64/elf32_machdep.c @@ -288,5 +288,4 @@ void elf32_dump_thread(struct thread *td, void *dst, size_t *off) { - /* XXX: VFP */ } diff --git a/sys/arm64/arm64/freebsd32_machdep.c b/sys/arm64/arm64/freebsd32_machdep.c --- a/sys/arm64/arm64/freebsd32_machdep.c +++ b/sys/arm64/arm64/freebsd32_machdep.c @@ -61,10 +61,6 @@ */ #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. */ @@ -127,7 +123,7 @@ } #ifdef VFP -static void +void get_fpcontext32(struct thread *td, mcontext32_vfp_t *mcp) { struct pcb *pcb; @@ -159,7 +155,7 @@ } } -static void +void set_fpcontext32(struct thread *td, mcontext32_vfp_t *mcp) { struct pcb *pcb; @@ -176,6 +172,7 @@ critical_exit(); } #endif + static void get_mcontext32(struct thread *td, mcontext32_t *mcp, int flags) { diff --git a/sys/arm64/arm64/ptrace_machdep.c b/sys/arm64/arm64/ptrace_machdep.c --- a/sys/arm64/arm64/ptrace_machdep.c +++ b/sys/arm64/arm64/ptrace_machdep.c @@ -30,6 +30,7 @@ #include #include +#include #include #include #include @@ -48,6 +49,38 @@ #include +#if defined(VFP) && defined(COMPAT_FREEBSD32) +static bool +get_arm_vfp(struct regset *rs, struct thread *td, void *buf, size_t *sizep) +{ + if (buf != NULL) { + KASSERT(*sizep == sizeof(mcontext32_vfp_t), + ("%s: invalid size", __func__)); + get_fpcontext32(td, buf); + } + *sizep = sizeof(mcontext32_vfp_t); + return (true); +} + +static bool +set_arm_vfp(struct regset *rs, struct thread *td, void *buf, + size_t size) +{ + KASSERT(size == sizeof(mcontext32_vfp_t), ("%s: invalid size", + __func__)); + set_fpcontext32(td, buf); + return (true); +} + +static struct regset regset_arm_vfp = { + .note = NT_ARM_VFP, + .size = sizeof(mcontext32_vfp_t), + .get = get_arm_vfp, + .set = set_arm_vfp, +}; +ELF32_REGSET(regset_arm_vfp); +#endif + int ptrace_set_pc(struct thread *td, u_long addr) { diff --git a/sys/arm64/include/vfp.h b/sys/arm64/include/vfp.h --- a/sys/arm64/include/vfp.h +++ b/sys/arm64/include/vfp.h @@ -94,6 +94,11 @@ #define VFP_FPSR_FROM_FPSCR(vpscr) ((vpscr) &~ 0x7c00000) #define VFP_FPCR_FROM_FPSCR(vpsrc) ((vpsrc) & 0x7c00000) +#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 #endif diff --git a/usr.bin/gcore/elfcore.c b/usr.bin/gcore/elfcore.c --- a/usr.bin/gcore/elfcore.c +++ b/usr.bin/gcore/elfcore.c @@ -110,9 +110,6 @@ static void *elf_note_prpsinfo(void *, size_t *); static void *elf_note_thrmisc(void *, size_t *); static void *elf_note_ptlwpinfo(void *, size_t *); -#if defined(__arm__) -static void *elf_note_arm_vfp(void *, size_t *); -#endif #if defined(__i386__) || defined(__amd64__) static void *elf_note_x86_xstate(void *, size_t *); #endif @@ -375,8 +372,8 @@ elf_putregnote(NT_FPREGSET, tids[i], sb); elf_putnote(NT_THRMISC, elf_note_thrmisc, tids + i, sb); elf_putnote(NT_PTLWPINFO, elf_note_ptlwpinfo, tids + i, sb); -#if defined(__arm__) - elf_putnote(NT_ARM_VFP, elf_note_arm_vfp, tids + i, sb); +#if (defined(ELFCORE_COMPAT_32) && defined(__aarch64__)) || defined(__arm__) + elf_putregnote(NT_ARM_VFP, tids[i], sb); #endif #if defined(__i386__) || defined(__amd64__) elf_putnote(NT_X86_XSTATE, elf_note_x86_xstate, tids + i, sb);