Received: by 2002:a05:6a10:c7c6:0:0:0:0 with SMTP id h6csp475919pxy; Sat, 31 Jul 2021 13:50:25 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzifcfLfiZX+BoxF+akIjocC8sjEAVkanAj2xbZWxCcdFRQPPSfQE35HD6ghicuzeU8zyYO X-Received: by 2002:a02:cf2e:: with SMTP id s14mr7799948jar.74.1627764624858; Sat, 31 Jul 2021 13:50:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1627764624; cv=none; d=google.com; s=arc-20160816; b=eTLzFxbqOcDsnaJDPMKJklpN5b6fu1kEHE9CEXSkxFf+rszVHa5LoIqDZutLfinPx6 8LTJFPkBETzr4c6XHOj+y5uX5KhCKebN2xao4SsnBiLbjD5loDW4pEOn8L+CGei5DA3+ AdP4Net6jvlqlqx6B67RX1ZHe9VRsGLmWn1wLbNLop0fQEQ4zOi6g4BsYeXcT2UAsehF ZMNe8LhjhkAsquPjF8YuRIqs80wVIBHtPTXb21xZKEnm6TiwIOcJztivOAYNSCUiUefP pJw/UfOBk1J5RbXKE1OSaUk1HxIvBmOgLuTP6xVJR+IDzyylzEh7u8XfIklG+P9dG6L4 kQ3g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:references:in-reply-to:message-id:date:subject :cc:to:from; bh=zGK++mvOAv3IP7SF8voMj/V4/nx38gKsbEiGfIPBbBg=; b=anp+5mjh++euXkCIZJPZ60VgndSNbSpRAyaYBnjdiMX7BMXeZ8qrDS+jvUCMPtHi6J ymGQ/8C9oodF9eilKlu0j9pMj8YKOlP5abKSV/5+vgPWL8JfcgBP5oHndwShZrrreom6 B7IaWN5vRaHNN+wkoT3WmBKdWJe0VRLye9cHzTCAoGfC6p4GT3+Bw6SFfsNf+9Jj+dQD 5WipqNCeNCbbCp4kLz3e+2sQiDj1tHqWV+Yy4u7VPiuvDlUBZ3RbM/CvjGNmLffpJE+P +i3pFIT3/h9Vo5jqjgJUDsEe/Nfe9t8Tkk+qW7u3eY+0jUse9yARqYnEjOpXLVC9aUqA WkVQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-crypto-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-crypto-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 q6si4264056jaj.77.2021.07.31.13.50.13; Sat, 31 Jul 2021 13:50:24 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-crypto-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-crypto-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-crypto-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 S231558AbhGaUtl (ORCPT + 99 others); Sat, 31 Jul 2021 16:49:41 -0400 Received: from foss.arm.com ([217.140.110.172]:52372 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229958AbhGaUtl (ORCPT ); Sat, 31 Jul 2021 16:49:41 -0400 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 4A859106F; Sat, 31 Jul 2021 13:49:34 -0700 (PDT) Received: from localhost.localdomain (unknown [172.31.20.19]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 06B103F70D; Sat, 31 Jul 2021 13:49:31 -0700 (PDT) From: Andre Przywara To: Matt Mackall , Herbert Xu , Mark Rutland , Lorenzo Pieralisi , Sudeep Holla Cc: linux-crypto@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, Benjamin Herrenschmidt , Ard Biesheuvel , Mark Brown , Will Deacon , Ali Saidi , Jon Nettleton Subject: [PATCH v4 1/2] firmware: smccc: Register smccc_trng platform device Date: Sat, 31 Jul 2021 21:48:44 +0100 Message-Id: <20210731204845.21196-2-andre.przywara@arm.com> X-Mailer: git-send-email 2.14.1 In-Reply-To: <20210731204845.21196-1-andre.przywara@arm.com> References: <20210731204845.21196-1-andre.przywara@arm.com> Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org At the moment we probe for the Random Number Generator SMCCC service, and use that in the core code (arch_get_random). However the hardware entropy can also be useful to access from userland, and be it to assess its quality. Register a platform device when the SMCCC TRNG service is detected, to allow a hw_random driver to hook onto this. The function registering the device is deliberately made in a way which allows expansion, so other services that could be exposed via a platform device (or some other interface), can be added here easily. Signed-off-by: Andre Przywara --- drivers/firmware/smccc/smccc.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/drivers/firmware/smccc/smccc.c b/drivers/firmware/smccc/smccc.c index 9f937b125ab0..60ccf3e90d7d 100644 --- a/drivers/firmware/smccc/smccc.c +++ b/drivers/firmware/smccc/smccc.c @@ -9,6 +9,7 @@ #include #include #include +#include #include static u32 smccc_version = ARM_SMCCC_VERSION_1_0; @@ -42,3 +43,19 @@ u32 arm_smccc_get_version(void) return smccc_version; } EXPORT_SYMBOL_GPL(arm_smccc_get_version); + +static int __init smccc_devices_init(void) +{ + struct platform_device *pdev; + + if (smccc_trng_available) { + pdev = platform_device_register_simple("smccc_trng", -1, + NULL, 0); + if (IS_ERR(pdev)) + pr_err("smccc_trng: could not register device: %ld\n", + PTR_ERR(pdev)); + } + + return 0; +} +device_initcall(smccc_devices_init); -- 2.17.6