OS Triple faults after paging is set up and cr0 is loaded

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
axgam190
Posts: 2
Joined: Tue Jun 02, 2026 3:08 am

OS Triple faults after paging is set up and cr0 is loaded

Post by axgam190 »

This is my OS https://github.com/TechEverythingTikTok/clarityOS
It triple faults after cr0 is loaded inside of paging.asm, this is what I get as output with qemu-system-i386 -d int,guest_errors -serial stdio .\clarityos.iso
```
Found module
Got past loop
paging init addr: 0x0000000000100619
ENTRY:

0x000000000009fc00
0x0000000000000000
0x0000000000000000
0x0000000000000001

ENTRY:

0x0000000000000400
0x000000000009fc00
0x0000000000000000
0x0000000000000002

ENTRY:

0x0000000000010000
0x00000000000f0000
0x0000000000000000
0x0000000000000002

ENTRY:

0x0000000007ee0000
0x0000000000100000
0x0000000000000000
0x0000000000000001

ENTRY:

0x0000000000020000
0x0000000007fe0000
0x0000000000000000
0x0000000000000002

ENTRY:

0x0000000000040000
0x00000000fffc0000
0x0000000000000000
0x0000000000000002

Set paegs
paging enable addr: 0x0000000000100080
pages addr: 0x0000000000000000
0x0000000000001000
0x0000000000002000
0x0000000000003000
pages contain addr: 0x0000000000001003, 0x0000000000002003,0x0000000000003003
PT[0x0000000000000000] = 0x0000000000000003
PT[0x0000000000000001] = 0x0000000000001003
PT[0x0000000000000002] = 0x0000000000002003
PT[0x0000000000000003] = 0x0000000000003003
PT[0x0000000000000004] = 0x0000000000004003
PT[0x0000000000000005] = 0x0000000000005003
PT[0x0000000000000006] = 0x0000000000006003
PT[0x0000000000000007] = 0x0000000000007003
PT[0x0000000000000008] = 0x0000000000008003
PT[0x0000000000000009] = 0x0000000000009003
PT[0x000000000000000a] = 0x000000000000a003
PT[0x000000000000000b] = 0x000000000000b003
PT[0x000000000000000c] = 0x000000000000c003
PT[0x000000000000000d] = 0x000000000000d003
PT[0x000000000000000e] = 0x000000000000e003
PT[0x000000000000000f] = 0x000000000000f003
PT[0x0000000000000010] = 0x0000000000010003
PT[0x0000000000000011] = 0x0000000000011003
PT[0x0000000000000012] = 0x0000000000012003
PT[0x0000000000000013] = 0x0000000000013003
PT[0x0000000000000014] = 0x0000000000014003
PT[0x0000000000000015] = 0x0000000000015003
PT[0x0000000000000016] = 0x0000000000016003
PT[0x0000000000000017] = 0x0000000000017003
PT[0x0000000000000018] = 0x0000000000018003
PT[0x0000000000000019] = 0x0000000000019003
PT[0x000000000000001a] = 0x000000000001a003
PT[0x000000000000001b] = 0x000000000001b003
PT[0x000000000000001c] = 0x000000000001c003
PT[0x000000000000001d] = 0x000000000001d003
PT[0x000000000000001e] = 0x000000000001e003
PT[0x000000000000001f] = 0x000000000001f003
PT[0x0000000000000020] = 0x0000000000020003
PT[0x0000000000000021] = 0x0000000000021003
PT[0x0000000000000022] = 0x0000000000022003
PT[0x0000000000000023] = 0x0000000000023003
PT[0x0000000000000024] = 0x0000000000024003
PT[0x0000000000000025] = 0x0000000000025003
PT[0x0000000000000026] = 0x0000000000026003
PT[0x0000000000000027] = 0x0000000000027003
PT[0x0000000000000028] = 0x0000000000028003
PT[0x0000000000000029] = 0x0000000000029003
PT[0x000000000000002a] = 0x000000000002a003
PT[0x000000000000002b] = 0x000000000002b003
PT[0x000000000000002c] = 0x000000000002c003
PT[0x000000000000002d] = 0x000000000002d003
PT[0x000000000000002e] = 0x000000000002e003
PT[0x000000000000002f] = 0x000000000002f003
PT[0x0000000000000030] = 0x0000000000030003
PT[0x0000000000000031] = 0x0000000000031003
PT[0x0000000000000032] = 0x0000000000032003
PT[0x0000000000000033] = 0x0000000000033003
PT[0x0000000000000034] = 0x0000000000034003
PT[0x0000000000000035] = 0x0000000000035003
PT[0x0000000000000036] = 0x0000000000036003
PT[0x0000000000000037] = 0x0000000000037003
PT[0x0000000000000038] = 0x0000000000038003
PT[0x0000000000000039] = 0x0000000000039003
PT[0x000000000000003a] = 0x000000000003a003
PT[0x000000000000003b] = 0x000000000003b003
PT[0x000000000000003c] = 0x000000000003c003
PT[0x000000000000003d] = 0x000000000003d003
PT[0x000000000000003e] = 0x000000000003e003
PT[0x000000000000003f] = 0x000000000003f003
PT[0x0000000000000040] = 0x0000000000040003
PT[0x0000000000000041] = 0x0000000000041003
PT[0x0000000000000042] = 0x0000000000042003
PT[0x0000000000000043] = 0x0000000000043003
PT[0x0000000000000044] = 0x0000000000044003
PT[0x0000000000000045] = 0x0000000000045003
PT[0x0000000000000046] = 0x0000000000046003
PT[0x0000000000000047] = 0x0000000000047003
PT[0x0000000000000048] = 0x0000000000048003
PT[0x0000000000000049] = 0x0000000000049003
PT[0x000000000000004a] = 0x000000000004a003
PT[0x000000000000004b] = 0x000000000004b003
PT[0x000000000000004c] = 0x000000000004c003
PT[0x000000000000004d] = 0x000000000004d003
PT[0x000000000000004e] = 0x000000000004e003
PT[0x000000000000004f] = 0x000000000004f003
PT[0x0000000000000050] = 0x0000000000050003
PT[0x0000000000000051] = 0x0000000000051003
PT[0x0000000000000052] = 0x0000000000052003
PT[0x0000000000000053] = 0x0000000000053003
PT[0x0000000000000054] = 0x0000000000054003
PT[0x0000000000000055] = 0x0000000000055003
PT[0x0000000000000056] = 0x0000000000056003
PT[0x0000000000000057] = 0x0000000000057003
PT[0x0000000000000058] = 0x0000000000058003
PT[0x0000000000000059] = 0x0000000000059003
PT[0x000000000000005a] = 0x000000000005a003
PT[0x000000000000005b] = 0x000000000005b003
PT[0x000000000000005c] = 0x000000000005c003
PT[0x000000000000005d] = 0x000000000005d003
PT[0x000000000000005e] = 0x000000000005e003
PT[0x000000000000005f] = 0x000000000005f003
PT[0x0000000000000060] = 0x0000000000060003
PT[0x0000000000000061] = 0x0000000000061003
PT[0x0000000000000062] = 0x0000000000062003
PT[0x0000000000000063] = 0x0000000000063003
PT[0x0000000000000064] = 0x0000000000064003
PT[0x0000000000000065] = 0x0000000000065003
PT[0x0000000000000066] = 0x0000000000066003
PT[0x0000000000000067] = 0x0000000000067003
PT[0x0000000000000068] = 0x0000000000068003
PT[0x0000000000000069] = 0x0000000000069003
PT[0x000000000000006a] = 0x000000000006a003
PT[0x000000000000006b] = 0x000000000006b003
PT[0x000000000000006c] = 0x000000000006c003
PT[0x000000000000006d] = 0x000000000006d003
PT[0x000000000000006e] = 0x000000000006e003
PT[0x000000000000006f] = 0x000000000006f003
PT[0x0000000000000070] = 0x0000000000070003
PT[0x0000000000000071] = 0x0000000000071003
PT[0x0000000000000072] = 0x0000000000072003
PT[0x0000000000000073] = 0x0000000000073003
PT[0x0000000000000074] = 0x0000000000074003
PT[0x0000000000000075] = 0x0000000000075003
PT[0x0000000000000076] = 0x0000000000076003
PT[0x0000000000000077] = 0x0000000000077003
PT[0x0000000000000078] = 0x0000000000078003
PT[0x0000000000000079] = 0x0000000000079003
PT[0x000000000000007a] = 0x000000000007a003
PT[0x000000000000007b] = 0x000000000007b003
PT[0x000000000000007c] = 0x000000000007c003
PT[0x000000000000007d] = 0x000000000007d003
PT[0x000000000000007e] = 0x000000000007e003
PT[0x000000000000007f] = 0x000000000007f003
PT[0x0000000000000080] = 0x0000000000080003
PT[0x0000000000000081] = 0x0000000000081003
PT[0x0000000000000082] = 0x0000000000082003
PT[0x0000000000000083] = 0x0000000000083003
PT[0x0000000000000084] = 0x0000000000084003
PT[0x0000000000000085] = 0x0000000000085003
PT[0x0000000000000086] = 0x0000000000086003
PT[0x0000000000000087] = 0x0000000000087003
PT[0x0000000000000088] = 0x0000000000088003
PT[0x0000000000000089] = 0x0000000000089003
PT[0x000000000000008a] = 0x000000000008a003
PT[0x000000000000008b] = 0x000000000008b003
PT[0x000000000000008c] = 0x000000000008c003
PT[0x000000000000008d] = 0x000000000008d003
PT[0x000000000000008e] = 0x000000000008e003
PT[0x000000000000008f] = 0x000000000008f003
PT[0x0000000000000090] = 0x0000000000090003
PT[0x0000000000000091] = 0x0000000000091003
PT[0x0000000000000092] = 0x0000000000092003
PT[0x0000000000000093] = 0x0000000000093003
PT[0x0000000000000094] = 0x0000000000094003
PT[0x0000000000000095] = 0x0000000000095003
PT[0x0000000000000096] = 0x0000000000096003
PT[0x0000000000000097] = 0x0000000000097003
PT[0x0000000000000098] = 0x0000000000098003
PT[0x0000000000000099] = 0x0000000000099003
PT[0x000000000000009a] = 0x000000000009a003
PT[0x000000000000009b] = 0x000000000009b003
PT[0x000000000000009c] = 0x000000000009c003
PT[0x000000000000009d] = 0x000000000009d003
PT[0x000000000000009e] = 0x000000000009e003
PT[0x000000000000009f] = 0x000000000009f003
PT[0x00000000000000a0] = 0x00000000000a0003
PT[0x00000000000000a1] = 0x00000000000a1003
PT[0x00000000000000a2] = 0x00000000000a2003
PT[0x00000000000000a3] = 0x00000000000a3003
PT[0x00000000000000a4] = 0x00000000000a4003
PT[0x00000000000000a5] = 0x00000000000a5003
PT[0x00000000000000a6] = 0x00000000000a6003
PT[0x00000000000000a7] = 0x00000000000a7003
PT[0x00000000000000a8] = 0x00000000000a8003
PT[0x00000000000000a9] = 0x00000000000a9003
PT[0x00000000000000aa] = 0x00000000000aa003
PT[0x00000000000000ab] = 0x00000000000ab003
PT[0x00000000000000ac] = 0x00000000000ac003
PT[0x00000000000000ad] = 0x00000000000ad003
PT[0x00000000000000ae] = 0x00000000000ae003
PT[0x00000000000000af] = 0x00000000000af003
PT[0x00000000000000b0] = 0x00000000000b0003
PT[0x00000000000000b1] = 0x00000000000b1003
PT[0x00000000000000b2] = 0x00000000000b2003
PT[0x00000000000000b3] = 0x00000000000b3003
PT[0x00000000000000b4] = 0x00000000000b4003
PT[0x00000000000000b5] = 0x00000000000b5003
PT[0x00000000000000b6] = 0x00000000000b6003
PT[0x00000000000000b7] = 0x00000000000b7003
PT[0x00000000000000b8] = 0x00000000000b8003
PT[0x00000000000000b9] = 0x00000000000b9003
PT[0x00000000000000ba] = 0x00000000000ba003
PT[0x00000000000000bb] = 0x00000000000bb003
PT[0x00000000000000bc] = 0x00000000000bc003
PT[0x00000000000000bd] = 0x00000000000bd003
PT[0x00000000000000be] = 0x00000000000be003
PT[0x00000000000000bf] = 0x00000000000bf003
PT[0x00000000000000c0] = 0x00000000000c0003
PT[0x00000000000000c1] = 0x00000000000c1003
PT[0x00000000000000c2] = 0x00000000000c2003
PT[0x00000000000000c3] = 0x00000000000c3003
PT[0x00000000000000c4] = 0x00000000000c4003
PT[0x00000000000000c5] = 0x00000000000c5003
PT[0x00000000000000c6] = 0x00000000000c6003
PT[0x00000000000000c7] = 0x00000000000c7003
PT[0x00000000000000c8] = 0x00000000000c8003
PT[0x00000000000000c9] = 0x00000000000c9003
PT[0x00000000000000ca] = 0x00000000000ca003
PT[0x00000000000000cb] = 0x00000000000cb003
PT[0x00000000000000cc] = 0x00000000000cc003
PT[0x00000000000000cd] = 0x00000000000cd003
PT[0x00000000000000ce] = 0x00000000000ce003
PT[0x00000000000000cf] = 0x00000000000cf003
PT[0x00000000000000d0] = 0x00000000000d0003
PT[0x00000000000000d1] = 0x00000000000d1003
PT[0x00000000000000d2] = 0x00000000000d2003
PT[0x00000000000000d3] = 0x00000000000d3003
PT[0x00000000000000d4] = 0x00000000000d4003
PT[0x00000000000000d5] = 0x00000000000d5003
PT[0x00000000000000d6] = 0x00000000000d6003
PT[0x00000000000000d7] = 0x00000000000d7003
PT[0x00000000000000d8] = 0x00000000000d8003
PT[0x00000000000000d9] = 0x00000000000d9003
PT[0x00000000000000da] = 0x00000000000da003
PT[0x00000000000000db] = 0x00000000000db003
PT[0x00000000000000dc] = 0x00000000000dc003
PT[0x00000000000000dd] = 0x00000000000dd003
PT[0x00000000000000de] = 0x00000000000de003
PT[0x00000000000000df] = 0x00000000000df003
PT[0x00000000000000e0] = 0x00000000000e0003
PT[0x00000000000000e1] = 0x00000000000e1003
PT[0x00000000000000e2] = 0x00000000000e2003
PT[0x00000000000000e3] = 0x00000000000e3003
PT[0x00000000000000e4] = 0x00000000000e4003
PT[0x00000000000000e5] = 0x00000000000e5003
PT[0x00000000000000e6] = 0x00000000000e6003
PT[0x00000000000000e7] = 0x00000000000e7003
PT[0x00000000000000e8] = 0x00000000000e8003
PT[0x00000000000000e9] = 0x00000000000e9003
PT[0x00000000000000ea] = 0x00000000000ea003
PT[0x00000000000000eb] = 0x00000000000eb003
PT[0x00000000000000ec] = 0x00000000000ec003
PT[0x00000000000000ed] = 0x00000000000ed003
PT[0x00000000000000ee] = 0x00000000000ee003
PT[0x00000000000000ef] = 0x00000000000ef003
PT[0x00000000000000f0] = 0x00000000000f0003
PT[0x00000000000000f1] = 0x00000000000f1003
PT[0x00000000000000f2] = 0x00000000000f2003
PT[0x00000000000000f3] = 0x00000000000f3003
PT[0x00000000000000f4] = 0x00000000000f4003
PT[0x00000000000000f5] = 0x00000000000f5003
PT[0x00000000000000f6] = 0x00000000000f6003
PT[0x00000000000000f7] = 0x00000000000f7003
PT[0x00000000000000f8] = 0x00000000000f8003
PT[0x00000000000000f9] = 0x00000000000f9003
PT[0x00000000000000fa] = 0x00000000000fa003
PT[0x00000000000000fb] = 0x00000000000fb003
PT[0x00000000000000fc] = 0x00000000000fc003
PT[0x00000000000000fd] = 0x00000000000fd003
PT[0x00000000000000fe] = 0x00000000000fe003
PT[0x00000000000000ff] = 0x00000000000ff003
Level4 page address: 0x0000000000000000
Base address: 0x0000000000000000
sanity test:0x0000000000000010
check_exception old: 0xffffffff new 0xe
0: v=0e e=0000 i=0 cpl=0 IP=0008:001000aa pc=001000aa SP=0010:00104e54 CR2=001000aa
EAX=80000011 EBX=001ff003 ECX=c0000080 EDX=00000000
ESI=00000000 EDI=00000000 EBP=00104e80 ESP=00104e54
EIP=001000aa EFL=00200086 [--S--P-] 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= 00104ec0 00000027
IDT= 00000000 00000000
CR0=80000011 CR2=001000aa CR3=00000000 CR4=00000020
DR0=00000000 DR1=00000000 DR2=00000000 DR3=00000000
DR6=ffff0ff0 DR7=00000400
CCS=00000010 CCD=80000011 CCO=LOGICL
EFER=0000000000000000
check_exception old: 0xe new 0xd
1: v=08 e=0000 i=0 cpl=0 IP=0008:001000aa pc=001000aa SP=0010:00104e54
```

Most of there are 0x3F8 port outputs
I have port output code in main.cpp, I'll change it soom..
axgam190
Posts: 2
Joined: Tue Jun 02, 2026 3:08 am

Re: OS Triple faults after paging is set up and cr0 is loaded

Post by axgam190 »

pls guys i need help i debugged for days but every single thing looks correct, bump
MichaelPetch
Member
Member
Posts: 857
Joined: Fri Aug 26, 2016 1:41 pm
Libera.chat IRC: mpetch

Re: OS Triple faults after paging is set up and cr0 is loaded

Post by MichaelPetch »

axgam190 wrote: ↑Tue Jun 02, 2026 10:27 am pls guys i need help i debugged for days but every single thing looks correct, bump
I haven't looked at your code at all. I'm just showing you an important part:

Code: Select all

0: v=0e e=0000 i=0 cpl=0 IP=0008:001000aa pc=001000aa SP=0010:00104e54 CR2=001000aa
v=0e is a page fault. e=0000 is the exceptions code. Review the wiki about this exception: https://wiki.osdev.org/Exceptions#Page_Fault . decoding error code 0x0000 would mean in kernel mode (ring 0) there was an attempt to read address (0x001000aa the address in CR2) from a non-present page. Since IP=IP=0008:001000aa (which matches the address in CR2) it would also seem to be the code that is running isn't paged properly into memory and you are trying to execute an instruction from that non-preesnt page. So the question is whether your paging structures have been properly defined.
Octocontrabass
Member
Member
Posts: 6275
Joined: Mon Mar 25, 2013 7:01 pm

Re: OS Triple faults after paging is set up and cr0 is loaded

Post by Octocontrabass »

axgam190 wrote: ↑Tue Jun 02, 2026 3:13 amqemu-system-i386
If you had checked CPUID, you would have seen that your CPU doesn't support 64-bit mode. Try qemu-system-x86_64 instead.
Post Reply