patches for DPDK stable branches
 help / color / mirror / Atom feed
* [dpdk-stable] [PATCH v2] eal: fix crash when the random init
       [not found] <586680073-11075-1-git-send-email-xiangxia.m.yue@gmail.com>
@ 2020-04-15  7:43 ` xiangxia.m.yue
  2020-04-16 16:12   ` Mattias Rönnblom
  2020-04-15 17:41 ` [dpdk-stable] [PATCH v3] " xiangxia.m.yue
  1 sibling, 1 reply; 4+ messages in thread
From: xiangxia.m.yue @ 2020-04-15  7:43 UTC (permalink / raw)
  To: mattias.ronnblom, david.marchand; +Cc: dev, Tonghao Zhang, stable

From: Tonghao Zhang <xiangxia.m.yue@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@dpdk.org

Reported-by: Ravi Kerur <rkerur@gmail.com>
Signed-off-by: Tonghao Zhang <xiangxia.m.yue@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


^ permalink raw reply	[flat|nested] 4+ messages in thread

* [dpdk-stable] [PATCH v3] eal: fix crash when the random init
       [not found] <586680073-11075-1-git-send-email-xiangxia.m.yue@gmail.com>
  2020-04-15  7:43 ` [dpdk-stable] [PATCH v2] eal: fix crash when the random init xiangxia.m.yue
@ 2020-04-15 17:41 ` xiangxia.m.yue
  2020-04-21 16:17   ` David Marchand
  1 sibling, 1 reply; 4+ messages in thread
From: xiangxia.m.yue @ 2020-04-15 17:41 UTC (permalink / raw)
  To: mattias.ronnblom, david.marchand; +Cc: dev, Tonghao Zhang, stable

From: Tonghao Zhang <xiangxia.m.yue@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.

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.

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

Cc: stable@dpdk.org

Signed-off-by: Tonghao Zhang <xiangxia.m.yue@gmail.com>
Acked-by: Mattias Rönnblom <mattias.ronnblom@ericsson.com>
---
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(-)

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


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [dpdk-stable] [PATCH v2] eal: fix crash when the random init
  2020-04-15  7:43 ` [dpdk-stable] [PATCH v2] eal: fix crash when the random init xiangxia.m.yue
@ 2020-04-16 16:12   ` Mattias Rönnblom
  0 siblings, 0 replies; 4+ messages in thread
From: Mattias Rönnblom @ 2020-04-16 16:12 UTC (permalink / raw)
  To: xiangxia.m.yue, david.marchand; +Cc: dev, stable

On 2020-04-15 09:43, xiangxia.m.yue@gmail.com wrote:
> From: Tonghao Zhang <xiangxia.m.yue@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.

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.


> To fix that, use rte_get_tsc_cycles instread of rte_get_timer_cycles.


"instead"


With those updates,

Acked-by: Mattias Rönnblom <mattias.ronnblom@ericsson.com>

> Fixes: faf8fd252785 ("eal: improve entropy for initial PRNG seed")
> Fixes: 3f002f069612 ("eal: replace libc-based random generation with LFSR")
>
> Cc: stable@dpdk.org
>
> Reported-by: Ravi Kerur <rkerur@gmail.com>
> Signed-off-by: Tonghao Zhang <xiangxia.m.yue@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)



^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [dpdk-stable] [PATCH v3] eal: fix crash when the random init
  2020-04-15 17:41 ` [dpdk-stable] [PATCH v3] " xiangxia.m.yue
@ 2020-04-21 16:17   ` David Marchand
  0 siblings, 0 replies; 4+ messages in thread
From: David Marchand @ 2020-04-21 16:17 UTC (permalink / raw)
  To: Tonghao Zhang; +Cc: Mattias Rönnblom, dev, dpdk stable

On Fri, Apr 17, 2020 at 1:37 PM <xiangxia.m.yue@gmail.com> wrote:
>
> From: Tonghao Zhang <xiangxia.m.yue@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.
>
> 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.
>
> Fixes: 3f002f069612 ("eal: replace libc-based random generation with LFSR")
> Cc: stable@dpdk.org
>
> Signed-off-by: Tonghao Zhang <xiangxia.m.yue@gmail.com>
> Acked-by: Mattias Rönnblom <mattias.ronnblom@ericsson.com>

Applied, thanks.


-- 
David Marchand


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2020-04-21 16:18 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <586680073-11075-1-git-send-email-xiangxia.m.yue@gmail.com>
2020-04-15  7:43 ` [dpdk-stable] [PATCH v2] eal: fix crash when the random init xiangxia.m.yue
2020-04-16 16:12   ` Mattias Rönnblom
2020-04-15 17:41 ` [dpdk-stable] [PATCH v3] " xiangxia.m.yue
2020-04-21 16:17   ` David Marchand

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).