Page 1 of 1

triple fault when moving 0x3 to CR0

Posted: Thu Jul 20, 2006 3:22 am
by earlz
Well I got these trivial triple faults from moving anything into CR0 and bochs says like invalid opcode or something

this is my simple code which disabled paging and leaves everything else the same..

Code: Select all

mov eax,CR0
and eax,0x7FFFFFFF
mov CR0,eax
hlt
and bochs never gets to the hlt I really don't know how much simpler it could possibly be!
and the code in my bootloader is this and it works fine!

Code: Select all

   mov   eax, CR0      ;Turn on paging and protected mode
   or   eax, 0x80000001
   mov   CR0, eax
btw I have interrupts off in this whole thing

Re:triple fault when moving 0x3 to CR0

Posted: Thu Jul 20, 2006 3:48 am
by paulbarker
Are you sure you're in ring 0?

Re:triple fault when moving 0x3 to CR0

Posted: Thu Jul 20, 2006 6:25 am
by bluecode
Are you sure that your code is identity mapped? If it is not then you have a huge problem, because after you disable paging you will be somewhere in ram, but certainly not where your "hlt" is.

Re:triple fault when moving 0x3 to CR0

Posted: Thu Jul 20, 2006 9:45 am
by earlz
well my code is mapped to 8FFF0000 but is actually at 0x100000

oh I got it, I have to jump to an 0x100000 piece of code and turn off cr0!


edit:
thank you so much I jmped to a piece of 0x100000 code and it is all good now(worked first time without me even changing around my memory manager!)