Bug#519391: libgcrypt11: SIGILL on _gcry_detect_hw_features

Werner Koch wk at gnupg.org
Thu Mar 12 10:20:22 UTC 2009

On Thu, 12 Mar 2009 09:32, dexter at debian.org said:

> Program received signal SIGILL, Illegal instruction.
> [Switching to Thread 0xb7b9c6e0 (LWP 2196)]
> 0xb7bae10e in _gcry_detect_hw_features () at hwfeatures.c:78

That seems to be the cpuid opcode which is not available, Linux knows
about it:

> cpuid level     : -1

but my code gets the detection wrong:

  /* Detect the CPUID feature by testing some undefined behaviour (16
     vs 32 bit pushf/popf). */
  asm volatile
    ("pushf\n\t"                 /* Copy flags to EAX.  */
     "popl %%eax\n\t"
     "movl %%eax, %%ecx\n\t"     /* Save flags into ECX.  */
     "xorl $0x200000, %%eax\n\t" /* Toggle ID bit and copy it to the flags.  */
     "pushl %%eax\n\t"            
     "pushf\n\t"                 /* Copy changed flags again to EAX.  */    
     "popl %%eax\n\t"
     "pushl %%ecx\n\t"           /* Restore flags from ECX.  */
     "xorl %%eax, %%ecx\n\t"     /* Compare flags against saved flags.  */
     "jz .Lno_cpuid%=\n\t"       /* Toggling did not work, thus no CPUID.  */
     "movl $1, %0\n"             /* Worked. true -> HAS_CPUID.  */
     : "=r" (has_cpuid)
     : "%eax", "%ecx", "cc"
  if (!has_cpuid)
    return;  /* No way.  */

Any ideas?  Would anyone be so kind and compare it to the Linux code?

A workaround is to use 

  ./configure --disable-padlock-support

However, that makes it slow on VIA CPUs.



Die Gedanken sind frei.  Auschnahme regelt ein Bundeschgesetz.

More information about the Pkg-gnutls-maint mailing list