From 6620a6fb459531921b1730d9a67f54c692e424c7 Mon Sep 17 00:00:00 2001 From: guenther Date: Sat, 18 Apr 2015 05:14:05 +0000 Subject: [PATCH] i386 and amd64 have only one syscall entry point now, so simply the EIP/RIP adjustment for ERESTART ok mlarkin@ --- sys/arch/amd64/amd64/locore.S | 4 ++-- sys/arch/amd64/amd64/trap.c | 10 +++------- sys/arch/i386/i386/locore.s | 4 ++-- sys/arch/i386/i386/trap.c | 13 ++++--------- 4 files changed, 11 insertions(+), 20 deletions(-) diff --git a/sys/arch/amd64/amd64/locore.S b/sys/arch/amd64/amd64/locore.S index c4d9cee4d6a..d3f9cffcfb0 100644 --- a/sys/arch/amd64/amd64/locore.S +++ b/sys/arch/amd64/amd64/locore.S @@ -1,4 +1,4 @@ -/* $OpenBSD: locore.S,v 1.63 2015/03/22 05:55:39 guenther Exp $ */ +/* $OpenBSD: locore.S,v 1.64 2015/04/18 05:14:05 guenther Exp $ */ /* $NetBSD: locore.S,v 1.13 2004/03/25 18:33:17 drochner Exp $ */ /* @@ -1024,7 +1024,7 @@ IDTVEC(syscall) movq %r11, TF_RFLAGS(%rsp) /* old rflags from syscall insn */ movq $(GSEL(GUCODE_SEL, SEL_UPL)), TF_CS(%rsp) movq %rcx,TF_RIP(%rsp) - movq $2,TF_ERR(%rsp) + movq $2,TF_ERR(%rsp) /* ignored */ movq $T_ASTFLT, TF_TRAPNO(%rsp) movq CPUVAR(CURPROC),%r14 diff --git a/sys/arch/amd64/amd64/trap.c b/sys/arch/amd64/amd64/trap.c index 473273c3262..3c452797354 100644 --- a/sys/arch/amd64/amd64/trap.c +++ b/sys/arch/amd64/amd64/trap.c @@ -1,4 +1,4 @@ -/* $OpenBSD: trap.c,v 1.44 2015/03/14 03:38:46 jsg Exp $ */ +/* $OpenBSD: trap.c,v 1.45 2015/04/18 05:14:05 guenther Exp $ */ /* $NetBSD: trap.c,v 1.2 2003/05/04 23:51:56 fvdl Exp $ */ /*- @@ -562,12 +562,8 @@ syscall(struct trapframe *frame) frame->tf_rflags &= ~PSL_C; /* carry bit */ break; case ERESTART: - /* - * The offset to adjust the PC by depends on whether we entered - * the kernel through the trap or call gate. We pushed the - * size of the instruction into tf_err on entry. - */ - frame->tf_rip -= frame->tf_err; + /* Back up over the syscall instruction (2 bytes) */ + frame->tf_rip -= 2; break; case EJUSTRETURN: /* nothing to do */ diff --git a/sys/arch/i386/i386/locore.s b/sys/arch/i386/i386/locore.s index ed000829dc7..81e61c70cdb 100644 --- a/sys/arch/i386/i386/locore.s +++ b/sys/arch/i386/i386/locore.s @@ -1,4 +1,4 @@ -/* $OpenBSD: locore.s,v 1.152 2015/04/12 18:37:53 mlarkin Exp $ */ +/* $OpenBSD: locore.s,v 1.153 2015/04/18 05:14:05 guenther Exp $ */ /* $NetBSD: locore.s,v 1.145 1996/05/03 19:41:19 christos Exp $ */ /*- @@ -1491,7 +1491,7 @@ calltrap: * Trap gate entry for syscall */ IDTVEC(syscall) - pushl $2 # size of instruction for restart + pushl $2 # ignored pushl $T_ASTFLT # trap # for doing ASTs INTRENTRY pushl %esp diff --git a/sys/arch/i386/i386/trap.c b/sys/arch/i386/i386/trap.c index 5119002090d..e277cdf1940 100644 --- a/sys/arch/i386/i386/trap.c +++ b/sys/arch/i386/i386/trap.c @@ -1,4 +1,4 @@ -/* $OpenBSD: trap.c,v 1.120 2015/01/11 19:34:52 guenther Exp $ */ +/* $OpenBSD: trap.c,v 1.121 2015/04/18 05:14:05 guenther Exp $ */ /* $NetBSD: trap.c,v 1.95 1996/05/05 06:50:02 mycroft Exp $ */ /*- @@ -531,7 +531,7 @@ syscall(struct trapframe *frame) caddr_t params; struct sysent *callp; struct proc *p; - int error, opc, nsys; + int error, nsys; register_t code, args[8], rval[2]; #ifdef DIAGNOSTIC int ocpl = lapic_tpr; @@ -545,7 +545,6 @@ syscall(struct trapframe *frame) #endif p = curproc; p->p_md.md_regs = frame; - opc = frame->tf_eip; code = frame->tf_eax; nsys = p->p_p->ps_emul->e_nsysent; @@ -640,12 +639,8 @@ syscall(struct trapframe *frame) frame->tf_eflags &= ~PSL_C; /* carry bit */ break; case ERESTART: - /* - * The offset to adjust the PC by depends on whether we entered - * the kernel through the trap or call gate. We pushed the - * size of the instruction into tf_err on entry. - */ - frame->tf_eip = opc - frame->tf_err; + /* Back up over the int$80 (2 bytes) that made the syscall */ + frame->tf_eip -= 2; break; case EJUSTRETURN: /* nothing to do */ -- 2.20.1