X-Git-Url: https://git.distorted.org.uk/~mdw/catacomb/blobdiff_plain/1b07c4f340465551b7d12c3be3bcecd258a3c32d..1519ef6617fd7351bd40026b9eeb47c7f7f42234:/base/dispatch-x86ish.S diff --git a/base/dispatch-x86ish.S b/base/dispatch-x86ish.S index b3b6d1cb..57d8d32b 100644 --- a/base/dispatch-x86ish.S +++ b/base/dispatch-x86ish.S @@ -158,10 +158,11 @@ ENDFUNC /// Checking `rdrand'. FUNC(dispatch_x86ish_rdrand) - // Enter with two arguments: a code OP requesting `rdrand' (0), and a - // pointer X_OUT to a 32-bit word. Try to generate a random word - // using the requested instruction. If successful, set *X_OUT to the - // generated word, and return zero; otherwise, return -1. + // Enter with two arguments: a code OP requesting either `rdrand' (0) + // or `rdseed' (1), and a pointer X_OUT to a 32-bit word. Try to + // generate a random word using the requested instruction'. If + // successful, set *X_OUT to the generated word, and return zero; + // otherwise, return -1. #if CPUFAM_X86 # define OP eax @@ -182,13 +183,22 @@ FUNC(dispatch_x86ish_rdrand) #endif endprologue + cmp OP, 0 mov COUNT, 16 // fairly persistent + jne 1f + 0: rdrand eax jc 9f dec COUNT jnz 0b jmp 8f +1: rdseed eax + jc 9f + dec COUNT + jnz 1b + jmp 8f + // Failed to come up with a random value. 8: mov eax, -1 ret