0

Cpuid 说我的系统上有 rdrand,但是 rdrand 指令会抛出 sigill。我在 VmWare 工作站 11 中使用 linux mint,我搜索了 rdrand 的工作站支持,他们说它从第 9 版开始启用。主机进程是i5-2550k,应该支持rdrand。我能以某种方式解决这个问题吗?这是 gdb 清单:

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

2 回答 2

6

你读错了 ECX 寄存器。RDRAND 位未设置。第 30 位是左起第二位:

10011111101110100010001000000011
 ^
 Bit 30                        ^ Bit 0

ECX中返回的CPUID信息

上图取自 Intel 64 and IA-32 Architectures Software Developer's Manual 中给出的 CPUID 指令描述。

此外,您的 i5-2550K CPU 是 Sandy Bridge 处理器。直到下一代英特尔处理器 Ivy Bridge 才推出 RDRAND。

于 2015-06-16T09:11:19.443 回答
0

RdRand 是在 Ivy Bridge 中引入的。i5-2550K 是上一代 Sandy Bridge 的一部分。

于 2020-07-07T19:15:03.767 回答