[dpdk-dev] [PATCH v2] eal: fix crash when the random init

xiangxia.m.yue at gmail.com xiangxia.m.yue at gmail.com
Wed Apr 15 09:43:35 CEST 2020


From: Tonghao Zhang <xiangxia.m.yue at gmail.com>

When rte_rand_init is invoked, and the kernel running dpdk does't
support *getentropy, at the same time, the cpu does't support rdseed,
then rte_rand_init invoked rte_get_timer_cycles which invoked
rte_get_hpet_cycles while *eal_hpet is not available.

To fix that, use rte_get_tsc_cycles instread of rte_get_timer_cycles.

Fixes: faf8fd252785 ("eal: improve entropy for initial PRNG seed")
Fixes: 3f002f069612 ("eal: replace libc-based random generation with LFSR")

Cc: stable at dpdk.org

Reported-by: Ravi Kerur <rkerur at gmail.com>
Signed-off-by: Tonghao Zhang <xiangxia.m.yue at gmail.com>
---
v2:
* use rte_get_tsc_cycles instread of rte_get_timer_cycles

---
 lib/librte_eal/common/rte_random.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lib/librte_eal/common/rte_random.c b/lib/librte_eal/common/rte_random.c
index 57ec8fb2b3dd..b7a089ac4fe0 100644
--- a/lib/librte_eal/common/rte_random.c
+++ b/lib/librte_eal/common/rte_random.c
@@ -198,7 +198,7 @@ struct rte_rand_state *__rte_rand_get_state(void)
 		return (uint64_t)rdseed_low | ((uint64_t)rdseed_high << 32);
 #endif
 	/* second fallback: seed using rdtsc */
-	return rte_get_timer_cycles();
+	return rte_get_tsc_cycles();
 }
 
 RTE_INIT(rte_rand_init)
-- 
1.8.3.1



More information about the dev mailing list