wrmsr指令设置EFER.LME导致system hang,请高手帮忙
我尝试用以下代码实到从32bit non-paged模式向64bit的切换,结果系统hang在wrmsr指令上,请高手帮忙分析下原因,感激
mov edx, esi
add edx, INIT64_STRUCT_GDTR_OFFSET
lgdt [edx]
// update cr3 for x64 mode
mov eax, dword ptr INIT64_STRUCT_CR3_OFFSET[esi]
mov cr3, eax
// update CR4 for x64
_emit 0x0F
_emit 0x20
_emit 0xE0 // mov eax, cr4
// enable PAE, PSE??
or eax, 0x30
_emit 0x0F
_emit 0x22
_emit 0xE0 // mov cr4, eax
// write msr (EFER) to enable x64
mov ecx, 0C0000080h
mov edx, 0
mov eax, 0
bts eax, 8
wrmsr // write from EDX:EAX into MSR[ECX]
查看文档,有以下原因可导致设置失败
1. An attempt is made to enable or disable IA-32e mode while paging is enabled.
2. IA-32e mode is enabled and an attempt is made to enable paging prior to
enabling physical-address extensions (PAE).
3. IA-32e mode is active and an attempt is made to disable physical-address
extensions (PAE).
4. If the current CS has the L-bit set on an attempt to activate IA-32e mode.
5. If the TR contains a 16-bit TSS.
其中1,4可以排除,2,3跟这段code无关。5不知如何验证。
另外,consistency check失败一般来说应该是bsod,系统hang住的情况还是第一次见到,不知道大家有没有遇到过。