On Thu, 2009-03-12 at 11:20 +0100, Werner Koch wrote: > On Thu, 12 Mar 2009 09:32, dex...@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" > "popf\n\t" > "pushf\n\t" /* Copy changed flags again to EAX. */ > "popl %%eax\n\t" > "pushl %%ecx\n\t" /* Restore flags from ECX. */ > "popf\n\t" > "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. */ > ".Lno_cpuid%=:\n\t" > : "=r" (has_cpuid) [...]
"=r" means that the code *will* write to register %0, which is then written to has_cpuid. But if this code does not detect cpuid, the register is uninitialised and probably has a non-zero value. You must either change the detection code to set %0 to 0 if the condition is not met, or change "=r" to "+r" so that %0 will be initialised to the previous value of has_cpuid (i.e. 0). Ben. -- Ben Hutchings Quantity is no substitute for quality, but it's the only one we've got.
signature.asc
Description: This is a digitally signed message part