From bc588e93d717531ddba3a8fb4d1b54155ed5c15d Mon Sep 17 00:00:00 2001 From: Matthew Dillon Date: Thu, 15 Jan 2004 00:03:08 +0000 Subject: [PATCH] npx_intr() expects an interrupt frame but was given something inbetween an interrupt frame and a trap frame, causing a panic. Save/restore %ebx (the CPL) just like the other entry points in this file do, push the two 32 bit words required to convert the trap frame into an interrupt frame, and clean up the frame on return for the jump to doreti. Reported-by: David Rhodus --- sys/i386/i386/exception.s | 16 +++++++++++++--- sys/platform/pc32/i386/exception.s | 16 +++++++++++++--- 2 files changed, 26 insertions(+), 6 deletions(-) diff --git a/sys/i386/i386/exception.s b/sys/i386/i386/exception.s index b3593fb02c..db84e15a96 100644 --- a/sys/i386/i386/exception.s +++ b/sys/i386/i386/exception.s @@ -31,7 +31,7 @@ * SUCH DAMAGE. * * $FreeBSD: src/sys/i386/i386/exception.s,v 1.65.2.3 2001/08/15 01:23:49 peter Exp $ - * $DragonFly: src/sys/i386/i386/Attic/exception.s,v 1.20 2003/10/25 17:36:22 dillon Exp $ + * $DragonFly: src/sys/i386/i386/Attic/exception.s,v 1.21 2004/01/15 00:03:08 dillon Exp $ */ #include "use_npx.h" @@ -725,12 +725,18 @@ IDTVEC(fpu) movl PCPU(curthread),%ebx /* save original cpl */ movl TD_CPL(%ebx), %ebx - pushl %ebx incl PCPU(cnt)+V_TRAP + /* additional dummy pushes to fake an interrupt frame */ + pushl $0 /* ppl */ + pushl $0 /* vector */ + + /* warning, trap frame dummy arg, no extra reg pushes */ call npx_intr /* note: call might mess w/ argument */ - movl %ebx, (%esp) /* save cpl for doreti */ + /* convert back to a trapframe for doreti */ + addl $4,%esp + movl %ebx,(%esp) MEXITCOUNT jmp doreti #else /* NNPX > 0 */ @@ -772,6 +778,7 @@ calltrap: incl PCPU(cnt)+V_TRAP movl PCPU(curthread),%eax /* keep orig cpl here during call */ movl TD_CPL(%eax),%ebx + /* warning, trap frame dummy arg, no extra reg pushes */ call trap /* @@ -815,6 +822,7 @@ IDTVEC(syscall) movl $7,TF_ERR(%esp) /* sizeof "lcall 7,0" */ FAKE_MCOUNT(13*4(%esp)) incl PCPU(cnt)+V_SYSCALL /* YYY per-cpu */ + /* warning, trap frame dummy arg, no extra reg pushes */ call syscall2 MEXITCOUNT cli /* atomic reqflags interlock w/iret */ @@ -848,6 +856,7 @@ IDTVEC(int0x80_syscall) movl $2,TF_ERR(%esp) /* sizeof "int 0x80" */ FAKE_MCOUNT(13*4(%esp)) incl PCPU(cnt)+V_SYSCALL + /* warning, trap frame dummy arg, no extra reg pushes */ call syscall2 MEXITCOUNT cli /* atomic reqflags interlock w/irq */ @@ -880,6 +889,7 @@ IDTVEC(int0x81_syscall) /* note: tf_err is not used */ FAKE_MCOUNT(13*4(%esp)) incl PCPU(cnt)+V_SENDSYS + /* warning, trap frame dummy arg, no extra reg pushes */ call sendsys2 MEXITCOUNT cli /* atomic reqflags interlock w/irq */ diff --git a/sys/platform/pc32/i386/exception.s b/sys/platform/pc32/i386/exception.s index 9de3ae183b..6255e659b9 100644 --- a/sys/platform/pc32/i386/exception.s +++ b/sys/platform/pc32/i386/exception.s @@ -31,7 +31,7 @@ * SUCH DAMAGE. * * $FreeBSD: src/sys/i386/i386/exception.s,v 1.65.2.3 2001/08/15 01:23:49 peter Exp $ - * $DragonFly: src/sys/platform/pc32/i386/exception.s,v 1.20 2003/10/25 17:36:22 dillon Exp $ + * $DragonFly: src/sys/platform/pc32/i386/exception.s,v 1.21 2004/01/15 00:03:08 dillon Exp $ */ #include "use_npx.h" @@ -725,12 +725,18 @@ IDTVEC(fpu) movl PCPU(curthread),%ebx /* save original cpl */ movl TD_CPL(%ebx), %ebx - pushl %ebx incl PCPU(cnt)+V_TRAP + /* additional dummy pushes to fake an interrupt frame */ + pushl $0 /* ppl */ + pushl $0 /* vector */ + + /* warning, trap frame dummy arg, no extra reg pushes */ call npx_intr /* note: call might mess w/ argument */ - movl %ebx, (%esp) /* save cpl for doreti */ + /* convert back to a trapframe for doreti */ + addl $4,%esp + movl %ebx,(%esp) MEXITCOUNT jmp doreti #else /* NNPX > 0 */ @@ -772,6 +778,7 @@ calltrap: incl PCPU(cnt)+V_TRAP movl PCPU(curthread),%eax /* keep orig cpl here during call */ movl TD_CPL(%eax),%ebx + /* warning, trap frame dummy arg, no extra reg pushes */ call trap /* @@ -815,6 +822,7 @@ IDTVEC(syscall) movl $7,TF_ERR(%esp) /* sizeof "lcall 7,0" */ FAKE_MCOUNT(13*4(%esp)) incl PCPU(cnt)+V_SYSCALL /* YYY per-cpu */ + /* warning, trap frame dummy arg, no extra reg pushes */ call syscall2 MEXITCOUNT cli /* atomic reqflags interlock w/iret */ @@ -848,6 +856,7 @@ IDTVEC(int0x80_syscall) movl $2,TF_ERR(%esp) /* sizeof "int 0x80" */ FAKE_MCOUNT(13*4(%esp)) incl PCPU(cnt)+V_SYSCALL + /* warning, trap frame dummy arg, no extra reg pushes */ call syscall2 MEXITCOUNT cli /* atomic reqflags interlock w/irq */ @@ -880,6 +889,7 @@ IDTVEC(int0x81_syscall) /* note: tf_err is not used */ FAKE_MCOUNT(13*4(%esp)) incl PCPU(cnt)+V_SENDSYS + /* warning, trap frame dummy arg, no extra reg pushes */ call sendsys2 MEXITCOUNT cli /* atomic reqflags interlock w/irq */ -- 2.41.0