Triple fault after enabling long mode

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
aod
Member
Member
Posts: 26
Joined: Fri Sep 30, 2011 2:36 am

Triple fault after enabling long mode

Post by aod »

I'm trying to enable long mode.
I setup page directories, CR4, CR3, EFER and am trying to enable paging. But after

Code: Select all

mov eax, cr0
or eax, 0x80000000
mov cr0, eax
system triple faults and resets. I don't know why. What are possible causes of such a behaviour?
User avatar
Combuster
Member
Member
Posts: 9301
Joined: Wed Oct 18, 2006 3:45 am
Libera.chat IRC: [com]buster
Location: On the balcony, where I can actually keep 1½m distance
Contact:

Re: Triple fault after enabling long mode

Post by Combuster »

aod wrote:What are possible causes of such a behaviour?
Most likely your paging structures are broken. As far as the exact cause is concerned, my crystal ball isn't accurate beyond the fact that you obviously screwed up.

I don't have any information to confirm any hypothesis either - Bochs logs will help you with that.
"Certainly avoid yourself. He is a newbie and might not realize it. You'll hate his code deeply a few years down the road." - Sortie
[ My OS ] [ VDisk/SFS ]
aod
Member
Member
Posts: 26
Joined: Fri Sep 30, 2011 2:36 am

Re: Triple fault after enabling long mode

Post by aod »

Maybe I shall past some code:

Code: Select all

Boot32:
extern CrKrnlMemMap
	mov esp, stack+4096
	call CrKrnlMemMap   
extern PML4
	mov eax, PML4
	mov cr3, eax
	mov eax, cr4
	or  eax, 0xA0
	mov cr4, eax
	mov ecx, 0xC0000080
	rdmsr
	or eax, 0x100
	wrmsr
	mov eax, cr0
	or eax, 0x80000000
	mov cr0, eax
	lgdt [gdt_descriptor]
	mov ax, 0x10
	mov ds, ax
	mov ss, ax
	jmp 0x08:Here
Here:
	mov eax, 0xb8000
	mov bl, 0x41
	mov byte [eax], bl
	jmp Here

section .data
align 4
	dw 0
gdt_descriptor:
	dw 3*8-1
	dd gdt
gdt:
	dd 0,0
 	dd 0,0x00209800
	dd 0,0x00009000
section .bss
stack:
	resb 4096

Code: Select all

#include "Paging32.h"

void StPML4Entry(struct PML4Table *PML4,
                 long long Address,
                 void *PhysAddress,
                 long Present,
                 long ReadWrite,
                 long UserSystem)
{
   PML4->Table[(Address>>39)&0x1FF] =
                 (long)PhysAddress |
                 Present |
                 (ReadWrite<<1) |
                 (UserSystem<<2);
} 

void StPDPEntry(struct PDPTable *PDP,
                long long Address,
                void *PhysAddress,
                long Present,
                long ReadWrite,
                long UserSystem)
{
   PDP->Table[(Address>>30)&0x1FF] =
                (long)PhysAddress |
                Present |
                (ReadWrite<<1) |
                (UserSystem<<2); 
}

void StPDEntry(struct PDTable *PD,
               long long Address,
               void *PhysAddress,
               long Present,
               long ReadWrite,
               long UserSystem)
{
   PD->Table[(Address>>21)&0x1FF] =
               (long)PhysAddress |
               Present |  
               (ReadWrite<<1) |
               (UserSystem<<2);
}

void StPTEntry(struct PTTable *PT,
               long long Address,
               void *PhysAddress,
               long Present,
               long ReadWrite,
               long UserSystem,
               long Global)
{
   PT->Table[(Address>>12)&0x1FF] =
               (long)PhysAddress |
               Present |
               (ReadWrite<<1) |
               (UserSystem<<2) | 
               (Global<<8);
}

struct PML4Table PML4;
struct PDPTable  PDP_32;
struct PDTable   PD_32;
struct PTTable   PT_32;

void CrKrnlMemMap()
{
   long Addr = 0;
   long i;
   StPML4Entry(&PML4, 0, &PDP_32, 1, 1, 0);
   StPDPEntry(&PDP_32, 0, &PD_32, 1, 1, 0);
   StPDEntry(&PD_32, 0, &PT_32, 1, 1, 0);
   for(i=0; i<512; ++i, Addr += 4096)
      StPTEntry(&PT_32, Addr, (void*)Addr, 1, 1, 0, 1);
}

