Received: by 2002:a25:c593:0:0:0:0:0 with SMTP id v141csp3760382ybe; Mon, 16 Sep 2019 00:17:16 -0700 (PDT) X-Google-Smtp-Source: APXvYqxYbfrKYh7CmCPxMlFvuG3KjVRHnHwpkiMLQ2SkGcT7nB8gGlWl6VcwpFIXlsG7064mGMeB X-Received: by 2002:a50:fd83:: with SMTP id o3mr1311662edt.67.1568618236290; Mon, 16 Sep 2019 00:17:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1568618236; cv=none; d=google.com; s=arc-20160816; b=IycbuZRDAoRlIcx6LizvSEKKXuMS//IQNIsyUd4sP01/m/CYXEQZJahzXwhDmZas+G tby4Aux6ED9pam4IuqpeILp5vy03e1bjWDg4subSSb0savEOQmdfv+wpT6sC4GDIdPTr 4BTwh3KhOo2eEl7d7BO/vpaw0/h3Bv9tERRyIMOPSUpNrTi2EMxfa20lsdzn4DEBnoHD 9lVqOUNtLF5Z0GwENWk5eQCaD2zue/i3+x7HAOxq2cUEJJ1/3TRsoAaASdEC9Edyb9cK 5vI5i1Z7zvAzOmWdaY3/MPDTUjibBKcCbf4O6yLisCAaoLpPhSm5qJmnT0+W1mRsu/7T bFwQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=PmPRSSp7K6w4xBbSeoK52H24yu8MQXBQAMnDW5a1/hk=; b=VClKS8JVsdpttyRd0EKPqkDrfblA9MG9qBYI/mv06JrK70+zRi/cUCRUH6FzzLEGzs 5sKkLo+vyowuvRUEgPPK592fRY1dAsoI3WtMEpQ9P1L3sC8F8PuVfcJzXO6pd2Bgyshv 8fDzIN6vQeGwL8ivcMebKeGSj8rBNoJgeTNBijOJW8DO26zN2OHaLEqmE+NOr/I8Lhf3 MWtwF6RNt5QP4AxPa6xeUukiGIQ2919ZgHxDQ/6ls84Wb9IMF5P8CLDGvyH9hjZGpmEu Y+vceEqfmBzZqI2QVkYVLtrn5drgZtqM3fH+Z6m9UK4SEEKjXWooWKvm/mt+ZJT8byJo peJw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-ext4-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-ext4-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id lc2si18271392ejb.382.2019.09.16.00.16.51; Mon, 16 Sep 2019 00:17:16 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-ext4-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-ext4-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-ext4-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727051AbfIPEx7 (ORCPT + 99 others); Mon, 16 Sep 2019 00:53:59 -0400 Received: from wtarreau.pck.nerim.net ([62.212.114.60]:45673 "EHLO 1wt.eu" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726128AbfIPEx6 (ORCPT ); Mon, 16 Sep 2019 00:53:58 -0400 Received: (from willy@localhost) by pcw.home.local (8.15.2/8.15.2/Submit) id x8G4rVbY023928; Mon, 16 Sep 2019 06:53:31 +0200 Date: Mon, 16 Sep 2019 06:53:31 +0200 From: Willy Tarreau To: Linus Torvalds Cc: Herbert Xu , "Theodore Y. Ts'o" , "Ahmed S. Darwish" , Andreas Dilger , Jan Kara , Ray Strode , William Jon McCann , zhangjs , linux-ext4@vger.kernel.org, Linux List Kernel Mailing Subject: Re: Linux 5.3-rc8 Message-ID: <20190916045331.GC23719@1wt.eu> References: <20190911160729.GF2740@mit.edu> <20190916035228.GA1767@gondor.apana.org.au> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.6.1 (2016-04-27) Sender: linux-ext4-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-ext4@vger.kernel.org On Sun, Sep 15, 2019 at 09:21:06PM -0700, Linus Torvalds wrote: > The timer interrupt could be somewhat interesting if you are also > CPU-bound on a non-trivial load, because then "what program counter > got interrupted" ends up being possibly unpredictable - even with a > very stable timer interrupt source - and effectively stand in for a > cycle counter even on hardware that doesn't have a native TSC. Lots of > possible low-level jitter there to use for entropy. But especially if > you're just idly _waiting_ for entropy, you won't be "CPU-bound on an > interesting load" - you'll just hit the CPU idle loop all the time so > even that wouldn't work. In the old DOS era, I used to produce randoms by measuring the time it took for some devices to reset themselves (typically 8250 UARTs could take in the order of milliseconds). And reading their status registers during the reset phase used to show various sequences of flags at approximate timings. I suspect this method is still usable, even with SoCs full of peripherals, in part because not all clocks are synchronous, so we can retrieve a little bit of entropy by measuring edge transitions. I don't know how we can assess the number of bits provided by such method (probably log2(card(discrete values))) but maybe this is something we should progressively encourage drivers authors to do in the various device probing functions once we figure the best way to do it. The idea is around this. Instead of : probe(dev) { (...) while (timeout && !(status_reg & STATUS_RDY)) timeout--; (...) } We could do something like this (assuming 1 bit of randomness here) : probe(dev) { (...) prev_timeout = timeout; prev_reg = status_reg; while (timeout && !(status_reg & STATUS_RDY)) { if (status_reg != prev_reg) { add_device_randomness_bits(timeout - prev_timeout, 1); prev_timeout = timeout; prev_reg = status_reg; } timeout--; } (...) } It's also interesting to note that on many motherboards there are still multiple crystal oscillators (typically one per ethernet port) and that such types of independent, free-running clocks do present unpredictable edges compared to the CPU's clock, so when they affect the device's setup time, this does help quite a bit. Willy