Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp857898ybl; Thu, 12 Dec 2019 06:05:26 -0800 (PST) X-Google-Smtp-Source: APXvYqwj8pTNWv0Wvc5ljbUKcuwzccpsvDgAqXZ6h25T+/NCc0wXp1VEFKC3sdwcaWBSaczUIiKn X-Received: by 2002:aca:4b8f:: with SMTP id y137mr4902468oia.42.1576159526081; Thu, 12 Dec 2019 06:05:26 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1576159526; cv=none; d=google.com; s=arc-20160816; b=NapNUhnwFbokzCcg1Ogv6qhBDeIZIb8ciW0uVmv9dSE4eC88vcB6IkhEOY/o7cSqvA FV4P9dlt14RalIkdYp9fTdzvIn1vUJem+Yson+e7/5eONptwmwOT0G6sHyXm7ehDy0SC QoHD4+LnMbcXd8uU8r8tQy7+Vujpbp9v5DfLakwmQUoCXMXVSl8GDPyzfuwgIn7/NHm1 CgSqhppHdKdTBH/CgQwuzEeYl7i7MxW1gHLx1DuCkrdx0RIWQEjvyarUAJqSmBQbnY2S x6wLkgHc9zy3s/EhgtUpSt1LFzMaAjHMbSvOFFLSylfakBSjT75SH6Z06Fjltw6PBXOD 4QXg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=YadRPUKRq+F+OfrkUFp7sfL3GGaSi5RtCx1mrcXaajw=; b=aAPaJZeUx09HhDTvdk/8kAEWgIaerKgSTxzm5xapkBRkmFs/Y+HOOoqLyyp87x+Ccf OJWMmaVRjgLjupqH7cbqsMQ0qD/gsCtxTB6Yfp685UoBttGLUh0jgPGbRRSVo8mKDPE9 aoIwdJos1UGsDLZwzF3XRJfz+dATGShg3kIHR5PbMA0ZAhWP/DD+2twVGiwc9dm96sL/ cObo9ssm/3FhxMX+QT9Ps3FX6WrsIoPWtUR4IVtQHfneOOuH/6gQ3dfzgefyGppVT1NL 778ZisMcqbXxCkXGNrMrmYggic5XdpDG63Mfh8sxGPyPDd7x+uAnwPNsAbcv/q6zZiZM OnGg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=XiZKyVtF; spf=pass (google.com: best guess record for domain of linux-crypto-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-crypto-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 14si3005650oie.181.2019.12.12.06.05.05; Thu, 12 Dec 2019 06:05:26 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-crypto-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=XiZKyVtF; spf=pass (google.com: best guess record for domain of linux-crypto-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-crypto-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729582AbfLLOED (ORCPT + 99 others); Thu, 12 Dec 2019 09:04:03 -0500 Received: from mail-wr1-f68.google.com ([209.85.221.68]:41052 "EHLO mail-wr1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729567AbfLLOEA (ORCPT ); Thu, 12 Dec 2019 09:04:00 -0500 Received: by mail-wr1-f68.google.com with SMTP id c9so2850472wrw.8 for ; Thu, 12 Dec 2019 06:03:58 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=YadRPUKRq+F+OfrkUFp7sfL3GGaSi5RtCx1mrcXaajw=; b=XiZKyVtF24JXNcMYL8Xwe6LFXRC5rGLAOXIUebbHSaeHrG07WKUNr8RJwQ823LolID XnFR2jJK+OvfWeKwOzAJUnPI+UDjOIOAgaUxlmeNOgEYTjulFbraIKmKbxd3ld4BJepg G8B4irn4mFBPM4Zu1GzyaWBuarsTxkULoMSdz25SJyyVexc+thf8CLbZtfVE9FbRTaOh 07zSU07GZuRh33XLh0EaBWoqfCLw6SwC7WrBpEUnaHaZ6x4A62aUKnANPqKliM4Y0vez uxK2fzumLw0PuinGG6OouRcXDf86rYM3J9sV+PomXgyY3qXZ+pLRC39ja+f/oDQUrtUn HCsg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=YadRPUKRq+F+OfrkUFp7sfL3GGaSi5RtCx1mrcXaajw=; b=QENSq9EeQTYBkrz2D6geJQDdLLbUC/SkkJ8OnxJ0nFgu+e/YMysmJSvTo+qm2EY4uk u6ZKUG1CPDLjExRstKwN/B4yjXE2Rg0M8KvTe8KoZu9UM1vhBGOrdv9dfAtqbQOMlz93 mVy4Pey/DUIsGmnqR1eZXliQ5RQ60DottORzg+TUFZxe8EF0nQVO7+Fs4Pxj+e28UUDN hFriBYBNLdMhDFq566m6gO/gBVr9SHIe1HXK3zioiVAlwAJ35bCbYZt+Sr9mGic0mzm4 nMVgykucUgW4b05UVr5IR1JqRXDP+Jl6XrTQplx96DAuuNeRapspYZOFfTuUi9NLeTPn Li8A== X-Gm-Message-State: APjAAAXiTaMGNX806gb5aqyLH9vG/JM7qFMoDlmckWglVIFFoSzul0gr 4nDszBwqOpoaGZ4E0SOKJu8L+HL04FJ3dNmpBIu0RQ== X-Received: by 2002:a5d:6652:: with SMTP id f18mr6737640wrw.246.1576159437310; Thu, 12 Dec 2019 06:03:57 -0800 (PST) MIME-Version: 1.0 References: <1574864578-467-1-git-send-email-neal.liu@mediatek.com> <1574864578-467-4-git-send-email-neal.liu@mediatek.com> <1575027046.24848.4.camel@mtkswgap22> <20191202191146.79e6368c@why> <299029b0-0689-c2c4-4656-36ced31ed513@gmail.com> <1576127609.27185.8.camel@mtkswgap22> In-Reply-To: From: Ard Biesheuvel Date: Thu, 12 Dec 2019 15:03:42 +0100 Message-ID: Subject: Re: [PATCH v5 3/3] hwrng: add mtk-sec-rng driver To: Marc Zyngier Cc: Neal Liu , Florian Fainelli , Pawel Moll , Mark Rutland , DTML , Herbert Xu , wsd_upstream , Catalin Marinas , Sean Wang , "moderated list:ARM/Mediatek SoC support" , Linux Kernel Mailing List , Rob Herring , "open list:HARDWARE RANDOM NUMBER GENERATOR CORE" , Matt Mackall , Matthias Brugger , =?UTF-8?B?Q3J5c3RhbCBHdW8gKOmDreaZtik=?= , Will Deacon , Lars Persson , linux-arm-kernel Content-Type: text/plain; charset="UTF-8" Sender: linux-crypto-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org On Thu, 12 Dec 2019 at 12:45, Marc Zyngier wrote: > > On 2019-12-12 05:13, Neal Liu wrote: > > On Tue, 2019-12-03 at 11:17 +0000, Marc Zyngier wrote: > >> On 2019-12-03 04:16, Florian Fainelli wrote: > >> > On 12/2/2019 11:11 AM, Marc Zyngier wrote: > >> >> On Mon, 2 Dec 2019 16:12:09 +0000 > >> >> Ard Biesheuvel wrote: > >> >> > >> >>> (adding some more arm64 folks) > >> >>> > >> >>> On Fri, 29 Nov 2019 at 11:30, Neal Liu > >> >>> wrote: > >> >>>> > >> >>>> On Fri, 2019-11-29 at 18:02 +0800, Lars Persson wrote: > >> >>>>> Hi Neal, > >> >>>>> > >> >>>>> On Wed, Nov 27, 2019 at 3:23 PM Neal Liu > >> > >> >>>>> wrote: > >> >>>>>> > >> >>>>>> For MediaTek SoCs on ARMv8 with TrustZone enabled, > >> peripherals > >> >>>>>> like > >> >>>>>> entropy sources is not accessible from normal world (linux) > >> and > >> >>>>>> rather accessible from secure world (ATF/TEE) only. This > >> driver > >> >>>>>> aims > >> >>>>>> to provide a generic interface to ATF rng service. > >> >>>>>> > >> >>>>> > >> >>>>> I am working on several SoCs that also will need this kind of > >> >>>>> driver > >> >>>>> to get entropy from Arm trusted firmware. > >> >>>>> If you intend to make this a generic interface, please clean > >> up > >> >>>>> the > >> >>>>> references to MediaTek and give it a more generic name. For > >> >>>>> example > >> >>>>> "Arm Trusted Firmware random number driver". > >> >>>>> > >> >>>>> It will also be helpful if the SMC call number is > >> configurable. > >> >>>>> > >> >>>>> - Lars > >> >>>> > >> >>>> Yes, I'm trying to make this to a generic interface. I'll try > >> to > >> >>>> make > >> >>>> HW/platform related dependency to be configurable and let it > >> more > >> >>>> generic. > >> >>>> Thanks for your suggestion. > >> >>>> > >> >>> > >> >>> I don't think it makes sense for each arm64 platform to expose > >> an > >> >>> entropy source via SMC calls in a slightly different way, and > >> model > >> >>> it > >> >>> as a h/w driver. Instead, we should try to standardize this, and > >> >>> perhaps expose it via the architectural helpers that already > >> exist > >> >>> (get_random_seed_long() and friends), so they get plugged into > >> the > >> >>> kernel random pool driver directly. > >> >> > >> >> Absolutely. I'd love to see a standard, ARM-specified, > >> virtualizable > >> >> RNG that is abstracted from the HW. > >> > > >> > Do you think we could use virtio-rng on top of a modified > >> virtio-mmio > >> > which instead of being backed by a hardware mailbox, could use > >> > hvc/smc > >> > calls to signal writes to shared memory and get notifications via > >> an > >> > interrupt? This would also open up the doors to other virtio uses > >> > cases > >> > beyond just RNG (e.g.: console, block devices?). If this is > >> > completely > >> > stupid, then please disregard this comment. > >> > >> The problem with a virtio device is that it is a ... device. What we > >> want > >> is to be able to have access to an entropy source extremely early in > >> the > >> kernel life, and devices tend to be available pretty late in the > >> game. > >> This means we cannot plug them in the architectural helpers that Ard > >> mentions above. > >> > >> What you're suggesting looks more like a new kind of virtio > >> transport, > >> which is interesting, in a remarkably twisted way... ;-) > >> > >> Thanks, > >> > >> M. > > > > In conclusion, is it helpful that hw_random has a generic interface > > to > > add device randomness by talking to hwrng which is implemented in the > > firmware or the hypervisor? > > For most chip vendors, I think the answer is yes. We already prepared > > a > > new patchset and need you agree with this idea. > > As long as it is a *unified* interface, I'm all for that. > Yeah, but I'm not sure it makes sense to model it as a device like this. It would be nice if we could tie this into the ARM SMCCC discovery, and use the SMC calls to back arch_get_random_seed_long() [provided we fix the braindead way in which that is being used today in the interrupt code]