Fri Oct 26 14:46:44 2012 UTC ()
in osyscall, set the PSL_I bit into the correct field of the trapframe.
it was going into tf_eip instead of tf_eflags, which would sometimes
corrupt %eip and always return to user mode with interrupts disabled.
this was found with a netbsd 1.0 binary, and dsl@ points out that
this should also fix PR 41342.


(chs)
diff -r1.102 -r1.103 src/sys/arch/i386/i386/locore.S

cvs diff -r1.102 -r1.103 src/sys/arch/i386/i386/locore.S (expand / switch to unified diff)

--- src/sys/arch/i386/i386/locore.S 2012/09/01 23:19:46 1.102
+++ src/sys/arch/i386/i386/locore.S 2012/10/26 14:46:44 1.103
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: locore.S,v 1.102 2012/09/01 23:19:46 cherry Exp $ */ 1/* $NetBSD: locore.S,v 1.103 2012/10/26 14:46:44 chs Exp $ */
2 2
3/* 3/*
4 * Copyright-o-rama! 4 * Copyright-o-rama!
5 */ 5 */
6 6
7/* 7/*
8 * Copyright (c) 2006 Manuel Bouyer. 8 * Copyright (c) 2006 Manuel Bouyer.
9 * 9 *
10 * Redistribution and use in source and binary forms, with or without 10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions 11 * modification, are permitted provided that the following conditions
12 * are met: 12 * are met:
13 * 1. Redistributions of source code must retain the above copyright 13 * 1. Redistributions of source code must retain the above copyright
14 * notice, this list of conditions and the following disclaimer. 14 * notice, this list of conditions and the following disclaimer.
@@ -119,27 +119,27 @@ @@ -119,27 +119,27 @@
119 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 119 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
120 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 120 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
121 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 121 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
122 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 122 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
123 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 123 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
124 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 124 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
125 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 125 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
126 * SUCH DAMAGE. 126 * SUCH DAMAGE.
127 * 127 *
128 * @(#)locore.s 7.3 (Berkeley) 5/13/91 128 * @(#)locore.s 7.3 (Berkeley) 5/13/91
129 */ 129 */
130 130
131#include <machine/asm.h> 131#include <machine/asm.h>
132__KERNEL_RCSID(0, "$NetBSD: locore.S,v 1.102 2012/09/01 23:19:46 cherry Exp $"); 132__KERNEL_RCSID(0, "$NetBSD: locore.S,v 1.103 2012/10/26 14:46:44 chs Exp $");
133 133
134#include "opt_compat_oldboot.h" 134#include "opt_compat_oldboot.h"
135#include "opt_ddb.h" 135#include "opt_ddb.h"
136#include "opt_modular.h" 136#include "opt_modular.h"
137#include "opt_multiboot.h" 137#include "opt_multiboot.h"
138#include "opt_realmem.h" 138#include "opt_realmem.h"
139#include "opt_vm86.h" 139#include "opt_vm86.h"
140#include "opt_xen.h" 140#include "opt_xen.h"
141 141
142#include "npx.h" 142#include "npx.h"
143#include "assym.h" 143#include "assym.h"
144#include "lapic.h" 144#include "lapic.h"
145#include "ioapic.h" 145#include "ioapic.h"
@@ -1120,27 +1120,27 @@ END(savectx) @@ -1120,27 +1120,27 @@ END(savectx)
1120 1120
1121/* 1121/*
1122 * osyscall() 1122 * osyscall()
1123 * 1123 *
1124 * Old call gate entry for syscall 1124 * Old call gate entry for syscall
1125 */ 1125 */
1126IDTVEC(osyscall) 1126IDTVEC(osyscall)
1127#ifndef XEN 1127#ifndef XEN
1128 /* XXX we are in trouble! interrupts be off here. */ 1128 /* XXX we are in trouble! interrupts be off here. */
1129 cli # must be first instruction 1129 cli # must be first instruction
1130#endif 1130#endif
1131 pushfl # set eflags in trap frame 1131 pushfl # set eflags in trap frame
1132 popl 8(%esp) 1132 popl 8(%esp)
1133 orl $PSL_I,(%esp) # re-enable ints on return to user 1133 orl $PSL_I,8(%esp) # re-enable ints on return to user
1134 pushl $7 # size of instruction for restart 1134 pushl $7 # size of instruction for restart
1135 jmp syscall1 1135 jmp syscall1
1136IDTVEC_END(osyscall) 1136IDTVEC_END(osyscall)
1137 1137
1138/* 1138/*
1139 * syscall() 1139 * syscall()
1140 * 1140 *
1141 * Trap gate entry for syscall 1141 * Trap gate entry for syscall
1142 */ 1142 */
1143IDTVEC(syscall) 1143IDTVEC(syscall)
1144 pushl $2 # size of instruction for restart 1144 pushl $2 # size of instruction for restart
1145syscall1: 1145syscall1:
1146 pushl $T_ASTFLT # trap # for doing ASTs 1146 pushl $T_ASTFLT # trap # for doing ASTs