diff options
author | Mark Kettenis <kettenis@cvs.openbsd.org> | 2017-03-21 18:43:41 +0000 |
---|---|---|
committer | Mark Kettenis <kettenis@cvs.openbsd.org> | 2017-03-21 18:43:41 +0000 |
commit | 63327ee62b11799f0b21cad3968f4b112e027039 (patch) | |
tree | 5d0f228cd49968edbe127ade8422ffcc01e43355 | |
parent | e9d18dcf7b851749d4bc15196cafe09e56d419b5 (diff) |
Revise the definition of "struct reg" to have a layout compatible with other
operating systems. Implement process_read_regs() and make
process_read_fpregs() clear the struct fpreg to avoid leaking kernel stack
contents. This makes core dumps actually usable.
ok drahn@
-rw-r--r-- | sys/arch/arm64/arm64/process_machdep.c | 12 | ||||
-rw-r--r-- | sys/arch/arm64/include/reg.h | 13 |
2 files changed, 18 insertions, 7 deletions
diff --git a/sys/arch/arm64/arm64/process_machdep.c b/sys/arch/arm64/arm64/process_machdep.c index 9665e40a5f8..fc704aa5205 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.1 2016/12/17 23:38:33 patrick Exp $ */ +/* $OpenBSD: process_machdep.c,v 1.2 2017/03/21 18:43:40 kettenis Exp $ */ /* * Copyright (c) 2014 Patrick Wildt <patrick@blueri.se> * @@ -53,12 +53,22 @@ int process_read_regs(struct proc *p, struct reg *regs) { + struct trapframe *tf = p->p_addr->u_pcb.pcb_tf; + + memcpy(®s->r_reg[0], &tf->tf_x[0], sizeof(regs->r_reg)); + regs->r_lr = tf->tf_lr; + regs->r_sp = tf->tf_sp; + regs->r_pc = tf->tf_elr; + regs->r_spsr = tf->tf_spsr; + regs->r_tpidr = (uint64_t)p->p_addr->u_pcb.pcb_tcb; + return(0); } int process_read_fpregs(struct proc *p, struct fpreg *regs) { + memset(regs, 0, sizeof(*regs)); return(0); } diff --git a/sys/arch/arm64/include/reg.h b/sys/arch/arm64/include/reg.h index ac431b864e6..566c63e2bd9 100644 --- a/sys/arch/arm64/include/reg.h +++ b/sys/arch/arm64/include/reg.h @@ -1,4 +1,4 @@ -/* $OpenBSD: reg.h,v 1.1 2016/12/17 23:38:33 patrick Exp $ */ +/* $OpenBSD: reg.h,v 1.2 2017/03/21 18:43:40 kettenis Exp $ */ /* * Copyright (c) 2014 Patrick Wildt <patrick@blueri.se> * @@ -19,11 +19,12 @@ #define _MACHINE_REG_H_ struct reg { - unsigned long x[30]; - unsigned long x_sp; - unsigned long x_lr; - unsigned long x_pc; - unsigned long x_cpsr; + uint64_t r_reg[30]; + uint64_t r_lr; + uint64_t r_sp; + uint64_t r_pc; + uint64_t r_spsr; + uint64_t r_tpidr; }; struct fpreg { |