Received: by 2002:a05:6a10:16a7:0:0:0:0 with SMTP id gp39csp462054pxb; Thu, 5 Nov 2020 04:59:20 -0800 (PST) X-Google-Smtp-Source: ABdhPJxbsHgBnMRUK9g/Sv/Bya+VJ1pc/Y9G7I4U9D0cOEVD0FbRWSt2LX0Mx72ShmhweibaDUS5 X-Received: by 2002:a17:906:4dc2:: with SMTP id f2mr2152730ejw.446.1604581160374; Thu, 05 Nov 2020 04:59:20 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1604581160; cv=none; d=google.com; s=arc-20160816; b=UQ+3Cch55c1V4DOwjDFQJkMbhe4mGwERcACTFne7z3bccV2jedU0lZHDnbkG0h3V/U 6pwEj4gQodMXMGxCGFJ/ESYNeg+SmoExZG7nn1BDc4C86bNvW3OXB3FgJwKZlvtLeZL/ 29YOtVJB+erbPnH9RTwb0eCGJtUGWnkL2+CKaHG7yGxNncTQn2kwXyVJWjo5e0lwCQPQ gaDi8KoWQ/hfaO2Bbdb57FqpleWE2CWTWHOs74sqBeEDg0CZcHQHdMVpnwnWGtWlk3ZX wzy4nfw/Zx+kxEPh8hKXSQUqmc/I4MnWRUZTX1n4kLTeSAEiexO78CIb8zjbLcUE8PlP zKPA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:message-id:date:subject:cc:to:from; bh=yMQOVvSPXyqYjcQnsz+CQ07CgIgExo3WKP5lSWCRQsY=; b=Zz5fHmeRqqWqPpHXRucNnw7bUO7GjWKhJ2T/BEBldiE81Ju9p1xyWuDs72+PdM1z49 koGYP568jcfwHlBlDlNIU3iOJMtXS2SFhSis/zgPmi+6nPGlDddX61PjBjM7TOIJRGh7 QHo+ngXnG1SspbHdaF44VfWeoNWrY4JmJHginGdLOSnjNncCLKY5XisJtbcHlHuhMHUN iQTCzQcgGvhbXfMTCm5EdRbApRZuLaqy8gaexF8Smtxox3GsyAn0PRmN/DOjp+vY8d2k 8pQQuKh0+2/Ix3Gmeas6O2inp0C+1t9gXH8l6QHgzh8IsHVpWwlYrLerzwOWkHW8bPQh jz5w== 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 h60si1035597edd.117.2020.11.05.04.58.57; Thu, 05 Nov 2020 04:59:20 -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 S1730880AbgKEM5H (ORCPT + 99 others); Thu, 5 Nov 2020 07:57:07 -0500 Received: from foss.arm.com ([217.140.110.172]:60080 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730850AbgKEM5G (ORCPT ); Thu, 5 Nov 2020 07:57:06 -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 79205142F; Thu, 5 Nov 2020 04:57:05 -0800 (PST) Received: from donnerap.arm.com (donnerap.cambridge.arm.com [10.1.195.35]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id CD4383F719; Thu, 5 Nov 2020 04:57:03 -0800 (PST) From: Andre Przywara To: Will Deacon , Catalin Marinas , Ard Biesheuvel , Russell King Cc: linux-arm-kernel@lists.infradead.org, kvmarm@lists.cs.columbia.edu, linux-kernel@vger.kernel.org, Sudeep Holla , Mark Rutland , Mark Brown , Lorenzo Pieralisi , Linus Walleij Subject: [PATCH v2 0/5] ARM: arm64: Add SMCCC TRNG entropy service Date: Thu, 5 Nov 2020 12:56:51 +0000 Message-Id: <20201105125656.25259-1-andre.przywara@arm.com> X-Mailer: git-send-email 2.17.1 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The ARM architected TRNG firmware interface, described in ARM spec DEN0098[1], 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. Compared to the initial posts, this version: - triggers the ARCH_RANDOM initialisation from the SMCCC firmware driver - uses a single bool in smccc.c to hold the initialisation state for arm64 - handles endianess correctly in the KVM provider This was tested on: - QEMU -kernel (no SMCCC, regression test) - Juno w/ standard firmware (SMCCC, but no TRNG: regression test) - Juno w/ "fake TRNG" firmware (to verify "random" numbers) - 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-rc2, 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/v2/ Cheers, Andre [1] https://developer.arm.com/documentation/den0098/latest/ 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 | 63 +++++++++++++++++--- arch/arm64/include/asm/kvm_host.h | 2 + arch/arm64/kvm/Makefile | 2 +- arch/arm64/kvm/hypercalls.c | 6 ++ arch/arm64/kvm/trng.c | 91 +++++++++++++++++++++++++++++ drivers/firmware/smccc/smccc.c | 5 ++ include/linux/arm-smccc.h | 31 ++++++++++ 9 files changed, 270 insertions(+), 8 deletions(-) create mode 100644 arch/arm/include/asm/archrandom.h create mode 100644 arch/arm64/kvm/trng.c -- 2.17.1