From cd5fa11721249e9f366ba0d82e48afeb11bd5816 Mon Sep 17 00:00:00 2001 From: kettenis Date: Tue, 11 Apr 2017 06:52:13 +0000 Subject: [PATCH] Revise 'struct fpreg' and dump floating-point register in core dumps. Also reset the floating-point register state upon exec. ok guenther@ --- sys/arch/arm64/arm64/machdep.c | 8 +++++++- sys/arch/arm64/arm64/process_machdep.c | 8 ++++++-- sys/arch/arm64/include/reg.h | 4 ++-- 3 files changed, 15 insertions(+), 5 deletions(-) diff --git a/sys/arch/arm64/arm64/machdep.c b/sys/arch/arm64/arm64/machdep.c index dcdfbaf29d2..be7c3b18216 100644 --- a/sys/arch/arm64/arm64/machdep.c +++ b/sys/arch/arm64/arm64/machdep.c @@ -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 * @@ -42,6 +42,7 @@ #include #include #include +#include #include #include @@ -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)); diff --git a/sys/arch/arm64/arm64/process_machdep.c b/sys/arch/arm64/arm64/process_machdep.c index fc704aa5205..79d2d959e5c 100644 --- a/sys/arch/arm64/arm64/process_machdep.c +++ b/sys/arch/arm64/arm64/process_machdep.c @@ -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 * @@ -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); } diff --git a/sys/arch/arm64/include/reg.h b/sys/arch/arm64/include/reg.h index 566c63e2bd9..33efe4bef62 100644 --- a/sys/arch/arm64/include/reg.h +++ b/sys/arch/arm64/include/reg.h @@ -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 * @@ -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; }; -- 2.20.1