Received: by 2002:a05:6a10:16a7:0:0:0:0 with SMTP id gp39csp507661pxb; Thu, 5 Nov 2020 06:06:14 -0800 (PST) X-Google-Smtp-Source: ABdhPJyOAJrFcIbnoOSg3Hn1MMijhbxFPz9tySLrozgJN8iGepcfh0GAsf2ftnkhktgruGHceQUt X-Received: by 2002:a05:6402:1388:: with SMTP id b8mr2761980edv.1.1604585174648; Thu, 05 Nov 2020 06:06:14 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1604585174; cv=none; d=google.com; s=arc-20160816; b=HAmBwQmaXvNmHdoBR8YoebFwpQeNG9SPN0F1jmWEm//fILkNiHrWRvEWRPggozXqEP ojxhUPyaA9bCilQdLAgQoavtg6+BBuWJiAuXTfCL791Ifjk7oWDE1KSm4mhHtckO1sB0 Y1Ipz0Wf+L3HiyBdlnQdrEuZB/etpVjIQHMkes8hokNEanuHdlyrIdn+KZtUsV1GKXw/ CQmTbGyyzGzYCiM7ga1C9B2QeUz7ZLL9zpvh6ngORdOFQVML8Qt43m5KfhqKIkO0PkRl Q4N8R5ZnShNowvvd26VVDmHhWf5Lf1nmfEtsac2gvdFy8IlGnu4yma1Fx659BX6Tnj5f iWMw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date; bh=979LLRrClfD6ViLd1WV6SHz2Ulz3eZhzmhroruso3gQ=; b=b6nU9fyLK9vPvT9jpUpZs9qp3/wMnfcUBpp56erBu62L/q4cIbib0kgBEqTHAipvfI kS6WMkEl1c0vmsW85RWdTSgXcAUI5kkZKf3qSPIDMoagfgK7a5vFsGsiuz16AJI6p6rs cJYQ/T95dES+1jQQQ+F1uaIUaZC12mSK0DDhQQbCdeyeVp+wi2Ia6sP6mDnXKEcy3JSf WHFrF8xvNRw3s3wWc1M2c0wLI3jJ9crB34b37SejZTuZHzbu0bB8DScc/ldDGj03p5OC OlFhc716RhNPJGA6+92fkp7Gi6vZ6Q8lsdiLt1GgGzvyuB3Un6j2TXjXfTgyoGNTsSKQ zM3Q== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id e5si1197130edr.30.2020.11.05.06.05.49; Thu, 05 Nov 2020 06:06:14 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730808AbgKEOD2 (ORCPT + 99 others); Thu, 5 Nov 2020 09:03:28 -0500 Received: from foss.arm.com ([217.140.110.172]:33388 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729990AbgKEOD2 (ORCPT ); Thu, 5 Nov 2020 09:03:28 -0500 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id ED82614BF; Thu, 5 Nov 2020 06:03:27 -0800 (PST) Received: from C02TD0UTHF1T.local (unknown [10.57.58.72]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 78F9C3F719; Thu, 5 Nov 2020 06:03:25 -0800 (PST) Date: Thu, 5 Nov 2020 14:03:22 +0000 From: Mark Rutland To: Mark Brown Cc: Andre Przywara , Will Deacon , Catalin Marinas , Ard Biesheuvel , Russell King , linux-arm-kernel@lists.infradead.org, kvmarm@lists.cs.columbia.edu, linux-kernel@vger.kernel.org, Sudeep Holla , Lorenzo Pieralisi , Linus Walleij Subject: Re: [PATCH v2 4/5] arm64: Add support for SMCCC TRNG entropy source Message-ID: <20201105140322.GH82102@C02TD0UTHF1T.local> References: <20201105125656.25259-1-andre.przywara@arm.com> <20201105125656.25259-5-andre.przywara@arm.com> <20201105134142.GA4856@sirena.org.uk> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20201105134142.GA4856@sirena.org.uk> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Nov 05, 2020 at 01:41:42PM +0000, Mark Brown wrote: > On Thu, Nov 05, 2020 at 12:56:55PM +0000, Andre Przywara wrote: > > > static inline bool __must_check arch_get_random_seed_int(unsigned int *v) > > { > > + struct arm_smccc_res res; > > unsigned long val; > > - bool ok = arch_get_random_seed_long(&val); > > > > - *v = val; > > - return ok; > > + if (cpus_have_const_cap(ARM64_HAS_RNG)) { > > + if (arch_get_random_seed_long(&val)) { > > + *v = val; > > + return true; > > + } > > + return false; > > + } > > It isn't obvious to me why we don't fall through to trying the SMCCC > TRNG here if for some reason the v8.5-RNG didn't give us something. > Definitely an obscure possibility but still... I think it's better to assume that if we have a HW RNG and it's not giving us entropy, it's not worthwhile trapping to the host, which might encounter the exact same issue. I'd rather we have one RNG source that we trust works, and use that exclusively. That said, I'm not sure it's great to plumb this under the arch_get_random*() interfaces, e.g. given this measn that add_interrupt_randomness() will end up trapping to the host all the time when it calls arch_get_random_seed_long(). Is there an existing interface for "slow" runtime entropy that we can plumb this into instead? Thanks, Mark.