Commit 604fbcb3 authored by Sam Lantinga's avatar Sam Lantinga

Fixed crash - need to save and restore rbx around cpuid, since the compiler...

Fixed crash - need to save and restore rbx around cpuid, since the compiler may be assuming the stack pointer isn't being modified when filling in %0.

I did it around each call to cpuid which isn't strictly necessary, but is definitely future proof. :)

--HG--
extra : convert_revision : svn%3Ac70aab31-4412-0410-b14c-859654838e24/trunk%404239
parent a8a1831e
...@@ -170,17 +170,19 @@ CPU_getCPUIDFeatures(void) ...@@ -170,17 +170,19 @@ CPU_getCPUIDFeatures(void)
); );
#elif defined(__GNUC__) && defined(__x86_64__) #elif defined(__GNUC__) && defined(__x86_64__)
__asm__ ( __asm__ (
" pushq %%rbx\n"
" xorl %%eax,%%eax # Set up for CPUID instruction \n" " xorl %%eax,%%eax # Set up for CPUID instruction \n"
" pushq %%rbx\n"
" cpuid # Get and save vendor ID \n" " cpuid # Get and save vendor ID \n"
" popq %%rbx\n"
" cmpl $1,%%eax # Make sure 1 is valid input for CPUID\n" " cmpl $1,%%eax # Make sure 1 is valid input for CPUID\n"
" jl 1f # We dont have the CPUID instruction\n" " jl 1f # We dont have the CPUID instruction\n"
" xorl %%eax,%%eax \n" " xorl %%eax,%%eax \n"
" incl %%eax \n" " incl %%eax \n"
" pushq %%rbx\n"
" cpuid # Get family/model/stepping/features\n" " cpuid # Get family/model/stepping/features\n"
" popq %%rbx\n"
" movl %%edx,%0 \n" " movl %%edx,%0 \n"
"1: \n" "1: \n"
" popq %%rbx\n"
: "=m" (features) : "=m" (features)
: :
: "%rax", "%rcx", "%rdx" : "%rax", "%rcx", "%rdx"
...@@ -242,16 +244,18 @@ CPU_getCPUIDFeaturesExt(void) ...@@ -242,16 +244,18 @@ CPU_getCPUIDFeaturesExt(void)
); );
#elif defined(__GNUC__) && defined (__x86_64__) #elif defined(__GNUC__) && defined (__x86_64__)
__asm__ ( __asm__ (
" pushq %%rbx\n"
" movl $0x80000000,%%eax # Query for extended functions \n" " movl $0x80000000,%%eax # Query for extended functions \n"
" pushq %%rbx\n"
" cpuid # Get extended function limit \n" " cpuid # Get extended function limit \n"
" popq %%rbx\n"
" cmpl $0x80000001,%%eax \n" " cmpl $0x80000001,%%eax \n"
" jl 1f # Nope, we dont have function 800000001h\n" " jl 1f # Nope, we dont have function 800000001h\n"
" movl $0x80000001,%%eax # Setup extended function 800000001h\n" " movl $0x80000001,%%eax # Setup extended function 800000001h\n"
" pushq %%rbx\n"
" cpuid # and get the information \n" " cpuid # and get the information \n"
" popq %%rbx\n"
" movl %%edx,%0 \n" " movl %%edx,%0 \n"
"1: \n" "1: \n"
" popq %%rbx\n"
: "=m" (features) : "=m" (features)
: :
: "%rax", "%rcx", "%rdx" : "%rax", "%rcx", "%rdx"
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment