So, I check if bit 18 of cr4 is enabled:XCR0 can only be accessed if bit 18 of CR4 is set to 1. XGETBV and XSETBV instructions are used to access XCR0.
Code: Select all
uint32_t cr0 = 0;
asm ("movl %%cr4, %0;" : "=r" (cr4) ::);
if((cr4 & (1 << 18)) == 1){
printf("XCR0 can be accessed.\n");
}
- Checking if SSE is enable from CPUID
- Enabling it (from what the OSDev wiki says)
Code: Select all
check_sse:
mov $0x1, %eax
cpuid
test $1<<25, %edx
jz .NoSSE
ret
.NoSSE:
cli
2: hlt
jmp 2b
enable_sse:
# Check if SSE is supported
call check_sse
mov %cr0, %eax
and $0xfffb, %ax
or $0x2, %ax
mov %eax, %cr0
mov %cr4, %eax
or $0x600, %eax
mov %eax, %cr4
ret
_start:
mov $stack_top, %esp
call enable_sse
...
Code: Select all
x86 base base CPU model type with no features enabled
x86 host processor with all supported host features
x86 max Enables all features supported by the accelerator in the current host
Code: Select all
qemu-system-i386 -enable-kvm -cpu max -cdrom myos.iso