Module Name: src Committed By: reinoud Date: Fri May 18 20:21:14 UTC 2018
Modified Files: src/sys/arch/usermode/target/i386: cpu_i386.c Log Message: Use knowledge of mcontext for i386 support To generate a diff of this commit: cvs rdiff -u -r1.4 -r1.5 src/sys/arch/usermode/target/i386/cpu_i386.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/sys/arch/usermode/target/i386/cpu_i386.c diff -u src/sys/arch/usermode/target/i386/cpu_i386.c:1.4 src/sys/arch/usermode/target/i386/cpu_i386.c:1.5 --- src/sys/arch/usermode/target/i386/cpu_i386.c:1.4 Sat Mar 3 21:15:16 2012 +++ src/sys/arch/usermode/target/i386/cpu_i386.c Fri May 18 20:21:14 2018 @@ -1,4 +1,4 @@ -/* $NetBSD: cpu_i386.c,v 1.4 2012/03/03 21:15:16 reinoud Exp $ */ +/* $NetBSD: cpu_i386.c,v 1.5 2018/05/18 20:21:14 reinoud Exp $ */ /*- * Copyright (c) 2011 Reinoud Zandijk <rein...@netbsd.org> @@ -27,14 +27,9 @@ * POSSIBILITY OF SUCH DAMAGE. */ -/* - * Note that this machdep.c uses the `dummy' mcontext_t defined for usermode. - * This is basicly a blob of PAGE_SIZE big. We might want to switch over to - * non-generic mcontext_t's one day, but will this break non-NetBSD hosts? - */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: cpu_i386.c,v 1.4 2012/03/03 21:15:16 reinoud Exp $"); +__KERNEL_RCSID(0, "$NetBSD: cpu_i386.c,v 1.5 2018/05/18 20:21:14 reinoud Exp $"); #include <sys/types.h> #include <sys/systm.h> @@ -117,7 +112,7 @@ sendsig_siginfo(const ksiginfo_t *ksi, c KASSERT(mutex_owned(p->p_lock)); ucp = &pcb->pcb_userret_ucp; - reg = (register_t *) &ucp->uc_mcontext; + reg = (register_t *) &ucp->uc_mcontext.__gregs; #if 0 thunk_printf("%s: ", __func__); thunk_printf("flags %d, ", (int) ksi->ksi_flags); @@ -198,7 +193,7 @@ setregs(struct lwp *l, struct exec_packa /* set up the user context */ ucp = &pcb->pcb_userret_ucp; - reg = (int *) &ucp->uc_mcontext; + reg = (int *) &ucp->uc_mcontext.__gregs; for (i = 4; i < 11; i++) reg[i] = 0; @@ -228,7 +223,7 @@ setregs(struct lwp *l, struct exec_packa void md_syscall_get_syscallnumber(ucontext_t *ucp, uint32_t *code) { - uint *reg = (int *) &ucp->uc_mcontext; + uint *reg = (int *) &ucp->uc_mcontext.__gregs; *code = reg[11]; /* EAX */ } @@ -236,7 +231,7 @@ int md_syscall_getargs(lwp_t *l, ucontext_t *ucp, int nargs, int argsize, register_t *args) { - uint *reg = (int *) &ucp->uc_mcontext; + uint *reg = (int *) &ucp->uc_mcontext.__gregs; register_t *sp = (register_t *) reg[17];/* ESP */ int ret; @@ -250,7 +245,7 @@ void md_syscall_set_returnargs(lwp_t *l, ucontext_t *ucp, int error, register_t *rval) { - register_t *reg = (register_t *) &ucp->uc_mcontext; + register_t *reg = (register_t *) &ucp->uc_mcontext.__gregs; reg[16] &= ~PSL_C; /* EFL */ if (error > 0) { @@ -270,7 +265,7 @@ register_t md_get_pc(ucontext_t *ucp) { KASSERT(ucp); - register_t *reg = (register_t *) &ucp->uc_mcontext; + register_t *reg = (register_t *) &ucp->uc_mcontext.__gregs; return reg[14]; /* EIP */ } @@ -279,7 +274,7 @@ register_t md_get_sp(ucontext_t *ucp) { KASSERT(ucp); - register_t *reg = (register_t *) &ucp->uc_mcontext; + register_t *reg = (register_t *) &ucp->uc_mcontext.__gregs; return reg[17]; /* ESP */ } @@ -307,7 +302,7 @@ void md_syscall_get_opcode(ucontext_t *ucp, uint32_t *opcode) { KASSERT(ucp); - register_t *reg = (register_t *) &ucp->uc_mcontext; + register_t *reg = (register_t *) &ucp->uc_mcontext.__gregs; // uint8_t *p8 = (uint8_t *) (reg[14]); uint16_t *p16 = (uint16_t*) (reg[14]); /* EIP */ @@ -328,7 +323,7 @@ void md_syscall_inc_pc(ucontext_t *ucp, uint32_t opcode) { KASSERT(ucp); - uint *reg = (int *) &ucp->uc_mcontext; + uint *reg = (int *) &ucp->uc_mcontext.__gregs; /* advance program counter */ switch (opcode) { @@ -349,7 +344,7 @@ void md_syscall_dec_pc(ucontext_t *ucp, uint32_t opcode) { KASSERT(ucp); - uint *reg = (int *) &ucp->uc_mcontext; + uint *reg = (int *) &ucp->uc_mcontext.__gregs; switch (opcode) { case 0xff0f: /* UD1 */