Module Name: src Committed By: martin Date: Wed Apr 26 14:52:50 UTC 2017
Modified Files: src/sys/arch/amd64/amd64 [netbsd-7]: locore.S machdep.c trap.c Log Message: Pull up following revision(s) (requested by bsiegert in ticket #1397): sys/arch/amd64/amd64/locore.S 1.122 (via patch) sys/arch/amd64/amd64/machdep.c 1.254 (via patch) sys/arch/amd64/amd64/trap.c 1.95 (via patch) Remove the call gate on amd64, it is useless and vulnerable. To generate a diff of this commit: cvs rdiff -u -r1.76 -r1.76.2.1 src/sys/arch/amd64/amd64/locore.S cvs rdiff -u -r1.211 -r1.211.2.1 src/sys/arch/amd64/amd64/machdep.c cvs rdiff -u -r1.78.4.1 -r1.78.4.2 src/sys/arch/amd64/amd64/trap.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/amd64/amd64/locore.S diff -u src/sys/arch/amd64/amd64/locore.S:1.76 src/sys/arch/amd64/amd64/locore.S:1.76.2.1 --- src/sys/arch/amd64/amd64/locore.S:1.76 Fri May 16 00:48:41 2014 +++ src/sys/arch/amd64/amd64/locore.S Wed Apr 26 14:52:50 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: locore.S,v 1.76 2014/05/16 00:48:41 rmind Exp $ */ +/* $NetBSD: locore.S,v 1.76.2.1 2017/04/26 14:52:50 martin Exp $ */ /* * Copyright-o-rama! @@ -1287,27 +1287,6 @@ NENTRY(lwp_trampoline) END(lwp_trampoline) /* - * oosyscall() - * - * Old call gate entry for syscall. only needed if we're - * going to support running old i386 NetBSD 1.0 or ibcs2 binaries, etc, - * on NetBSD/amd64. - * The 64bit call gate can't request that arguments be copied from the - * user stack (which the i386 code uses to get a gap for the flags). - * push/pop are <read>:<modify_sp>:<write> cycles. - */ -IDTVEC(oosyscall) - /* Set rflags in trap frame. */ - pushq (%rsp) # move user's %eip - pushq 16(%rsp) # and %cs - popq 8(%rsp) - pushfq - popq 16(%rsp) - pushq $7 # size of instruction for restart - jmp osyscall1 -IDTVEC_END(oosyscall) - -/* * osyscall() * * Trap gate entry for int $80 syscall, also used by sigreturn. Index: src/sys/arch/amd64/amd64/machdep.c diff -u src/sys/arch/amd64/amd64/machdep.c:1.211 src/sys/arch/amd64/amd64/machdep.c:1.211.2.1 --- src/sys/arch/amd64/amd64/machdep.c:1.211 Mon May 12 22:50:03 2014 +++ src/sys/arch/amd64/amd64/machdep.c Wed Apr 26 14:52:50 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: machdep.c,v 1.211 2014/05/12 22:50:03 uebayasi Exp $ */ +/* $NetBSD: machdep.c,v 1.211.2.1 2017/04/26 14:52:50 martin Exp $ */ /*- * Copyright (c) 1996, 1997, 1998, 2000, 2006, 2007, 2008, 2011 @@ -111,7 +111,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.211 2014/05/12 22:50:03 uebayasi Exp $"); +__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.211.2.1 2017/04/26 14:52:50 martin Exp $"); /* #define XENDEBUG_LOW */ @@ -1696,10 +1696,7 @@ init_x86_64(paddr_t first_avail) set_mem_segment(GDT_ADDR_MEM(gdtstore, GUDATA_SEL), 0, x86_btop(VM_MAXUSER_ADDRESS) - 1, SDT_MEMRWA, SEL_UPL, 1, 0, 1); - /* make ldt gates and memory segments */ - setgate((struct gate_descriptor *)(ldtstore + LSYS5CALLS_SEL), - &IDTVEC(oosyscall), 0, SDT_SYS386CGT, SEL_UPL, - GSEL(GCODE_SEL, SEL_KPL)); + /* make ldt memory segments */ *(struct mem_segment_descriptor *)(ldtstore + LUCODE_SEL) = *GDT_ADDR_MEM(gdtstore, GUCODE_SEL); *(struct mem_segment_descriptor *)(ldtstore + LUDATA_SEL) = @@ -1731,16 +1728,6 @@ init_x86_64(paddr_t first_avail) set_mem_segment(ldt_segp, 0, x86_btop(VM_MAXUSER_ADDRESS32) - 1, SDT_MEMRWA, SEL_UPL, 1, 1, 0); - /* - * Other entries. - */ - memcpy((struct gate_descriptor *)(ldtstore + LSOL26CALLS_SEL), - (struct gate_descriptor *)(ldtstore + LSYS5CALLS_SEL), - sizeof (struct gate_descriptor)); - memcpy((struct gate_descriptor *)(ldtstore + LBSDICALLS_SEL), - (struct gate_descriptor *)(ldtstore + LSYS5CALLS_SEL), - sizeof (struct gate_descriptor)); - /* exceptions */ for (x = 0; x < 32; x++) { #ifndef XEN Index: src/sys/arch/amd64/amd64/trap.c diff -u src/sys/arch/amd64/amd64/trap.c:1.78.4.1 src/sys/arch/amd64/amd64/trap.c:1.78.4.2 --- src/sys/arch/amd64/amd64/trap.c:1.78.4.1 Sat Mar 25 16:57:39 2017 +++ src/sys/arch/amd64/amd64/trap.c Wed Apr 26 14:52:50 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: trap.c,v 1.78.4.1 2017/03/25 16:57:39 snj Exp $ */ +/* $NetBSD: trap.c,v 1.78.4.2 2017/04/26 14:52:50 martin Exp $ */ /*- * Copyright (c) 1998, 2000 The NetBSD Foundation, Inc. @@ -68,7 +68,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: trap.c,v 1.78.4.1 2017/03/25 16:57:39 snj Exp $"); +__KERNEL_RCSID(0, "$NetBSD: trap.c,v 1.78.4.2 2017/04/26 14:52:50 martin Exp $"); #include "opt_ddb.h" #include "opt_kgdb.h" @@ -222,7 +222,6 @@ trap(struct trapframe *frame) struct proc *p; struct pcb *pcb; extern char fusuintrfailure[], kcopy_fault[]; - extern char IDTVEC(oosyscall)[]; extern char IDTVEC(osyscall)[]; extern char IDTVEC(syscall32)[]; #ifndef XEN @@ -647,8 +646,7 @@ faultcommon: case T_TRCTRAP: /* Check whether they single-stepped into a lcall. */ - if (frame->tf_rip == (uint64_t)IDTVEC(oosyscall) || - frame->tf_rip == (uint64_t)IDTVEC(osyscall) || + if (frame->tf_rip == (uint64_t)IDTVEC(osyscall) || frame->tf_rip == (uint64_t)IDTVEC(syscall32)) { frame->tf_rflags &= ~PSL_T; return;