03.03.2013 Views

Intel® Architecture Instruction Set Extensions Programming Reference

Intel® Architecture Instruction Set Extensions Programming Reference

Intel® Architecture Instruction Set Extensions Programming Reference

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

ADDITIONAL NEW INSTRUCTIONS<br />

----------------------------------------------------------------------------------------<br />

#define SUCCESS 1<br />

#define RETRY_LIMIT_EXCEEDED 0<br />

#define RETRY_LIMIT 10<br />

int get_random_64( unsigned __int 64 * arand)<br />

{int i ;<br />

for ( i = 0; i < RETRY_LIMIT; i ++) {<br />

if(_rdrand64_step(arand) ) return SUCCESS;<br />

}<br />

return RETRY_LIMIT_EXCEEDED;<br />

}<br />

-------------------------------------------------------------------------------<br />

The RDRAND instruction is first introduced in third-generation Intel Core processors built on 22-nm process.<br />

9.2.2 RDSEED<br />

The RDSEED instruction returns a random number. All Intel processors that support the RDSEED instruction indicate<br />

the availability of the RDSEED instruction via reporting CPUID.(EAX=07H, ECX=0H):EBX.RDSEED[bit 18] =<br />

1.<br />

RDSEED returns random numbers that are supplied by a cryptographically secure, enhanced non-deterministic<br />

random bit generator (Enhanced NRBG). The NRBG is designed to meet the NIST SP 800-90B and NIST SP800-<br />

90C standards.<br />

In order for the hardware design to meet its security goals, the random number generator continuously tests<br />

itself and the random data it is generating. Runtime failures in the random number generator circuitry or statistically<br />

anomalous data occurring by chance will be detected by the self test hardware and flag the resulting data as<br />

being bad. In such extremely rare cases, the RDSEED instruction will return no data instead of bad data.<br />

Under heavy load, with multiple cores executing RDSEED in parallel, it is possible for the demand of random<br />

numbers by software processes/threads to exceed the rate at which the random number generator hardware can<br />

supply them. This will lead to the RDSEED instruction returning no data transitorily. The RDSEED instruction indicates<br />

the occurrence of this situation by clearing the CF flag.<br />

The RDSEED instruction returns with the carry flag set (CF = 1) to indicate valid data is returned. It is recommended<br />

that software using the RDSEED instruction to get random numbers retry for a limited number of iterations<br />

while RDSEED returns CF=0 and complete when valid data is returned, indicated with CF=1. This will deal<br />

with transitory underflows. A retry limit should be employed to prevent a hard failure in the NRBG (expected to<br />

be extremely rare) leading to a busy loop in software.<br />

The intrinsic primitive for RDSEED is defined to address software’s need for the common cases (CF = 1) and the<br />

rare situations (CF = 0). The intrinsic primitive returns a value that reflects the value of the carry flag returned by<br />

the underlying RDRAND instruction. The example below illustrates the recommended usage of an RDRAND<br />

instrinsic in a utility function, a loop to fetch a 64 bit random value with a retry count limit of 10.<br />

9.2.3 RDSEED and VMX interactions<br />

A VM-execution control exists that allows the virtual machine monitor to trap on the instruction. The "RDSEED<br />

exiting" VM-execution control is located at bit 16 of the secondary processor-based VM-execution controls. A VM<br />

exit due to RDSEED will have exit reason 61 (decimal).<br />

9-2 Ref. # 319433-014

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!