This brings armv7 in line with arm64.

ok?


Index: arch/arm/arm/arm_machdep.c
===================================================================
RCS file: /cvs/src/sys/arch/arm/arm/arm_machdep.c,v
retrieving revision 1.4
diff -u -p -r1.4 arm_machdep.c
--- arch/arm/arm/arm_machdep.c  16 Jul 2016 06:41:20 -0000      1.4
+++ arch/arm/arm/arm_machdep.c  16 Mar 2018 13:19:10 -0000
@@ -81,6 +81,7 @@
 #include <sys/pool.h>
 
 #include <arm/cpufunc.h>
+#include <arm/vfp.h>
 
 #include <machine/pcb.h>
 #include <machine/vmparam.h>
@@ -108,6 +109,11 @@ setregs(struct proc *p, struct exec_pack
 {
        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;
 
        memset(tf, 0, sizeof(*tf));
@@ -118,6 +124,5 @@ setregs(struct proc *p, struct exec_pack
        tf->tf_pc = pack->ep_entry;
        tf->tf_spsr = PSR_USR32_MODE;
 
-       p->p_addr->u_pcb.pcb_flags = 0;
        retval[1] = 0;
 }
Index: arch/arm/arm/process_machdep.c
===================================================================
RCS file: /cvs/src/sys/arch/arm/arm/process_machdep.c,v
retrieving revision 1.5
diff -u -p -r1.5 process_machdep.c
--- arch/arm/arm/process_machdep.c      31 Jan 2016 00:14:50 -0000      1.5
+++ arch/arm/arm/process_machdep.c      16 Mar 2018 13:19:10 -0000
@@ -113,6 +113,7 @@
 #include <machine/reg.h>
 
 #include <arm/armreg.h>
+#include <arm/vfp.h>
 
 static __inline struct trapframe *
 process_frame(struct proc *p)
@@ -145,8 +146,11 @@ process_read_regs(struct proc *p, struct
 int
 process_read_fpregs(struct proc *p, struct fpreg *regs)
 {
-       /* No hardware FP support */
-       memset(regs, 0, sizeof(struct fpreg));
+       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);
 }
 
@@ -174,9 +178,13 @@ process_write_regs(struct proc *p, struc
 }
 
 int
-process_write_fpregs(struct proc *p,  struct fpreg *regs)
+process_write_fpregs(struct proc *p, struct fpreg *regs)
 {
-       /* No hardware FP support */
+       if (p->p_addr->u_pcb.pcb_fpcpu != NULL)
+               vfp_discard(p);
+
+       memcpy(&p->p_addr->u_pcb.pcb_fpstate, regs, sizeof(*regs));
+       p->p_addr->u_pcb.pcb_flags |= PCB_FPU;
        return(0);
 }
 
Index: arch/arm/arm/vfp.c
===================================================================
RCS file: /cvs/src/sys/arch/arm/arm/vfp.c,v
retrieving revision 1.1
diff -u -p -r1.1 vfp.c
--- arch/arm/arm/vfp.c  26 Jan 2018 16:22:19 -0000      1.1
+++ arch/arm/arm/vfp.c  16 Mar 2018 13:19:10 -0000
@@ -186,11 +186,11 @@ vfp_fault(unsigned int pc, unsigned int 
 }
 
 void
-vfp_discard(void)
+vfp_discard(struct proc *p)
 {
        struct cpu_info *ci = curcpu();
 
-       if (curpcb->pcb_fpcpu == ci && ci->ci_fpuproc == curproc) {
+       if (curpcb->pcb_fpcpu == ci && ci->ci_fpuproc == p) {
                ci->ci_fpuproc = NULL;
                curpcb->pcb_fpcpu = NULL;
        }
Index: arch/arm/arm/vm_machdep.c
===================================================================
RCS file: /cvs/src/sys/arch/arm/arm/vm_machdep.c,v
retrieving revision 1.22
diff -u -p -r1.22 vm_machdep.c
--- arch/arm/arm/vm_machdep.c   26 Jan 2018 16:22:19 -0000      1.22
+++ arch/arm/arm/vm_machdep.c   16 Mar 2018 13:19:10 -0000
@@ -134,7 +134,10 @@ cpu_fork(struct proc *p1, struct proc *p
 void
 cpu_exit(struct proc *p)
 {
-       vfp_discard();
+       /* If we were using the FPU, forget about it. */
+       if (p->p_addr->u_pcb.pcb_fpcpu != NULL)
+               vfp_discard(p);
+
        pmap_deactivate(p);
        sched_exit(p);
 }
Index: arch/arm/include/vfp.h
===================================================================
RCS file: /cvs/src/sys/arch/arm/include/vfp.h,v
retrieving revision 1.1
diff -u -p -r1.1 vfp.h
--- arch/arm/include/vfp.h      26 Jan 2018 16:22:20 -0000      1.1
+++ arch/arm/include/vfp.h      16 Mar 2018 13:19:11 -0000
@@ -128,7 +128,7 @@
 #define COPROC11               (0x3 << 22)
 
 void           vfp_init(void);
-void           vfp_discard(void);
+void           vfp_discard(struct proc *);
 void           vfp_save(void);
 void           vfp_enable(void);
 

Reply via email to