Skip to content

Commit

Permalink
Avoid failure on qemu guests declaring an Athlon CPU without 3dnow!
Browse files Browse the repository at this point in the history
The present patch verifies that, on machines declaring an Athlon CPU model and
family, the 3dnow and 3dnowext feature flags are indeed present. If they are
not, it fallbacks on the most generic x86 kernel. This prevents crashes due to
illegal instruction on qemu guests with a weird configuration.

Closes #272
  • Loading branch information
svillemot committed Aug 28, 2013
1 parent fe98de2 commit eae4cfa
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion driver/others/dynamic.c
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,19 @@ static gotoblas_t *get_coretype(void){
}

if (vendor == VENDOR_AMD){
if (family <= 0xe) return &gotoblas_ATHLON;
if (family <= 0xe) {
// Verify that CPU has 3dnow and 3dnowext before claiming it is Athlon
cpuid(0x80000000, &eax, &ebx, &ecx, &edx);
if (eax & 0xffff >= 0x01) {
cpuid(0x80000001, &eax, &ebx, &ecx, &edx);
if ((edx & (1 << 30)) == 0 || (edx & (1 << 31)) == 0)
return NULL;
}
else
return NULL;

return &gotoblas_ATHLON;
}
if (family == 0xf){
if ((exfamily == 0) || (exfamily == 2)) {
if (ecx & (1 << 0)) return &gotoblas_OPTERON_SSE3;
Expand Down

0 comments on commit eae4cfa

Please sign in to comment.