Rdrand instrucrtion SIGILL

霸气de小男生 提交于 2019-12-13 07:39:21

问题


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 ()

回答1:


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

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.



来源:https://stackoverflow.com/questions/30860025/rdrand-instrucrtion-sigill

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!