Page 1 of 1
Disabling paging
Posted: Sat Mar 19, 2005 10:00 am
by pini
I wrote a little thing based upon my kernel.
It works pretty the same, but has rather no features implemented
When a CPL3->CPL0 switch occurs, I'm disabling paging, re-enabling it and switching back to CPL3.
Currently, only the IRQ0 is enabled.
This works perfectly under bochs and qemu and with my two simple Pentium computers (90 and 166), but it reboots when I'm trying it under my two other machines (Pentium III 667 and Pentium 4M 2GHz).
I don't remind of any special difference between these families concerning paging, but maybe I missed something in the Intel books.
Anyone has an idea of why this is happening ?
Re:Disabling paging
Posted: Sat Mar 19, 2005 10:03 am
by Candy
You might have a case of bad caching there. Think the P3/P4 wille xecute the rest of the code from the current paged history up to a certain point and only then switch to the nonpaged history. You could try to reload CR3 between them?
Re:Disabling paging
Posted: Sat Mar 19, 2005 10:22 am
by pini
I spent some time handling with the couple cli/hlt to know exactly where was the faulty instruction located.
Surprise : it isn't paging disabling that causes reboot, it's paging enabling.
This is particularly strange, as it is working both in emulators and real machines, so it isn't a problem of missing PDEs or PTEs.
I still don't know what is the real cause, but I will try again and will post feedback
Re:Disabling paging
Posted: Sat Mar 19, 2005 10:31 am
by pini
here is the faulty code.
Code: Select all
cli
mov eax,cr0
mov ecx,[edi + CONTEXT_PD]
mov esp,[edi + CONTEXT_OFFSET]
or eax,0x80000000
pop edx
mov cr3,ecx
and esp,MEM_OFFSET_MASK
mov [edi + CONTEXT_OFFSET],edx
mov cr0,eax
pop_all
iret
The code about CONTEXT_OFFSET is used for kernel preemption (currently disabled).
pop_all is a macro that simply pops gs,fs,es,ds,ebp,edi,esi,edx,ecx,ebx,eax in this order
Re:Disabling paging
Posted: Sat Mar 19, 2005 11:25 am
by Candy
So, you take CR0, or it with 0x80000000 and then move that into CR0 AND CR3? Looks kind of weird, or at least unreliable.
Re:Disabling paging
Posted: Sat Mar 19, 2005 11:27 am
by pini
You must have mis-read the code above.
I used EAX to compute new CR0 value and ECX to compute new CR3 value.
Re:Disabling paging
Posted: Sat Mar 19, 2005 11:31 am
by Candy
hm.. ok, slightly dysiectlc...
Assuming this works in bochs, I can't see any reason it wouldn't on a p3/p4.
You don't do PAE stuff anywhere I hope?
Re:Disabling paging
Posted: Sun Mar 20, 2005 9:25 am
by pini
Candy wrote:
You don't do PAE stuff anywhere I hope?
No, I don't