Code: Select all

#ifndef _PAGING32_H_
#define _PAGING32_H_

typedef unsigned long long PageEntry;

struct PML4Table
{
	PageEntry Table[512];
}	__attribute__ ((aligned (4096)));

void StPML4Entry(struct PML4Table *PML4, 
                 long long Address,
                 void *PhysAddress,
                 long Present,
                 long ReadWrite,
                 long UserSystem);						

struct PDPTable
{
	PageEntry Table[512];
}	__attribute__ ((aligned (4096)));

void StPDPEntry(struct PDPTable *PDP,
                long long Address,
                void *PhysAddress,
                long Present,
                long ReadWrite,
                long UserSystem);

struct PDTable
{
	PageEntry Table[512];
} __attribute__ ((aligned (4096)));

void StPDEntry(struct PDTable *PD,
               long long Address,
               void *PhysAddress,
               long Present,
               long ReadWrite,
               long UserSystem);

struct PTTable
{
	PageEntry Table[512];
} __attribute__ ((aligned (4096)));

void StPTEntry(struct PTTable *PT,
               long long Address,
               void *PhysAddress,
               long Present,
               long ReadWrite,
               long UserSystem,
               long Global);

#endif
User avatar
Combuster
Member
Member
Posts: 9301
Joined: Wed Oct 18, 2006 3:45 am
Libera.chat IRC: [com]buster
Location: On the balcony, where I can actually keep 1½m distance
Contact:

Re: Triple fault after enabling long mode

Post by Combuster »

Ever heard of stdint.h?

Also, bochs log's still missing
"Certainly avoid yourself. He is a newbie and might not realize it. You'll hate his code deeply a few years down the road." - Sortie
[ My OS ] [ VDisk/SFS ]
aod
Member
Member
Posts: 26
Joined: Fri Sep 30, 2011 2:36 am

Re: Triple fault after enabling long mode

Post by aod »

Code: Select all

