From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id 528E5A046B for ; Fri, 28 Jun 2019 23:08:55 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id C1BC14CA9; Fri, 28 Jun 2019 23:08:53 +0200 (CEST) Received: from sesbmg23.ericsson.net (sesbmg23.ericsson.net [193.180.251.37]) by dpdk.org (Postfix) with ESMTP id BD36CF64 for ; Fri, 28 Jun 2019 23:08:51 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; d=ericsson.com; s=mailgw201801; c=relaxed/relaxed; q=dns/txt; i=@ericsson.com; t=1561756131; x=1564348131; h=From:Sender:Reply-To:Subject:Date:Message-ID:To:CC:MIME-Version:Content-Type: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=5Ygjbb9OqYrNyGv1YYe95f1+M9S6SDnC+Se0IYq2u6Q=; b=H2avObwieyEiL7Mb0YDZsvAP+zHp5GrnCC7vgY2vvUVLwQUUsQOCNv1Vh22r5UMP i7FZJjOX9sWPz8T5pZ2bQ5ldKVsgW9M8gmZS6YwsIgX4nTsXu1dXex+RxPWRpw3n DVQpbeo6cECK3maFlDKhucc7keIVFuhuDEdUEWXnp3k=; X-AuditID: c1b4fb25-3b1ff700000029f0-c5-5d1681e372f7 Received: from ESESSMB502.ericsson.se (Unknown_Domain [153.88.183.120]) by sesbmg23.ericsson.net (Symantec Mail Security) with SMTP id 80.2C.10736.3E1861D5; Fri, 28 Jun 2019 23:08:51 +0200 (CEST) Received: from ESESSMR504.ericsson.se (153.88.183.126) by ESESSMB502.ericsson.se (153.88.183.163) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1713.5; Fri, 28 Jun 2019 23:08:50 +0200 Received: from ESESBMB503.ericsson.se (153.88.183.170) by ESESSMR504.ericsson.se (153.88.183.126) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1713.5; Fri, 28 Jun 2019 23:08:50 +0200 Received: from selio1a020.lmera.ericsson.se (153.88.183.153) by smtp.internal.ericsson.com (153.88.183.186) with Microsoft SMTP Server id 15.1.1713.5 via Frontend Transport; Fri, 28 Jun 2019 23:08:50 +0200 Received: from breslau.lmera.ericsson.se (breslau.lmera.ericsson.se [150.132.109.241]) by selio1a020.lmera.ericsson.se (8.15.1+Sun/8.15.1) with ESMTP id x5SL8nET020635; Fri, 28 Jun 2019 23:08:50 +0200 (CEST) From: =?UTF-8?q?Mattias=20R=C3=B6nnblom?= To: CC: , , =?UTF-8?q?Mattias=20R=C3=B6nnblom?= Date: Fri, 28 Jun 2019 23:08:46 +0200 Message-ID: <20190628210846.20717-1-mattias.ronnblom@ericsson.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: References: MIME-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 8bit X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFrrPLMWRmVeSWpSXmKPExsUyM2J7he7jRrFYg+1zeSxurLK3ePdpO5PF nb2n2R2YPX4tWMrqsXjPS6YApigum5TUnMyy1CJ9uwSujMlPZjIVrOSqOLSovIHxNkcXIyeH hICJxNdVbaxdjFwcQgJHGSUOz+2Ccr4xSvT8WcEM53ztfMUC4VxklJjf84UdwrnMKHHv+RxW kGFsAp4Sk991s4DYIgJCEks/XgYrYhZoZJTYteAxWEJYwFFiY/dEZhCbRUBV4vveo0wgNq+A k8Sm3dsYIa6Sl1i94QBYDaeAg8S5N+uBejmAttlLdH7whygXlDg58wnYSGYBTYnW7b/ZIWx5 ieats8FahQS0JO4v+cI8gVF4FpKWWUhaZiFpWcDIvIpRtDi1OCk33chYL7UoM7m4OD9PLy+1 ZBMjMNgPbvmtuoPx8hvHQ4wCHIxKPLwfCsVihVgTy4orcw8xSnAwK4nwSp4TiRXiTUmsrEot yo8vKs1JLT7EKM3BoiTOu977X4yQQHpiSWp2ampBahFMlomDU6qB0fLnrU7TSyGfPB63MVhc db8SwCWv0cb8UXe9tFlGmbnar3lPD21b6HH86sNXu35tnbgzZG9eyZeXn02vH7nKG247waj5 voqexSnRrqKrbrWTpvX0JZ/43PBg8t1zv1af0Jz24ayLovnamPznZx87v8m6VzgpsVBXr6S6 f/XE2xLuIk+CF9rsWaTEUpyRaKjFXFScCACoXoK3cgIAAA== Subject: [dpdk-dev] [PATCH] eal: use 32-bit RDSEED to allow 32-bit x86 usage X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" When seeding the pseudo-random number generator, replace the 64-bit RDSEED with two 32-bit RDSEED instructions to allow building and running on 32-bit x86. Fixes: faf8fd252785 ("eal: improve entropy for initial PRNG seed") Reported-by: Ferruh Yigit Signed-off-by: Mattias Rönnblom --- lib/librte_eal/common/rte_random.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/lib/librte_eal/common/rte_random.c b/lib/librte_eal/common/rte_random.c index 3d9b9b7d8..f51708b30 100644 --- a/lib/librte_eal/common/rte_random.c +++ b/lib/librte_eal/common/rte_random.c @@ -189,14 +189,13 @@ __rte_random_initial_seed(void) return ge_seed; #endif #ifdef RTE_MACHINE_CPUFLAG_RDSEED - unsigned int rdseed_rc; - unsigned long long rdseed_seed; + unsigned int rdseed_low; + unsigned int rdseed_high; /* first fallback: rdseed instruction, if available */ - rdseed_rc = _rdseed64_step(&rdseed_seed); - - if (rdseed_rc == 1) - return (uint64_t)rdseed_seed; + 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 */ return rte_get_timer_cycles(); -- 2.17.1