triple fault executing kernel

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Post Reply
spectrum
Member
Member
Posts: 37
Joined: Wed Jun 13, 2007 7:06 am

triple fault executing kernel

Post by spectrum »

Dear all,
i recently changed my small os to be loaded from a vbr, in this way:

mbr -> vbr -> os

So the vbr actually reads 255 sectors from IDE /virtual, bochs) disk and loads it to 0x1e0000.
So the os code is build as to be executed at 0x1e0000.

The os binary includes a startup.S that just jump to the main function in main.o

Code: Select all

.file "startup.S"

.text
.code64
start:
	mov	$_kmain, %rax
        jmp	*%rax
But at the moment the jump to kmain is taken (kmain is @ 0x1e2667, seen from map file)
i get the following error:

Code: Select all

00018056871e[CPU0 ] interrupt(long mode): IDT entry extended attributes DWORD4 TYPE != 0
00018056871e[CPU0 ] interrupt(long mode): IDT entry extended attributes DWORD4 TYPE != 0
00018056871i[CPU0 ] CPU is in long mode (active)
00018056871i[CPU0 ] CS.mode = 64 bit
00018056871i[CPU0 ] SS.mode = 64 bit
00018056871i[CPU0 ] EFER   = 0x00000500
00018056871i[CPU0 ] | RAX=00000000001e2667  RBX=0000000000000081
00018056871i[CPU0 ] | RCX=0000000000000000  RDX=00000000000001f0
00018056871i[CPU0 ] | RSP=0000000000217dd0  RBP=000000000000010b
00018056871i[CPU0 ] | RSI=00000000000e0174  RDI=0000000000200000
00018056871i[CPU0 ] |  R8=0000000000000000   R9=0000000000000000
00018056871i[CPU0 ] | R10=0000000000000000  R11=0000000000000000
00018056871i[CPU0 ] | R12=0000000000000000  R13=0000000000000000
00018056871i[CPU0 ] | R14=0000000000000000  R15=0000000000000000
00018056871i[CPU0 ] | IOPL=0 id vip vif ac vm RF nt of df if tf sf ZF af PF cf
00018056871i[CPU0 ] | SEG sltr(index|ti|rpl)     base    limit G D
00018056871i[CPU0 ] |  CS:0008( 0001| 0|  0) 00000000 00000000 0 0
00018056871i[CPU0 ] |  DS:0010( 0002| 0|  0) 00000000 00000000 0 0
00018056871i[CPU0 ] |  SS:0010( 0002| 0|  0) 00000000 00000000 0 0
00018056871i[CPU0 ] |  ES:0010( 0002| 0|  0) 00000000 00000000 0 0
00018056871i[CPU0 ] |  FS:0010( 0002| 0|  0) 00000000 00000000 0 0
00018056871i[CPU0 ] |  GS:0010( 0002| 0|  0) 00000000 00000000 0 0
00018056871i[CPU0 ] |  MSR_FS_BASE:0000000000000000
00018056871i[CPU0 ] |  MSR_GS_BASE:0000000000000000
00018056871i[CPU0 ] | RIP=00000000001e2667 (00000000001e2667)
00018056871i[CPU0 ] | CR0=0xe0000011 CR2=0x0000000000217dc8
00018056871i[CPU0 ] | CR3=0x00001000 CR4=0x00000020
(0).[18056871] [0x00000000001e2667] 0008:00000000001e2667 (unk. ctxt): push rbp                  ; 55
00018056871e[CPU0 ] exception(): 3rd (13) exception with no resolution, shutdown status is 00h, resetting
00018056871i[SYS  ] bx_pc_system_c::Reset(HARDWARE) called
00018056871i[CPU0 ] cpu hardware reset
00018056871i[APIC0] allocate APIC id=0 (MMIO enabled) to 0x00000000fee00000
00018056871i[CPU0 ] CPUID[0x00000000]: 00000002 756e6547 6c65746e 49656e69
00018056871i[CPU0 ] CPUID[0x00000001]: 00000633 00010800 00002028 1fcbfbff
00018056871i[CPU0 ] CPUID[0x00000002]: 00410601 00000000 00000000 00000000
00018056871i[CPU0 ] CPUID[0x80000000]: 80000008 00000000 00000000 00000000
00018056871i[CPU0 ] CPUID[0x80000001]: 00000000 00000000 00000101 2a100000
00018056871i[CPU0 ] CPUID[0x80000002]: 20202020 20202020 20202020 6e492020
00018056871i[CPU0 ] CPUID[0x80000003]: 286c6574 50202952 69746e65 52286d75
00018056871i[CPU0 ] CPUID[0x80000004]: 20342029 20555043 20202020 00202020
00018056871i[CPU0 ] CPUID[0x80000005]: 01ff01ff 01ff01ff 40020140 40020140
00018056871i[CPU0 ] CPUID[0x80000006]: 00000000 42004200 02008140 00000000
00018056871i[CPU0 ] CPUID[0x80000007]: 00000000 00000000 00000000 00000000
00018056871i[CPU0 ] CPUID[0x80000008]: 00003028 00000000 00000000 00000000
00018056871i[PLGIN] reset of 'pci' plugin device by virtual method
00018056871i[PLGIN] reset of 'pci2isa' plugin device by virtual method
00018056871i[PLGIN] reset of 'cmos' plugin device by virtual method
00018056871i[PLGIN] reset of 'dma' plugin device by virtual method
00018056871i[PLGIN] reset of 'pic' plugin device by virtual method
00018056871i[PLGIN] reset of 'pit' plugin device by virtual method
00018056871i[PLGIN] reset of 'floppy' plugin device by virtual method
00018056871i[PLGIN] reset of 'vga' plugin device by virtual method
00018056871i[PLGIN] reset of 'acpi' plugin device by virtual method
00018056871i[PLGIN] reset of 'ioapic' plugin device by virtual method
00018056871i[PLGIN] reset of 'keyboard' plugin device by virtual method
00018056871i[PLGIN] reset of 'harddrv' plugin device by virtual method
00018056871i[PLGIN] reset of 'pci_ide' plugin device by virtual method
00018056871i[PLGIN] reset of 'unmapped' plugin device by virtual method
00018056871i[PLGIN] reset of 'biosdev' plugin device by virtual method
00018056871i[PLGIN] reset of 'speaker' plugin device by virtual method
00018056871i[PLGIN] reset of 'extfpuirq' plugin device by virtual method
00018056871i[PLGIN] reset of 'parallel' plugin device by virtual method
00018056871i[PLGIN] reset of 'serial' plugin device by virtual method
00018056871i[PLGIN] reset of 'gameport' plugin device by virtual method
00018056871i[PLGIN] reset of 'iodebug' plugin device by virtual method
Next at t=18056872
(0) [0x00000000fffffff0] f000:fff0 (unk. ctxt): jmp far f000:e05b         ; ea5be000f0
00018056872i[XGUI ] Mouse capture off
<bochs:2> ^C00018056872i[     ] Ctrl-C detected in signal handler.

You see, RIP register is exactly at 0x1e2667 where kmain starts.


Every help is very appreciated,
thanks
Angelo
embryo2
Member
Member
Posts: 397
Joined: Wed Jun 03, 2015 5:03 am

Re: triple fault executing kernel

Post by embryo2 »

spectrum wrote:Dear all
...

Code: Select all

00018056871e[CPU0 ] exception(): 3rd (13) exception with no resolution, shutdown status is 00h, resetting
...
You see, RIP register is exactly at 0x1e2667 where kmain starts.
If you use Bochs's debugger you can see the instruction at 0x1e2667 and processor state. Triple fault at this point tells me about wrong instruction or a problem with processor state (like wrong segments or paging settings).
My previous account (embryo) was accidentally deleted, so I have no chance but to use something new. But may be it was a good lesson about software reliability :)
Stamerlan
Member
Member
Posts: 25
Joined: Thu Nov 05, 2015 8:59 am
Location: Minsk, Belarus

Re: triple fault executing kernel

Post by Stamerlan »

Hi,

Does IDT and IDTR setup correctly? If not does interrupts disabled?
IDT entry extended attributes DWORD4 TYPE != 0
jnc100
Member
Member
Posts: 775
Joined: Mon Apr 09, 2007 12:10 pm
Location: London, UK
Contact:

Re: triple fault executing kernel

Post by jnc100 »

Your stack is set up to be at 0x217dd0, and that region is not mapped as can be seen by the value of cr2 (and that the faults occurred during a push operation). Additionally, your IDT is set up wrong (it is either not present or you are using 32-bit entries rather than 64-bit ones).

Regards,
John.
spectrum
Member
Member
Posts: 37
Joined: Wed Jun 13, 2007 7:06 am

Re: triple fault executing kernel

Post by spectrum »

Thanks all,

jnc100 get it.

Sometime a look into registers values can help.
Post Reply