From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753791AbdEJPkq (ORCPT ); Wed, 10 May 2017 11:40:46 -0400 Received: from mail-db5eur01on0089.outbound.protection.outlook.com ([104.47.2.89]:59568 "EHLO EUR01-DB5-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1753162AbdEJPkn (ORCPT ); Wed, 10 May 2017 11:40:43 -0400 From: Octavian Purdila To: "smueller@chronox.de" CC: "linux-kernel@vger.kernel.org" Subject: jitterentropy init test failure on ARMv7 with gcc 6.2 Thread-Topic: jitterentropy init test failure on ARMv7 with gcc 6.2 Thread-Index: AQHSyaPHDpQ2J83Y3EGWlqX//5eeNg== Date: Wed, 10 May 2017 15:40:40 +0000 Message-ID: <1494430839.8189.22.camel@nxp.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: authentication-results: chronox.de; dkim=none (message not signed) header.d=none;chronox.de; dmarc=none action=none header.from=nxp.com; x-originating-ip: [192.88.146.1] x-ms-publictraffictype: Email x-microsoft-exchange-diagnostics: 1;DB5PR04MB1400;7:lwMjm4X0nLubztF4ASHT2/HBMokp0DVazlOGCwj8foDB5cBmjtCTk8AOTvJR0qBscHUAHoaIn5nq1vpBEjua8WAFevNiRVjS0kwsUdDw3sOU7xRgK2yFatRj3x1fU0RYoY98d2EMqiXySUTz2hw3ibUfBprSmJ0s4FlgLBY4M598XcbY9BZrk5x2mD3h77Z71U5NsGmWTwxZ3k5ELIe3xc9A1TNWWgizwAyzf1mNkRK6EgicXp5HJS+p6tPlfolbqfUuTRiy7vtWvo7EiauVw+ffBYAn7aSxSzv9g+SabcbaQoXgXc3RwlBpMGWP3/F0/4BFbUiYC+jRRxjlTZyRfw== x-ms-office365-filtering-correlation-id: 5c36499f-12f7-498b-5232-08d497bae9e3 x-ms-office365-filtering-ht: Tenant x-microsoft-antispam: UriScan:;BCL:0;PCL:0;RULEID:(22001)(2017030254075)(48565401081)(201703131423075)(201703031133081);SRVR:DB5PR04MB1400; x-microsoft-antispam-prvs: x-exchange-antispam-report-test: UriScan:; x-exchange-antispam-report-cfa-test: BCL:0;PCL:0;RULEID:(6040450)(601004)(2401047)(5005006)(8121501046)(93006095)(93001095)(10201501046)(3002001)(6055026)(6041248)(20161123555025)(20161123560025)(20161123564025)(20161123558100)(20161123562025)(201703131423075)(201702281528075)(201703061421075)(201703061406153)(6072148);SRVR:DB5PR04MB1400;BCL:0;PCL:0;RULEID:;SRVR:DB5PR04MB1400; x-forefront-prvs: 03030B9493 x-forefront-antispam-report: SFV:NSPM;SFS:(10009020)(6009001)(39840400002)(39860400002)(39400400002)(39450400003)(39850400002)(39410400002)(36756003)(25786009)(103116003)(189998001)(8936002)(66066001)(4326008)(33646002)(86362001)(81166006)(1730700003)(8676002)(2351001)(99286003)(5640700003)(53936002)(6512007)(6916009)(6436002)(6506006)(6486002)(110136004)(38730400002)(5250100002)(3280700002)(305945005)(2501003)(6116002)(3660700001)(54356999)(50986999)(102836003)(3846002)(2900100001)(5660300001)(478600001)(2906002);DIR:OUT;SFP:1101;SCL:1;SRVR:DB5PR04MB1400;H:DB5PR04MB1399.eurprd04.prod.outlook.com;FPR:;SPF:None;MLV:sfv;LANG:en; spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM Content-Type: text/plain; charset="utf-8" Content-ID: <319F0DF2E5EEFF4DA609732D13B6F5E4@eurprd04.prod.outlook.com> MIME-Version: 1.0 X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-originalarrivaltime: 10 May 2017 15:40:40.7741 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB5PR04MB1400 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Transfer-Encoding: 8bit X-MIME-Autoconverted: from base64 to 8bit by mail.home.local id v4AFep7W000389 Hi Stephan, Recently I started seeing the following on some of our ARMv7 boards (IMX7D): jitterentropy: Initialization failed with host not compliant with requirements: 2 and I traced this to the followin init test: lowdelta = time2 - time; if (!(lowdelta % 100)) count_mod++; ...         /*          * Ensure that we have variations in the time stamp below 10  * for at least 10% of all checks -- on some platforms, the  * counter increments in multiples of 100, but not always.          */ if ((TESTLOOPCOUNT/10 * 9) < count_mod) return JENT_ECOARSETIME; Digging deeper, I've noticed that the delta between the timestamp is almost always constant. With the gcc 4.9 it is 102 but with gcc 6.2 it is 100 and this is the reason the above test fails. Running a tight loop and measuring the delta in between shows that the timestamp counter increments with a fairly low value of 7 (it looks like random_get_entropy() is used and that it is defined to get_cycles()).  So the reason is not that the counter increments in multiples of 100, but that the time to run jent_fold_time() is constant during the initialization tests. Further analyzing it, it looks like jent_fold_time() is called with a constant loop count of 1 which would explain why the delta is constant. At this point, I am not sure that the test above is correct. Am I missing something? Thanks, Tavi