From 9b41c276fd35fe3c0ed3fb0d9cf98a83a58b31b2 Mon Sep 17 00:00:00 2001 From: Tonghao Zhang Date: Thu, 16 Apr 2020 01:41:06 +0800 Subject: [PATCH] eal: fix PRNG init with HPET enabled MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit When rte_rand_init is invoked, and the kernel running dpdk does not support *getentropy, at the same time, the cpu does not support rdseed, then rte_rand_init invoked rte_get_timer_cycles. If HPET was enabled in the DPDK build (CONFIG_RTE_LIBEAL_USE_HPET=y) and the system, rte_get_timer_cycles will invoke rte_get_hpet_cycles while *eal_hpet is not available. To fix that, use rte_get_tsc_cycles instead of rte_get_timer_cycles. Fixes: 3f002f069612 ("eal: replace libc-based random generation with LFSR") Cc: stable@dpdk.org Signed-off-by: Tonghao Zhang Acked-by: Mattias Rönnblom --- 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 57ec8fb2b3..b7a089ac4f 100644 --- a/lib/librte_eal/common/rte_random.c +++ b/lib/librte_eal/common/rte_random.c @@ -198,7 +198,7 @@ __rte_random_initial_seed(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) -- 2.20.1