diff --git a/src/arch/x86_64/boot.asm b/src/arch/x86_64/boot.asm index 58bbed04..64d0c0db 100644 --- a/src/arch/x86_64/boot.asm +++ b/src/arch/x86_64/boot.asm @@ -148,14 +148,17 @@ check_cpuid: ; Throw error 2 if the CPU doesn't support Long Mode. check_long_mode: - mov eax, 0x80000000 ; Set the A-register to 0x80000000. - cpuid ; CPU identification. - cmp eax, 0x80000001 ; Compare the A-register with 0x80000001. - jb .no_long_mode ; It is less, there is no long mode. - mov eax, 0x80000001 ; Set the A-register to 0x80000001. - cpuid ; CPU identification. - test edx, 1 << 29 ; Test if the LM-bit, which is bit 29, is set in the D-register. - jz .no_long_mode ; They aren't, there is no long mode. + ; test if extended processor info in available + mov eax, 0x80000000 ; implicit argument for cpuid + cpuid ; get highest supported argument + cmp eax, 0x80000001 ; it needs to be at least 0x80000001 + jb .no_long_mode ; if it's less, the CPU is too old for long mode + + ; use extended info to test if long mode is available + mov eax, 0x80000001 ; argument for extended processor info + cpuid ; returns various feature bits in ecx and edx + test edx, 1 << 29 ; test if the LM-bit is set in the D-register + jz .no_long_mode ; If it's not set, there is no long mode ret .no_long_mode: mov al, "2"