summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--sys/arch/amd64/amd64/process_machdep.c59
-rw-r--r--sys/arch/amd64/include/reg.h68
2 files changed, 99 insertions, 28 deletions
diff --git a/sys/arch/amd64/amd64/process_machdep.c b/sys/arch/amd64/amd64/process_machdep.c
index cb8650eb822..a7982608504 100644
--- a/sys/arch/amd64/amd64/process_machdep.c
+++ b/sys/arch/amd64/amd64/process_machdep.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: process_machdep.c,v 1.1 2004/01/28 01:39:39 mickey Exp $ */
+/* $OpenBSD: process_machdep.c,v 1.2 2004/01/29 12:43:35 mickey Exp $ */
/* $NetBSD: process_machdep.c,v 1.1 2003/04/26 18:39:31 fvdl Exp $ */
/*-
@@ -102,7 +102,30 @@ process_read_regs(struct proc *p, struct reg *regs)
{
struct trapframe *tf = process_frame(p);
- memcpy(regs, tf, sizeof (*regs));
+ regs->r_rdi = tf->tf_rdi;
+ regs->r_rsi = tf->tf_rsi;
+ regs->r_rdx = tf->tf_rdx;
+ regs->r_rcx = tf->tf_rcx;
+ regs->r_r8 = tf->tf_r8;
+ regs->r_r9 = tf->tf_r9;
+ regs->r_r10 = tf->tf_r10;
+ regs->r_r11 = tf->tf_r11;
+ regs->r_r12 = tf->tf_r12;
+ regs->r_r13 = tf->tf_r13;
+ regs->r_r14 = tf->tf_r14;
+ regs->r_r15 = tf->tf_r15;
+ regs->r_rbp = tf->tf_rbp;
+ regs->r_rbx = tf->tf_rbx;
+ regs->r_rax = tf->tf_rax;
+ regs->r_rsp = tf->tf_rsp;
+ regs->r_rip = tf->tf_rip;
+ regs->r_rflags = tf->tf_rflags;
+ regs->r_cs = tf->tf_cs;
+ regs->r_ss = tf->tf_ss;
+ regs->r_ds = tf->tf_ds;
+ regs->r_es = tf->tf_es;
+ regs->r_fs = tf->tf_fs;
+ regs->r_gs = tf->tf_gs;
return (0);
}
@@ -135,19 +158,41 @@ process_read_fpregs(struct proc *p, struct fpreg *regs)
}
int
-process_write_regs(struct proc *p, struct reg *regp)
+process_write_regs(struct proc *p, struct reg *regs)
{
struct trapframe *tf = process_frame(p);
- long *regs = regp->regs;
/*
* Check for security violations.
*/
- if (((regs[_REG_RFL] ^ tf->tf_rflags) & PSL_USERSTATIC) != 0 ||
- !USERMODE(regs[_REG_CS], regs[_REG_RFL]))
+ if (((regs->r_rflags ^ tf->tf_rflags) & PSL_USERSTATIC) != 0 ||
+ !USERMODE(regs->r_cs, regs->r_rflags))
return (EINVAL);
- memcpy(tf, regs, sizeof (*tf));
+ tf->tf_rdi = regs->r_rdi;
+ tf->tf_rsi = regs->r_rsi;
+ tf->tf_rdx = regs->r_rdx;
+ tf->tf_rcx = regs->r_rcx;
+ tf->tf_r8 = regs->r_r8;
+ tf->tf_r9 = regs->r_r9;
+ tf->tf_r10 = regs->r_r10;
+ tf->tf_r11 = regs->r_r11;
+ tf->tf_r12 = regs->r_r12;
+ tf->tf_r13 = regs->r_r13;
+ tf->tf_r14 = regs->r_r14;
+ tf->tf_r15 = regs->r_r15;
+ tf->tf_rbp = regs->r_rbp;
+ tf->tf_rbx = regs->r_rbx;
+ tf->tf_rax = regs->r_rax;
+ tf->tf_rsp = regs->r_rsp;
+ tf->tf_rip = regs->r_rip;
+ tf->tf_rflags = regs->r_rflags;
+ tf->tf_cs = regs->r_cs;
+ tf->tf_ss = regs->r_ss;
+ tf->tf_ds = regs->r_ds;
+ tf->tf_es = regs->r_es;
+ tf->tf_fs = regs->r_fs;
+ tf->tf_gs = regs->r_gs;
return (0);
}
diff --git a/sys/arch/amd64/include/reg.h b/sys/arch/amd64/include/reg.h
index f594a44c6fc..d2ab5521203 100644
--- a/sys/arch/amd64/include/reg.h
+++ b/sys/arch/amd64/include/reg.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: reg.h,v 1.1 2004/01/28 01:39:39 mickey Exp $ */
+/* $OpenBSD: reg.h,v 1.2 2004/01/29 12:43:35 mickey Exp $ */
/* $NetBSD: reg.h,v 1.1 2003/04/26 18:39:47 fvdl Exp $ */
/*-
@@ -53,27 +53,30 @@
/* When referenced during a trap/exception, registers are at these offsets */
-#define tR15 0
-#define tR14 1
-#define tR13 2
-#define tR12 3
-#define tR11 4
-#define tR10 5
-#define tR9 6
-#define tR8 7
-#define tRDI 8
-#define tRSI 9
-#define tRBP 10
-#define tRBX 11
-#define tRDX 12
-#define tRCX 13
+#define tRDI 0
+#define tRSI 1
+#define tRDX 2
+#define tRCX 3
+#define tR8 4
+#define tR9 5
+#define tR10 6
+#define tR11 7
+#define tR12 8
+#define tR13 9
+#define tR14 10
+#define tR15 11
+#define tRBP 12
+#define tRBX 13
#define tRAX 14
-
-#define tRIP 17
+#define tRSP 15
+#define tRIP 16
+#define tRFLAGS 17
#define tCS 18
-#define tRFLAGS 19
-#define tRSP 20
-#define tSS 21
+#define tSS 19
+#define tDS 20
+#define tES 21
+#define tFS 22
+#define tGS 23
/*
* Registers accessible to ptrace(2) syscall for debugger use.
@@ -81,7 +84,30 @@
* remain synced (XXX should use common structure).
*/
struct reg {
- long regs[_NGREG];
+ int64_t r_rdi;
+ int64_t r_rsi;
+ int64_t r_rdx;
+ int64_t r_rcx;
+ int64_t r_r8;
+ int64_t r_r9;
+ int64_t r_r10;
+ int64_t r_r11;
+ int64_t r_r12;
+ int64_t r_r13;
+ int64_t r_r14;
+ int64_t r_r15;
+ int64_t r_rbp;
+ int64_t r_rbx;
+ int64_t r_rax;
+ int64_t r_rsp;
+ int64_t r_rip;
+ int64_t r_rflags;
+ int64_t r_cs;
+ int64_t r_ss;
+ int64_t r_ds;
+ int64_t r_es;
+ int64_t r_fs;
+ int64_t r_gs;
};
struct fpreg {