Revise 'struct fpreg' and dump floating-point register in core dumps. Also
authorkettenis <kettenis@openbsd.org>
Tue, 11 Apr 2017 06:52:13 +0000 (06:52 +0000)
committerkettenis <kettenis@openbsd.org>
Tue, 11 Apr 2017 06:52:13 +0000 (06:52 +0000)
reset the floating-point register state upon exec.

ok guenther@

sys/arch/arm64/arm64/machdep.c
sys/arch/arm64/arm64/process_machdep.c
sys/arch/arm64/include/reg.h

index dcdfbaf..be7c3b1 100644 (file)
@@ -1,4 +1,4 @@
-/* $OpenBSD: machdep.c,v 1.12 2017/03/13 00:53:56 jsg Exp $ */
+/* $OpenBSD: machdep.c,v 1.13 2017/04/11 06:52:13 kettenis Exp $ */
 /*
  * Copyright (c) 2014 Patrick Wildt <patrick@blueri.se>
  *
@@ -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>
@@ -455,6 +456,11 @@ setregs(struct proc *p, struct exec_package *pack, u_long stack,
 {
        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));
index fc704aa..79d2d95 100644 (file)
@@ -1,4 +1,4 @@
-/* $OpenBSD: process_machdep.c,v 1.2 2017/03/21 18:43:40 kettenis Exp $ */
+/* $OpenBSD: process_machdep.c,v 1.3 2017/04/11 06:52:13 kettenis Exp $ */
 /*
  * Copyright (c) 2014 Patrick Wildt <patrick@blueri.se>
  *
@@ -68,7 +68,11 @@ process_read_regs(struct proc *p, struct reg *regs)
 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 566c63e..33efe4b 100644 (file)
@@ -1,4 +1,4 @@
-/* $OpenBSD: reg.h,v 1.2 2017/03/21 18:43:40 kettenis Exp $ */
+/* $OpenBSD: reg.h,v 1.3 2017/04/11 06:52:13 kettenis Exp $ */
 /*
  * Copyright (c) 2014 Patrick Wildt <patrick@blueri.se>
  *
@@ -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;
 };