Rdrand instrucrtion SIGILL

507 views Asked by At

Cpuid says that I have rdrand on my system, but rdrand instruction throws sigill. I'm using linux mint inside VmWare workstation 11, I googled workstation support of rdrand, and they say that it enabled since 9th version. Proccess of host is i5-2550k and it should support rdrand. Can I somehow fix this? Here is gdb listing:

Breakpoint 1, 0x08048060 in _start ()
(gdb) x/5i $eip

=> 0x8048060 <_start>:  mov    $0x1,%eax

   0x8048065 <_start+5>:    cpuid  

   0x8048067 <_start+7>:    rdrand %eax

   0x804806a <_start+10>:   mov    $0x1,%eax

   0x804806f <_start+15>:   int    $0x80

(gdb) si 2

0x08048067 in _start ()

(gdb) p/t $ecx

$1 = 10011111101110100010001000000011 ; bit 30 is set -- rdrand enabled.

(gdb) p/t $ebx

$2 = 10000100000000000

(gdb) p/t $eax

$3 = 100000011010100111

(gdb) si


Program received signal SIGILL, Illegal instruction.

0x08048067 in _start ()

Breakpoint 1, 0x08048060 in _start ()

(gdb) x/5i $eip

=> 0x8048060 <_start>:  mov    $0x1,%eax

  0x8048065 <_start+5>: cpuid  

  0x8048067 <_start+7>: rdrand %eax

 0x804806a <_start+10>: mov    $0x1,%eax

  0x804806f <_start+15>:    int    $0x80

(gdb) si 2

0x08048067 in _start ()

(gdb) p/t $ecx

$1 = 10011111101110100010001000000011

(gdb) p/t $ebx

$2 = 10000100000000000

(gdb) p/t $eax

$3 = 100000011010100111

(gdb) si


Program received signal SIGILL, Illegal instruction.

0x08048067 in _start ()
2

There are 2 answers

0
Ross Ridge On BEST ANSWER

You've read the ECX register wrong. The RDRAND bit is not set. Bit 30 is the second bit from the left:

10011111101110100010001000000011
 ^
 Bit 30                        ^ Bit 0

CPUID information returned in ECX

The above image is taken from the CPUID instruction description given in the Intel 64 and IA-32 Architectures Software Developer’s Manual.

Also your i5-2550K CPU is a Sandy Bridge processor. RDRAND wasn't introduced until the next generation of Intel processors, Ivy Bridge.

1
David Johnston On

RdRand was introduced in Ivy Bridge. The i5-2550K is part of the Sandy Bridge which was the previous generation.