summaryrefslogtreecommitdiff
path: root/trap.c
diff options
context:
space:
mode:
authorrtm <rtm>2006-08-10 22:08:14 +0000
committerrtm <rtm>2006-08-10 22:08:14 +0000
commit5be0039ce9e22f140a29e167526c64c723c5be3c (patch)
tree4096ed2b728cbee37dd2adee06e83f0e908f72b6 /trap.c
parent8a8be1b8c36e38f58f8ba3e425b6e701ad65abf3 (diff)
downloadxv6-labs-5be0039ce9e22f140a29e167526c64c723c5be3c.tar.gz
xv6-labs-5be0039ce9e22f140a29e167526c64c723c5be3c.tar.bz2
xv6-labs-5be0039ce9e22f140a29e167526c64c723c5be3c.zip
interrupts could be recursive since lapic_eoi() called before rti
so fast interrupts overflow the kernel stack fix: cli() before lapic_eoi()
Diffstat (limited to 'trap.c')
-rw-r--r--trap.c20
1 files changed, 20 insertions, 0 deletions
diff --git a/trap.c b/trap.c
index b172a77..99aaa70 100644
--- a/trap.c
+++ b/trap.c
@@ -41,6 +41,17 @@ trap(struct trapframe *tf)
panic("interrupt while holding a lock");
}
+ if(cpu() == 1 && curproc[cpu()] == 0){
+ if(&tf < cpus[cpu()].mpstack || &tf > cpus[cpu()].mpstack + 512){
+ cprintf("&tf %x mpstack %x\n", &tf, cpus[cpu()].mpstack);
+ panic("trap cpu stack");
+ }
+ } else if(curproc[cpu()]){
+ if(&tf < curproc[cpu()]->kstack){
+ panic("trap kstack");
+ }
+ }
+
if(v == T_SYSCALL){
struct proc *cp = curproc[cpu()];
int num = cp->tf->eax;
@@ -97,11 +108,20 @@ trap(struct trapframe *tf)
if(v == (IRQ_OFFSET + IRQ_IDE)){
ide_intr();
+ if(cpus[cpu()].nlock)
+ panic("ide_intr returned while holding a lock");
+ cli(); // prevent a waiting interrupt from overflowing stack
+ lapic_eoi();
return;
}
if(v == (IRQ_OFFSET + IRQ_KBD)){
kbd_intr();
+ if(cpus[cpu()].nlock){
+ panic("kbd_intr returned while holding a lock");
+ }
+ cli(); // prevent a waiting interrupt from overflowing stack
+ lapic_eoi();
return;
}