Received: by 2002:a05:6a10:16a7:0:0:0:0 with SMTP id gp39csp508701pxb; Thu, 5 Nov 2020 06:07:27 -0800 (PST) X-Google-Smtp-Source: ABdhPJw38nCeFBq4L4mP8N4rEiw/majhPNl6pvW1IYMPCogWENTgL3WjsPDkZx8W3/CuWSC+SZBm X-Received: by 2002:a05:6402:b28:: with SMTP id bo8mr2753715edb.57.1604585247154; Thu, 05 Nov 2020 06:07:27 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1604585247; cv=none; d=google.com; s=arc-20160816; b=mW2/oihfbDEtrIzKX3jpX8YqjfOMK3teRMbBDtKti9SoCoVJqbMjpEHgvVdFP4YtIr H/JzeLwWdO0UhAMeEziaFt/vmXPiIdXTR3bZ6FPhN1CO0smousQYjndKigS85qHzTTgd s7WtfuSUnEDGsWQftOYhoMONTjSvT56KAvjO+adtcQOmdrt50d8CipujFpSBS3GymZvI Dobc12hFD8Q94vB4KyqARNtb9TC8W93xDBmoDrqMQeA+GOhmWUW4Ywb7vPS2IbfqVYp2 Wc/me3+D/jWDo6UwYZJjfy4A9p+EgvxVRb/h4MSxvJcYwGWh2xKf8NE6TaBaRT5yiDeh bSKQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=6acubM2tiyd2lhpGcQxRzUCFrhAvQnoK3h907jZOEMU=; b=C3CI60sIJeF5E9un4fKd/DPwlo1bJVwobHp9WyCfw7rK8sbZNKdtMdD2UIshyppeRQ BMVxiarVfh7vzXzfPFc7/itnS1gykFuIKlfR/0DQ4TmMCRi76h7dp9HzmcTnRQgyVaPs Uq9VFEkRgKTus4WKhs7B6f+6sFRb27OvVUffsm0goNWMCzwgFJPd0o8wru9d93SrsVcl 3B6Cjsc/Sf1znlQxc5GXdA/dQHmsm92DFpsVl8j5V5cdjTyTPm5JGWRdBmCew6346yrz miyY2V+IQjaivqkIlSdSwlae041p3iYJWtOGxgYobLnHquGVSNI5VbDOTHvwfyxi/rnk pM7A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=p0Avospv; 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=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id z16si1116218ejc.435.2020.11.05.06.07.01; Thu, 05 Nov 2020 06:07:27 -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; dkim=pass header.i=@kernel.org header.s=default header.b=p0Avospv; 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=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730775AbgKEOFM (ORCPT + 99 others); Thu, 5 Nov 2020 09:05:12 -0500 Received: from mail.kernel.org ([198.145.29.99]:33116 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730465AbgKEOFL (ORCPT ); Thu, 5 Nov 2020 09:05:11 -0500 Received: from mail-oi1-f178.google.com (mail-oi1-f178.google.com [209.85.167.178]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 8A5362151B for ; Thu, 5 Nov 2020 14:05:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1604585110; bh=esBcP/AJui6XiODiwrRpOoJCZgU1uTPnZxKtrRhiwcQ=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=p0Avospvm9Lp2t90GSwX+PDScEW9y9WjpQyOZ/4BKa83ieD2OGsfWV5jRNyiM/aDm 9nk0uok6m3Xa66LyTG14bQXYC2S0pWeB6ElqYQiozYM7JWBGNa75/RFcx7pq3GF23w AL7Xu7QQPpAL/z9XBzQePs8klKyRBXZtzWv5J0Kk= Received: by mail-oi1-f178.google.com with SMTP id d9so1776191oib.3 for ; Thu, 05 Nov 2020 06:05:10 -0800 (PST) X-Gm-Message-State: AOAM530qj0oqhTAXvqXJiHil6/X490MvNUUKtXksJqmIdFRTE+RDqHse QmS0Xdb5/JEQV3H94LpqZjgsn8ySs4z9sV2LQgw= X-Received: by 2002:aca:2310:: with SMTP id e16mr1519564oie.47.1604585109752; Thu, 05 Nov 2020 06:05:09 -0800 (PST) MIME-Version: 1.0 References: <20201105125656.25259-1-andre.przywara@arm.com> <20201105125656.25259-5-andre.przywara@arm.com> <20201105134142.GA4856@sirena.org.uk> <20201105140322.GH82102@C02TD0UTHF1T.local> In-Reply-To: <20201105140322.GH82102@C02TD0UTHF1T.local> From: Ard Biesheuvel Date: Thu, 5 Nov 2020 15:04:57 +0100 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH v2 4/5] arm64: Add support for SMCCC TRNG entropy source To: Mark Rutland Cc: Mark Brown , Andre Przywara , Will Deacon , Catalin Marinas , Russell King , Linux ARM , kvmarm , Linux Kernel Mailing List , Sudeep Holla , Lorenzo Pieralisi , Linus Walleij Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, 5 Nov 2020 at 15:03, Mark Rutland wrote: > > 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(). > As it turns out, add_interrupt_randomness() isn't actually used on ARM. > Is there an existing interface for "slow" runtime entropy that we can > plumb this into instead? > > Thanks, > Mark.