From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.2 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,NICE_REPLY_A,SPF_HELO_NONE, SPF_PASS,URIBL_BLOCKED,USER_AGENT_SANE_1 autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3D5C2C4742C for ; Fri, 13 Nov 2020 23:55:18 +0000 (UTC) Received: from mm01.cs.columbia.edu (mm01.cs.columbia.edu [128.59.11.253]) by mail.kernel.org (Postfix) with ESMTP id 881AB20B80 for ; Fri, 13 Nov 2020 23:55:17 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 881AB20B80 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=arm.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=kvmarm-bounces@lists.cs.columbia.edu Received: from localhost (localhost [127.0.0.1]) by mm01.cs.columbia.edu (Postfix) with ESMTP id B67F44B8F8; Fri, 13 Nov 2020 18:55:16 -0500 (EST) X-Virus-Scanned: at lists.cs.columbia.edu Received: from mm01.cs.columbia.edu ([127.0.0.1]) by localhost (mm01.cs.columbia.edu [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id KWsGcOekM5zU; Fri, 13 Nov 2020 18:55:15 -0500 (EST) Received: from mm01.cs.columbia.edu (localhost [127.0.0.1]) by mm01.cs.columbia.edu (Postfix) with ESMTP id 7BF804B8FF; Fri, 13 Nov 2020 18:55:15 -0500 (EST) Received: from localhost (localhost [127.0.0.1]) by mm01.cs.columbia.edu (Postfix) with ESMTP id 13E554B8C4 for ; Fri, 13 Nov 2020 18:55:14 -0500 (EST) X-Virus-Scanned: at lists.cs.columbia.edu Received: from mm01.cs.columbia.edu ([127.0.0.1]) by localhost (mm01.cs.columbia.edu [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id YVMKQhwxHy29 for ; Fri, 13 Nov 2020 18:55:12 -0500 (EST) Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by mm01.cs.columbia.edu (Postfix) with ESMTP id 67F4C4B8C3 for ; Fri, 13 Nov 2020 18:55:12 -0500 (EST) 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 DA3CD1042; Fri, 13 Nov 2020 15:55:11 -0800 (PST) Received: from [192.168.2.22] (unknown [172.31.20.19]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 0B4673F718; Fri, 13 Nov 2020 15:55:09 -0800 (PST) Subject: Re: [PATCH v3 0/5] ARM: arm64: Add SMCCC TRNG entropy service To: Ard Biesheuvel References: <20201113182435.64015-1-andre.przywara@arm.com> From: =?UTF-8?Q?Andr=c3=a9_Przywara?= Autocrypt: addr=andre.przywara@arm.com; prefer-encrypt=mutual; keydata= xsFNBFNPCKMBEAC+6GVcuP9ri8r+gg2fHZDedOmFRZPtcrMMF2Cx6KrTUT0YEISsqPoJTKld tPfEG0KnRL9CWvftyHseWTnU2Gi7hKNwhRkC0oBL5Er2hhNpoi8x4VcsxQ6bHG5/dA7ctvL6 kYvKAZw4X2Y3GTbAZIOLf+leNPiF9175S8pvqMPi0qu67RWZD5H/uT/TfLpvmmOlRzNiXMBm kGvewkBpL3R2clHquv7pB6KLoY3uvjFhZfEedqSqTwBVu/JVZZO7tvYCJPfyY5JG9+BjPmr+ REe2gS6w/4DJ4D8oMWKoY3r6ZpHx3YS2hWZFUYiCYovPxfj5+bOr78sg3JleEd0OB0yYtzTT esiNlQpCo0oOevwHR+jUiaZevM4xCyt23L2G+euzdRsUZcK/M6qYf41Dy6Afqa+PxgMEiDto ITEH3Dv+zfzwdeqCuNU0VOGrQZs/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JtoGxq9Y+tmm22xwApSiIOyMwUi9A1iLjQLmngLeUdsHyrEWTbEYHd2sAM2sqKoZRyBDSv ejRvZD6zwkY/9nRqXt02H1quVOP42xlkwOQU6gxm93o/bxd7S5tEA359Sli5gZRaucpNQkwd KLQdCvFdksD270r4jU/rwR2R/Ubi+txfy0dk2wGBjl1xpSf0Lbl/KMR5TQntELfLR4etizLq Xpd2byn96Ivi8C8u9zJruXTueHH8vt7gJ1oax3yKRGU5o2eipCRiKZ0s/T7fvkdq+8beg9ku fDO4SAgJMIl6H5awliCY2zQvLHysS/Wb8QuB09hmhLZ4AifdHyF1J5qeePEhgTA+BaUbiUZf i4aIXCH3Wv6K Organization: ARM Ltd. Message-ID: Date: Fri, 13 Nov 2020 23:54:30 +0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.12.0 MIME-Version: 1.0 In-Reply-To: Content-Language: en-GB Cc: Marc Zyngier , Lorenzo Pieralisi , Theodore Ts'o , Catalin Marinas , Linus Walleij , Russell King , Linux Kernel Mailing List , Mark Brown , Sudeep Holla , Will Deacon , kvmarm , Linux ARM X-BeenThere: kvmarm@lists.cs.columbia.edu X-Mailman-Version: 2.1.14 Precedence: list List-Id: Where KVM/ARM decisions are made List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: kvmarm-bounces@lists.cs.columbia.edu Sender: kvmarm-bounces@lists.cs.columbia.edu On 13/11/2020 23:05, Ard Biesheuvel wrote: > On Fri, 13 Nov 2020 at 19:24, Andre Przywara wrote: >> >> Hi, >> >> an update to v2 with some fixes and a few tweaks. Ard's patch [1] should >> significantly reduce the frequency of arch_get_random_seed_long() calls, >> not sure if that is enough the appease the concerns about the >> potentially long latency of SMC calls. I also dropped the direct >> arch_get_random() call in KVM for the same reason. An alternative could >> be to just use the SMC in the _early() versions, but then we would lose >> the SMCCC entropy source for the periodic reseeds. This could be mitigated >> by using a hwrng driver [2] and rngd. >> The only other non-minor change to v2 is the addition of using the SMCCC >> call in the _early() variant. For a changelog see below. >> >> Sudeep: patch 1/5 is a prerequisite for all other patches, which >> themselves could be considered separate and need to go via different trees. >> If we could agree on that one now and get that merged, it would help the >> handling of the other patches going forward. >> >> Cheers, >> Andre >> ============================== >> >> The ARM architected TRNG firmware interface, described in ARM spec >> DEN0098[3], defines an ARM SMCCC based interface to a true random number >> generator, provided by firmware. >> >> This series collects all the patches implementing this in various >> places: as a user feeding into the ARCH_RANDOM pool, both for ARM and >> arm64, and as a service provider for KVM guests. >> >> Patch 1 introduces the interface definition used by all three entities. >> Patch 2 prepares the Arm SMCCC firmware driver to probe for the >> interface. This patch is needed to avoid a later dependency on *two* >> patches (there might be a better solution to this problem). >> >> Patch 3 implements the ARM part, patch 4 is the arm64 version. >> The final patch 5 adds support to provide random numbers to KVM guests. >> >> This was tested on: >> - QEMU -kernel (no SMCCC, regression test) >> - Juno w/ prototype of the h/w Trusted RNG support >> - mainline KVM (SMCCC, but no TRNG: regression test) >> - ARM and arm64 KVM guests, using the KVM service in patch 5/5 >> >> Based on v5.10-rc3, please let me know if I should rebased on something >> else. A git repo is accessible at: >> https://gitlab.arm.com/linux-arm/linux-ap/-/commits/smccc-trng/v3/ >> >> Cheers, >> Andre >> >> [1] http://lists.infradead.org/pipermail/linux-arm-kernel/2020-November/615446.html >> [2] https://gitlab.arm.com/linux-arm/linux-ap/-/commit/87e3722f437 >> [3] https://developer.arm.com/documentation/den0098/latest/ >> >> Changelog v2 ... v3: >> - ARM: fix compilation with randconfig >> - arm64: use SMCCC call also in arch_get_random_seed_long_early() >> - KVM: comment on return value usage >> - KVM: use more interesting UUID (enjoy, Marc!) > > UUIDs are constructed using certain rules, so probably better to > refrain from playing games with them here. Hey, it's a valid variant 1 version 1 UUID (otherwise this would be no real easter egg). uuidgen -t should be able to generate this one. I found it too easy to use the random variant, but we can revert to that. > If Marc wants an easter egg, he will have to wait until Easter. Don't mess with your maintainer ;-) Cheers, Andre > >> - KVM: use bitmaps instead of open coded long arrays >> - KVM: drop direct usage of arch_get_random() interface >> >> Changelog "v1" ... v2: >> - trigger ARCH_RANDOM initialisation from the SMCCC firmware driver >> - use a single bool in smccc.c to hold the initialisation state for arm64 >> - handle endianess correctly in the KVM provider >> >> Andre Przywara (2): >> firmware: smccc: Introduce SMCCC TRNG framework >> arm64: Add support for SMCCC TRNG entropy source >> >> Ard Biesheuvel (3): >> firmware: smccc: Add SMCCC TRNG function call IDs >> ARM: implement support for SMCCC TRNG entropy source >> KVM: arm64: implement the TRNG hypervisor call >> >> arch/arm/Kconfig | 4 ++ >> arch/arm/include/asm/archrandom.h | 74 +++++++++++++++++++++++++ >> arch/arm64/include/asm/archrandom.h | 79 +++++++++++++++++++++++---- >> arch/arm64/include/asm/kvm_host.h | 2 + >> arch/arm64/kvm/Makefile | 2 +- >> arch/arm64/kvm/hypercalls.c | 6 ++ >> arch/arm64/kvm/trng.c | 85 +++++++++++++++++++++++++++++ >> drivers/firmware/smccc/smccc.c | 5 ++ >> include/linux/arm-smccc.h | 31 +++++++++++ >> 9 files changed, 277 insertions(+), 11 deletions(-) >> create mode 100644 arch/arm/include/asm/archrandom.h >> create mode 100644 arch/arm64/kvm/trng.c >> >> -- >> 2.17.1 >> _______________________________________________ kvmarm mailing list kvmarm@lists.cs.columbia.edu https://lists.cs.columbia.edu/mailman/listinfo/kvmarm