Code: Select all
xor eax,eax
mov cr3,eax
This code should work even with PAE-enabled: (some pseudo-code)
Code: Select all
SetupInvalidProtectionFaultHandler
SetupInvalidDoubleFaultHandler
mov ax,-1
mov ds,ax
Code: Select all
xor eax,eax
mov cr3,eax
Code: Select all
SetupInvalidProtectionFaultHandler
SetupInvalidDoubleFaultHandler
mov ax,-1
mov ds,ax
Code: Select all
mov eax,idt_sel
mov ds,eax
mov ebx,13 * 8
xor eax,eax
mov [ebx],eax
mov [ebx+4],eax
mov ebx,8 * 8
mov [ebx],eax
mov [ebx+4],eax
mov eax,-1
mov ds,eax
I think a simpler way is to mess up the kernel stack, so that #SS > #DF (if you use gate, mess up that stack too) > #TF, and don't need to alter the IDT.rdos wrote:This logic zeros IDT descriptors for protection fault and double fault, and then generates a protection fault.
That resets almost nothing; which means that you can expect problems afterwards caused by the firmware making assumptions about the contents/state of various things (including the contents of MSRs, MTRRs, IOMMUs, ACPI's controller, PCI configuration space, PICs/APICs, timers, and more or less everything else you could think of).linguofreak wrote:What about returning to real mode and jumping to FFFF:0?