Diff below revises the struct fpreg definition and enables the dumping
of fpu registers in core dumps.  That pointed out that we need to
reset the FPU state upon exec.

ok?


Index: arch/arm64/arm64/machdep.c
===================================================================
RCS file: /cvs/src/sys/arch/arm64/arm64/machdep.c,v
retrieving revision 1.12
diff -u -p -r1.12 machdep.c
--- arch/arm64/arm64/machdep.c  13 Mar 2017 00:53:56 -0000      1.12
+++ arch/arm64/arm64/machdep.c  10 Apr 2017 11:10:43 -0000
@@ -42,6 +42,7 @@
 #include <machine/kcore.h>
 #include <machine/bootconfig.h>
 #include <machine/bus.h>
+#include <machine/vfp.h>
 #include <arm64/arm64/arm64var.h>
 
 #include <machine/db_machdep.h>
@@ -454,6 +455,11 @@ setregs(struct proc *p, struct exec_pack
     register_t *retval)
 {
        struct trapframe *tf;
+
+       /* If we were using the FPU, forget about it. */
+       if (p->p_addr->u_pcb.pcb_fpcpu != NULL)
+               vfp_discard(p);
+       p->p_addr->u_pcb.pcb_flags &= ~PCB_FPU;
 
        tf = p->p_addr->u_pcb.pcb_tf;
 
Index: arch/arm64/arm64/process_machdep.c
===================================================================
RCS file: /cvs/src/sys/arch/arm64/arm64/process_machdep.c,v
retrieving revision 1.2
diff -u -p -r1.2 process_machdep.c
--- arch/arm64/arm64/process_machdep.c  21 Mar 2017 18:43:40 -0000      1.2
+++ arch/arm64/arm64/process_machdep.c  10 Apr 2017 11:10:43 -0000
@@ -68,7 +68,11 @@ process_read_regs(struct proc *p, struct
 int
 process_read_fpregs(struct proc *p, struct fpreg *regs)
 {
-       memset(regs, 0, sizeof(*regs));
+       if (p->p_addr->u_pcb.pcb_flags & PCB_FPU)
+               memcpy(regs, &p->p_addr->u_pcb.pcb_fpstate, sizeof(*regs));
+       else
+               memset(regs, 0, sizeof(*regs));
+
        return(0);
 }
 
Index: arch/arm64/include/reg.h
===================================================================
RCS file: /cvs/src/sys/arch/arm64/include/reg.h,v
retrieving revision 1.2
diff -u -p -r1.2 reg.h
--- arch/arm64/include/reg.h    21 Mar 2017 18:43:40 -0000      1.2
+++ arch/arm64/include/reg.h    10 Apr 2017 11:10:43 -0000
@@ -28,7 +28,7 @@ struct reg {
 };
 
 struct fpreg {
-       uint64_t        fp_registers[64]; // really 32 128 bit registers.
+       __uint128_t     fp_reg[32];
        uint32_t        fp_sr;
        uint32_t        fp_cr;
 };

Reply via email to