Page 1 of 1

Cpu halts when enabling osxsave

Posted: Sat Feb 19, 2022 10:00 am
by devc1
I'm trying to enable extended processor features, when emulating on qemu with "Cascadelake-Server" i got the AVX, SSE Features but when emulating with normal cpu, it exactly halts when enabling OSXSAVE bit[18] on CR4

Here is the code :

Code: Select all

mov eax, 1
cpuid
test ecx, 1 << 26
je .enable_osxsave

.enable_osxsave:
push rax
mov rax, cr4
or rax, 1 << 18 ; Anything another than this bit works fine
mov cr4, rax ; Cpu Shutdown without any message by qemu and in debug the "halt" instruction is not executed
cli
hlt
jmp ,ret0

Re: Cpu halts when enabling osxsave

Posted: Sat Feb 19, 2022 4:30 pm
by Octocontrabass
The TEST instruction sets ZF when none of the tested bits are set.

The JE instruction jumps when ZF is set.

You're trying to set CR4.OSXSAVE on a CPU that does not support XSAVE.