RDSEED is an x86 instruction that returns random bits from a hardware
source. It has well known reliability problems: it can fail
persistently when many cores use it at once, and several processors
have errata affecting it. Since "random: always use getentropy"
earlier in this series it was only reachable if getentropy() failed,
which does not happen in practice.

Nothing is lost by removing it. The kernel already mixes RDSEED into
its own entropy pool as one of several sources, so what it provides is
present in the getentropy() result anyway, combined with other sources
rather than trusted on its own.

The remaining fallback, the timestamp counter, still logs an error so
that a low entropy seed is reported.

Signed-off-by: Stephen Hemminger <[email protected]>
---
 lib/eal/common/rte_random.c | 17 ++---------------
 1 file changed, 2 insertions(+), 15 deletions(-)

diff --git a/lib/eal/common/rte_random.c b/lib/eal/common/rte_random.c
index 3c5b36aa2c..c14df2cce7 100644
--- a/lib/eal/common/rte_random.c
+++ b/lib/eal/common/rte_random.c
@@ -2,11 +2,6 @@
  * Copyright(c) 2019 Ericsson AB
  */
 
-#ifdef __RDSEED__
-#ifndef RTE_TOOLCHAIN_MSVC
-#include <x86intrin.h>
-#endif
-#endif
 #include <errno.h>
 #include <string.h>
 #include <unistd.h>
@@ -226,16 +221,8 @@ __rte_random_initial_seed(void)
 
        if (ge_rc == 0)
                return ge_seed;
-#ifdef __RDSEED__
-       unsigned int rdseed_low;
-       unsigned int rdseed_high;
-
-       /* first fallback: rdseed instruction, if available */
-       if (_rdseed32_step(&rdseed_low) == 1 &&
-           _rdseed32_step(&rdseed_high) == 1)
-               return (uint64_t)rdseed_low | ((uint64_t)rdseed_high << 32);
-#endif
-       /* second fallback: seed using rdtsc */
+
+       /* fallback: seed using rdtsc */
        EAL_LOG(ERR, "getentropy() failed (%s), seeding PRNG from TSC: seed has 
low entropy",
                strerror(errno));
        return rte_get_tsc_cycles();
-- 
2.53.0

Reply via email to