eal: fix crash when the random init
A message that is not in the archive (sent off-list or not yet received): [email protected]
PATCH v2 1/1 eal: fix crash when the random init
From: Tonghao Zhang <[email protected]>
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.
---
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(-)
lib/librte_eal/common/rte_random.c +1 -1
@@ -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)
Signature · 1 line
1.8.3.1
Quoted 6 lines · On 2020-04-15 09:43, [email protected] wrote:
From: Tonghao Zhang <[email protected]>
When
rte_rand_initis invoked, and the kernel running dpdk does't support *getentropy, at the same time, the cpu does't support rdseed, thenrte_rand_initinvokedrte_get_timer_cycleswhich invokedrte_get_hpet_cycleswhile*eal_hpetis not available.
You fail to mention that HPET must be enabled in the DPDK build (which it is not, by default), and enabled in the BIOS, for this bug to be triggered.
Quoted 1 line
To fix that, use
rte_get_tsc_cyclesinstread ofrte_get_timer_cycles.
"instead"
With those updates,
Quoted 28 lines
Fixes faf8fd252785 ("eal: improve entropy for initial PRNG seed")Fixes 3f002f069612 ("eal: replace libc-based random generation with LFSR")Reported-by Ravi Kerur <[email protected]>Signed-off-by Tonghao Zhang <[email protected]>---
v2:
* userte_get_tsc_cyclesinstread ofrte_get_timer_cycles--- lib/librte_eal/common/rte_random.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)lib/librte_eal/common/rte_random.c +1
-1@@ -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)
PATCH v3 1/1 eal: fix crash when the random init
In reply to a message not in the archiveFrom: Tonghao Zhang <[email protected]>
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.
If HPET was enabled in the DPDK build (CONFIG_RTE_LIBEAL_USE_HPET=y). 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.
---
v3:
* add more info in commit log and fix a typo v2:
* use rte_get_tsc_cycles instead of rte_get_timer_cycles
--- lib/librte_eal/common/rte_random.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
lib/librte_eal/common/rte_random.c +1 -1
@@ -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)
Signature · 1 line
1.8.3.1
David Marchand
AppliedQuoted 11 lines · On Fri, Apr 17, 2020 at 1:37 PM <[email protected]> wrote:
From: Tonghao Zhang <[email protected]>
When
rte_rand_initis invoked, and the kernel running dpdk does't support *getentropy, at the same time, the cpu does't support rdseed, thenrte_rand_initinvokedrte_get_timer_cycles.If HPET was enabled in the DPDK build (
CONFIG_RTE_LIBEAL_USE_HPET=y).rte_get_timer_cycleswill invokerte_get_hpet_cycleswhile*eal_hpetis not available.
Quoted 7 lines
To fix that, use
rte_get_tsc_cyclesinstead ofrte_get_timer_cycles.Fixes 3f002f069612 ("eal: replace libc-based random generation with LFSR")Signed-off-by Tonghao Zhang <[email protected]>Acked-by Mattias Rönnblom <[email protected]>
Applied, thanks.
Signature · 1 line
David Marchand