summaryrefslogtreecommitdiff
path: root/trap.c
diff options
context:
space:
mode:
Diffstat (limited to 'trap.c')
-rw-r--r--trap.c26
1 files changed, 23 insertions, 3 deletions
diff --git a/trap.c b/trap.c
index 6f5409b..66b15e0 100644
--- a/trap.c
+++ b/trap.c
@@ -36,8 +36,14 @@ trap(struct Trapframe *tf)
{
int v = tf->tf_trapno;
+ if(cpus[cpu()].clis){
+ cprintf("cpu %d v %d eip %x\n", cpu(), v, tf->tf_eip);
+ panic("interrupt while interrupts are off");
+ }
+
if(v == T_SYSCALL){
struct proc *cp = curproc[cpu()];
+ int num = cp->tf->tf_regs.reg_eax;
if(cp == 0)
panic("syscall with no proc");
if(cp->killed)
@@ -50,6 +56,14 @@ trap(struct Trapframe *tf)
panic("trap ret but not RUNNING");
if(tf != cp->tf)
panic("trap ret wrong tf");
+ if(cp->locks){
+ cprintf("num=%d\n", num);
+ panic("syscall returning locks held");
+ }
+ if(cpus[cpu()].clis)
+ panic("syscall returning but clis != 0");
+ if((read_eflags() & FL_IF) == 0)
+ panic("syscall returning but FL_IF clear");
if(read_esp() < (unsigned)cp->kstack ||
read_esp() >= (unsigned)cp->kstack + KSTACKSIZE)
panic("trap ret esp wrong");
@@ -61,14 +75,20 @@ trap(struct Trapframe *tf)
if(v == (IRQ_OFFSET + IRQ_TIMER)){
struct proc *cp = curproc[cpu()];
lapic_timerintr();
+ if(cp && cp->locks)
+ panic("timer interrupt while holding a lock");
if(cp){
- if(cpus[cpu()].clis != 0)
- panic("trap clis > 0");
+#if 1
+ if((read_eflags() & FL_IF) == 0)
+ panic("timer interrupt but interrupts now disabled");
+#else
cpus[cpu()].clis += 1;
sti();
+#endif
if(cp->killed)
proc_exit();
- yield();
+ if(cp->state == RUNNING)
+ yield();
}
return;
}