[Bug target/56068] -march=native creates Illegal instruction on KVM guests
ubizjak at gmail dot com
gcc-bugzilla@gcc.gnu.org
Mon Jan 21 19:32:00 GMT 2013
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=56068
--- Comment #13 from Uros Bizjak <ubizjak at gmail dot com> 2013-01-21 19:31:47 UTC ---
(In reply to comment #12)
> (In reply to comment #11)
> > I will try 4.6 to prove that. Off to build 4.6...
>
> Thanks for checking. See http://gcc.gnu.org/wiki/InstallingGCC for the
> foolproof way to do build it.
>
> You could also try this with any GCC version on the KVM guest:
>
> #include <stdio.h>
> #include "cpuid.h"
>
> int main()
> {
> unsigned bit_osxsave = bit_AVX >> 1;
>
> unsigned int eax, ebx, ecx, edx;
>
> __cpuid (1, eax, ebx, ecx, edx);
>
> printf("bit_OSXSAVE (%u) = %u\n", bit_osxsave, ecx & bit_osxsave);
> printf("bit_AVX (%u) = %u\n", bit_AVX, ecx & bit_AVX);
> }
>
> If that prints 0 for OSXSAVE and non-zero for AVX then it's the same problem I
> had.
>
> Maybe GCC could work around it by checking both flags in the AVX detection
> logic.
Recent 4.6+ does. Please see driver-i386.c around line 470:
--snip--
/* Get XCR_XFEATURE_ENABLED_MASK register with xgetbv. */
#define XCR_XFEATURE_ENABLED_MASK 0x0
#define XSTATE_FP 0x1
#define XSTATE_SSE 0x2
#define XSTATE_YMM 0x4
if (has_osxsave)
asm (".byte 0x0f; .byte 0x01; .byte 0xd0"
: "=a" (eax), "=d" (edx)
: "c" (XCR_XFEATURE_ENABLED_MASK));
/* Check if SSE and YMM states are supported. */
if (!has_osxsave
|| (eax & (XSTATE_SSE | XSTATE_YMM)) != (XSTATE_SSE | XSTATE_YMM))
{
has_avx = 0;
has_fma = 0;
has_fma4 = 0;
has_xop = 0;
}
--snip--
More information about the Gcc-bugs
mailing list