00000000000i[     ] Bochs x86 Emulator 2.4.6
00000000000i[     ]   Build from CVS snapshot, on February 22, 2011
00000000000i[     ] Compiled at Jun 10 2011, 01:23:55
00000000000i[     ] System configuration
00000000000i[     ]   processors: 1 (cores=1, HT threads=1)
00000000000i[     ]   A20 line support: yes
00000000000i[     ] CPU configuration
00000000000i[     ]   level: 6
00000000000i[     ]   SMP support: no
00000000000i[     ]   APIC support: yes
00000000000i[     ]   FPU support: yes
00000000000i[     ]   MMX support: yes
00000000000i[     ]   3dnow! support: yes
00000000000i[     ]   SEP support: yes
00000000000i[     ]   SSE support: sse2
00000000000i[     ]   XSAVE support: no
00000000000i[     ]   AES support: no
00000000000i[     ]   MOVBE support: no
00000000000i[     ]   x86-64 support: no
00000000000i[     ]   VMX support: no
00000000000i[     ] Optimization configuration
00000000000i[     ]   RepeatSpeedups support: no
00000000000i[     ]   Trace cache support: no
00000000000i[     ]   Fast function calls: no
00000000000i[     ] Devices configuration
00000000000i[     ]   ACPI support: no
00000000000i[     ]   NE2000 support: no
00000000000i[     ]   PCI support: no, enabled=no
00000000000i[     ]   SB16 support: no
00000000000i[     ]   USB support: no
00000000000i[     ]   VGA extension support: vbe 
00000000000i[MEM0 ] allocated memory at 0x7f9e2d851010. after alignment, vector=
0x7f9e2d852000
00000000000i[MEM0 ] 32.00MB
00000000000i[MEM0 ] mem block size = 0x00100000, blocks=32
00000000000i[MEM0 ] rom at 0xfffe0000/131072 ('/usr/share/bochs/BIOS-bochs-lates
t')
00000000000i[MEM0 ] rom at 0xc0000/40448 ('/usr/share/bochs/VGABIOS-lgpl-latest'
)
00000000000i[CMOS ] Using local time for initial clock
00000000000i[CMOS ] Setting initial clock to: Tue Oct 11 18:55:23 2011 (time0=13
18352123)
00000000000i[DMA  ] channel 4 used by cascade
00000000000i[DMA  ] channel 2 used by Floppy Drive
00000000000i[VGA  ] interval=50000
00000000000i[MEM0 ] Register memory access handlers: 0x00000000000a0000 - 0x0000
0000000bffff
00000000000i[XGUI ] test_alloc_colors: 16 colors available out of 16 colors trie
d
00000000000i[XGUI ] font 8 wide x 16 high, display depth = 24
00000000000i[MEM0 ] Register memory access handlers: 0x00000000e0000000 - 0x0000
0000e0ffffff
00000000000i[VGA  ] VBE Bochs Display Extension Enabled
00000000000i[     ] init_dev of 'unmapped' plugin device by virtual method
00000000000i[     ] init_dev of 'biosdev' plugin device by virtual method
00000000000i[     ] init_dev of 'speaker' plugin device by virtual method
00000000000i[SPEAK] Open /dev/console successfully
00000000000i[     ] init_dev of 'extfpuirq' plugin device by virtual method
00000000000i[     ] init_dev of 'ioapic' plugin device by virtual method
00000000000i[IOAP ] initializing I/O APIC
00000000000i[MEM0 ] Register memory access handlers: 0x00000000fec00000 - 0x0000
0000fec00fff
00000000000i[     ] init_dev of 'keyboard' plugin device by virtual method
00000000000i[KBD  ] will paste characters every 1000 keyboard ticks
00000000000i[     ] init_dev of 'harddrv' plugin device by virtual method
00000000000i[HD   ] CD on ata0-0: '/home/aod/projects/razor/bin/razor.iso'
00000000000i[CD1  ] load cdrom with path=/home/aod/projects/razor/bin/razor.iso
00000000000i[CD1  ] Opening image file as a cd.
00000000000i[HD   ] Media present in CD-ROM drive
00000000000i[HD   ] Capacity is 257 sectors (0.50 MB)
00000000000i[HD   ] Using boot sequence cdrom, none, none
00000000000i[HD   ] Floppy boot signature check is enabled
00000000000i[     ] init_dev of 'serial' plugin device by virtual method
00000000000i[SER  ] com1 at 0x03f8 irq 4
00000000000i[     ] init_dev of 'parallel' plugin device by virtual method
00000000000i[PAR  ] parallel port 1 at 0x0378 irq 7
00000000000i[     ] register state of 'unmapped' plugin device by virtual method
00000000000i[     ] register state of 'biosdev' plugin device by virtual method
00000000000i[     ] register state of 'speaker' plugin device by virtual method
00000000000i[     ] register state of 'extfpuirq' plugin device by virtual metho
d
00000000000i[     ] register state of 'ioapic' plugin device by virtual method
00000000000i[     ] register state of 'keyboard' plugin device by virtual method
00000000000i[     ] register state of 'harddrv' plugin device by virtual method
00000000000i[     ] register state of 'serial' plugin device by virtual method
00000000000i[     ] register state of 'parallel' plugin device by virtual method
00000000000i[SYS  ] bx_pc_system_c::Reset(HARDWARE) called
00000000000i[CPU0 ] cpu hardware reset
00000000000i[APIC0] allocate APIC id=0 (MMIO enabled) to 0x00000000fee00000
00000000000i[CPU0 ] CPUID[0x00000000]: 00000003 68747541 444d4163 69746e65
00000000000i[CPU0 ] CPUID[0x00000001]: 00000f03 00000800 00000000 07cbfbff
00000000000i[CPU0 ] CPUID[0x00000002]: 00000000 00000000 00000000 00000000
00000000000i[CPU0 ] CPUID[0x00000003]: 00000000 00000000 00000000 00000000
00000000000i[CPU0 ] CPUID[0x00000004]: 00000000 00000000 00000000 00000000
00000000000i[CPU0 ] CPUID[0x00000007]: 00000000 00000000 00000000 00000000
00000000000i[CPU0 ] CPUID[0x80000000]: 80000004 68747541 444d4163 69746e65
00000000000i[CPU0 ] CPUID[0x80000001]: 00000f03 00000000 00000000 c1c3f3ff
00000000000i[CPU0 ] CPUID[0x80000002]: 20444d41 6c687441 74286e6f 7020296d
00000000000i[CPU0 ] CPUID[0x80000003]: 65636f72 726f7373 00000000 00000000
00000000000i[CPU0 ] CPUID[0x80000004]: 00000000 00000000 00000000 00000000
00000000000i[     ] reset of 'unmapped' plugin device by virtual method
00000000000i[     ] reset of 'biosdev' plugin device by virtual method
00000000000i[     ] reset of 'speaker' plugin device by virtual method
00000000000i[     ] reset of 'extfpuirq' plugin device by virtual method
00000000000i[     ] reset of 'ioapic' plugin device by virtual method
00000000000i[     ] reset of 'keyboard' plugin device by virtual method
00000000000i[     ] reset of 'harddrv' plugin device by virtual method
00000000000i[     ] reset of 'serial' plugin device by virtual method
00000000000i[     ] reset of 'parallel' plugin device by virtual method
00000000000i[XGUI ] [x] Mouse off
00000003305i[BIOS ] $Revision: 1.257 $ $Date: 2011/01/26 09:52:02 $
00000318042i[KBD  ] reset-disable command received
00000444800i[VBIOS] VGABios $Id: vgabios.c,v 1.69 2009/04/07 18:18:20 vruppert E
xp $
00000444871i[VGA  ] VBE known Display Interface b0c0
00000444903i[VGA  ] VBE known Display Interface b0c5
00000447828i[VBIOS] VBE Bios $Id: vbe.c,v 1.62 2009/01/25 15:46:25 vruppert Exp 
$
00000600000i[XGUI ] charmap update. Font Height is 16
00000760517i[BIOS ] Starting rombios32
00000761014i[BIOS ] Shutdown flag 0
00000761695i[BIOS ] ram_size=0x02000000
00000762173i[BIOS ] ram_end=32MB
00000802745i[BIOS ] Found 1 cpu(s)
00000821732i[BIOS ] bios_table_addr: 0x000fb928 end=0x000fcc00
00000834409i[BIOS ] bios_table_cur_addr: 0x000fb928
00004710150i[BIOS ] IDE time out
00016746901i[BIOS ] Booting from 07c0:0000
00016863198i[BIOS ] int13_harddisk: function 41, unmapped device for ELDL=80
00016867978i[BIOS ] int13_harddisk: function 08, unmapped device for ELDL=80
00016872626i[BIOS ] *** int 15h function AX=00c0, BX=0000 not yet supported!
00043044326e[CPU0 ] RDMSR: Unknown register 0xc0000080
00043044328e[CPU0 ] WRMSR: Unknown register 0xc0000080
00043044332e[CPU0 ] SetCR0(): PDPTR check failed !
00043044332e[CPU0 ] interrupt(): gate descriptor is not valid sys seg (vector=0x
0d)
00043044332e[CPU0 ] interrupt(): gate descriptor is not valid sys seg (vector=0x
08)
00043044332i[CPU0 ] CPU is in protected mode (active)
00043044332i[CPU0 ] CS.d_b = 32 bit
00043044332i[CPU0 ] SS.d_b = 32 bit
00043044332i[CPU0 ] | EAX=e0000011  EBX=00037220  ECX=c0000080  EDX=00000000
00043044332i[CPU0 ] | ESP=00102000  EBP=00067e2c  ESI=000373b4  EDI=000372e4
00043044332i[CPU0 ] | IOPL=0 id vip vif ac vm RF nt of df if tf SF zf af PF cf
00043044332i[CPU0 ] | SEG selector     base    limit G D
00043044332i[CPU0 ] | SEG sltr(index|ti|rpl)     base    limit G D
00043044332i[CPU0 ] |  CS:0008( 0001| 0|  0) 00000000 ffffffff 1 1
00043044332i[CPU0 ] |  DS:0010( 0002| 0|  0) 00000000 ffffffff 1 1
00043044332i[CPU0 ] |  SS:0010( 0002| 0|  0) 00000000 ffffffff 1 1
00043044332i[CPU0 ] |  ES:0010( 0002| 0|  0) 00000000 ffffffff 1 1
00043044332i[CPU0 ] |  FS:0010( 0002| 0|  0) 00000000 ffffffff 1 1
00043044332i[CPU0 ] |  GS:0010( 0002| 0|  0) 00000000 ffffffff 1 1
00043044332i[CPU0 ] | EIP=0010004c (0010004c)
00043044332i[CPU0 ] | CR0=0x60000011 CR2=0x00000000
00043044332i[CPU0 ] | CR3=0x00105000 CR4=0x000000a0
00043044332i[CPU0 ] 0x0010004c>> mov cr0, eax : 0F22C0
00043044332e[CPU0 ] exception(): 3rd (13) exception with no resolution, shutdown
 status is 00h, resetting
00043044332i[SYS  ] bx_pc_system_c::Reset(HARDWARE) called
00043044332i[CPU0 ] cpu hardware reset
Missing output.
User avatar
Solar
Member
Member
Posts: 7615
Joined: Thu Nov 16, 2006 12:01 pm
Location: Germany
Contact:

Re: Triple fault after enabling long mode

Post by Solar »

Hmm... let me see... I've never tinkered with long mode, but this here looks suspicious:

Code: Select all


00043044332e[CPU0 ] SetCR0(): PDPTR check failed !
00043044332e[CPU0 ] interrupt(): gate descriptor is not valid sys seg (vector=0x
0d)
00043044332e[CPU0 ] interrupt(): gate descriptor is not valid sys seg (vector=0x
08)
I've also never touched the MSR's, so I'll assume that rdmsr and wrmsr failing right before that is somehow OK.

So:
Combuster wrote:Most likely your paging structures are broken.
Last edited by Solar on Tue Oct 11, 2011 9:26 am, edited 1 time in total.
Every good solution is obvious once you've found it.
aod
Member
Member
Posts: 26
Joined: Fri Sep 30, 2011 2:36 am

Re: Triple fault after enabling long mode

Post by aod »

Oops, it seems that I've used 32-bit version of Bochs.

Code: Select all

00000000000i[     ] Bochs x86 Emulator 2.4.6
00000000000i[     ]   Build from CVS snapshot, on February 22, 2011
00000000000i[     ] Compiled at Oct 11 2011, 19:28:31
00000000000i[     ] System configuration
00000000000i[     ]   processors: 1 (cores=1, HT threads=1)
00000000000i[     ]   A20 line support: yes
00000000000i[     ]   load configurable MSRs from file "msrs.def"
00000000000i[     ] CPU configuration
00000000000i[     ]   level: 6
00000000000i[     ]   SMP support: no
00000000000i[     ]   APIC support: yes
00000000000i[     ]   FPU support: yes
00000000000i[     ]   MMX support: yes
00000000000i[     ]   3dnow! support: no
00000000000i[     ]   SEP support: yes
00000000000i[     ]   SSE support: sse4_2
00000000000i[     ]   XSAVE support: yes
00000000000i[     ]   AES support: yes
00000000000i[     ]   MOVBE support: yes
00000000000i[     ]   x86-64 support: yes
00000000000i[     ]   1G paging support: no
00000000000i[     ]   VMX support: no
00000000000i[     ] Optimization configuration
00000000000i[     ]   RepeatSpeedups support: no
00000000000i[     ]   Trace cache support: no
00000000000i[     ]   Fast function calls: no
00000000000i[     ] Devices configuration
00000000000i[     ]   ACPI support: no
00000000000i[     ]   NE2000 support: no
00000000000i[     ]   PCI support: no, enabled=yes
00000000000i[     ]   SB16 support: no
00000000000i[     ]   USB support: no
00000000000i[     ]   VGA extension support: vbe 
00000000000i[MEM0 ] allocated memory at 0x7f70183a1010. after alignment, vector=0x7f70183a2000
00000000000i[MEM0 ] 512.00MB
00000000000i[MEM0 ] mem block size = 0x00100000, blocks=512
00000000000i[MEM0 ] rom at 0xfffe0000/131072 ('/usr/local/share/bochs/BIOS-bochs-latest')
00000000000i[MEM0 ] rom at 0xc0000/40448 ('/usr/local/share/bochs/VGABIOS-lgpl-latest')
00000000000i[CPU0 ] loaded MSR[0x02c] type=0 00000000:00000000 00000000:00000000 00000000:00000000
00000000000e[DEV  ] Bochs is not compiled with PCI support
00000000000i[CMOS ] Using local time for initial clock
00000000000i[CMOS ] Setting initial clock to: Tue Oct 11 19:29:57 2011 (time0=1318354197)
00000000000i[DMA  ] channel 4 used by cascade
00000000000i[DMA  ] channel 2 used by Floppy Drive
00000000000i[FDD  ] tried to open '/dev/fd0' read/write: No such file or directory
00000000000i[FDD  ] tried to open '/dev/fd0' read only: No such file or directory
00000000000i[VGA  ] interval=300000
00000000000i[MEM0 ] Register memory access handlers: 0x00000000000a0000 - 0x00000000000bffff
00000000000i[XGUI ] test_alloc_colors: 16 colors available out of 16 colors tried
00000000000i[XGUI ] font 8 wide x 16 high, display depth = 24
00000000000i[MEM0 ] Register memory access handlers: 0x00000000e0000000 - 0x00000000e0ffffff
00000000000i[VGA  ] VBE Bochs Display Extension Enabled
00000000000i[     ] init_dev of 'unmapped' plugin device by virtual method
00000000000i[     ] init_dev of 'biosdev' plugin device by virtual method
00000000000i[     ] init_dev of 'speaker' plugin device by virtual method
00000000000i[SPEAK] Open /dev/console successfully
00000000000i[     ] init_dev of 'extfpuirq' plugin device by virtual method
00000000000i[     ] init_dev of 'ioapic' plugin device by virtual method
00000000000i[IOAP ] initializing I/O APIC
00000000000i[MEM0 ] Register memory access handlers: 0x00000000fec00000 - 0x00000000fec00fff
00000000000i[     ] init_dev of 'keyboard' plugin device by virtual method
00000000000i[KBD  ] will paste characters every 1000 keyboard ticks
00000000000i[     ] init_dev of 'harddrv' plugin device by virtual method
00000000000i[HD   ] CD on ata0-0: '/home/aod/projects/razor/bin/razor.iso'
00000000000i[CD1  ] load cdrom with path=/home/aod/projects/razor/bin/razor.iso
00000000000i[CD1  ] Opening image file as a cd.
00000000000i[HD   ] Media present in CD-ROM drive
00000000000i[HD   ] Capacity is 257 sectors (0.50 MB)
00000000000i[HD   ] Using boot sequence cdrom, none, none
00000000000i[HD   ] Floppy boot signature check is enabled
00000000000i[     ] init_dev of 'serial' plugin device by virtual method
00000000000i[SER  ] com1 at 0x03f8 irq 4
00000000000i[     ] init_dev of 'parallel' plugin device by virtual method
00000000000i[PAR  ] parallel port 1 at 0x0378 irq 7
00000000000i[     ] register state of 'unmapped' plugin device by virtual method
00000000000i[     ] register state of 'biosdev' plugin device by virtual method
00000000000i[     ] register state of 'speaker' plugin device by virtual method
00000000000i[     ] register state of 'extfpuirq' plugin device by virtual method
00000000000i[     ] register state of 'ioapic' plugin device by virtual method
00000000000i[     ] register state of 'keyboard' plugin device by virtual method
00000000000i[     ] register state of 'harddrv' plugin device by virtual method
00000000000i[     ] register state of 'serial' plugin device by virtual method
00000000000i[     ] register state of 'parallel' plugin device by virtual method
00000000000i[SYS  ] bx_pc_system_c::Reset(HARDWARE) called
00000000000i[CPU0 ] cpu hardware reset
00000000000i[APIC0] allocate APIC id=0 (MMIO enabled) to 0x00000000fee00000
00000000000i[CPU0 ] CPUID[0x00000000]: 0000000d 756e6547 6c65746e 49656e69
00000000000i[CPU0 ] CPUID[0x00000001]: 00000f25 00000800 0ed82203 07cbfbff
00000000000i[CPU0 ] CPUID[0x00000002]: 00410601 00000000 00000000 00000000
00000000000i[CPU0 ] CPUID[0x00000003]: 00000000 00000000 00000000 00000000
00000000000i[CPU0 ] CPUID[0x00000004]: 00000000 00000000 00000000 00000000
00000000000i[CPU0 ] CPUID[0x00000007]: 00000000 00000000 00000000 00000000
00000000000i[CPU0 ] CPUID[0x0000000D]: 00000003 00000240 00000240 00000000
00000000000i[CPU0 ] CPUID[0x80000000]: 80000008 00000000 00000000 00000000
00000000000i[CPU0 ] CPUID[0x80000001]: 00000000 00000000 00000001 2a100800
00000000000i[CPU0 ] CPUID[0x80000002]: 20202020 20202020 20202020 6e492020
00000000000i[CPU0 ] CPUID[0x80000003]: 286c6574 50202952 69746e65 52286d75
00000000000i[CPU0 ] CPUID[0x80000004]: 20342029 20555043 20202020 00202020
00000000000i[CPU0 ] CPUID[0x80000006]: 00000000 42004200 02008140 00000000
00000000000i[CPU0 ] CPUID[0x80000007]: 00000000 00000000 00000000 00000000
00000000000i[CPU0 ] CPUID[0x80000008]: 00003028 00000000 00000000 00000000
00000000000i[     ] reset of 'unmapped' plugin device by virtual method
00000000000i[     ] reset of 'biosdev' plugin device by virtual method
00000000000i[     ] reset of 'speaker' plugin device by virtual method
00000000000i[     ] reset of 'extfpuirq' plugin device by virtual method
00000000000i[     ] reset of 'ioapic' plugin device by virtual method
00000000000i[     ] reset of 'keyboard' plugin device by virtual method
00000000000i[     ] reset of 'harddrv' plugin device by virtual method
00000000000i[     ] reset of 'serial' plugin device by virtual method
00000000000i[     ] reset of 'parallel' plugin device by virtual method
00000000000i[XGUI ] [x] Mouse off
00000003305i[BIOS ] $Revision: 1.257 $ $Date: 2011/01/26 09:52:02 $
00000337574i[KBD  ] reset-disable command received
00000487284i[VBIOS] VGABios $Id: vgabios.c,v 1.69 2009/04/07 18:18:20 vruppert Exp $
00000487355i[VGA  ] VBE known Display Interface b0c0
00000487387i[VGA  ] VBE known Display Interface b0c5
00000490312i[VBIOS] VBE Bios $Id: vbe.c,v 1.62 2009/01/25 15:46:25 vruppert Exp $
00000803001i[BIOS ] Starting rombios32
00000803498i[BIOS ] Shutdown flag 0
00000804188i[BIOS ] ram_size=0x20000000
00000804693i[BIOS ] ram_end=512MB
00001300245i[BIOS ] Found 1 cpu(s)
00001319232i[BIOS ] bios_table_addr: 0x000fb928 end=0x000fcc00
00001331909i[BIOS ] bios_table_cur_addr: 0x000fb928
00005213376i[BIOS ] IDE time out
00015000000i[XGUI ] charmap update. Font Height is 16
00153840867i[BIOS ] Booting from 07c0:0000
00153957164i[BIOS ] int13_harddisk: function 41, unmapped device for ELDL=80
00153961944i[BIOS ] int13_harddisk: function 08, unmapped device for ELDL=80
00153966592i[BIOS ] *** int 15h function AX=00c0, BX=0000 not yet supported!
00242395579i[CPU0 ] LOCK prefix unallowed (op1=0x39, modrm=0xe7)
00242395579e[CPU0 ] interrupt(long mode): IDT entry extended attributes DWORD4 TYPE != 0
00242395579e[CPU0 ] interrupt(long mode): IDT entry extended attributes DWORD4 TYPE != 0
00242395579e[CPU0 ] interrupt(long mode): IDT entry extended attributes DWORD4 TYPE != 0
00242395579i[CPU0 ] CPU is in compatibility mode (active)
00242395579i[CPU0 ] CS.d_b = 32 bit
00242395579i[CPU0 ] SS.d_b = 32 bit
00242395579i[CPU0 ] EFER   = 0x00000500
00242395579i[CPU0 ] | RAX=00000000e0000011  RBX=0000000000037220
00242395579i[CPU0 ] | RCX=00000000c0000080  RDX=0000000000000000
00242395579i[CPU0 ] | RSP=0000000000102000  RBP=0000000000067e2c
00242395579i[CPU0 ] | RSI=00000000000373b4  RDI=00000000000372e4
00242395579i[CPU0 ] |  R8=0000000000000000   R9=0000000000000000
00242395579i[CPU0 ] | R10=0000000000000000  R11=0000000000000000
00242395579i[CPU0 ] | R12=0000000000000000  R13=0000000000000000
00242395579i[CPU0 ] | R14=0000000000000000  R15=0000000000000000
00242395579i[CPU0 ] | IOPL=0 id vip vif ac vm RF nt of df if tf SF zf af PF cf
00242395579i[CPU0 ] | SEG selector     base    limit G D
00242395579i[CPU0 ] | SEG sltr(index|ti|rpl)     base    limit G D
00242395579i[CPU0 ] |  CS:0008( 0001| 0|  0) 00000000 ffffffff 1 1
00242395579i[CPU0 ] |  DS:0010( 0002| 0|  0) 00000000 ffffffff 1 1
00242395579i[CPU0 ] |  SS:0010( 0002| 0|  0) 00000000 ffffffff 1 1
00242395579i[CPU0 ] |  ES:0010( 0002| 0|  0) 00000000 ffffffff 1 1
00242395579i[CPU0 ] |  FS:0010( 0002| 0|  0) 00000000 ffffffff 1 1
00242395579i[CPU0 ] |  GS:0010( 0002| 0|  0) 00000000 ffffffff 1 1
00242395579i[CPU0 ] |  MSR_FS_BASE:0000000000000000
00242395579i[CPU0 ] |  MSR_GS_BASE:0000000000000000
00242395579i[CPU0 ] | RIP=000000000010004f (000000000010004f)
00242395579i[CPU0 ] | CR0=0xe0000011 CR2=0x0000000000000000
00242395579i[CPU0 ] | CR3=0x00105000 CR4=0x000000a0
00242395579i[CPU0 ] 0x000000000010004f>> lock cmp edi, esp : F039E7
00242395579e[CPU0 ] exception(): 3rd (13) exception with no resolution, shutdown status is 00h, resetting
00242395579i[SYS  ] bx_pc_system_c::Reset(HARDWARE) called
00242395579i[CPU0 ] cpu hardware reset

There it is.
User avatar
xenos
Member
Member
Posts: 1121
Joined: Thu Aug 11, 2005 11:00 pm
Libera.chat IRC: xenos1984
Location: Tartu, Estonia
Contact:

Re: Triple fault after enabling long mode

Post by xenos »

aod wrote:

Code: Select all

00000000000i[     ]   x86-64 support: no
Are you kidding? You are trying to get into long mode with a bochs version that does not have long mode support enabled!
Programmers' Hardware Database // GitHub user: xenos1984; OS project: NOS
aod
Member
Member
Posts: 26
Joined: Fri Sep 30, 2011 2:36 am

Re: Triple fault after enabling long mode

Post by aod »

XenOS wrote:
aod wrote:

Code: Select all

00000000000i[     ]   x86-64 support: no
Are you kidding? You are trying to get into long mode with a bochs version that does not have long mode support enabled!
Look at the second logfile.
jnc100
Member
Member
Posts: 775
Joined: Mon Apr 09, 2007 12:10 pm
Location: London, UK
Contact:

Re: Triple fault after enabling long mode

Post by jnc100 »

From the log you've obviously entered compatibility mode before encountering the problem. I haven't bothered to check your GDT to see if you intended to be in long mode or compatibility mode after the switch to 64 bit mode but will assume you intended compatibility mode. The invalid opcode (F0 39 E7) is the problem and this does not appear anywhere in a disassembly of your bootloader source, so my feeling is that you are running code from somewhere you didn't expect.

Options are:
1) your code is not loaded at the location it expects to be run at
2) there is a problem with your paging structures

The simplest way to diagnose it is to single step through your code with the bochs debugger. You can place a magic break point (xchg bx, bx) prior to the jmp 0x8:Here, enable magic break points in the bochs setup and then run the bochs debugger to see what is going on.

Regards,
John.
User avatar
Combuster
Member
Member
Posts: 9301
Joined: Wed Oct 18, 2006 3:45 am
Libera.chat IRC: [com]buster
Location: On the balcony, where I can actually keep 1½m distance
Contact:

Re: Triple fault after enabling long mode

Post by Combuster »

0x0010004c>> mov cr0, eax : 0F22C0
0x000000000010004f>> lock cmp edi, esp : F039E7
So you got one instruction further. Now you might want to tell me why your pagetable maps what looks like the IVT at 0x100000? Did you forget to set the offset?
"Certainly avoid yourself. He is a newbie and might not realize it. You'll hate his code deeply a few years down the road." - Sortie
[ My OS ] [ VDisk/SFS ]
Post Reply