title: QEMU Triple Faulting when enabling interrupts
body: <p>I'm working on a simple operating system, and I'm currently trying to load the IDT. I'm not getting any errors during compilation, but QEMU is triple faulting when I try to enable interrupts.</p>
  
  <p>I have looked at the address in the EIP register with iHex, but it seems to be auto generated code because it is nowhere in the kernel code. I have also tried loading the GDT in my c++ code, but it didn't make a difference and I have already loaded it in my boot loader.</p>
  
  <p>IDT Install function</p>
  
  <pre><code>void idt_install()
  {
      /* Sets the special IDT pointer up, just like in 'gdt.c' */
      idtp.limit = (sizeof (struct idt_entry) * 256) - 1;
      idtp.base = (unsigned int) idt;
  
      /* Clear out the entire IDT, initializing it to zeros */
      memset(&amp;idt, 0, sizeof(struct idt_entry) * 256);
  
      /* Add any new ISRs to the IDT here using idt_set_gate */
  
  
  
      /* Points the processor's internal register to the new IDT */
      idt_load();
  }
  </code></pre>
  
  <p>Relavent code in kernel_init function
  idt_install();</p>
  
  <pre><code>__asm__ __volatile__ ("sti");
  </code></pre>
  
  <p>It should load the IDT and enable interrupts however I get a triple fault and QEMU repeatedly reboots. Here are the results of running QEMU with -d int option.</p>
  
  <pre><code>EAX=000000fa EBX=000b8022 ECX=000b8000 EDX=00000060
  ESI=00007e12 EDI=00000000 EBP=0000de88 ESP=0000de70
  EIP=00007e4a EFL=00000202 [-------] CPL=0 II=0 A20=1 SMM=0 HLT=0
  ES =0010 00000000 ffffffff 00cf9300 DPL=0 DS   [-WA]
  CS =0008 00000000 ffffffff 00cf9a00 DPL=0 CS32 [-R-]
  SS =0010 00000000 ffffffff 00cf9300 DPL=0 DS   [-WA]
  DS =0010 00000000 ffffffff 00cf9300 DPL=0 DS   [-WA]
  FS =0010 00000000 ffffffff 00cf9300 DPL=0 DS   [-WA]
  GS =0010 00000000 ffffffff 00cf9300 DPL=0 DS   [-WA]
  LDT=0000 00000000 0000ffff 00008200 DPL=0 LDT
  TR =0000 00000000 0000ffff 00008b00 DPL=0 TSS32-busy
  GDT=     00007c43 00000018
  IDT=     000096c0 000007ff
  CR0=00000011 CR2=00000000 CR3=00000000 CR4=00000000
  DR0=00000000 DR1=00000000 DR2=00000000 DR3=00000000 
  DR6=ffff0ff0 DR7=00000400
  CCS=00000000 CCD=0000de54 CCO=EFLAGS  
  EFER=0000000000000000
  check_exception old: 0xffffffff new 0xd
       1: v=0d e=0042 i=0 cpl=0 IP=0008:00007e4a pc=00007e4a SP=0010:0000de70 env-&gt;regs[R_EAX]=000000fa
  EAX=000000fa EBX=000b8022 ECX=000b8000 EDX=00000060
  ESI=00007e12 EDI=00000000 EBP=0000de88 ESP=0000de70
  EIP=00007e4a EFL=00000202 [-------] CPL=0 II=0 A20=1 SMM=0 HLT=0
  ES =0010 00000000 ffffffff 00cf9300 DPL=0 DS   [-WA]
  CS =0008 00000000 ffffffff 00cf9a00 DPL=0 CS32 [-R-]
  SS =0010 00000000 ffffffff 00cf9300 DPL=0 DS   [-WA]
  DS =0010 00000000 ffffffff 00cf9300 DPL=0 DS   [-WA]
  FS =0010 00000000 ffffffff 00cf9300 DPL=0 DS   [-WA]
  GS =0010 00000000 ffffffff 00cf9300 DPL=0 DS   [-WA]
  LDT=0000 00000000 0000ffff 00008200 DPL=0 LDT
  TR =0000 00000000 0000ffff 00008b00 DPL=0 TSS32-busy
  GDT=     00007c43 00000018
  IDT=     000096c0 000007ff
  CR0=00000011 CR2=00000000 CR3=00000000 CR4=00000000
  DR0=00000000 DR1=00000000 DR2=00000000 DR3=00000000 
  DR6=ffff0ff0 DR7=00000400
  CCS=00000000 CCD=0000de54 CCO=EFLAGS  
  EFER=0000000000000000
  check_exception old: 0xd new 0xd
       2: v=08 e=0000 i=0 cpl=0 IP=0008:00007e4a pc=00007e4a SP=0010:0000de70 env-&gt;regs[R_EAX]=000000fa
  EAX=000000fa EBX=000b8022 ECX=000b8000 EDX=00000060
  ESI=00007e12 EDI=00000000 EBP=0000de88 ESP=0000de70
  EIP=00007e4a EFL=00000202 [-------] CPL=0 II=0 A20=1 SMM=0 HLT=0
  ES =0010 00000000 ffffffff 00cf9300 DPL=0 DS   [-WA]
  CS =0008 00000000 ffffffff 00cf9a00 DPL=0 CS32 [-R-]
  SS =0010 00000000 ffffffff 00cf9300 DPL=0 DS   [-WA]
  DS =0010 00000000 ffffffff 00cf9300 DPL=0 DS   [-WA]
  FS =0010 00000000 ffffffff 00cf9300 DPL=0 DS   [-WA]
  GS =0010 00000000 ffffffff 00cf9300 DPL=0 DS   [-WA]
  LDT=0000 00000000 0000ffff 00008200 DPL=0 LDT
  TR =0000 00000000 0000ffff 00008b00 DPL=0 TSS32-busy
  GDT=     00007c43 00000018
  IDT=     000096c0 000007ff
  CR0=00000011 CR2=00000000 CR3=00000000 CR4=00000000
  DR0=00000000 DR1=00000000 DR2=00000000 DR3=00000000 
  DR6=ffff0ff0 DR7=00000400
  CCS=00000000 CCD=0000de54 CCO=EFLAGS  
  EFER=0000000000000000
  check_exception old: 0x8 new 0xd
  </code></pre>