From: "PierreGondois" <pierre.gondois@arm.com>
To: devel@edk2.groups.io
Cc: Sami Mujawar <sami.mujawar@arm.com>,
Leif Lindholm <quic_llindhol@quicinc.com>,
Ard Biesheuvel <ardb+tianocore@kernel.org>,
Rebecca Cran <rebecca@bsdio.com>,
Michael D Kinney <michael.d.kinney@intel.com>,
Liming Gao <gaoliming@byosoft.com.cn>,
Jiewen Yao <jiewen.yao@intel.com>,
Jian J Wang <jian.j.wang@intel.com>
Subject: [PATCH v3 07/22] ArmPkg: Add FID definitions for Firmware TRNG
Date: Wed, 29 Jun 2022 17:02:16 +0200 [thread overview]
Message-ID: <20220629150241.2597898-8-Pierre.Gondois@arm.com> (raw)
In-Reply-To: <20220629150241.2597898-1-Pierre.Gondois@arm.com>
From: Sami Mujawar <sami.mujawar@arm.com>
Bugzilla: 3668 (https://bugzilla.tianocore.org/show_bug.cgi?id=3668)
The Arm True Random Number Generator Firmware, Interface 1.0,
Platform Design Document
(https://developer.arm.com/documentation/den0098/latest/)
defines an interface between an Operating System (OS) executing
at EL1 and Firmware (FW) exposing a conditioned entropy source
that is provided by a TRNG back end.
New function IDs have been defined by the specification for
accessing the TRNG services. Therefore, add these definitions
to the Arm standard SMC header.
Signed-off-by: Sami Mujawar <sami.mujawar@arm.com>
---
ArmPkg/Include/IndustryStandard/ArmStdSmc.h | 109 +++++++++++++++++++-
1 file changed, 107 insertions(+), 2 deletions(-)
diff --git a/ArmPkg/Include/IndustryStandard/ArmStdSmc.h b/ArmPkg/Include/IndustryStandard/ArmStdSmc.h
index 655edc21b205..4b2edcf0154c 100644
--- a/ArmPkg/Include/IndustryStandard/ArmStdSmc.h
+++ b/ArmPkg/Include/IndustryStandard/ArmStdSmc.h
@@ -1,13 +1,20 @@
/** @file
*
* Copyright (c) 2020, NUVIA Inc. All rights reserved.<BR>
-* Copyright (c) 2012-2017, ARM Limited. All rights reserved.
+* Copyright (c) 2012 - 2022, Arm Limited. All rights reserved.
*
* SPDX-License-Identifier: BSD-2-Clause-Patent
*
* @par Revision Reference:
-* - SMC Calling Convention version 1.2
+* - [1] SMC Calling Convention version 1.2
* (https://developer.arm.com/documentation/den0028/c/?lang=en)
+* - [2] Arm True Random Number Generator Firmware, Interface 1.0,
+* Platform Design Document.
+* (https://developer.arm.com/documentation/den0098/latest/)
+*
+* @par Glossary:
+* - TRNG - True Random Number Generator
+*
**/
#ifndef ARM_STD_SMC_H_
@@ -137,4 +144,102 @@
/* 0xbf00ff02 is reserved */
#define ARM_SMC_ID_TOS_REVISION 0xbf00ff03
+// Firmware TRNG interface Function IDs
+
+/*
+ SMC/HVC call to get the version of the TRNG backend,
+ Cf. [2], 2.1 TRNG_VERSION
+ Input values:
+ W0 0x8400_0050
+ W1-W7 Reserved (MBZ)
+ Return values:
+ Success (W0 > 0) W0[31] MBZ
+ W0[30:16] Major revision
+ W0[15:0] Minor revision
+ W1 - W3 Reserved (MBZ)
+ Error (W0 < 0)
+ NOT_SUPPORTED Function not implemented
+*/
+#define FID_TRNG_VERSION 0x84000050
+
+/*
+ SMC/HVC call to check if a TRNG function ID is implemented by the backend,
+ Cf. [2], Section 2.2 TRNG_FEATURES
+ Input Values
+ W0 0x8400_0051
+ W1 trng_func_id
+ W2-W7 Reserved (MBZ)
+ Return values:
+ Success (W0 >= 0):
+ SUCCESS Function is implemented.
+ > 0 Function is implemented and
+ has specific capabilities,
+ see function definition.
+ Error (W0 < 0)
+ NOT_SUPPORTED Function with FID=trng_func_id
+ is not implemented
+*/
+#define FID_TRNG_FEATURES 0x84000051
+
+/*
+ SMC/HVC call to get the UUID of the TRNG backend,
+ Cf. [2], Section 2.3 TRNG_GET_UUID
+ Input Values:
+ W0 0x8400_0052
+ W1-W7 Reserved (MBZ)
+ Return Values:
+ Success (W0 != -1)
+ W0 UUID[31:0]
+ W1 UUID[63:32]
+ W2 UUID[95:64]
+ W3 UUID[127:96]
+ Error (W0 = -1)
+ W0 NOT_SUPPORTED
+*/
+#define FID_TRNG_GET_UUID 0x84000052
+
+/*
+ AARCH32 SMC/HVC call to get entropy bits, Cf. [2], Section 2.4 TRNG_RND.
+ Input values:
+ W0 0x8400_0053
+ W2-W7 Reserved (MBZ)
+ Return values:
+ Success (W0 = 0):
+ W0 MBZ
+ W1 Entropy[95:64]
+ W2 Entropy[63:32]
+ W3 Entropy[31:0]
+ Error (W0 < 0)
+ W0 NOT_SUPPORTED
+ NO_ENTROPY
+ INVALID_PARAMETERS
+ W1 - W3 Reserved (MBZ)
+*/
+#define FID_TRNG_RND_AARCH32 0x84000053
+
+/*
+ AARCH64 SMC/HVC call to get entropy bits, Cf. [2], Section 2.4 TRNG_RND.
+ Input values:
+ X0 0xC400_0053
+ X2-X7 Reserved (MBZ)
+ Return values:
+ Success (X0 = 0):
+ X0 MBZ
+ X1 Entropy[191:128]
+ X2 Entropy[127:64]
+ X3 Entropy[63:0]
+ Error (X0 < 0)
+ X0 NOT_SUPPORTED
+ NO_ENTROPY
+ INVALID_PARAMETERS
+ X1 - X3 Reserved (MBZ)
+*/
+#define FID_TRNG_RND_AARCH64 0xC4000053
+
+// Firmware TRNG status codes
+#define TRNG_STATUS_SUCCESS (INT32)(0)
+#define TRNG_STATUS_NOT_SUPPORTED (INT32)(-1)
+#define TRNG_STATUS_INVALID_PARAMETER (INT32)(-2)
+#define TRNG_STATUS_NO_ENTROPY (INT32)(-3)
+
#endif // ARM_STD_SMC_H_
--
2.25.1
next prev parent reply other threads:[~2022-06-29 15:04 UTC|newest]
Thread overview: 35+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-06-29 15:02 [PATCH v3 00/22] Add Raw algorithm support using Arm FW-TRNG interface PierreGondois
2022-06-29 15:02 ` [PATCH v3 01/22] ArmPkg: PCD to select conduit for monitor calls PierreGondois
2022-06-29 15:02 ` [PATCH v3 02/22] ArmPkg/ArmMonitorLib: Definition for ArmMonitorLib library class PierreGondois
2022-06-29 15:02 ` [PATCH v3 03/22] ArmPkg/ArmMonitorLib: Add ArmMonitorLib PierreGondois
2022-06-29 15:02 ` [PATCH v3 04/22] ArmPkg/ArmHvcNullLib: Add NULL instance of ArmHvcLib PierreGondois
2022-06-29 15:02 ` [PATCH v3 05/22] MdePkg/TrngLib: Definition for TRNG library class interface PierreGondois
2022-06-29 15:02 ` [PATCH v3 06/22] MdePkg/TrngLib: Add NULL instance of TRNG Library PierreGondois
2022-06-29 15:02 ` PierreGondois [this message]
2022-06-29 15:02 ` [PATCH v3 08/22] ArmPkg/TrngLib: Add Arm Firmware TRNG library PierreGondois
2022-06-29 15:02 ` [PATCH v3 09/22] MdePkg/BaseRngLib: Rename ArmReadIdIsar0() to ArmGetFeatRng() PierreGondois
2022-06-29 15:02 ` [PATCH v3 10/22] ArmPkg/ArmLib: Add ArmReadIdIsar0() helper PierreGondois
2022-06-29 15:02 ` [PATCH v3 11/22] ArmPkg/ArmLib: Add ArmHasRngExt() PierreGondois
2022-06-29 15:02 ` [PATCH v3 12/21] SecurityPkg/RngDxe: Rename RdRandGenerateEntropy to generic name PierreGondois
2022-06-29 15:02 ` [PATCH v3 12/22] SecurityPkg: Update Securitypkg.ci.yaml PierreGondois
2022-06-29 15:02 ` [PATCH v3 13/22] SecurityPkg/RngDxe: Rename RdRandGenerateEntropy to generic name PierreGondois
2022-06-29 15:02 ` [PATCH v3 13/21] SecurityPkg/RngDxe: Replace Pcd with Sp80090Ctr256Guid PierreGondois
2022-06-29 15:02 ` [PATCH v3 14/21] SecurityPkg/RngDxe: Remove ArchGetSupportedRngAlgorithms() PierreGondois
2022-06-29 15:02 ` [PATCH v3 14/22] SecurityPkg/RngDxe: Replace Pcd with Sp80090Ctr256Guid PierreGondois
2022-07-21 10:51 ` Yao, Jiewen
2022-06-29 15:02 ` [PATCH v3 15/21] SecurityPkg/RngDxe: Documentation/include/parameter cleanup PierreGondois
2022-06-29 15:02 ` [PATCH v3 15/22] SecurityPkg/RngDxe: Remove ArchGetSupportedRngAlgorithms() PierreGondois
2022-06-29 15:02 ` [PATCH v3 16/21] SecurityPkg/RngDxe: Check before advertising Cpu Rng algo PierreGondois
2022-06-29 15:02 ` [PATCH v3 16/22] SecurityPkg/RngDxe: Documentation/include/parameter cleanup PierreGondois
2022-06-29 15:02 ` [PATCH v3 17/21] SecurityPkg/RngDxe: Add AArch64 RawAlgorithm support through TrngLib PierreGondois
2022-06-29 15:02 ` [PATCH v3 17/22] SecurityPkg/RngDxe: Check before advertising Cpu Rng algo PierreGondois
2022-06-29 15:02 ` [PATCH v3 18/22] SecurityPkg/RngDxe: Add AArch64 RawAlgorithm support through TrngLib PierreGondois
2022-06-29 15:02 ` [PATCH v3 18/21] SecurityPkg/RngDxe: Add debug warning for NULL PcdCpuRngSupportedAlgorithm PierreGondois
2022-06-29 15:02 ` [PATCH v3 19/22] " PierreGondois
2022-06-29 15:02 ` [PATCH v3 19/21] SecurityPkg/RngDxe: Rename AArch64/RngDxe.c PierreGondois
2022-06-29 15:02 ` [PATCH v3 20/21] SecurityPkg/RngDxe: Add Arm support of RngDxe PierreGondois
2022-07-21 10:47 ` Yao, Jiewen
2022-06-29 15:02 ` [PATCH v3 20/22] SecurityPkg/RngDxe: Rename AArch64/RngDxe.c PierreGondois
2022-06-29 15:02 ` [PATCH v3 21/21] ArmVirtPkg: Kvmtool: Add RNG support using FW-TRNG interface PierreGondois
2022-06-29 15:02 ` [PATCH v3 21/22] SecurityPkg/RngDxe: Add Arm support of RngDxe PierreGondois
2022-06-29 15:02 ` [PATCH v3 22/22] ArmVirtPkg: Kvmtool: Add RNG support using FW-TRNG interface PierreGondois
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-list from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20220629150241.2597898-8-Pierre.Gondois@arm.com \
--to=devel@edk2.groups.io \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox