From nobody Fri Apr 19 21:37:26 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) client-ip=66.175.222.108; envelope-from=bounce+27952+93944+1787277+3901457@groups.io; helo=mail02.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+93944+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=arm.com ARC-Seal: i=1; a=rsa-sha256; t=1663615344; cv=none; d=zohomail.com; s=zohoarc; b=i5DzFlK/iYFU36joHw5omtqZqdVwgBAbWoQUn3ZqAj7FW35mMAhsjF06WeEgTjP9QM0OIaAOZqOhW2KakJ73bIgZAdTne+HMGC33sI0kB0B3YdfuF2NcYMxtugMjb2Bvqq56Fp1T/AKOjl12QabVQ5IfoJUdd9lD9BjIF1DrVrQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1663615344; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:References:Sender:Subject:To; bh=z+yTK1WV+j76iQeRJB1LEbTOeFIEFYrjd3/vIGSbcHs=; b=Ph4yIQZ7pKWmOhyB2rmOZ/eQvu5FOW9i8IQvQQF4jab6WairBptx+llJXpAb/lSo3glGTXlTNNBgL+W/B3a51zgQVJGzOnh7uyJGM2xvhkiw1k60wFJH9EdlThA4CxXVa+5jlUoMMIvHmUAp3jbHmlTF5+uL3450cHKRX2nsz14= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+93944+1787277+3901457@groups.io; dmarc=fail header.from= (p=none dis=none) Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by mx.zohomail.com with SMTPS id 166361534473082.65748055442054; Mon, 19 Sep 2022 12:22:24 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id TLPRYY1788612xpvKyEYq6IN; Mon, 19 Sep 2022 12:22:24 -0700 X-Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by mx.groups.io with SMTP id smtpd.web12.3254.1663615343594659607 for ; Mon, 19 Sep 2022 12:22:23 -0700 X-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 B7B4D143D; Mon, 19 Sep 2022 12:22:29 -0700 (PDT) X-Received: from pierre123.arm.com (unknown [172.31.20.19]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 161083F73B; Mon, 19 Sep 2022 12:22:20 -0700 (PDT) From: "PierreGondois" To: devel@edk2.groups.io Cc: Sami Mujawar , Leif Lindholm , Ard Biesheuvel , Rebecca Cran , Michael D Kinney , Liming Gao , Jiewen Yao , Jian J Wang Subject: [edk2-devel] [PATCH v5 01/21] ArmPkg: PCD to select conduit for monitor calls Date: Mon, 19 Sep 2022 21:21:47 +0200 Message-Id: <20220919192207.637786-2-Pierre.Gondois@arm.com> In-Reply-To: <20220919192207.637786-1-Pierre.Gondois@arm.com> References: <20220919192207.637786-1-Pierre.Gondois@arm.com> MIME-Version: 1.0 Precedence: Bulk List-Unsubscribe: List-Subscribe: List-Help: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,pierre.gondois@arm.com X-Gm-Message-State: Kw5avS0TY3C9iFx7ax0jV7zlx1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1663615344; bh=wP1GZZQPjlZmxQ4VQxGXEnUFo8iulWw5jT1BEfUNIgI=; h=Cc:Date:From:Reply-To:Subject:To; b=qw+azu8zkHepmsunxgX+urLkqaTf2qC1RABrAl7qWB5MEibUaJ/8CiojZpHqVtTWGTz A01RMM0DDR2EYKNfozkRCRCIax53tIVj+9GdElqLofDBfcPuMF7ooAuP89UFYGbIGuBtS EVLjftgmlI2fP0dB9C6nhLUC3l2rUswPwMg= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1663615346784100005 Content-Type: text/plain; charset="utf-8" From: Sami Mujawar Define a PCD 'PcdMonitorConduitHvc' to select the conduit to use for monitor calls. PcdMonitorConduitHvc is defined as FALSE by default, meaning the SMC conduit is enabled as default. Adding PcdMonitorConduitHvc allows selection of HVC conduit to be used by virtual firmware implementations. Signed-off-by: Sami Mujawar --- ArmPkg/ArmPkg.dec | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/ArmPkg/ArmPkg.dec b/ArmPkg/ArmPkg.dec index 9da1bbc9f216..bb5cbecbc228 100644 --- a/ArmPkg/ArmPkg.dec +++ b/ArmPkg/ArmPkg.dec @@ -2,7 +2,7 @@ # ARM processor package. # # Copyright (c) 2009 - 2010, Apple Inc. All rights reserved.
-# Copyright (c) 2011 - 2021, ARM Limited. All rights reserved. +# Copyright (c) 2011 - 2022, ARM Limited. All rights reserved. # Copyright (c) 2021, Ampere Computing LLC. All rights reserved. # # SPDX-License-Identifier: BSD-2-Clause-Patent @@ -132,6 +132,11 @@ [PcdsFeatureFlag.common] # Define if the GICv3 controller should use the GICv2 legacy gArmTokenSpaceGuid.PcdArmGicV3WithV2Legacy|FALSE|BOOLEAN|0x00000042 =20 + ## Define the conduit to use for monitor calls. + # Default PcdMonitorConduitHvc =3D FALSE, conduit =3D SMC + # If PcdMonitorConduitHvc =3D TRUE, conduit =3D HVC + gArmTokenSpaceGuid.PcdMonitorConduitHvc|FALSE|BOOLEAN|0x00000047 + [PcdsFeatureFlag.ARM] # Whether to map normal memory as non-shareable. FALSE is the safe choic= e, but # TRUE may be appropriate to fix performance problems if you don't care = about --=20 2.25.1 -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#93944): https://edk2.groups.io/g/devel/message/93944 Mute This Topic: https://groups.io/mt/93788862/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- From nobody Fri Apr 19 21:37:27 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) client-ip=66.175.222.108; envelope-from=bounce+27952+93945+1787277+3901457@groups.io; helo=mail02.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+93945+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=arm.com ARC-Seal: i=1; a=rsa-sha256; t=1663615347; cv=none; d=zohomail.com; s=zohoarc; b=EIp3jhV9NfX9WO9phEENldSrypJw0gFjJr1T6kjBdvYgFFWnfqQ+gD+CJuhqiCTqR7/1SWLYaHznOG2aHMWFSzm4/+VjeIQ0mIRxGJowAObJl9m59ALt3jKVYCaytXgkHFOirZQPtIK9JZjVEyx4tBseJEfEHU/lEhIVIS8B0UM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1663615347; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:References:Sender:Subject:To; bh=Bl5iqdY+t0SyJRYp5/GyyS5BCkLuEj0+nrAMYZrijuc=; b=blNEPKVlYo42pXz7anlwUgD1UIDH6dlxOsaZENNkjP0dI+XkVICy280mkRtdfpq8e1zHHEqtGfH6KPaq4EaKaEb2HN61UPPqIpBDYqOWzy8OGgrHOLAeG6kGWB78EIWdqWPqyyllAiFdCFB/DCr9yeOjUU41XmA7/oRUWKgSyN8= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+93945+1787277+3901457@groups.io; dmarc=fail header.from= (p=none dis=none) Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by mx.zohomail.com with SMTPS id 1663615347984109.39729011814347; Mon, 19 Sep 2022 12:22:27 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id EDmFYY1788612xPbT45a3UEn; Mon, 19 Sep 2022 12:22:26 -0700 X-Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by mx.groups.io with SMTP id smtpd.web11.3342.1663615346066418150 for ; Mon, 19 Sep 2022 12:22:26 -0700 X-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 4B9A21BF3; Mon, 19 Sep 2022 12:22:32 -0700 (PDT) X-Received: from pierre123.arm.com (unknown [172.31.20.19]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 9F08A3F73B; Mon, 19 Sep 2022 12:22:23 -0700 (PDT) From: "PierreGondois" To: devel@edk2.groups.io Cc: Sami Mujawar , Leif Lindholm , Ard Biesheuvel , Rebecca Cran , Michael D Kinney , Liming Gao , Jiewen Yao , Jian J Wang Subject: [edk2-devel] [PATCH v5 02/21] ArmPkg/ArmMonitorLib: Definition for ArmMonitorLib library class Date: Mon, 19 Sep 2022 21:21:48 +0200 Message-Id: <20220919192207.637786-3-Pierre.Gondois@arm.com> In-Reply-To: <20220919192207.637786-1-Pierre.Gondois@arm.com> References: <20220919192207.637786-1-Pierre.Gondois@arm.com> MIME-Version: 1.0 Precedence: Bulk List-Unsubscribe: List-Subscribe: List-Help: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,pierre.gondois@arm.com X-Gm-Message-State: HM8XezULAwlSJC2jctZedhTJx1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1663615346; bh=NkI4+5FqnLMAWLBFCNFNoztPT0CGPAkhD709+i3HsuA=; h=Cc:Date:From:Reply-To:Subject:To; b=C3FGs+EfQwAUIon7C0kKAVgK1khBGuNC4t3wSJXkcoeRTUGFaB6RtnhjDTlc4E1bqjI JymCSWkdD3Hy1BaU4QtQy4SkMzExhK5oQ99cT+54g6qu3dtVAUW5OynYWulZsqV7RVAlC epU51rAp6sopIEP7vva6649gpgSvqtK4zfk= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1663615348823100010 Content-Type: text/plain; charset="utf-8" From: Pierre Gondois The ArmMonitorLib provides an abstract interface to issue an HyperVisor Call (HVC) or System Monitor Call (SMC) depending on the default conduit. The PcdMonitorConduitHvc PCD allows to select the default conduit. The new library relies on the ArmHvcLib and ArmSmcLib libraries. A Null instance of these libraries can be used for the unused conduit. Signed-off-by: Pierre Gondois --- ArmPkg/ArmPkg.dec | 5 +++ ArmPkg/Include/Library/ArmMonitorLib.h | 42 ++++++++++++++++++++++++++ 2 files changed, 47 insertions(+) create mode 100644 ArmPkg/Include/Library/ArmMonitorLib.h diff --git a/ArmPkg/ArmPkg.dec b/ArmPkg/ArmPkg.dec index bb5cbecbc228..653942ff63c3 100644 --- a/ArmPkg/ArmPkg.dec +++ b/ArmPkg/ArmPkg.dec @@ -71,6 +71,11 @@ [LibraryClasses.common] # ArmSvcLib|Include/Library/ArmSvcLib.h =20 + ## @libraryclass Provides a Monitor Call interface that will use the + # default conduit (HVC or SMC). + # + ArmMonitorLib|Include/Library/ArmMonitorLib.h + ## @libraryclass Provides a default exception handler. # DefaultExceptionHandlerLib|Include/Library/DefaultExceptionHandlerLib.h diff --git a/ArmPkg/Include/Library/ArmMonitorLib.h b/ArmPkg/Include/Librar= y/ArmMonitorLib.h new file mode 100644 index 000000000000..8bc430f92036 --- /dev/null +++ b/ArmPkg/Include/Library/ArmMonitorLib.h @@ -0,0 +1,42 @@ +/** @file + + Copyright (c) 2022, Arm Limited. All rights reserved.
+ + SPDX-License-Identifier: BSD-2-Clause-Patent + +**/ + +#ifndef ARM_MONITOR_LIB_H_ +#define ARM_MONITOR_LIB_H_ + +/** The size of the SMC arguments is different between AArch64 and AArch32. + + The native size is used for the arguments. + It will be casted to either HVC or SMC args. +*/ +typedef struct { + UINTN Arg0; + UINTN Arg1; + UINTN Arg2; + UINTN Arg3; + UINTN Arg4; + UINTN Arg5; + UINTN Arg6; + UINTN Arg7; +} ARM_MONITOR_ARGS; + +/** Monitor call. + + An HyperVisor Call (HVC) or System Monitor Call (SMC) will be issued + depending on the default conduit. PcdMonitorConduitHvc determines the ty= pe + of the call: if true, do an HVC. + + @param [in, out] Args Arguments for the HVC/SMC. +**/ +VOID +EFIAPI +ArmMonitorCall ( + IN OUT ARM_MONITOR_ARGS *Args + ); + +#endif // ARM_MONITOR_LIB_H_ --=20 2.25.1 -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#93945): https://edk2.groups.io/g/devel/message/93945 Mute This Topic: https://groups.io/mt/93788864/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- From nobody Fri Apr 19 21:37:27 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) client-ip=66.175.222.108; envelope-from=bounce+27952+93946+1787277+3901457@groups.io; helo=mail02.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+93946+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=arm.com ARC-Seal: i=1; a=rsa-sha256; t=1663615349; cv=none; d=zohomail.com; s=zohoarc; b=O3o/ZGRgS9+2kmqzStwtrKf4yP0b795sKHa/0F3E9GwwiGi+M20ukPuV/x+SgoJ/LqygsA9gPjbQcurWV6u4ukTWHXdai1RNdpTtC9rWm0bKyRWNk7AnBHpTkw6r+67NzQKeX7+Aq6gGLIgBMKyO5VIO3q42KJ5mayS/Qk9cAoE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1663615349; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:References:Sender:Subject:To; bh=zmgjaSWCAkI2h1HgpgfrzoKuNBLezWlcMprQy20F9m8=; b=ZXRpF1tObY89OcXQo2cCYHLUySEllsG2BCk7N010pReeN6h0FiQx+8/68ZrQNDGQJfvgSnFJ8mUwaR4EY42sPx1+CLXxV1qc+otYh7EYDR0oKgNLI3L9NxSVpmX3ThJI6KdgLsUelF7f3AEYRSbmtG2wRnJIQy8KY6vSg2LBPPM= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+93946+1787277+3901457@groups.io; dmarc=fail header.from= (p=none dis=none) Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by mx.zohomail.com with SMTPS id 1663615349849976.0675477484685; Mon, 19 Sep 2022 12:22:29 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id TIV5YY1788612xQ3rt8bx6UA; Mon, 19 Sep 2022 12:22:29 -0700 X-Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by mx.groups.io with SMTP id smtpd.web10.3208.1663615348662820370 for ; Mon, 19 Sep 2022 12:22:29 -0700 X-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 C371024E9; Mon, 19 Sep 2022 12:22:34 -0700 (PDT) X-Received: from pierre123.arm.com (unknown [172.31.20.19]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 2469E3F73B; Mon, 19 Sep 2022 12:22:26 -0700 (PDT) From: "PierreGondois" To: devel@edk2.groups.io Cc: Sami Mujawar , Leif Lindholm , Ard Biesheuvel , Rebecca Cran , Michael D Kinney , Liming Gao , Jiewen Yao , Jian J Wang Subject: [edk2-devel] [PATCH v5 03/21] ArmPkg/ArmMonitorLib: Add ArmMonitorLib Date: Mon, 19 Sep 2022 21:21:49 +0200 Message-Id: <20220919192207.637786-4-Pierre.Gondois@arm.com> In-Reply-To: <20220919192207.637786-1-Pierre.Gondois@arm.com> References: <20220919192207.637786-1-Pierre.Gondois@arm.com> MIME-Version: 1.0 Precedence: Bulk List-Unsubscribe: List-Subscribe: List-Help: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,pierre.gondois@arm.com X-Gm-Message-State: 4ZY9sN7uYBramDeYqIJS62Vyx1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1663615349; bh=LQgtUvz8qETiEwn808X9rNJZYDzxwL8z6W8V6oERp/c=; h=Cc:Date:From:Reply-To:Subject:To; b=bS97nw3GLVMLRw1DpLbHdUz4VinLEF9kGqORQieb3tPv30bDV7MRBCboSR9o7yFvfHp F1e8EfnOcPl15DM3SLXizVU2tFuS8YfAhLwFQLKuAzEybQtv/qF0P9MwoI3nhoGnWkwwN P/og9YaUBkfAIpd0IsyvgkACZS8LfDCtjDI= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1663615350808100013 Content-Type: text/plain; charset="utf-8" From: Pierre Gondois The ArmMonitorLib provides an abstract interface to issue an HyperVisor Call (HVC) or System Monitor Call (SMC) depending on the default conduit. The PcdMonitorConduitHvc PCD allows to select the default conduit. Signed-off-by: Pierre Gondois Reviewed-by: Leif Lindholm --- ArmPkg/ArmPkg.dsc | 1 + ArmPkg/Library/ArmMonitorLib/ArmMonitorLib.c | 34 +++++++++++++++++++ .../Library/ArmMonitorLib/ArmMonitorLib.inf | 29 ++++++++++++++++ 3 files changed, 64 insertions(+) create mode 100644 ArmPkg/Library/ArmMonitorLib/ArmMonitorLib.c create mode 100644 ArmPkg/Library/ArmMonitorLib/ArmMonitorLib.inf diff --git a/ArmPkg/ArmPkg.dsc b/ArmPkg/ArmPkg.dsc index 59fd8f295d4f..3afd212f472b 100644 --- a/ArmPkg/ArmPkg.dsc +++ b/ArmPkg/ArmPkg.dsc @@ -135,6 +135,7 @@ [Components.common] ArmPkg/Library/ArmSmcLibNull/ArmSmcLibNull.inf ArmPkg/Library/ArmHvcLib/ArmHvcLib.inf ArmPkg/Library/ArmSvcLib/ArmSvcLib.inf + ArmPkg/Library/ArmMonitorLib/ArmMonitorLib.inf ArmPkg/Library/OpteeLib/OpteeLib.inf =20 ArmPkg/Filesystem/SemihostFs/SemihostFs.inf diff --git a/ArmPkg/Library/ArmMonitorLib/ArmMonitorLib.c b/ArmPkg/Library/= ArmMonitorLib/ArmMonitorLib.c new file mode 100644 index 000000000000..5e91f2957325 --- /dev/null +++ b/ArmPkg/Library/ArmMonitorLib/ArmMonitorLib.c @@ -0,0 +1,34 @@ +/** @file + Arm Monitor Library. + + Copyright (c) 2022, Arm Limited. All rights reserved.
+ + SPDX-License-Identifier: BSD-2-Clause-Patent + +**/ + +#include +#include +#include +#include + +/** Monitor call. + + An HyperVisor Call (HVC) or System Monitor Call (SMC) will be issued + depending on the default conduit. PcdMonitorConduitHvc determines the ty= pe + of the call: if true, do an HVC. + + @param [in, out] Args Arguments for the HVC/SMC. +**/ +VOID +EFIAPI +ArmMonitorCall ( + IN OUT ARM_MONITOR_ARGS *Args + ) +{ + if (FeaturePcdGet (PcdMonitorConduitHvc)) { + ArmCallHvc ((ARM_HVC_ARGS *)Args); + } else { + ArmCallSmc ((ARM_SMC_ARGS *)Args); + } +} diff --git a/ArmPkg/Library/ArmMonitorLib/ArmMonitorLib.inf b/ArmPkg/Librar= y/ArmMonitorLib/ArmMonitorLib.inf new file mode 100644 index 000000000000..abaeb556d471 --- /dev/null +++ b/ArmPkg/Library/ArmMonitorLib/ArmMonitorLib.inf @@ -0,0 +1,29 @@ +## @file +# Arm Monitor Library +# +# Copyright (c) 2022, Arm Limited. All rights reserved.
+# +# SPDX-License-Identifier: BSD-2-Clause-Patent +## + +[Defines] + INF_VERSION =3D 0x0001001B + BASE_NAME =3D ArmMonitorLib + FILE_GUID =3D F918DACB-FBB8-4CB6-A61D-08E75AF0E7CD + MODULE_TYPE =3D BASE + VERSION_STRING =3D 1.0 + LIBRARY_CLASS =3D ArmMonitorLib + +[Sources] + ArmMonitorLib.c + +[Packages] + ArmPkg/ArmPkg.dec + MdePkg/MdePkg.dec + +[LibraryClasses] + ArmHvcLib + ArmSmcLib + +[Pcd] + gArmTokenSpaceGuid.PcdMonitorConduitHvc --=20 2.25.1 -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#93946): https://edk2.groups.io/g/devel/message/93946 Mute This Topic: https://groups.io/mt/93788866/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- From nobody Fri Apr 19 21:37:27 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) client-ip=66.175.222.108; envelope-from=bounce+27952+93947+1787277+3901457@groups.io; helo=mail02.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+93947+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=arm.com ARC-Seal: i=1; a=rsa-sha256; t=1663615351; cv=none; d=zohomail.com; s=zohoarc; b=WKwTjcau3xAExh1JGxlQxAg471P2ssKLwz6qNTXa5uEgIjzPtgue79pUV0kv+et9AyQL+7KBgAFIB9AZiv+/4tvYCkjKt/507SuFf0ZPknXE8hM0Q5r9BW5nKHTeZGX/mk5IQrr2Q1qb0Fo6OccYDQCKkYtcd1INsVzP1IYYn48= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1663615351; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:References:Sender:Subject:To; bh=emlZby73p/3wpV2ieT61Ip7AruScr2SY/g0+3GkSEGI=; b=SvnN1CySeT8tM9JGL3HeMyYdw7EBMdwH9Kf9L0aTFtgo7o1O4EBmTHoHVFSAN/5eSiF1Xt0iHfqw2HuUAHQaK1wDlorjVj/wE4kdAu7KCo7xLEPlwMmEZlx9fJ4mQFzHw/FCvkkMpoYSoHu1MdSseu0MgG5EIBX5wvLwGbC5OnU= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+93947+1787277+3901457@groups.io; dmarc=fail header.from= (p=none dis=none) Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by mx.zohomail.com with SMTPS id 1663615351660712.0443024676237; Mon, 19 Sep 2022 12:22:31 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id S6x0YY1788612xpyeBoahiod; Mon, 19 Sep 2022 12:22:31 -0700 X-Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by mx.groups.io with SMTP id smtpd.web11.3344.1663615350595480127 for ; Mon, 19 Sep 2022 12:22:30 -0700 X-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 CBF671424; Mon, 19 Sep 2022 12:22:36 -0700 (PDT) X-Received: from pierre123.arm.com (unknown [172.31.20.19]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 8913F3F73B; Mon, 19 Sep 2022 12:22:28 -0700 (PDT) From: "PierreGondois" To: devel@edk2.groups.io Cc: Sami Mujawar , Leif Lindholm , Ard Biesheuvel , Rebecca Cran , Michael D Kinney , Liming Gao , Jiewen Yao , Jian J Wang Subject: [edk2-devel] [PATCH v5 04/21] ArmPkg/ArmHvcNullLib: Add NULL instance of ArmHvcLib Date: Mon, 19 Sep 2022 21:21:50 +0200 Message-Id: <20220919192207.637786-5-Pierre.Gondois@arm.com> In-Reply-To: <20220919192207.637786-1-Pierre.Gondois@arm.com> References: <20220919192207.637786-1-Pierre.Gondois@arm.com> MIME-Version: 1.0 Precedence: Bulk List-Unsubscribe: List-Subscribe: List-Help: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,pierre.gondois@arm.com X-Gm-Message-State: rqAx3pWk2uSfhXyKut2aHl8Ix1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1663615351; bh=Y9yW0FXdqkAWSo20CFqBezxRrCZKEerWYKCyORZ2ZwQ=; h=Cc:Date:From:Reply-To:Subject:To; b=wh7D9rhd0c+VwQQYu1e2BTK0QUGMiUzZqsh7YvGnpza90gPJ/oSKOouKyoJy6tGcFhG pQvjFDr/j5pqkLdZf8NbWdV6ZyBAfmg/WoAg33kry4sJDtLwFLIiNIr+Fj6oHvXde5WSR D8Ce05fRw2smztU/P+tXY30F5KIkKU6vqG8= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1663615352836100017 Content-Type: text/plain; charset="utf-8" From: Pierre Gondois Add a Null instance of ArmHvcLib in case of library dependencies. Signed-off-by: Pierre Gondois --- ArmPkg/ArmPkg.dsc | 1 + ArmPkg/Library/ArmHvcNullLib/ArmHvcNullLib.c | 29 +++++++++++++++++++ .../Library/ArmHvcNullLib/ArmHvcNullLib.inf | 22 ++++++++++++++ 3 files changed, 52 insertions(+) create mode 100644 ArmPkg/Library/ArmHvcNullLib/ArmHvcNullLib.c create mode 100644 ArmPkg/Library/ArmHvcNullLib/ArmHvcNullLib.inf diff --git a/ArmPkg/ArmPkg.dsc b/ArmPkg/ArmPkg.dsc index 3afd212f472b..e33b40f2c215 100644 --- a/ArmPkg/ArmPkg.dsc +++ b/ArmPkg/ArmPkg.dsc @@ -134,6 +134,7 @@ [Components.common] ArmPkg/Library/ArmSmcLib/ArmSmcLib.inf ArmPkg/Library/ArmSmcLibNull/ArmSmcLibNull.inf ArmPkg/Library/ArmHvcLib/ArmHvcLib.inf + ArmPkg/Library/ArmHvcNullLib/ArmHvcNullLib.inf ArmPkg/Library/ArmSvcLib/ArmSvcLib.inf ArmPkg/Library/ArmMonitorLib/ArmMonitorLib.inf ArmPkg/Library/OpteeLib/OpteeLib.inf diff --git a/ArmPkg/Library/ArmHvcNullLib/ArmHvcNullLib.c b/ArmPkg/Library/= ArmHvcNullLib/ArmHvcNullLib.c new file mode 100644 index 000000000000..6905631ccb6c --- /dev/null +++ b/ArmPkg/Library/ArmHvcNullLib/ArmHvcNullLib.c @@ -0,0 +1,29 @@ +/** @file + Arm HyperVisor Call (HVC) Null Library. + + Copyright (c) 2022, Arm Limited. All rights reserved.
+ + SPDX-License-Identifier: BSD-2-Clause-Patent + +**/ + +#include +#include + +/** + Trigger an HVC call + + HVC calls can take up to 8 arguments and return up to 4 return values. + Therefore, the 4 first fields in the ARM_HVC_ARGS structure are used + for both input and output values. + + @param [in, out] Args Arguments for the HVC call. +**/ +VOID +ArmCallHvc ( + IN OUT ARM_HVC_ARGS *Args + ) +{ + ASSERT (FALSE); + return; +} diff --git a/ArmPkg/Library/ArmHvcNullLib/ArmHvcNullLib.inf b/ArmPkg/Librar= y/ArmHvcNullLib/ArmHvcNullLib.inf new file mode 100644 index 000000000000..c4665d34018b --- /dev/null +++ b/ArmPkg/Library/ArmHvcNullLib/ArmHvcNullLib.inf @@ -0,0 +1,22 @@ +## @file +# Arm Hvc Null Library +# +# Copyright (c) 2022, Arm Limited. All rights reserved.
+# +# SPDX-License-Identifier: BSD-2-Clause-Patent +## + +[Defines] + INF_VERSION =3D 0x00010005 + BASE_NAME =3D ArmHvcNullLib + FILE_GUID =3D 02076A46-D6DB-48DD-8E5F-153172DD73A1 + MODULE_TYPE =3D BASE + VERSION_STRING =3D 1.0 + LIBRARY_CLASS =3D ArmHvcLib + +[Sources] + ArmHvcNullLib.c + +[Packages] + ArmPkg/ArmPkg.dec + MdePkg/MdePkg.dec --=20 2.25.1 -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#93947): https://edk2.groups.io/g/devel/message/93947 Mute This Topic: https://groups.io/mt/93788867/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- From nobody Fri Apr 19 21:37:27 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) client-ip=66.175.222.108; envelope-from=bounce+27952+93948+1787277+3901457@groups.io; helo=mail02.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+93948+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=arm.com ARC-Seal: i=1; a=rsa-sha256; t=1663615354; cv=none; d=zohomail.com; s=zohoarc; b=MD65gvBH4lsgJ2kNP+XdQAqSaIYLDn664U+5tr9NcEJBJo6tPilbXBA7LKEZRru93zZ4/+Zjj9iLdAvwclGtlDwU1heLAf+MR0ah1yNVopROSz0sNKoA1sBS0SUx2wmfchm1EZ4f4ioaKVeuk+EsiZctWz9P5761WAuV0dKjuNA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1663615354; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:References:Sender:Subject:To; bh=Rwz64Ta7BBoNJysRLrz6Dn0I+z0raDhI94llfHDlS20=; b=XFcLkQjI62fBlg/hZ3rrx5rPz1Dd2uECGqvl4jcKcgubSp+oq8baze7tNNNJHJ+e0gxSRWgwqDCJuXTK5lk/+GnVkEcThyWHCJdXosbH0yCPhgt8U6/6sHm57XuBRps0cUloHrYQgRSUviC1B8Kl1WwD/7sLY/06B270ly4FdF0= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+93948+1787277+3901457@groups.io; dmarc=fail header.from= (p=none dis=none) Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by mx.zohomail.com with SMTPS id 1663615354786615.2747408232844; Mon, 19 Sep 2022 12:22:34 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id 6YUGYY1788612xxaKzbOg9x5; Mon, 19 Sep 2022 12:22:34 -0700 X-Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by mx.groups.io with SMTP id smtpd.web08.3238.1663615353829478909 for ; Mon, 19 Sep 2022 12:22:34 -0700 X-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 098FF143D; Mon, 19 Sep 2022 12:22:40 -0700 (PDT) X-Received: from pierre123.arm.com (unknown [172.31.20.19]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id ABD563F73B; Mon, 19 Sep 2022 12:22:30 -0700 (PDT) From: "PierreGondois" To: devel@edk2.groups.io Cc: Sami Mujawar , Leif Lindholm , Ard Biesheuvel , Rebecca Cran , Michael D Kinney , Liming Gao , Jiewen Yao , Jian J Wang Subject: [edk2-devel] [PATCH v5 05/21] MdePkg/TrngLib: Definition for TRNG library class interface Date: Mon, 19 Sep 2022 21:21:51 +0200 Message-Id: <20220919192207.637786-6-Pierre.Gondois@arm.com> In-Reply-To: <20220919192207.637786-1-Pierre.Gondois@arm.com> References: <20220919192207.637786-1-Pierre.Gondois@arm.com> MIME-Version: 1.0 Precedence: Bulk List-Unsubscribe: List-Subscribe: List-Help: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,pierre.gondois@arm.com X-Gm-Message-State: tYquhGFPcAjTnbi67iBXN8mRx1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1663615354; bh=fNvOuR7oZoUuGavF7cEVlcjs4sl24so4lTwaoM6Ex4g=; h=Cc:Date:From:Reply-To:Subject:To; b=GHkVpVWT0iD3TgdVvhi2NpZYxGLnFidT8OlDy6kRWRcuIHo56mDbZV9D83rhaUvMjzQ CEdRjDXXhcishUiMGVibW9xyx3wqrIMnqzqOwix79Q0JNkTcN4yHk9W144sfi2eoF1JIm rH6hSum3Ngv3dNDy6pbtKWe2pBjO8fQ/Wdc= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1663615356873100002 Content-Type: text/plain; charset="utf-8" From: Sami Mujawar Bugzilla: 3668 (https://bugzilla.tianocore.org/show_bug.cgi?id=3D3668) The NIST Special Publications 800-90A, 800-90B and 800-90C provide recommendations for random number generation. The NIST 800-90C, Recommendation for Random Bit Generator (RBG) Constructions, defines the GetEntropy() interface that is used to access the entropy source. The GetEntropy() interface is further used by Deterministic Random Bit Generators (DRBG) to generate random numbers. The True Random Number Generator (TRNG) library defines an interface to access the entropy source on a platform. Some platforms/architectures may provide access to the entropy using a firmware interface. In such cases the TRNG library shall be used to provide an abstraction. Signed-off-by: Sami Mujawar --- MdePkg/Include/Library/TrngLib.h | 103 +++++++++++++++++++++++++++++++ MdePkg/MdePkg.dec | 5 ++ 2 files changed, 108 insertions(+) create mode 100644 MdePkg/Include/Library/TrngLib.h diff --git a/MdePkg/Include/Library/TrngLib.h b/MdePkg/Include/Library/Trng= Lib.h new file mode 100644 index 000000000000..535fd53f4305 --- /dev/null +++ b/MdePkg/Include/Library/TrngLib.h @@ -0,0 +1,103 @@ +/** @file + TRNG interface library definitions. + + Copyright (c) 2021 - 2022, Arm Limited. All rights reserved.
+ + SPDX-License-Identifier: BSD-2-Clause-Patent + + @par Reference(s): + - [1] NIST Special Publication 800-90B, Recommendation for the Entropy + Sources Used for Random Bit Generation. + (https://csrc.nist.gov/publications/detail/sp/800-90b/final) + + @par Glossary: + - TRNG - True Random Number Generator +**/ + +#ifndef TRNG_LIB_H_ +#define TRNG_LIB_H_ + +/** Get the version of the TRNG backend. + + A TRNG may be implemented by the system firmware, in which case this + function shall return the version of the TRNG backend. + The implementation must return NOT_SUPPORTED if a Back end is not presen= t. + + @param [out] MajorRevision Major revision. + @param [out] MinorRevision Minor revision. + + @retval RETURN_SUCCESS The function completed successfully. + @retval RETURN_INVALID_PARAMETER Invalid parameter. + @retval RETURN_UNSUPPORTED Backend not present. +**/ +RETURN_STATUS +EFIAPI +GetTrngVersion ( + OUT UINT16 *MajorRevision, + OUT UINT16 *MinorRevision + ); + +/** Get the UUID of the TRNG backend. + + A TRNG may be implemented by the system firmware, in which case this + function shall return the UUID of the TRNG backend. + Returning the TRNG UUID is optional and if not implemented, RETURN_UNSUP= PORTED + shall be returned. + + Note: The caller must not rely on the returned UUID as a trustworthy TRNG + Back end identity + + @param [out] Guid UUID of the TRNG backend. + + @retval RETURN_SUCCESS The function completed successfully. + @retval RETURN_INVALID_PARAMETER Invalid parameter. + @retval RETURN_UNSUPPORTED Function not implemented. +**/ +RETURN_STATUS +EFIAPI +GetTrngUuid ( + OUT GUID *Guid + ); + +/** Returns maximum number of entropy bits that can be returned in a single + call. + + @return Returns the maximum number of Entropy bits that can be returned + in a single call to GetTrngEntropy(). +**/ +UINTN +EFIAPI +GetTrngMaxSupportedEntropyBits ( + VOID + ); + +/** Returns N bits of conditioned entropy. + + See [1] Section 2.3.1 GetEntropy: An Interface to the Entropy Source + GetEntropy + Input: + bits_of_entropy: the requested amount of entropy + Output: + entropy_bitstring: The string that provides the requested entropy. + status: A Boolean value that is TRUE if the request has been satisfi= ed, + and is FALSE otherwise. + + @param [in] EntropyBits Number of entropy bits requested. + @param [in] BufferSize Size of the Buffer in bytes. + @param [out] Buffer Buffer to return the entropy bits. + + @retval RETURN_SUCCESS The function completed successfully. + @retval RETURN_INVALID_PARAMETER Invalid parameter. + @retval RETURN_UNSUPPORTED Function not implemented. + @retval RETURN_BAD_BUFFER_SIZE Buffer size is too small. + @retval RETURN_NOT_READY No Entropy available. +**/ +RETURN_STATUS +EFIAPI +GetTrngEntropy ( + IN UINTN EntropyBits, + IN UINTN BufferSize, + OUT UINT8 *Buffer + ); + +#endif // TRNG_LIB_H_ diff --git a/MdePkg/MdePkg.dec b/MdePkg/MdePkg.dec index f1ebf9e251c1..7ff26e22f915 100644 --- a/MdePkg/MdePkg.dec +++ b/MdePkg/MdePkg.dec @@ -7,6 +7,7 @@ # Copyright (c) 2007 - 2022, Intel Corporation. All rights reserved.
# Portions copyright (c) 2008 - 2009, Apple Inc. All rights reserved.
# (C) Copyright 2016 - 2021 Hewlett Packard Enterprise Development LP
+# Copyright (c) 2021 - 2022, Arm Limited. All rights reserved.
# # SPDX-License-Identifier: BSD-2-Clause-Patent # @@ -275,6 +276,10 @@ [LibraryClasses] ## @libraryclass Provides function for SMM CPU Rendezvous Library. SmmCpuRendezvousLib|Include/Library/SmmCpuRendezvousLib.h =20 + ## @libraryclass Provides services to generate Entropy using a TRNG. + # + TrngLib|Include/Library/TrngLib.h + [LibraryClasses.IA32, LibraryClasses.X64, LibraryClasses.AARCH64] ## @libraryclass Provides services to generate random number. # --=20 2.25.1 -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#93948): https://edk2.groups.io/g/devel/message/93948 Mute This Topic: https://groups.io/mt/93788870/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- From nobody Fri Apr 19 21:37:27 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) client-ip=66.175.222.108; envelope-from=bounce+27952+93949+1787277+3901457@groups.io; helo=mail02.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+93949+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=arm.com ARC-Seal: i=1; a=rsa-sha256; t=1663615358; cv=none; d=zohomail.com; s=zohoarc; b=AT2mgZsFYzUz/6tbSEZcBG8lqbIqw+VuytVmDJK5BGCd7TeyCjUpPaFVlrStnHXS2Xf1+laUhF/ZcmbDcU+63Xmn8WBhwfWii5C9lRD3UW8vHtUBAGe+9DAtNspDMoza11sTV8huMyCrmBeIQal519BefD/DrDazx1bYo58llc0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1663615358; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:References:Sender:Subject:To; bh=WfNhAYrkhYnTwhJu6ZXYyPRtp6THURFQO4iCLVo5LsE=; b=nLLtBSS93TkjzY18BL8OZfeC7GGb36yNS6GnJSV7QtCrck12Qd+1Db84uOyGJU1mpoXitHY5tsu1MdROt8NAMn08ymo2D5aiDV5y0oe14Bh6TgkzkhgAF3+4f0BgTC7iEHh9QuavqmycJSk1f/JicTbdlXbK7CFSEc6qXMoocxo= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+93949+1787277+3901457@groups.io; dmarc=fail header.from= (p=none dis=none) Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by mx.zohomail.com with SMTPS id 1663615358496538.459177096324; Mon, 19 Sep 2022 12:22:38 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id 8uorYY1788612xzpWCktxNDU; Mon, 19 Sep 2022 12:22:38 -0700 X-Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by mx.groups.io with SMTP id smtpd.web08.3239.1663615357391335065 for ; Mon, 19 Sep 2022 12:22:37 -0700 X-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 9A0AF1424; Mon, 19 Sep 2022 12:22:43 -0700 (PDT) X-Received: from pierre123.arm.com (unknown [172.31.20.19]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 03D9C3F73B; Mon, 19 Sep 2022 12:22:33 -0700 (PDT) From: "PierreGondois" To: devel@edk2.groups.io Cc: Sami Mujawar , Leif Lindholm , Ard Biesheuvel , Rebecca Cran , Michael D Kinney , Liming Gao , Jiewen Yao , Jian J Wang Subject: [edk2-devel] [PATCH v5 06/21] MdePkg/TrngLib: Add NULL instance of TRNG Library Date: Mon, 19 Sep 2022 21:21:52 +0200 Message-Id: <20220919192207.637786-7-Pierre.Gondois@arm.com> In-Reply-To: <20220919192207.637786-1-Pierre.Gondois@arm.com> References: <20220919192207.637786-1-Pierre.Gondois@arm.com> MIME-Version: 1.0 Precedence: Bulk List-Unsubscribe: List-Subscribe: List-Help: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,pierre.gondois@arm.com X-Gm-Message-State: nPkuD7mby0YkK3V8vkHYwplvx1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1663615358; bh=fhoAC+yaXwhSpJ6FCN54aERJk5enpIamqTllkjTfxKw=; h=Cc:Date:From:Reply-To:Subject:To; b=tq4jWjq853JhcbbGjFbWXgdwmobmJ60NdmYw522s8O57Tn4tNwh21P3HPW3iYv020JL jLpML9poUKjW4TYrnXNzqykw5dgGQf1F2w+z7AMFdSujXW4B3OGMuemMt/jqO7M91w/j7 21I8N8SfWKTJCb7z0jLXvPIAgmgu+u5lm+E= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1663615358890100006 Content-Type: text/plain; charset="utf-8" From: Sami Mujawar Bugzilla: 3668 (https://bugzilla.tianocore.org/show_bug.cgi?id=3D3668) The True Random Number Generator (TRNG) library defines an interface to access the entropy source on a platform. On platforms that do not have access to an entropy source, a NULL instance of the TRNG library may be useful to satisfy the build dependency. Therefore, add a NULL instance of the TRNG library. Signed-off-by: Sami Mujawar --- .../Library/BaseTrngLibNull/BaseTrngLibNull.c | 117 ++++++++++++++++++ .../BaseTrngLibNull/BaseTrngLibNull.inf | 30 +++++ .../BaseTrngLibNull/BaseTrngLibNull.uni | 12 ++ MdePkg/MdePkg.dsc | 1 + 4 files changed, 160 insertions(+) create mode 100644 MdePkg/Library/BaseTrngLibNull/BaseTrngLibNull.c create mode 100644 MdePkg/Library/BaseTrngLibNull/BaseTrngLibNull.inf create mode 100644 MdePkg/Library/BaseTrngLibNull/BaseTrngLibNull.uni diff --git a/MdePkg/Library/BaseTrngLibNull/BaseTrngLibNull.c b/MdePkg/Libr= ary/BaseTrngLibNull/BaseTrngLibNull.c new file mode 100644 index 000000000000..60774b33dd58 --- /dev/null +++ b/MdePkg/Library/BaseTrngLibNull/BaseTrngLibNull.c @@ -0,0 +1,117 @@ +/** @file + Null version of TRNG (True Random Number Generator) services. + + Copyright (c) 2021 - 2022, Arm Limited. All rights reserved.
+ + SPDX-License-Identifier: BSD-2-Clause-Patent + + @par Reference(s): + - [1] NIST Special Publication 800-90B, Recommendation for the Entropy + Sources Used for Random Bit Generation. + (https://csrc.nist.gov/publications/detail/sp/800-90b/final) + + @par Glossary: + - TRNG - True Random Number Generator +**/ + +#include +#include + +/** Get the version of the TRNG backend. + + A TRNG may be implemented by the system firmware, in which case this + function shall return the version of the TRNG backend. + The implementation must return NOT_SUPPORTED if a Back end is not presen= t. + + @param [out] MajorRevision Major revision. + @param [out] MinorRevision Minor revision. + + @retval RETURN_SUCCESS The function completed successfully. + @retval RETURN_INVALID_PARAMETER Invalid parameter. + @retval RETURN_UNSUPPORTED Backend not present. +**/ +RETURN_STATUS +EFIAPI +GetTrngVersion ( + OUT UINT16 *MajorRevision, + OUT UINT16 *MinorRevision + ) +{ + ASSERT (FALSE); + return RETURN_UNSUPPORTED; +} + +/** Get the UUID of the TRNG backend. + + A TRNG may be implemented by the system firmware, in which case this + function shall return the UUID of the TRNG backend. + Returning the TRNG UUID is optional and if not implemented, RETURN_UNSUP= PORTED + shall be returned. + + Note: The caller must not rely on the returned UUID as a trustworthy TRNG + Back end identity + + @param [out] Guid UUID of the TRNG backend. + + @retval RETURN_SUCCESS The function completed successfully. + @retval RETURN_INVALID_PARAMETER Invalid parameter. + @retval RETURN_UNSUPPORTED Function not implemented. +**/ +RETURN_STATUS +EFIAPI +GetTrngUuid ( + OUT GUID *Guid + ) +{ + ASSERT (FALSE); + return RETURN_UNSUPPORTED; +} + +/** Returns maximum number of entropy bits that can be returned in a single + call. + + @return Returns the maximum number of Entropy bits that can be returned + in a single call to GetTrngEntropy(). +**/ +UINTN +EFIAPI +GetTrngMaxSupportedEntropyBits ( + VOID + ) +{ + ASSERT (FALSE); + return 0; +} + +/** Returns N bits of conditioned entropy. + + See [1] Section 2.3.1 GetEntropy: An Interface to the Entropy Source + GetEntropy + Input: + bits_of_entropy: the requested amount of entropy + Output: + entropy_bitstring: The string that provides the requested entropy. + status: A Boolean value that is TRUE if the request has been satisfi= ed, + and is FALSE otherwise. + + @param [in] EntropyBits Number of entropy bits requested. + @param [in] BufferSize Size of the Buffer in bytes. + @param [out] Buffer Buffer to return the entropy bits. + + @retval RETURN_SUCCESS The function completed successfully. + @retval RETURN_INVALID_PARAMETER Invalid parameter. + @retval RETURN_UNSUPPORTED Function not implemented. + @retval RETURN_BAD_BUFFER_SIZE Buffer size is too small. + @retval RETURN_NOT_READY No Entropy available. +**/ +RETURN_STATUS +EFIAPI +GetTrngEntropy ( + IN UINTN EntropyBits, + IN UINTN BufferSize, + OUT UINT8 *Buffer + ) +{ + ASSERT (FALSE); + return RETURN_UNSUPPORTED; +} diff --git a/MdePkg/Library/BaseTrngLibNull/BaseTrngLibNull.inf b/MdePkg/Li= brary/BaseTrngLibNull/BaseTrngLibNull.inf new file mode 100644 index 000000000000..004aa8445a25 --- /dev/null +++ b/MdePkg/Library/BaseTrngLibNull/BaseTrngLibNull.inf @@ -0,0 +1,30 @@ +## @file +# Null instance of TRNG (True Random Number Generator) Library. +# +# Copyright (c) 2021 - 2022, Arm Limited. All rights reserved.
+# +# SPDX-License-Identifier: BSD-2-Clause-Patent +# +## + +[Defines] + INF_VERSION =3D 0x0001001B + BASE_NAME =3D BaseTrngLibNull + MODULE_UNI_FILE =3D BaseTrngLibNull.uni + FILE_GUID =3D ABDE1C87-4F50-4B82-9133-7A79E13F69AB + MODULE_TYPE =3D BASE + VERSION_STRING =3D 1.0 + LIBRARY_CLASS =3D TrngLib + +# +# VALID_ARCHITECTURES =3D IA32 X64 ARM AARCH64 +# + +[Sources] + BaseTrngLibNull.c + +[Packages] + MdePkg/MdePkg.dec + +[LibraryClasses] + DebugLib diff --git a/MdePkg/Library/BaseTrngLibNull/BaseTrngLibNull.uni b/MdePkg/Li= brary/BaseTrngLibNull/BaseTrngLibNull.uni new file mode 100644 index 000000000000..952e4354c0cc --- /dev/null +++ b/MdePkg/Library/BaseTrngLibNull/BaseTrngLibNull.uni @@ -0,0 +1,12 @@ +// /** @file +// Null Instance of TRNG (True Random Number Generator) Library. +// +// Copyright (c) 2021 - 2022, Arm Limited. All rights reserved.
+// +// SPDX-License-Identifier: BSD-2-Clause-Patent +// +// **/ + +#string STR_MODULE_ABSTRACT #language en-US "Null instance of = TRNG Library" + +#string STR_MODULE_DESCRIPTION #language en-US "This library inst= ance should be used with modules that inherit an (indirect) dependency on t= he TrngLib class, but never actually call TrngLib APIs for consuming Entrop= y." diff --git a/MdePkg/MdePkg.dsc b/MdePkg/MdePkg.dsc index cc1ac196a931..1a3a3c3243f5 100644 --- a/MdePkg/MdePkg.dsc +++ b/MdePkg/MdePkg.dsc @@ -67,6 +67,7 @@ [Components] MdePkg/Library/DxeRngLib/DxeRngLib.inf MdePkg/Library/BaseRngLibNull/BaseRngLibNull.inf MdePkg/Library/BaseRngLibTimerLib/BaseRngLibTimerLib.inf + MdePkg/Library/BaseTrngLibNull/BaseTrngLibNull.inf =20 MdePkg/Library/BaseSerialPortLibNull/BaseSerialPortLibNull.inf MdePkg/Library/BaseSynchronizationLib/BaseSynchronizationLib.inf --=20 2.25.1 -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#93949): https://edk2.groups.io/g/devel/message/93949 Mute This Topic: https://groups.io/mt/93788872/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- From nobody Fri Apr 19 21:37:27 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) client-ip=66.175.222.108; envelope-from=bounce+27952+93950+1787277+3901457@groups.io; helo=mail02.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+93950+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=arm.com ARC-Seal: i=1; a=rsa-sha256; t=1663615362; cv=none; d=zohomail.com; s=zohoarc; b=H5zotjnlIk60jlLdMT9eratXPXqQWMclRBg9AdMOWKvZneVz3AD3d4ep8JYBzKck1SiI6VS6KMyzTKU8iWUo69IiQFienevVPTp5fqXXR7MsmTgtkpte8BT7Y5IZPFvrX3hmO0o+qtFp+07//pKqJC9B/54RDLU5PbIHdVPWtxw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1663615362; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:References:Sender:Subject:To; bh=GRw5P4f6IbNbfHS21zAJsaEtdGktn9wpXLrHAKWeFvI=; b=STJxvQZx/HXd1qVThKdmQytzCMLRA/4zV6IWEE5pzCmgv9CHnYNAcYMnlfKNR3HuAyXaAfIwYTH+dZ7x/yfAbngyZytbSGE9bp9XtJJgNKcQRGw0NqKhm29h0uRUOerihWB3TV/pdWOEyg/sgsee5wYveEpO8gw9ZCCtb4zWIUg= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+93950+1787277+3901457@groups.io; dmarc=fail header.from= (p=none dis=none) Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by mx.zohomail.com with SMTPS id 1663615362529634.2845171046469; Mon, 19 Sep 2022 12:22:42 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id oiEhYY1788612x2TvpU0rcgG; Mon, 19 Sep 2022 12:22:41 -0700 X-Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by mx.groups.io with SMTP id smtpd.web08.3240.1663615360137728423 for ; Mon, 19 Sep 2022 12:22:40 -0700 X-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 5E4071BF3; Mon, 19 Sep 2022 12:22:46 -0700 (PDT) X-Received: from pierre123.arm.com (unknown [172.31.20.19]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id B07D23F73B; Mon, 19 Sep 2022 12:22:37 -0700 (PDT) From: "PierreGondois" To: devel@edk2.groups.io Cc: Sami Mujawar , Leif Lindholm , Ard Biesheuvel , Rebecca Cran , Michael D Kinney , Liming Gao , Jiewen Yao , Jian J Wang Subject: [edk2-devel] [PATCH v5 07/21] ArmPkg: Add FID definitions for Firmware TRNG Date: Mon, 19 Sep 2022 21:21:53 +0200 Message-Id: <20220919192207.637786-8-Pierre.Gondois@arm.com> In-Reply-To: <20220919192207.637786-1-Pierre.Gondois@arm.com> References: <20220919192207.637786-1-Pierre.Gondois@arm.com> MIME-Version: 1.0 Precedence: Bulk List-Unsubscribe: List-Subscribe: List-Help: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,pierre.gondois@arm.com X-Gm-Message-State: kRVl7aP5odhsfAgyaURAvZnMx1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1663615361; bh=tJaYPoBQl2pDfB+kutewdGIiGupxwCsgx0XiIKLlDNk=; h=Cc:Date:From:Reply-To:Subject:To; b=d0sPzM9HOmUpr1tHZbH3+oguTutmSD7e7rGFBD5QQL4T3gtSvr4tg/kgiQJbmbEqJAU XkDZhNaWQtOX2xJD+tHiPvMSuLitBShC2pSnoNrCXv4Pd16rkEqQNIYm9F6txNBIgap75 R9hepsGSFjP2pmGbhjoQOERSCwq1q9k5f94= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1663615362870100002 Content-Type: text/plain; charset="utf-8" From: Sami Mujawar Bugzilla: 3668 (https://bugzilla.tianocore.org/show_bug.cgi?id=3D3668) 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 --- ArmPkg/Include/IndustryStandard/ArmStdSmc.h | 109 +++++++++++++++++++- 1 file changed, 107 insertions(+), 2 deletions(-) diff --git a/ArmPkg/Include/IndustryStandard/ArmStdSmc.h b/ArmPkg/Include/I= ndustryStandard/ArmStdSmc.h index 78ce77cd734d..fa977a03a7ab 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.
-* 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=3Den) +* - [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 +* **/ =20 #ifndef ARM_STD_SMC_H_ @@ -139,4 +146,102 @@ /* 0xbf00ff02 is reserved */ #define ARM_SMC_ID_TOS_REVISION 0xbf00ff03 =20 +// 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 backen= d, + Cf. [2], Section 2.2 TRNG_FEATURES + Input Values + W0 0x8400_0051 + W1 trng_func_id + W2-W7 Reserved (MBZ) + Return values: + Success (W0 >=3D 0): + SUCCESS Function is implemented. + > 0 Function is implemented and + has specific capabilities, + see function definition. + Error (W0 < 0) + NOT_SUPPORTED Function with FID=3Dtrng_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 !=3D -1) + W0 UUID[31:0] + W1 UUID[63:32] + W2 UUID[95:64] + W3 UUID[127:96] + Error (W0 =3D -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 =3D 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 =3D 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_ --=20 2.25.1 -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#93950): https://edk2.groups.io/g/devel/message/93950 Mute This Topic: https://groups.io/mt/93788874/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- From nobody Fri Apr 19 21:37:27 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) client-ip=66.175.222.108; envelope-from=bounce+27952+93951+1787277+3901457@groups.io; helo=mail02.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+93951+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=arm.com ARC-Seal: i=1; a=rsa-sha256; t=1663615363; cv=none; d=zohomail.com; s=zohoarc; b=Lmoy4gFhzlI6kD27UxAdxilhhAyuycsRlpbC+aDv58TlW5N39m9y9kMKuwwSiw4dn2DnRBmXeLsF1oUTgzPXgJ+LlCWOMJYnTSwPVk47jVqzLUCYbXcABM4sxB14G8EomL2//aWX+JzDFouwn+3hZmJ4F1WwgC2Mw3H/TRp7OIA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1663615363; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:References:Sender:Subject:To; bh=H/yHgsWyWjdn1+82h2uDt0mxJ/Tg+nfdva5s3j3U1s8=; b=DjrpXftgZrAcvMrWpivcUAWpywIfQ//jbC+4FlZp7zCNtyoDO4hFC9JwbZqYArkMYiQkK1aoDaceVAG7ZQnqwVlWcE11out9NCx1Buotl6Bp19OyJFyj1Jh6+vTgSlmZU1xwQtwmKusup5/tqen7lRZNrVRT3HwJQUEg//rPpws= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+93951+1787277+3901457@groups.io; dmarc=fail header.from= (p=none dis=none) Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by mx.zohomail.com with SMTPS id 1663615363949576.5431277476205; Mon, 19 Sep 2022 12:22:43 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id fHonYY1788612xqIetTDCUee; Mon, 19 Sep 2022 12:22:43 -0700 X-Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by mx.groups.io with SMTP id smtpd.web12.3260.1663615362876597223 for ; Mon, 19 Sep 2022 12:22:43 -0700 X-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 1171B1424; Mon, 19 Sep 2022 12:22:49 -0700 (PDT) X-Received: from pierre123.arm.com (unknown [172.31.20.19]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 42D8A3F73B; Mon, 19 Sep 2022 12:22:40 -0700 (PDT) From: "PierreGondois" To: devel@edk2.groups.io Cc: Sami Mujawar , Leif Lindholm , Ard Biesheuvel , Rebecca Cran , Michael D Kinney , Liming Gao , Jiewen Yao , Jian J Wang Subject: [edk2-devel] [PATCH v5 08/21] ArmPkg/TrngLib: Add Arm Firmware TRNG library Date: Mon, 19 Sep 2022 21:21:54 +0200 Message-Id: <20220919192207.637786-9-Pierre.Gondois@arm.com> In-Reply-To: <20220919192207.637786-1-Pierre.Gondois@arm.com> References: <20220919192207.637786-1-Pierre.Gondois@arm.com> MIME-Version: 1.0 Precedence: Bulk List-Unsubscribe: List-Subscribe: List-Help: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,pierre.gondois@arm.com X-Gm-Message-State: fGbodYTMfY7FuA4UIdNE2HDJx1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1663615363; bh=HTDgtIAJbiIclBsyuGZr/ULPN/+0mJWCY1UcuOAvB+U=; h=Cc:Date:From:Reply-To:Subject:To; b=vt3LKiQnYi6W0zw+vsH03Mqh1FwbYjQ57AaLsB9JvqtRVp4I6AoD31rVk58eYUsREBL Zp4VIBa0YpF7P7huBUgPvAYznzy7yBUP0XfKfyawOfZi8PRhBoTF8XrnfTceA5S+q71rr fXYEfuBTKm3Miw8iVu0BkuzDMXP9eb/lQoo= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1663615364926100006 Content-Type: text/plain; charset="utf-8" From: Sami Mujawar Bugzilla: 3668 (https://bugzilla.tianocore.org/show_bug.cgi?id=3D3668) 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. The conditioned entropy, that is provided by the TRNG FW interface, is commonly used to seed deterministic random number generators. This patch adds a TrngLib library that implements the Arm TRNG firmware interface. Signed-off-by: Sami Mujawar --- ArmPkg/ArmPkg.dsc | 1 + ArmPkg/Library/ArmFwTrngLib/ArmFwTrngDefs.h | 50 +++ ArmPkg/Library/ArmFwTrngLib/ArmFwTrngLib.c | 388 +++++++++++++++++++ ArmPkg/Library/ArmFwTrngLib/ArmFwTrngLib.inf | 29 ++ 4 files changed, 468 insertions(+) create mode 100644 ArmPkg/Library/ArmFwTrngLib/ArmFwTrngDefs.h create mode 100644 ArmPkg/Library/ArmFwTrngLib/ArmFwTrngLib.c create mode 100644 ArmPkg/Library/ArmFwTrngLib/ArmFwTrngLib.inf diff --git a/ArmPkg/ArmPkg.dsc b/ArmPkg/ArmPkg.dsc index e33b40f2c215..02d1caa3ab40 100644 --- a/ArmPkg/ArmPkg.dsc +++ b/ArmPkg/ArmPkg.dsc @@ -138,6 +138,7 @@ [Components.common] ArmPkg/Library/ArmSvcLib/ArmSvcLib.inf ArmPkg/Library/ArmMonitorLib/ArmMonitorLib.inf ArmPkg/Library/OpteeLib/OpteeLib.inf + ArmPkg/Library/ArmFwTrngLib/ArmFwTrngLib.inf =20 ArmPkg/Filesystem/SemihostFs/SemihostFs.inf =20 diff --git a/ArmPkg/Library/ArmFwTrngLib/ArmFwTrngDefs.h b/ArmPkg/Library/A= rmFwTrngLib/ArmFwTrngDefs.h new file mode 100644 index 000000000000..150c89fe7969 --- /dev/null +++ b/ArmPkg/Library/ArmFwTrngLib/ArmFwTrngDefs.h @@ -0,0 +1,50 @@ +/** @file + Arm Firmware TRNG definitions. + + Copyright (c) 2021 - 2022, Arm Limited. All rights reserved.
+ + SPDX-License-Identifier: BSD-2-Clause-Patent + + @par Reference(s): + - [1] 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 + - FID - Function ID +**/ + +#ifndef ARM_FW_TRNG_DEFS_H_ +#define ARM_FW_TRNG_DEFS_H_ + +#include + +// Firmware TRNG revision mask and shift +#define TRNG_REV_MAJOR_MASK 0x7FFF +#define TRNG_REV_MINOR_MASK 0xFFFF +#define TRNG_REV_MAJOR_SHIFT 16 + +#if defined (MDE_CPU_ARM) + +/** FID to use on AArch32 platform to request entropy. +*/ +#define FID_TRNG_RND FID_TRNG_RND_AARCH32 + +/** Maximum bits of entropy supported on AArch32. +*/ +#define MAX_ENTROPY_BITS 96 +#elif defined (MDE_CPU_AARCH64) + +/** FID to use on AArch64 platform to request entropy. +*/ +#define FID_TRNG_RND FID_TRNG_RND_AARCH64 + +/** Maximum bits of entropy supported on AArch64. +*/ +#define MAX_ENTROPY_BITS 192 +#else + #error "Firmware TRNG not supported. Unknown chipset." +#endif + +#endif // ARM_FW_TRNG_DEFS_H_ diff --git a/ArmPkg/Library/ArmFwTrngLib/ArmFwTrngLib.c b/ArmPkg/Library/Ar= mFwTrngLib/ArmFwTrngLib.c new file mode 100644 index 000000000000..df4c59ce7736 --- /dev/null +++ b/ArmPkg/Library/ArmFwTrngLib/ArmFwTrngLib.c @@ -0,0 +1,388 @@ +/** @file + Arm Firmware TRNG interface library. + + Copyright (c) 2021 - 2022, Arm Limited. All rights reserved.
+ + SPDX-License-Identifier: BSD-2-Clause-Patent + + @par Reference(s): + - [1] NIST Special Publication 800-90B, Recommendation for the Entropy + Sources Used for Random Bit Generation. + (https://csrc.nist.gov/publications/detail/sp/800-90b/final) + - [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 + - FID - Function ID +**/ + +#include +#include +#include +#include +#include + +#include "ArmFwTrngDefs.h" + +/** Convert TRNG status codes to RETURN status codes. + + @param [in] TrngStatus TRNG status code. + + @retval RETURN_SUCCESS Success. + @retval RETURN_UNSUPPORTED Function not implemented or + negative return code. + @retval RETURN_INVALID_PARAMETER A parameter is invalid. + @retval RETURN_NOT_READY No Entropy available. +**/ +STATIC +RETURN_STATUS +TrngStatusToReturnStatus ( + IN INT32 TrngStatus + ) +{ + switch (TrngStatus) { + case TRNG_STATUS_NOT_SUPPORTED: + return RETURN_UNSUPPORTED; + + case TRNG_STATUS_INVALID_PARAMETER: + return RETURN_INVALID_PARAMETER; + + case TRNG_STATUS_NO_ENTROPY: + return RETURN_NOT_READY; + + case TRNG_STATUS_SUCCESS: + return RETURN_SUCCESS; + + default: + if (TrngStatus < 0) { + return RETURN_UNSUPPORTED; + } + + return RETURN_SUCCESS; + } +} + +/** Get the version of the TRNG backend. + + A TRNG may be implemented by the system firmware, in which case this + function shall return the version of the TRNG backend. + The implementation must return NOT_SUPPORTED if a Back end is not presen= t. + + @param [out] MajorRevision Major revision. + @param [out] MinorRevision Minor revision. + + @retval RETURN_SUCCESS The function completed successfully. + @retval RETURN_INVALID_PARAMETER Invalid parameter. + @retval RETURN_UNSUPPORTED Backend not present. +**/ +RETURN_STATUS +EFIAPI +GetTrngVersion ( + OUT UINT16 *MajorRevision, + OUT UINT16 *MinorRevision + ) +{ + RETURN_STATUS Status; + ARM_MONITOR_ARGS Parameters; + INT32 Revision; + + if ((MajorRevision =3D=3D NULL) || (MinorRevision =3D=3D NULL)) { + return RETURN_INVALID_PARAMETER; + } + + ZeroMem (&Parameters, sizeof (Parameters)); + + Parameters.Arg0 =3D FID_TRNG_VERSION; + ArmMonitorCall (&Parameters); + + Revision =3D (INT32)Parameters.Arg0; + Status =3D TrngStatusToReturnStatus (Revision); + if (RETURN_ERROR (Status)) { + return Status; + } + + *MinorRevision =3D (Revision & TRNG_REV_MINOR_MASK); + *MajorRevision =3D ((Revision >> TRNG_REV_MAJOR_SHIFT) & TRNG_REV_MAJOR_= MASK); + return RETURN_SUCCESS; +} + +/** Get the features supported by the TRNG backend. + + The caller can determine if functions defined in the TRNG ABI are + present in the ABI implementation. + + @param [in] FunctionId Function Id. + @param [out] Capability Function specific capability if present. + + @retval RETURN_SUCCESS The function completed successfully. + @retval RETURN_INVALID_PARAMETER Invalid parameter. + @retval RETURN_UNSUPPORTED Function not implemented. +**/ +STATIC +RETURN_STATUS +EFIAPI +GetTrngFeatures ( + IN CONST UINT32 FunctionId, + OUT UINT32 *Capability OPTIONAL + ) +{ + ARM_MONITOR_ARGS Parameters; + RETURN_STATUS Status; + + ZeroMem (&Parameters, sizeof (Parameters)); + + Parameters.Arg0 =3D FID_TRNG_FEATURES; + Parameters.Arg1 =3D FunctionId; + ArmMonitorCall (&Parameters); + + Status =3D TrngStatusToReturnStatus (Parameters.Arg0); + if (RETURN_ERROR (Status)) { + return Status; + } + + if (Capability !=3D NULL) { + *Capability =3D (UINT32)Parameters.Arg0; + } + + return RETURN_SUCCESS; +} + +/** Get the UUID of the TRNG backend. + + A TRNG may be implemented by the system firmware, in which case this + function shall return the UUID of the TRNG backend. + Returning the TRNG UUID is optional and if not implemented, RETURN_UNSUP= PORTED + shall be returned. + + Note: The caller must not rely on the returned UUID as a trustworthy TRNG + Back end identity + + @param [out] Guid UUID of the TRNG backend. + + @retval RETURN_SUCCESS The function completed successfully. + @retval RETURN_INVALID_PARAMETER Invalid parameter. + @retval RETURN_UNSUPPORTED Function not implemented. +**/ +RETURN_STATUS +EFIAPI +GetTrngUuid ( + OUT GUID *Guid + ) +{ + ARM_MONITOR_ARGS Parameters; + + if (Guid =3D=3D NULL) { + return RETURN_INVALID_PARAMETER; + } + + ZeroMem (&Parameters, sizeof (Parameters)); + + Parameters.Arg0 =3D FID_TRNG_GET_UUID; + ArmMonitorCall (&Parameters); + + // Only invalid value is TRNG_STATUS_NOT_SUPPORTED (-1). + if ((INT32)Parameters.Arg0 =3D=3D TRNG_STATUS_NOT_SUPPORTED) { + return TrngStatusToReturnStatus ((INT32)Parameters.Arg0); + } + + Guid->Data1 =3D (Parameters.Arg0 & MAX_UINT32); + Guid->Data2 =3D (Parameters.Arg1 & MAX_UINT16); + Guid->Data3 =3D ((Parameters.Arg1 >> 16) & MAX_UINT16); + + Guid->Data4[0] =3D (Parameters.Arg2 & MAX_UINT8); + Guid->Data4[1] =3D ((Parameters.Arg2 >> 8) & MAX_UINT8); + Guid->Data4[2] =3D ((Parameters.Arg2 >> 16) & MAX_UINT8); + Guid->Data4[3] =3D ((Parameters.Arg2 >> 24) & MAX_UINT8); + + Guid->Data4[4] =3D (Parameters.Arg3 & MAX_UINT8); + Guid->Data4[5] =3D ((Parameters.Arg3 >> 8) & MAX_UINT8); + Guid->Data4[6] =3D ((Parameters.Arg3 >> 16) & MAX_UINT8); + Guid->Data4[7] =3D ((Parameters.Arg3 >> 24) & MAX_UINT8); + + DEBUG ((DEBUG_INFO, "FW-TRNG: UUID %g\n", Guid)); + + return RETURN_SUCCESS; +} + +/** Returns maximum number of entropy bits that can be returned in a single + call. + + @return Returns the maximum number of Entropy bits that can be returned + in a single call to GetTrngEntropy(). +**/ +UINTN +EFIAPI +GetTrngMaxSupportedEntropyBits ( + VOID + ) +{ + return MAX_ENTROPY_BITS; +} + +/** Returns N bits of conditioned entropy. + + See [1] Section 2.3.1 GetEntropy: An Interface to the Entropy Source + GetEntropy + Input: + bits_of_entropy: the requested amount of entropy + Output: + entropy_bitstring: The string that provides the requested entropy. + status: A Boolean value that is TRUE if the request has been satisfi= ed, + and is FALSE otherwise. + + @param [in] EntropyBits Number of entropy bits requested. + @param [in] BufferSize Size of the Buffer in bytes. + @param [out] Buffer Buffer to return the entropy bits. + + @retval RETURN_SUCCESS The function completed successfully. + @retval RETURN_INVALID_PARAMETER Invalid parameter. + @retval RETURN_UNSUPPORTED Function not implemented. + @retval RETURN_BAD_BUFFER_SIZE Buffer size is too small. + @retval RETURN_NOT_READY No Entropy available. +**/ +RETURN_STATUS +EFIAPI +GetTrngEntropy ( + IN UINTN EntropyBits, + IN UINTN BufferSize, + OUT UINT8 *Buffer + ) +{ + RETURN_STATUS Status; + ARM_MONITOR_ARGS Parameters; + UINTN EntropyBytes; + UINTN LastValidBits; + UINTN BytesToClear; + UINTN EntropyData[3]; + + if ((EntropyBits =3D=3D 0) || + (EntropyBits > MAX_ENTROPY_BITS) || + (Buffer =3D=3D NULL)) + { + return RETURN_INVALID_PARAMETER; + } + + EntropyBytes =3D (EntropyBits + 7) >> 3; + if (EntropyBytes > BufferSize) { + return RETURN_BAD_BUFFER_SIZE; + } + + ZeroMem (Buffer, BufferSize); + ZeroMem (&Parameters, sizeof (Parameters)); + + Parameters.Arg0 =3D FID_TRNG_RND; + Parameters.Arg1 =3D EntropyBits; + ArmMonitorCall (&Parameters); + + Status =3D TrngStatusToReturnStatus ((INT32)Parameters.Arg0); + if (RETURN_ERROR (Status)) { + return Status; + } + + // The entropy data is returned in the Parameters.Arg<3..1> + // With the lower order bytes in Parameters.Arg3 and the higher + // order bytes being stored in Parameters.Arg1. + EntropyData[0] =3D Parameters.Arg3; + EntropyData[1] =3D Parameters.Arg2; + EntropyData[2] =3D Parameters.Arg1; + + CopyMem (Buffer, EntropyData, EntropyBytes); + + // Mask off any unused top bytes, in accordance with specification. + BytesToClear =3D BufferSize - EntropyBytes; + if (BytesToClear !=3D 0) { + ZeroMem (&Buffer[EntropyBytes], BytesToClear); + } + + // Clear the unused MSB bits of the last byte. + LastValidBits =3D EntropyBits & 0x7; + if (LastValidBits !=3D 0) { + Buffer[EntropyBytes - 1] &=3D (0xFF >> (8 - LastValidBits)); + } + + return Status; +} + +/** The constructor checks that the FW-TRNG interface is supported + by the host firmware. + + It will ASSERT() if FW-TRNG is not supported. + It will always return RETURN_SUCCESS. + + @retval RETURN_SUCCESS The constructor always returns RETURN_SUCCESS. +**/ +RETURN_STATUS +EFIAPI +ArmFwTrngLibConstructor ( + VOID + ) +{ + ARM_MONITOR_ARGS Parameters; + RETURN_STATUS Status; + UINT16 MajorRev; + UINT16 MinorRev; + GUID Guid; + + ZeroMem (&Parameters, sizeof (Parameters)); + + Parameters.Arg0 =3D SMCCC_VERSION; + ArmMonitorCall (&Parameters); + Status =3D TrngStatusToReturnStatus ((INT32)Parameters.Arg0); + if (RETURN_ERROR (Status)) { + ASSERT_RETURN_ERROR (Status); + goto ErrorHandler; + } + + // Cf [1] s2.1.3 'Caller responsibilities', + // SMCCC version must be greater or equal than 1.1 + if ((INT32)Parameters.Arg0 < 0x10001) { + ASSERT_RETURN_ERROR (RETURN_UNSUPPORTED); + goto ErrorHandler; + } + + Status =3D GetTrngVersion (&MajorRev, &MinorRev); + if (RETURN_ERROR (Status)) { + ASSERT_RETURN_ERROR (Status); + goto ErrorHandler; + } + + // Check that the required features are present. + Status =3D GetTrngFeatures (FID_TRNG_RND, NULL); + if (RETURN_ERROR (Status)) { + ASSERT_RETURN_ERROR (Status); + goto ErrorHandler; + } + + // Check if TRNG UUID is supported and if so trace the GUID. + Status =3D GetTrngFeatures (FID_TRNG_GET_UUID, NULL); + if (RETURN_ERROR (Status)) { + ASSERT_RETURN_ERROR (Status); + goto ErrorHandler; + } + + DEBUG_CODE_BEGIN (); + + Status =3D GetTrngUuid (&Guid); + if (RETURN_ERROR (Status)) { + ASSERT_RETURN_ERROR (Status); + goto ErrorHandler; + } + + DEBUG (( + DEBUG_INFO, + "FW-TRNG: Version %d.%d, GUID {%g}\n", + MajorRev, + MinorRev, + Guid + )); + + DEBUG_CODE_END (); + + return RETURN_SUCCESS; + +ErrorHandler: + DEBUG ((DEBUG_ERROR, "ArmFwTrngLib could not be correctly initialized.\n= ")); + return RETURN_SUCCESS; +} diff --git a/ArmPkg/Library/ArmFwTrngLib/ArmFwTrngLib.inf b/ArmPkg/Library/= ArmFwTrngLib/ArmFwTrngLib.inf new file mode 100644 index 000000000000..baeb00d832fd --- /dev/null +++ b/ArmPkg/Library/ArmFwTrngLib/ArmFwTrngLib.inf @@ -0,0 +1,29 @@ +## @file +# Arm Firmware TRNG interface library. +# +# Copyright (c) 2021 - 2022, Arm Limited. All rights reserved.
+# +# SPDX-License-Identifier: BSD-2-Clause-Patent +## + +[Defines] + INF_VERSION =3D 0x0001001B + BASE_NAME =3D ArmFwTrngLib + FILE_GUID =3D 10DE97C9-28E4-4C9B-A53E-8D7D1B0DD4E0 + VERSION_STRING =3D 1.0 + MODULE_TYPE =3D BASE + LIBRARY_CLASS =3D TrngLib + CONSTRUCTOR =3D ArmFwTrngLibConstructor + +[Sources] + ArmFwTrngDefs.h + ArmFwTrngLib.c + +[Packages] + ArmPkg/ArmPkg.dec + MdePkg/MdePkg.dec + +[LibraryClasses] + ArmMonitorLib + BaseLib + BaseMemoryLib --=20 2.25.1 -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#93951): https://edk2.groups.io/g/devel/message/93951 Mute This Topic: https://groups.io/mt/93788875/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- From nobody Fri Apr 19 21:37:27 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) client-ip=66.175.222.108; envelope-from=bounce+27952+93952+1787277+3901457@groups.io; helo=mail02.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+93952+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=arm.com ARC-Seal: i=1; a=rsa-sha256; t=1663615365; cv=none; d=zohomail.com; s=zohoarc; b=E7f/7toY6rrLuIFzrOi7fURvNfmJ3Xcc+GaESYP8/Jc/Vtqh6iXC9Ub2fseNPliGvd4ZJVW740VE+jcZtRmBZtlHIEf/PFMDcna1EoQqNuYpwEra6A4o9zVioVdA+/BEamyXQLu5iI6cCsvonZ9XMOyTGcm74YVesa1ewVtRGm4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1663615365; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:References:Sender:Subject:To; bh=7VCOHkl9z8dRutoqCtnyvKs7SeTL4E4FXUHERvSsRuc=; b=Hx+T2mfiHx25CHCU+QGIKrvK5LC89omFZuFP5VRXPWRW1biaYQEsJ/ZTzd4M9I/Rqe8RnhA0mFBx5fja2Uu3fwZObXTox7BVnUD/VJjneHoTK77mdPpk8W3BTIA3Np9glBKmiYFc3o+4OZG2I/+kfVlS+eJGH4Zp8w1v77G5Ttk= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+93952+1787277+3901457@groups.io; dmarc=fail header.from= (p=none dis=none) Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by mx.zohomail.com with SMTPS id 166361536592537.913335176347914; Mon, 19 Sep 2022 12:22:45 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id kDHIYY1788612x7kdnKYsF0D; Mon, 19 Sep 2022 12:22:45 -0700 X-Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by mx.groups.io with SMTP id smtpd.web11.3348.1663615364940235346 for ; Mon, 19 Sep 2022 12:22:45 -0700 X-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 24E71143D; Mon, 19 Sep 2022 12:22:51 -0700 (PDT) X-Received: from pierre123.arm.com (unknown [172.31.20.19]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id CB1303F73B; Mon, 19 Sep 2022 12:22:42 -0700 (PDT) From: "PierreGondois" To: devel@edk2.groups.io Cc: Sami Mujawar , Leif Lindholm , Ard Biesheuvel , Rebecca Cran , Michael D Kinney , Liming Gao , Jiewen Yao , Jian J Wang Subject: [edk2-devel] [PATCH v5 09/21] MdePkg/BaseRngLib: Rename ArmReadIdIsar0() to ArmGetFeatRng() Date: Mon, 19 Sep 2022 21:21:55 +0200 Message-Id: <20220919192207.637786-10-Pierre.Gondois@arm.com> In-Reply-To: <20220919192207.637786-1-Pierre.Gondois@arm.com> References: <20220919192207.637786-1-Pierre.Gondois@arm.com> MIME-Version: 1.0 Precedence: Bulk List-Unsubscribe: List-Subscribe: List-Help: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,pierre.gondois@arm.com X-Gm-Message-State: V0PRvCvPrQ7qxRu3hO6DbMoIx1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1663615365; bh=/HauOTEIoorIYGvlyedT6k+PfSDXIg7x2UcJ4FkFsW0=; h=Cc:Date:From:Reply-To:Subject:To; b=i+9e7zl2HFsVFWq3kYmB3NdK+aAk5VSvsRrQkuO1Alc4MkjKdol4duPqfyBKQImAz9x bfHUuusi6nZJMX6QBthiBH3Z9F0mjFnGCiTKPo4XQuHXVgEDOQ6noVxo6q2Gm0D8r0nkD o6iXLJEO/u8hxsaXnl+NiJ4U1HsslaJliRQ= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1663615366912100010 Content-Type: text/plain; charset="utf-8" From: Pierre Gondois The MdePkg must be self contained and not have external dependencies. ArmReadIdIsar0() is defined in MdePkg/Library/BaseRngLib and is limited to the scope of this library. The same function will be required to check the FEAT_AES and FEAT_RNG extensions in other libraries. As this function is Arm specific, it cannot be added to a library interface in MdePkg. It should be part of ArmPkg/ArmLib. To avoid having mutiple definitions/prototypes of ArmReadIdIsar0(), and as BaseRngLib only requires to check the RNG capability bits, rename the MdePkg/Library/BaseRngLib implementation to ArmGetFeatRng(). Signed-off-by: Pierre Gondois --- .../AArch64/{ArmReadIdIsar0.S =3D> ArmGetFeatRng.S} | 8 ++++---- .../AArch64/{ArmReadIdIsar0.asm =3D> ArmGetFeatRng.asm} | 8 ++++---- MdePkg/Library/BaseRngLib/AArch64/ArmRng.h | 2 +- MdePkg/Library/BaseRngLib/AArch64/Rndr.c | 2 +- MdePkg/Library/BaseRngLib/BaseRngLib.inf | 4 ++-- 5 files changed, 12 insertions(+), 12 deletions(-) rename MdePkg/Library/BaseRngLib/AArch64/{ArmReadIdIsar0.S =3D> ArmGetFeat= Rng.S} (78%) rename MdePkg/Library/BaseRngLib/AArch64/{ArmReadIdIsar0.asm =3D> ArmGetFe= atRng.asm} (81%) diff --git a/MdePkg/Library/BaseRngLib/AArch64/ArmReadIdIsar0.S b/MdePkg/Li= brary/BaseRngLib/AArch64/ArmGetFeatRng.S similarity index 78% rename from MdePkg/Library/BaseRngLib/AArch64/ArmReadIdIsar0.S rename to MdePkg/Library/BaseRngLib/AArch64/ArmGetFeatRng.S index 82a00d362212..c42d60513077 100644 --- a/MdePkg/Library/BaseRngLib/AArch64/ArmReadIdIsar0.S +++ b/MdePkg/Library/BaseRngLib/AArch64/ArmGetFeatRng.S @@ -1,6 +1,6 @@ #-------------------------------------------------------------------------= ----- # -# ArmReadIdIsar0() for AArch64 +# ArmGetFeatRng() for AArch64 # # Copyright (c) 2021, NUVIA Inc. All rights reserved.
# @@ -10,7 +10,7 @@ =20 .text .p2align 2 -GCC_ASM_EXPORT(ArmReadIdIsar0) +GCC_ASM_EXPORT(ArmGetFeatRng) =20 #/** # Reads the ID_AA64ISAR0 Register. @@ -20,11 +20,11 @@ GCC_ASM_EXPORT(ArmReadIdIsar0) #**/ #UINT64 #EFIAPI -#ArmReadIdIsar0 ( +#ArmGetFeatRng ( # VOID # ); # -ASM_PFX(ArmReadIdIsar0): +ASM_PFX(ArmGetFeatRng): mrs x0, id_aa64isar0_el1 // Read ID_AA64ISAR0 Register ret =20 diff --git a/MdePkg/Library/BaseRngLib/AArch64/ArmReadIdIsar0.asm b/MdePkg/= Library/BaseRngLib/AArch64/ArmGetFeatRng.asm similarity index 81% rename from MdePkg/Library/BaseRngLib/AArch64/ArmReadIdIsar0.asm rename to MdePkg/Library/BaseRngLib/AArch64/ArmGetFeatRng.asm index 1d9f9a808c0c..947adfcd2749 100644 --- a/MdePkg/Library/BaseRngLib/AArch64/ArmReadIdIsar0.asm +++ b/MdePkg/Library/BaseRngLib/AArch64/ArmGetFeatRng.asm @@ -1,6 +1,6 @@ ;-------------------------------------------------------------------------= ----- ; -; ArmReadIdIsar0() for AArch64 +; ArmGetFeatRng() for AArch64 ; ; Copyright (c) 2021, NUVIA Inc. All rights reserved.
; @@ -8,7 +8,7 @@ ; ;-------------------------------------------------------------------------= ----- =20 - EXPORT ArmReadIdIsar0 + EXPORT ArmGetFeatRng AREA BaseLib_LowLevel, CODE, READONLY =20 ;/** @@ -19,11 +19,11 @@ ;**/ ;UINT64 ;EFIAPI -;ArmReadIdIsar0 ( +;ArmGetFeatRng ( ; VOID ; ); ; -ArmReadIdIsar0 +ArmGetFeatRng mrs x0, id_aa64isar0_el1 // Read ID_AA64ISAR0 Register ret =20 diff --git a/MdePkg/Library/BaseRngLib/AArch64/ArmRng.h b/MdePkg/Library/Ba= seRngLib/AArch64/ArmRng.h index 2d6ef48ab941..b35cba3c063a 100644 --- a/MdePkg/Library/BaseRngLib/AArch64/ArmRng.h +++ b/MdePkg/Library/BaseRngLib/AArch64/ArmRng.h @@ -35,7 +35,7 @@ ArmRndr ( **/ UINT64 EFIAPI -ArmReadIdIsar0 ( +ArmGetFeatRng ( VOID ); =20 diff --git a/MdePkg/Library/BaseRngLib/AArch64/Rndr.c b/MdePkg/Library/Base= RngLib/AArch64/Rndr.c index 20811bf3ebf3..0cfdf4c37149 100644 --- a/MdePkg/Library/BaseRngLib/AArch64/Rndr.c +++ b/MdePkg/Library/BaseRngLib/AArch64/Rndr.c @@ -47,7 +47,7 @@ BaseRngLibConstructor ( // Determine RNDR support by examining bits 63:60 of the ISAR0 register = returned by // MSR. A non-zero value indicates that the processor supports the RNDR = instruction. // - Isar0 =3D ArmReadIdIsar0 (); + Isar0 =3D ArmGetFeatRng (); ASSERT ((Isar0 & RNDR_MASK) !=3D 0); =20 mRndrSupported =3D ((Isar0 & RNDR_MASK) !=3D 0); diff --git a/MdePkg/Library/BaseRngLib/BaseRngLib.inf b/MdePkg/Library/Base= RngLib/BaseRngLib.inf index 1fcceb941495..d6eccb07d469 100644 --- a/MdePkg/Library/BaseRngLib/BaseRngLib.inf +++ b/MdePkg/Library/BaseRngLib/BaseRngLib.inf @@ -37,10 +37,10 @@ [Sources.AARCH64] AArch64/Rndr.c AArch64/ArmRng.h =20 - AArch64/ArmReadIdIsar0.S | GCC + AArch64/ArmGetFeatRng.S | GCC AArch64/ArmRng.S | GCC =20 - AArch64/ArmReadIdIsar0.asm | MSFT + AArch64/ArmGetFeatRng.asm | MSFT AArch64/ArmRng.asm | MSFT =20 [Packages] --=20 2.25.1 -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#93952): https://edk2.groups.io/g/devel/message/93952 Mute This Topic: https://groups.io/mt/93788880/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- From nobody Fri Apr 19 21:37:27 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) client-ip=66.175.222.108; envelope-from=bounce+27952+93953+1787277+3901457@groups.io; helo=mail02.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+93953+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=arm.com ARC-Seal: i=1; a=rsa-sha256; t=1663615368; cv=none; d=zohomail.com; s=zohoarc; b=RXd+GSb/L0ygveX6/fcpbvRvurmZlIoKXODgisURshCt8jUM4AXPETdVnlmtuAfsn2fAOo+4jWvPjQ3TewjDdmXZjjsfH+4KPAMFzUGuTIcTz+tk/chrGMgNxnYtGv+s6+F8XAQVWbvF2S7gXf7iuItybAKYJaEAXKFkCZIagC8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1663615368; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:References:Sender:Subject:To; bh=kmy0hQX6oq2pNsR0DDg1k15cqTxZw9RgrhDj5c9rhUk=; b=k8g/aa4tjf/ItQGXPfwWeMldJuIRH8r/BWc9ZZQeqdLmP9P5B+11OY/bdhDMUkYALrYMUwrVMh1fPUyTzotd7sf+QvQPttjzWyMtbzYneD4lv8owtGeYLQjTu2Llp3PF9pSS5JjskhHwrSlRRm57VsozOfxJt5ywkiywOMGdLVc= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+93953+1787277+3901457@groups.io; dmarc=fail header.from= (p=none dis=none) Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by mx.zohomail.com with SMTPS id 1663615368441831.6696419253631; Mon, 19 Sep 2022 12:22:48 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id UfrJYY1788612xcqAYLijqDj; Mon, 19 Sep 2022 12:22:48 -0700 X-Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by mx.groups.io with SMTP id smtpd.web11.3349.1663615367374730161 for ; Mon, 19 Sep 2022 12:22:47 -0700 X-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 7D5AE1BF3; Mon, 19 Sep 2022 12:22:53 -0700 (PDT) X-Received: from pierre123.arm.com (unknown [172.31.20.19]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id E03DD3F73B; Mon, 19 Sep 2022 12:22:44 -0700 (PDT) From: "PierreGondois" To: devel@edk2.groups.io Cc: Sami Mujawar , Leif Lindholm , Ard Biesheuvel , Rebecca Cran , Michael D Kinney , Liming Gao , Jiewen Yao , Jian J Wang Subject: [edk2-devel] [PATCH v5 10/21] ArmPkg/ArmLib: Add ArmReadIdIsar0() helper Date: Mon, 19 Sep 2022 21:21:56 +0200 Message-Id: <20220919192207.637786-11-Pierre.Gondois@arm.com> In-Reply-To: <20220919192207.637786-1-Pierre.Gondois@arm.com> References: <20220919192207.637786-1-Pierre.Gondois@arm.com> MIME-Version: 1.0 Precedence: Bulk List-Unsubscribe: List-Subscribe: List-Help: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,pierre.gondois@arm.com X-Gm-Message-State: kR7U02iVAxXZX6j5o1BOJMy3x1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1663615368; bh=NdXZ5NigMmGWzJNIcCmlQphhsfPs/5Ghu9tjIbI8f2I=; h=Cc:Date:From:Reply-To:Subject:To; b=wrZigTDarZk8aYSEu8QQ/utP6ChwXW7G72YMjOkNRtzLpY8wLuu4BIGzyWl3qBEJJej Py1MLgdkQYuaTyAGujeLat00gbsKqbHViyX5fDlEjxbNK8VBA8sRW8d6snAxr1/fR9of3 azPWaTIymaxq5J+KltyI2nKDOdDhvQ+jjag= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1663615368884100013 Content-Type: text/plain; charset="utf-8" From: Pierre Gondois Add a ArmReadIdIsar0() helper function to access the AArch64 ID_ISAR0_EL1 register. Signed-off-by: Pierre Gondois --- ArmPkg/Library/ArmLib/AArch64/AArch64Lib.h | 12 +++++++++++- ArmPkg/Library/ArmLib/AArch64/AArch64Support.S | 7 ++++++- 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/ArmPkg/Library/ArmLib/AArch64/AArch64Lib.h b/ArmPkg/Library/Ar= mLib/AArch64/AArch64Lib.h index 330481fc50db..105a52ee16fe 100644 --- a/ArmPkg/Library/ArmLib/AArch64/AArch64Lib.h +++ b/ArmPkg/Library/ArmLib/AArch64/AArch64Lib.h @@ -1,7 +1,7 @@ /** @file =20 Copyright (c) 2008 - 2009, Apple Inc. All rights reserved.
- Portions Copyright (c) 2011 - 2013, ARM Ltd. All rights reserved.
+ Portions Copyright (c) 2011 - 2022, Arm Ltd. All rights reserved.
Copyright (c) 2020, NUVIA Inc. All rights reserved.
=20 SPDX-License-Identifier: BSD-2-Clause-Patent @@ -54,4 +54,14 @@ ArmReadIdAA64Mmfr2 ( VOID ); =20 +/** Reads the ID_ISAR0_EL1 register. + + @return The contents of the ID_ISAR0_EL1 register. +**/ +UINTN +EFIAPI +ArmReadIdIsar0 ( + VOID + ); + #endif // AARCH64_LIB_H_ diff --git a/ArmPkg/Library/ArmLib/AArch64/AArch64Support.S b/ArmPkg/Librar= y/ArmLib/AArch64/AArch64Support.S index d3cc1e86716b..baba283d01b9 100644 --- a/ArmPkg/Library/ArmLib/AArch64/AArch64Support.S +++ b/ArmPkg/Library/ArmLib/AArch64/AArch64Support.S @@ -1,7 +1,7 @@ #-------------------------------------------------------------------------= ----- # # Copyright (c) 2008 - 2010, Apple Inc. All rights reserved.
-# Copyright (c) 2011 - 2017, ARM Limited. All rights reserved. +# Copyright (c) 2011 - 2022, Arm Limited. All rights reserved. # Copyright (c) 2016, Linaro Limited. All rights reserved. # Copyright (c) 2020, NUVIA Inc. All rights reserved. # @@ -482,4 +482,9 @@ ASM_FUNC(ArmWriteCntHctl) msr cnthctl_el2, x0 ret =20 +// UINTN ArmReadIdIsar0(VOID) +ASM_FUNC(ArmReadIdIsar0) + mrs x0, id_aa64isar0_el1 + ret + ASM_FUNCTION_REMOVE_IF_UNREFERENCED --=20 2.25.1 -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#93953): https://edk2.groups.io/g/devel/message/93953 Mute This Topic: https://groups.io/mt/93788881/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- From nobody Fri Apr 19 21:37:27 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) client-ip=66.175.222.108; envelope-from=bounce+27952+93954+1787277+3901457@groups.io; helo=mail02.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+93954+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=arm.com ARC-Seal: i=1; a=rsa-sha256; t=1663615371; cv=none; d=zohomail.com; s=zohoarc; b=bEsCpxA/Pn3gKeTuzjomPxsSGC8BmQ4R6kkrFI3gNFCbW2IPntDvwsc02aTKiMX1g0mPaeb6VJEwg5jtuNBhon4LpTvwuRjm8CdCAzgCgbzFceow+abhG20NsaJVs2uwxMQHjRNVnSNtcHCD5NYwnuZZF6FDl9ly+8siDgSfcAc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1663615371; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:References:Sender:Subject:To; bh=l/yn6J0C4I4oUL//W9libXhPFwWe6DkSJD3T7HRWX+A=; b=BTP2KkPdB8/G2UWOTZKD38Yrf5UtjthJpuAgHXmgGS+Y7dCKm5B98VXVTF339E/Kn0GE6GXbZ5B9J0C50BN3pIdlyACNz+j/HVQqJcXteD+/tuFmkUj6zcwg1jyyIYf52R8DAE9QKqcgO9Q7/xd8JUG9ew7ajcDCp5CVns8Rz9c= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+93954+1787277+3901457@groups.io; dmarc=fail header.from= (p=none dis=none) Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by mx.zohomail.com with SMTPS id 1663615371099886.0225532091167; Mon, 19 Sep 2022 12:22:51 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id 6zQzYY1788612xJlkJoEjAwo; Mon, 19 Sep 2022 12:22:50 -0700 X-Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by mx.groups.io with SMTP id smtpd.web10.3212.1663615369997603694 for ; Mon, 19 Sep 2022 12:22:50 -0700 X-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 22D311424; Mon, 19 Sep 2022 12:22:56 -0700 (PDT) X-Received: from pierre123.arm.com (unknown [172.31.20.19]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 641823F73B; Mon, 19 Sep 2022 12:22:47 -0700 (PDT) From: "PierreGondois" To: devel@edk2.groups.io Cc: Sami Mujawar , Leif Lindholm , Ard Biesheuvel , Rebecca Cran , Michael D Kinney , Liming Gao , Jiewen Yao , Jian J Wang Subject: [edk2-devel] [PATCH v5 11/21] ArmPkg/ArmLib: Add ArmHasRngExt() Date: Mon, 19 Sep 2022 21:21:57 +0200 Message-Id: <20220919192207.637786-12-Pierre.Gondois@arm.com> In-Reply-To: <20220919192207.637786-1-Pierre.Gondois@arm.com> References: <20220919192207.637786-1-Pierre.Gondois@arm.com> MIME-Version: 1.0 Precedence: Bulk List-Unsubscribe: List-Subscribe: List-Help: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,pierre.gondois@arm.com X-Gm-Message-State: evnBKJUT2Wf8ojXJamXyHAyhx1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1663615370; bh=mPcS+iHxxVXlI+TUgGFWE323FdR2aocxvpq+7ocT5EY=; h=Cc:Date:From:Reply-To:Subject:To; b=lCMw4qXgOm73wduc0MFYUe1uSmPxYzNu6EXMCi0Ni5eTz1kBrc8FwG+smkN1Q3Hxm1K Y0xlBmRrJq1X8jN7qOvW9SanS7jig5O+vdrj7SYp2Fz1YKpqvi/19FeJigoLcRXOq5Gby OOLop1FJO86xhoAIW551B2Ueoh9TyPUGSKc= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1663615372917100002 Content-Type: text/plain; charset="utf-8" From: Pierre Gondois Add a ArmHasRngExt() to check for the FEAT_RNG extension. Also add a mask for the RNDR bits. Signed-off-by: Pierre Gondois --- ArmPkg/Include/Library/ArmLib.h | 12 +++++++++++- ArmPkg/Library/ArmLib/AArch64/AArch64Lib.c | 15 ++++++++++++++- ArmPkg/Library/ArmLib/AArch64/AArch64Lib.h | 2 ++ ArmPkg/Library/ArmLib/Arm/ArmV7Lib.c | 16 +++++++++++++++- 4 files changed, 42 insertions(+), 3 deletions(-) diff --git a/ArmPkg/Include/Library/ArmLib.h b/ArmPkg/Include/Library/ArmLi= b.h index 6566deebdde2..8058634dbc53 100644 --- a/ArmPkg/Include/Library/ArmLib.h +++ b/ArmPkg/Include/Library/ArmLib.h @@ -1,7 +1,7 @@ /** @file =20 Copyright (c) 2008 - 2009, Apple Inc. All rights reserved.
- Copyright (c) 2011 - 2016, ARM Ltd. All rights reserved.
+ Copyright (c) 2011 - 2022, Arm Limited. All rights reserved.
Copyright (c) 2020 - 2021, NUVIA Inc. All rights reserved.
=20 SPDX-License-Identifier: BSD-2-Clause-Patent @@ -769,6 +769,16 @@ ArmHasCcidx ( VOID ); =20 +/** Check if FEAT_RNG extension is available. + + @retval TRUE if FEAT_RNG extension is available. + @retval FALSE otherwise. +**/ +BOOLEAN +ArmHasRngExt ( + VOID + ); + #ifdef MDE_CPU_ARM /// /// AArch32-only ID Register Helper functions diff --git a/ArmPkg/Library/ArmLib/AArch64/AArch64Lib.c b/ArmPkg/Library/Ar= mLib/AArch64/AArch64Lib.c index 7ab28e3e05fe..124b28e16874 100644 --- a/ArmPkg/Library/ArmLib/AArch64/AArch64Lib.c +++ b/ArmPkg/Library/ArmLib/AArch64/AArch64Lib.c @@ -1,7 +1,7 @@ /** @file =20 Copyright (c) 2008 - 2009, Apple Inc. All rights reserved.
- Portions copyright (c) 2011 - 2014, ARM Ltd. All rights reserved.
+ Portions copyright (c) 2011 - 2022, Arm Limited. All rights reserved.
Copyright (c) 2021, NUVIA Inc. All rights reserved.
=20 SPDX-License-Identifier: BSD-2-Clause-Patent @@ -104,3 +104,16 @@ ArmHasCcidx ( Mmfr2 =3D ArmReadIdAA64Mmfr2 (); return (((Mmfr2 >> 20) & 0xF) =3D=3D 1) ? TRUE : FALSE; } + +/** Check if FEAT_RNG extension is available. + + @retval TRUE if FEAT_RNG extension is available. + @retval FALSE otherwise. +**/ +BOOLEAN +ArmHasRngExt ( + VOID + ) +{ + return ArmReadIdIsar0 () & ID_AA64ISAR0_EL1_RNDR_MASK; +} diff --git a/ArmPkg/Library/ArmLib/AArch64/AArch64Lib.h b/ArmPkg/Library/Ar= mLib/AArch64/AArch64Lib.h index 105a52ee16fe..61a775ea27e8 100644 --- a/ArmPkg/Library/ArmLib/AArch64/AArch64Lib.h +++ b/ArmPkg/Library/ArmLib/AArch64/AArch64Lib.h @@ -11,6 +11,8 @@ #ifndef AARCH64_LIB_H_ #define AARCH64_LIB_H_ =20 +#define ID_AA64ISAR0_EL1_RNDR_MASK ((UINT64)0xF << 60U) + typedef VOID (*AARCH64_CACHE_OPERATION)( UINTN ); diff --git a/ArmPkg/Library/ArmLib/Arm/ArmV7Lib.c b/ArmPkg/Library/ArmLib/A= rm/ArmV7Lib.c index 521d5be0de33..a4ec23c8f8d8 100644 --- a/ArmPkg/Library/ArmLib/Arm/ArmV7Lib.c +++ b/ArmPkg/Library/ArmLib/Arm/ArmV7Lib.c @@ -1,7 +1,7 @@ /** @file =20 Copyright (c) 2008 - 2009, Apple Inc. All rights reserved.
- Copyright (c) 2011 - 2014, ARM Limited. All rights reserved. + Copyright (c) 2011 - 2022, Arm Limited. All rights reserved. Copyright (c) 2021, NUVIA Inc. All rights reserved.
=20 SPDX-License-Identifier: BSD-2-Clause-Patent @@ -119,3 +119,17 @@ ArmHasCcidx ( Mmfr4 =3D ArmReadIdMmfr4 (); return (((Mmfr4 >> 24) & 0xF) =3D=3D 1) ? TRUE : FALSE; } + +/** Check if FEAT_RNG extension is available. + + @retval TRUE if FEAT_RNG extension is available. + @retval FALSE otherwise. +**/ +BOOLEAN +ArmHasRngExt ( + VOID + ) +{ + // Not supported. + return FALSE; +} --=20 2.25.1 -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#93954): https://edk2.groups.io/g/devel/message/93954 Mute This Topic: https://groups.io/mt/93788882/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- From nobody Fri Apr 19 21:37:27 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) client-ip=66.175.222.108; envelope-from=bounce+27952+93955+1787277+3901457@groups.io; helo=mail02.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+93955+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=arm.com ARC-Seal: i=1; a=rsa-sha256; t=1663615373; cv=none; d=zohomail.com; s=zohoarc; b=nhDemVBa2auTxdCIUkCOHM9y2kGE+SUYANCC6Te7++OPv96MwraIcmw9EgSoSJVtTYY34QM5de6vV6KLQ6z00FJy0FZEILNqmkb1ARMyT7/UCmffnYV14fYBKDLmnz3OuYB/ksaR/aS6xED+9MQRh8/1QEWfvlid4UYTcTLcCj0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1663615373; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:References:Sender:Subject:To; bh=jLzRbn8N1Xpia5d3/TK+u5OQMS/nw6WGurOVHeNQ5qE=; b=f3Yy3RyadF81uN7oaNYqWVnjlALPy30K06+9Er1ncl6G+4GDgtcivty4PvDCKfTkbBUJ/9kTNmjCKG7cc2deRB3J7r3jg1ZKKy902ylPAdrr/F254SNNHroMFlwsckHjVLy1yAYKuPUObOWt8zHpv86syYDXYFV17HZUj4Nogmk= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+93955+1787277+3901457@groups.io; dmarc=fail header.from= (p=none dis=none) Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by mx.zohomail.com with SMTPS id 1663615373880786.3517312989884; Mon, 19 Sep 2022 12:22:53 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id vY9HYY1788612xZQTuGcQKqK; Mon, 19 Sep 2022 12:22:53 -0700 X-Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by mx.groups.io with SMTP id smtpd.web12.3263.1663615372841360860 for ; Mon, 19 Sep 2022 12:22:53 -0700 X-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 11A77143D; Mon, 19 Sep 2022 12:22:59 -0700 (PDT) X-Received: from pierre123.arm.com (unknown [172.31.20.19]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 194523F73B; Mon, 19 Sep 2022 12:22:49 -0700 (PDT) From: "PierreGondois" To: devel@edk2.groups.io Cc: Sami Mujawar , Leif Lindholm , Ard Biesheuvel , Rebecca Cran , Michael D Kinney , Liming Gao , Jiewen Yao , Jian J Wang Subject: [edk2-devel] [PATCH v5 12/21] SecurityPkg/RngDxe: Rename RdRandGenerateEntropy to generic name Date: Mon, 19 Sep 2022 21:21:58 +0200 Message-Id: <20220919192207.637786-13-Pierre.Gondois@arm.com> In-Reply-To: <20220919192207.637786-1-Pierre.Gondois@arm.com> References: <20220919192207.637786-1-Pierre.Gondois@arm.com> MIME-Version: 1.0 Precedence: Bulk List-Unsubscribe: List-Subscribe: List-Help: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,pierre.gondois@arm.com X-Gm-Message-State: K8EQaOEy9a6OnN4cc0pC4tcLx1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1663615373; bh=rbjkqLXhD6ktd9tUYLEWwAdR0MNkTPf691k0QZ3mTr4=; h=Cc:Date:From:Reply-To:Subject:To; b=oTmXlciPqgzL2qMk21DZa5nwF+EWtGg4S71p3ke0IdN/d+droKllTZyU/Bz1Iq/nf2t KtyBzdecNfh9laWHE5rZOpa+QQDi11Q1bLjoZiHf6A9sWVwABRFqbdIMGOF1R2X+NUyF/ BBc+BLAZ5sIrNl/XoT14JeU0M5Ul3yFVH28= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1663615374935100005 Content-Type: text/plain; charset="utf-8" From: Sami Mujawar Bugzilla: 3668 (https://bugzilla.tianocore.org/show_bug.cgi?id=3D3668) Rename RdRandGenerateEntropy() to GenerateEntropy() to provide a common interface to generate entropy on other architectures. GenerateEntropy() is intended to generate high quality entropy. Also move the definition to RngDxeInternals.h Signed-off-by: Sami Mujawar --- .../RngDxe/Rand/RdRand.c | 14 ++++-- .../RngDxe/Rand/RdRand.h | 43 ------------------- .../RngDxe/Rand/RngDxe.c | 7 ++- .../RandomNumberGenerator/RngDxe/RngDxe.inf | 2 +- .../RngDxe/RngDxeInternals.h | 19 ++++++++ 5 files changed, 36 insertions(+), 49 deletions(-) delete mode 100644 SecurityPkg/RandomNumberGenerator/RngDxe/Rand/RdRand.h diff --git a/SecurityPkg/RandomNumberGenerator/RngDxe/Rand/RdRand.c b/Secur= ityPkg/RandomNumberGenerator/RngDxe/Rand/RdRand.c index 5b6644138231..4b011c7e8e49 100644 --- a/SecurityPkg/RandomNumberGenerator/RngDxe/Rand/RdRand.c +++ b/SecurityPkg/RandomNumberGenerator/RngDxe/Rand/RdRand.c @@ -1,15 +1,23 @@ /** @file - Support routines for RDRAND instruction access. + Support routines for RDRAND instruction access, which will leverage + Intel Secure Key technology to provide high-quality random numbers for u= se + in applications, or entropy for seeding other random number generators. + Refer to http://software.intel.com/en-us/articles/intel-digital-random-n= umber + -generator-drng-software-implementation-guide/ for more information abou= t Intel + Secure Key technology. =20 +Copyright (c) 2021 - 2022, Arm Limited. All rights reserved.
Copyright (c) 2013 - 2018, Intel Corporation. All rights reserved.
(C) Copyright 2015 Hewlett Packard Enterprise Development LP
SPDX-License-Identifier: BSD-2-Clause-Patent =20 **/ +#include +#include #include +#include =20 #include "AesCore.h" -#include "RdRand.h" #include "RngDxeInternals.h" =20 /** @@ -87,7 +95,7 @@ RdRandGetSeed128 ( **/ EFI_STATUS EFIAPI -RdRandGenerateEntropy ( +GenerateEntropy ( IN UINTN Length, OUT UINT8 *Entropy ) diff --git a/SecurityPkg/RandomNumberGenerator/RngDxe/Rand/RdRand.h b/Secur= ityPkg/RandomNumberGenerator/RngDxe/Rand/RdRand.h deleted file mode 100644 index 7fdb6891bd63..000000000000 --- a/SecurityPkg/RandomNumberGenerator/RngDxe/Rand/RdRand.h +++ /dev/null @@ -1,43 +0,0 @@ -/** @file - Header for the RDRAND APIs used by RNG DXE driver. - - Support API definitions for RDRAND instruction access, which will levera= ge - Intel Secure Key technology to provide high-quality random numbers for u= se - in applications, or entropy for seeding other random number generators. - Refer to http://software.intel.com/en-us/articles/intel-digital-random-n= umber - -generator-drng-software-implementation-guide/ for more information abou= t Intel - Secure Key technology. - -Copyright (c) 2013, Intel Corporation. All rights reserved.
-(C) Copyright 2015 Hewlett Packard Enterprise Development LP
-SPDX-License-Identifier: BSD-2-Clause-Patent - -**/ - -#ifndef __RD_RAND_H__ -#define __RD_RAND_H__ - -#include -#include -#include -#include -#include - -/** - Generate high-quality entropy source through RDRAND. - - @param[in] Length Size of the buffer, in bytes, to fill with. - @param[out] Entropy Pointer to the buffer to store the entropy da= ta. - - @retval EFI_SUCCESS Entropy generation succeeded. - @retval EFI_NOT_READY Failed to request random data. - -**/ -EFI_STATUS -EFIAPI -RdRandGenerateEntropy ( - IN UINTN Length, - OUT UINT8 *Entropy - ); - -#endif // __RD_RAND_H__ diff --git a/SecurityPkg/RandomNumberGenerator/RngDxe/Rand/RngDxe.c b/Secur= ityPkg/RandomNumberGenerator/RngDxe/Rand/RngDxe.c index 2df4ed44329a..8d44f0636c3d 100644 --- a/SecurityPkg/RandomNumberGenerator/RngDxe/Rand/RngDxe.c +++ b/SecurityPkg/RandomNumberGenerator/RngDxe/Rand/RngDxe.c @@ -14,13 +14,16 @@ - EFI_RNG_ALGORITHM_X9_31_3DES_GUID - Unsupported - EFI_RNG_ALGORITHM_X9_31_AES_GUID - Unsupported =20 + Copyright (c) 2021 - 2022, Arm Limited. All rights reserved.
Copyright (c) 2013 - 2018, Intel Corporation. All rights reserved.
(C) Copyright 2015 Hewlett Packard Enterprise Development LP
SPDX-License-Identifier: BSD-2-Clause-Patent =20 **/ =20 -#include "RdRand.h" +#include +#include + #include "RngDxeInternals.h" =20 /** @@ -88,7 +91,7 @@ RngGetRNG ( return EFI_INVALID_PARAMETER; } =20 - Status =3D RdRandGenerateEntropy (RNGValueLength, RNGValue); + Status =3D GenerateEntropy (RNGValueLength, RNGValue); return Status; } =20 diff --git a/SecurityPkg/RandomNumberGenerator/RngDxe/RngDxe.inf b/Security= Pkg/RandomNumberGenerator/RngDxe/RngDxe.inf index f3300971993f..60efb5562ee0 100644 --- a/SecurityPkg/RandomNumberGenerator/RngDxe/RngDxe.inf +++ b/SecurityPkg/RandomNumberGenerator/RngDxe/RngDxe.inf @@ -10,6 +10,7 @@ # # Copyright (c) 2013 - 2018, Intel Corporation. All rights reserved.
# (C) Copyright 2015 Hewlett Packard Enterprise Development LP
+# Copyright (c) 2021 - 2022, Arm Limited. All rights reserved.
# SPDX-License-Identifier: BSD-2-Clause-Patent # ## @@ -36,7 +37,6 @@ [Sources.common] [Sources.IA32, Sources.X64] Rand/RngDxe.c Rand/RdRand.c - Rand/RdRand.h Rand/AesCore.c Rand/AesCore.h =20 diff --git a/SecurityPkg/RandomNumberGenerator/RngDxe/RngDxeInternals.h b/S= ecurityPkg/RandomNumberGenerator/RngDxe/RngDxeInternals.h index 224d8bd4ea5f..48d2d27c1608 100644 --- a/SecurityPkg/RandomNumberGenerator/RngDxe/RngDxeInternals.h +++ b/SecurityPkg/RandomNumberGenerator/RngDxe/RngDxeInternals.h @@ -10,6 +10,8 @@ #ifndef RNGDXE_INTERNALS_H_ #define RNGDXE_INTERNALS_H_ =20 +#include + /** Returns information about the random number generation implementation. =20 @@ -114,4 +116,21 @@ RngGetBytes ( OUT UINT8 *RandBuffer ); =20 +/** + Generate high-quality entropy source using a TRNG or through RDRAND. + + @param[in] Length Size of the buffer, in bytes, to fill with. + @param[out] Entropy Pointer to the buffer to store the entropy da= ta. + + @retval EFI_SUCCESS Entropy generation succeeded. + @retval EFI_NOT_READY Failed to request random data. + +**/ +EFI_STATUS +EFIAPI +GenerateEntropy ( + IN UINTN Length, + OUT UINT8 *Entropy + ); + #endif // RNGDXE_INTERNALS_H_ --=20 2.25.1 -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#93955): https://edk2.groups.io/g/devel/message/93955 Mute This Topic: https://groups.io/mt/93788883/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- From nobody Fri Apr 19 21:37:27 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) client-ip=66.175.222.108; envelope-from=bounce+27952+93956+1787277+3901457@groups.io; helo=mail02.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+93956+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=arm.com ARC-Seal: i=1; a=rsa-sha256; t=1663615376; cv=none; d=zohomail.com; s=zohoarc; b=R4NtodW8TidvW000W0b+DugTxL+eXd56PaMaBULE5nBspdU+uxf68b31hQQ0sp3wbczKB8ZxeOslF/69axQctptcsH36lkiuo5mTZb2n96CusoIR9cyR2ZMhbyrFknmIB2QbeGbCgYh8JDu4Fq+nU/r/YpzJ5fEzbSIcPZoGTZ8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1663615376; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:References:Sender:Subject:To; bh=nPeMGRQ8cX46Zu7+5tDnXukAFwpiaPKfN8MqusfUBD8=; b=QHp0uYm7NB580lINREXfrGfN7H5pJGdnPeM5OyVtEXw6ocW+Q7jpyM/W8pb3pnXb3DNPiL/DXX6UZjXGAnuaQkjmFq8/Iab3xIuURlw22eV4+ozclsrPagSi0+KHZKSu9Rz9NCulazhvz66Hf+KM//3dJ0Kc/vmcJ1SFgWrizZU= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+93956+1787277+3901457@groups.io; dmarc=fail header.from= (p=none dis=none) Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by mx.zohomail.com with SMTPS id 1663615376863842.0113964783254; Mon, 19 Sep 2022 12:22:56 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id g0TcYY1788612x4ma76Oix6Z; Mon, 19 Sep 2022 12:22:56 -0700 X-Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by mx.groups.io with SMTP id smtpd.web12.3265.1663615375853200553 for ; Mon, 19 Sep 2022 12:22:55 -0700 X-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 0FF581424; Mon, 19 Sep 2022 12:23:02 -0700 (PDT) X-Received: from pierre123.arm.com (unknown [172.31.20.19]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 0517A3F73B; Mon, 19 Sep 2022 12:22:52 -0700 (PDT) From: "PierreGondois" To: devel@edk2.groups.io Cc: Sami Mujawar , Leif Lindholm , Ard Biesheuvel , Rebecca Cran , Michael D Kinney , Liming Gao , Jiewen Yao , Jian J Wang Subject: [edk2-devel] [PATCH v5 13/21] SecurityPkg/RngDxe: Replace Pcd with Sp80090Ctr256Guid Date: Mon, 19 Sep 2022 21:21:59 +0200 Message-Id: <20220919192207.637786-14-Pierre.Gondois@arm.com> In-Reply-To: <20220919192207.637786-1-Pierre.Gondois@arm.com> References: <20220919192207.637786-1-Pierre.Gondois@arm.com> MIME-Version: 1.0 Precedence: Bulk List-Unsubscribe: List-Subscribe: List-Help: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,pierre.gondois@arm.com X-Gm-Message-State: u6sx1iuLQogclf4orOfTnwb3x1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1663615376; bh=kme5c/3uiju5q9G5RcY/aOenjuoHbUR2NHnJ5YidGFU=; h=Cc:Date:From:Reply-To:Subject:To; b=nIou5xNgx2Lk/xhJMef0zeExu+hcG2zVSV8VNX+YGdwtKFopg4hBs136jwl6H+QLLi9 xf9wIMYS+DkPeAUuFuMXNzEe3eUvOXXazfBsWneUEdkuJF6keGWZJZx9c92ydAIqBLNCk 4LdHEgk+d5txppjRGCoWNazsLYMkQZIRFlE= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1663615378951100002 Content-Type: text/plain; charset="utf-8" From: Pierre Gondois gEfiRngAlgorithmSp80090Ctr256Guid was used as the default algorithm in RngGetRNG(). The commit below set the default algorithm to PcdCpuRngSupportedAlgorithm, which is a zero GUID by default. As the Pcd value is not defined for any platform in the edk2-platfoms repository, assume it was an error and go back to the first version, using gEfiRngAlgorithmSp80090Ctr256Guid. Fixes 4e5ecdbac8bd ("SecurityPkg: Add support for RngDxe on AARCH64") Signed-off-by: Pierre Gondois --- SecurityPkg/RandomNumberGenerator/RngDxe/Rand/RngDxe.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/SecurityPkg/RandomNumberGenerator/RngDxe/Rand/RngDxe.c b/Secur= ityPkg/RandomNumberGenerator/RngDxe/Rand/RngDxe.c index 8d44f0636c3d..df7db12b771c 100644 --- a/SecurityPkg/RandomNumberGenerator/RngDxe/Rand/RngDxe.c +++ b/SecurityPkg/RandomNumberGenerator/RngDxe/Rand/RngDxe.c @@ -126,8 +126,7 @@ ArchGetSupportedRngAlgorithms ( OUT EFI_RNG_ALGORITHM *RNGAlgorithmList ) { - UINTN RequiredSize; - EFI_RNG_ALGORITHM *CpuRngSupportedAlgorithm; + UINTN RequiredSize; =20 RequiredSize =3D 2 * sizeof (EFI_RNG_ALGORITHM); =20 @@ -136,9 +135,7 @@ ArchGetSupportedRngAlgorithms ( return EFI_BUFFER_TOO_SMALL; } =20 - CpuRngSupportedAlgorithm =3D PcdGetPtr (PcdCpuRngSupportedAlgorithm); - - CopyMem (&RNGAlgorithmList[0], CpuRngSupportedAlgorithm, sizeof (EFI_RNG= _ALGORITHM)); + CopyMem (&RNGAlgorithmList[0], &gEfiRngAlgorithmSp80090Ctr256Guid, sizeo= f (EFI_RNG_ALGORITHM)); =20 // x86 platforms also support EFI_RNG_ALGORITHM_RAW via RDSEED CopyMem (&RNGAlgorithmList[1], &gEfiRngAlgorithmRaw, sizeof (EFI_RNG_ALG= ORITHM)); --=20 2.25.1 -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#93956): https://edk2.groups.io/g/devel/message/93956 Mute This Topic: https://groups.io/mt/93788885/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- From nobody Fri Apr 19 21:37:27 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) client-ip=66.175.222.108; envelope-from=bounce+27952+93957+1787277+3901457@groups.io; helo=mail02.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+93957+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=arm.com ARC-Seal: i=1; a=rsa-sha256; t=1663615381; cv=none; d=zohomail.com; s=zohoarc; b=jPxJjbIdFJ2fu+CWwr/W9oQ0TnUBnWZlfIJRDzFJVEikJaPnl9/GSREHTyYxjYwcai1F1ga+tYr98V5hapY33MYqc298NTEd4Pd9pTsMvSkfEr7RdaVLyDpCTAnU7GAzU3oeFQ7uZDXz8+EQ0eCScGNUue3q3TIfhasrHNzTzqE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1663615381; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:References:Sender:Subject:To; bh=rVoAZ2RPpWtI7Qkl+ZBzAQTzszRUvf0nol14fTpYRKQ=; b=VqkRWARlPo7FBE2TG9dBf4rtmMtlLKFnEfJ3lY7yY2SpPCZOMFcWUHLMwOpCLTi/R/28yEiN8oLbuGej3TEXV2MHgcQLecJwluROQQK1N47YKzAfXKpY8z7D+r5WH7VcJdy81lBsWoDIxI90uFKzF6LLrSTkWA81WFrnQ57P4ok= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+93957+1787277+3901457@groups.io; dmarc=fail header.from= (p=none dis=none) Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by mx.zohomail.com with SMTPS id 166361538158167.18055006655766; Mon, 19 Sep 2022 12:23:01 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id eqI9YY1788612x0gqegxFj44; Mon, 19 Sep 2022 12:23:00 -0700 X-Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by mx.groups.io with SMTP id smtpd.web10.3216.1663615379432468270 for ; Mon, 19 Sep 2022 12:22:59 -0700 X-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 9D27B1424; Mon, 19 Sep 2022 12:23:05 -0700 (PDT) X-Received: from pierre123.arm.com (unknown [172.31.20.19]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 0B61C3F73B; Mon, 19 Sep 2022 12:22:55 -0700 (PDT) From: "PierreGondois" To: devel@edk2.groups.io Cc: Sami Mujawar , Leif Lindholm , Ard Biesheuvel , Rebecca Cran , Michael D Kinney , Liming Gao , Jiewen Yao , Jian J Wang Subject: [edk2-devel] [PATCH v5 14/21] SecurityPkg/RngDxe: Remove ArchGetSupportedRngAlgorithms() Date: Mon, 19 Sep 2022 21:22:00 +0200 Message-Id: <20220919192207.637786-15-Pierre.Gondois@arm.com> In-Reply-To: <20220919192207.637786-1-Pierre.Gondois@arm.com> References: <20220919192207.637786-1-Pierre.Gondois@arm.com> MIME-Version: 1.0 Precedence: Bulk List-Unsubscribe: List-Subscribe: List-Help: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,pierre.gondois@arm.com X-Gm-Message-State: 4Sdlaevr9t0mUohOaCz56rxFx1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1663615380; bh=q+WQoFquE6/p8gtqj8fDj9CaJo9CHHpc3NtSYlPpw8I=; h=Cc:Date:From:Reply-To:Subject:To; b=DlnMYbeuVJOaLCwqllF5mEQcGeai8YhsAPEETX+VPHGPjejNJTTyfYjXD7wdZPWrWjd 4yUdUoAqAbfJmvTOHxtu4Twcrnl2BT+NdawSsZDUzlt/bBRy+Yr+RnhxIusW8JETYKGhb C5lfU1FSOWt3JVGzUuD7sXVVmqZJTFv1AB8= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1663615382978100007 Content-Type: text/plain; charset="utf-8" From: Pierre Gondois RngGetInfo() is one of the 2 functions of the EFI_RNG_PROTOCOL. RngGetInfo() is currently a mere wrapper around ArchGetSupportedRngAlgorithms() which is implemented differently depending on the architecture used. RngGetInfo() does nothing more than calling ArchGetSupportedRngAlgorithms(). So remove it, and let RngGetInfo() be implemented differently according to the architecture. This follows the implementation of the other function of the EFI_RNG_PROTOCOL, RngGetRNG(). Signed-off-by: Pierre Gondois --- .../RngDxe/AArch64/RngDxe.c | 19 +++++-- .../RngDxe/Rand/RngDxe.c | 22 +++++++-- .../RandomNumberGenerator/RngDxe/RngDxe.c | 49 ------------------- .../RngDxe/RngDxeInternals.h | 25 ---------- 4 files changed, 33 insertions(+), 82 deletions(-) diff --git a/SecurityPkg/RandomNumberGenerator/RngDxe/AArch64/RngDxe.c b/Se= curityPkg/RandomNumberGenerator/RngDxe/AArch64/RngDxe.c index 3daf847d46d3..6d989f7ea376 100644 --- a/SecurityPkg/RandomNumberGenerator/RngDxe/AArch64/RngDxe.c +++ b/SecurityPkg/RandomNumberGenerator/RngDxe/AArch64/RngDxe.c @@ -14,6 +14,7 @@ Copyright (c) 2021, NUVIA Inc. All rights reserved.
Copyright (c) 2013 - 2018, Intel Corporation. All rights reserved.
(C) Copyright 2015 Hewlett Packard Enterprise Development LP
+ Copyright (c) 2021 - 2022, Arm Limited. All rights reserved.
=20 SPDX-License-Identifier: BSD-2-Clause-Patent =20 @@ -85,6 +86,7 @@ RngGetRNG ( /** Returns information about the random number generation implementation. =20 + @param[in] This A pointer to the EFI_RNG_PROTOCOL in= stance. @param[in,out] RNGAlgorithmListSize On input, the size in bytes of RNGAl= gorithmList. On output with a return code of EFI_= SUCCESS, the size in bytes of the data returned in RNG= AlgorithmList. On output @@ -97,14 +99,19 @@ RngGetRNG ( is the default algorithm for the dri= ver. =20 @retval EFI_SUCCESS The RNG algorithm list was returned = successfully. + @retval EFI_UNSUPPORTED The services is not supported by thi= s driver. + @retval EFI_DEVICE_ERROR The list of algorithms could not be = retrieved due to a + hardware or firmware error. + @retval EFI_INVALID_PARAMETER One or more of the parameters are in= correct. @retval EFI_BUFFER_TOO_SMALL The buffer RNGAlgorithmList is too s= mall to hold the result. =20 **/ -UINTN +EFI_STATUS EFIAPI -ArchGetSupportedRngAlgorithms ( - IN OUT UINTN *RNGAlgorithmListSize, - OUT EFI_RNG_ALGORITHM *RNGAlgorithmList +RngGetInfo ( + IN EFI_RNG_PROTOCOL *This, + IN OUT UINTN *RNGAlgorithmListSize, + OUT EFI_RNG_ALGORITHM *RNGAlgorithmList ) { UINTN RequiredSize; @@ -112,6 +119,10 @@ ArchGetSupportedRngAlgorithms ( =20 RequiredSize =3D sizeof (EFI_RNG_ALGORITHM); =20 + if ((This =3D=3D NULL) || (RNGAlgorithmListSize =3D=3D NULL)) { + return EFI_INVALID_PARAMETER; + } + if (*RNGAlgorithmListSize < RequiredSize) { *RNGAlgorithmListSize =3D RequiredSize; return EFI_BUFFER_TOO_SMALL; diff --git a/SecurityPkg/RandomNumberGenerator/RngDxe/Rand/RngDxe.c b/Secur= ityPkg/RandomNumberGenerator/RngDxe/Rand/RngDxe.c index df7db12b771c..b2d2236380fd 100644 --- a/SecurityPkg/RandomNumberGenerator/RngDxe/Rand/RngDxe.c +++ b/SecurityPkg/RandomNumberGenerator/RngDxe/Rand/RngDxe.c @@ -104,6 +104,7 @@ RngGetRNG ( /** Returns information about the random number generation implementation. =20 + @param[in] This A pointer to the EFI_RNG_PROTOCOL in= stance. @param[in,out] RNGAlgorithmListSize On input, the size in bytes of RNGAl= gorithmList. On output with a return code of EFI_= SUCCESS, the size in bytes of the data returned in RNG= AlgorithmList. On output @@ -116,18 +117,27 @@ RngGetRNG ( is the default algorithm for the dri= ver. =20 @retval EFI_SUCCESS The RNG algorithm list was returned = successfully. + @retval EFI_UNSUPPORTED No supported algorithms found. + @retval EFI_DEVICE_ERROR The list of algorithms could not be = retrieved due to a + hardware or firmware error. + @retval EFI_INVALID_PARAMETER One or more of the parameters are in= correct. @retval EFI_BUFFER_TOO_SMALL The buffer RNGAlgorithmList is too s= mall to hold the result. =20 **/ -UINTN +EFI_STATUS EFIAPI -ArchGetSupportedRngAlgorithms ( - IN OUT UINTN *RNGAlgorithmListSize, - OUT EFI_RNG_ALGORITHM *RNGAlgorithmList +RngGetInfo ( + IN EFI_RNG_PROTOCOL *This, + IN OUT UINTN *RNGAlgorithmListSize, + OUT EFI_RNG_ALGORITHM *RNGAlgorithmList ) { UINTN RequiredSize; =20 + if ((This =3D=3D NULL) || (RNGAlgorithmListSize =3D=3D NULL)) { + return EFI_INVALID_PARAMETER; + } + RequiredSize =3D 2 * sizeof (EFI_RNG_ALGORITHM); =20 if (*RNGAlgorithmListSize < RequiredSize) { @@ -135,6 +145,10 @@ ArchGetSupportedRngAlgorithms ( return EFI_BUFFER_TOO_SMALL; } =20 + if (RNGAlgorithmList =3D=3D NULL) { + return EFI_INVALID_PARAMETER; + } + CopyMem (&RNGAlgorithmList[0], &gEfiRngAlgorithmSp80090Ctr256Guid, sizeo= f (EFI_RNG_ALGORITHM)); =20 // x86 platforms also support EFI_RNG_ALGORITHM_RAW via RDSEED diff --git a/SecurityPkg/RandomNumberGenerator/RngDxe/RngDxe.c b/SecurityPk= g/RandomNumberGenerator/RngDxe/RngDxe.c index 6f52eeff4a09..6608ca8804a5 100644 --- a/SecurityPkg/RandomNumberGenerator/RngDxe/RngDxe.c +++ b/SecurityPkg/RandomNumberGenerator/RngDxe/RngDxe.c @@ -28,55 +28,6 @@ SPDX-License-Identifier: BSD-2-Clause-Patent =20 #include "RngDxeInternals.h" =20 -/** - Returns information about the random number generation implementation. - - @param[in] This A pointer to the EFI_RNG_PROTOCOL in= stance. - @param[in,out] RNGAlgorithmListSize On input, the size in bytes of RNGAl= gorithmList. - On output with a return code of EFI_= SUCCESS, the size - in bytes of the data returned in RNG= AlgorithmList. On output - with a return code of EFI_BUFFER_TOO= _SMALL, - the size of RNGAlgorithmList require= d to obtain the list. - @param[out] RNGAlgorithmList A caller-allocated memory buffer fil= led by the driver - with one EFI_RNG_ALGORITHM element f= or each supported - RNG algorithm. The list must not cha= nge across multiple - calls to the same driver. The first = algorithm in the list - is the default algorithm for the dri= ver. - - @retval EFI_SUCCESS The RNG algorithm list was returned = successfully. - @retval EFI_UNSUPPORTED The services is not supported by thi= s driver. - @retval EFI_DEVICE_ERROR The list of algorithms could not be = retrieved due to a - hardware or firmware error. - @retval EFI_INVALID_PARAMETER One or more of the parameters are in= correct. - @retval EFI_BUFFER_TOO_SMALL The buffer RNGAlgorithmList is too s= mall to hold the result. - -**/ -EFI_STATUS -EFIAPI -RngGetInfo ( - IN EFI_RNG_PROTOCOL *This, - IN OUT UINTN *RNGAlgorithmListSize, - OUT EFI_RNG_ALGORITHM *RNGAlgorithmList - ) -{ - EFI_STATUS Status; - - if ((This =3D=3D NULL) || (RNGAlgorithmListSize =3D=3D NULL)) { - return EFI_INVALID_PARAMETER; - } - - // - // Return algorithm list supported by driver. - // - if (RNGAlgorithmList !=3D NULL) { - Status =3D ArchGetSupportedRngAlgorithms (RNGAlgorithmListSize, RNGAlg= orithmList); - } else { - Status =3D EFI_INVALID_PARAMETER; - } - - return Status; -} - // // The Random Number Generator (RNG) protocol // diff --git a/SecurityPkg/RandomNumberGenerator/RngDxe/RngDxeInternals.h b/S= ecurityPkg/RandomNumberGenerator/RngDxe/RngDxeInternals.h index 48d2d27c1608..7ecab140483d 100644 --- a/SecurityPkg/RandomNumberGenerator/RngDxe/RngDxeInternals.h +++ b/SecurityPkg/RandomNumberGenerator/RngDxe/RngDxeInternals.h @@ -74,31 +74,6 @@ RngGetRNG ( OUT UINT8 *RNGValue ); =20 -/** - Returns information about the random number generation implementation. - - @param[in,out] RNGAlgorithmListSize On input, the size in bytes of RNGAl= gorithmList. - On output with a return code of EFI_= SUCCESS, the size - in bytes of the data returned in RNG= AlgorithmList. On output - with a return code of EFI_BUFFER_TOO= _SMALL, - the size of RNGAlgorithmList require= d to obtain the list. - @param[out] RNGAlgorithmList A caller-allocated memory buffer fil= led by the driver - with one EFI_RNG_ALGORITHM element f= or each supported - RNG algorithm. The list must not cha= nge across multiple - calls to the same driver. The first = algorithm in the list - is the default algorithm for the dri= ver. - - @retval EFI_SUCCESS The RNG algorithm list was returned = successfully. - @retval EFI_BUFFER_TOO_SMALL The buffer RNGAlgorithmList is too s= mall to hold the result. - -**/ -UINTN -EFIAPI -ArchGetSupportedRngAlgorithms ( - IN OUT UINTN *RNGAlgorithmListSize, - OUT EFI_RNG_ALGORITHM *RNGAlgorithmList - ); - /** Runs CPU RNG instruction to fill a buffer of arbitrary size with random = bytes. =20 --=20 2.25.1 -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#93957): https://edk2.groups.io/g/devel/message/93957 Mute This Topic: https://groups.io/mt/93788888/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- From nobody Fri Apr 19 21:37:27 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) client-ip=66.175.222.108; envelope-from=bounce+27952+93958+1787277+3901457@groups.io; helo=mail02.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+93958+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=arm.com ARC-Seal: i=1; a=rsa-sha256; t=1663615383; cv=none; d=zohomail.com; s=zohoarc; b=Z8UfoZy5bUz1UiL8u07MSo4Dr/ey5HBpotOjRr401sgIS6UFzh2KK/H1aK4KEhN72eko3bhe0qXjfs8BJnBBU40XilbmtqyoJIpDqvj5puI9h8dpZVAUFNJxhCY7kB5RLMk86bERiNwTox04oOlrvlDfHylx3ipUm6pS6JqxaSo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1663615383; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:References:Sender:Subject:To; bh=05pocQJn3jWjmn+raJD1WDQ37Soq/YdMX8oUg/f3/6o=; b=jYYD9PYHoqQSgjEDzARqAIP4nkaolPrcHhG35BDu//MvE+4Vj0zKCu8/zYr3ZELAN8kSlPWv/Zy6MKltr7PwNZ09YgccogfHp+3UfXT7Ihs7bNsWPnyIwJP+Z9M2kqVfhOJG4VwgtSde5OfXyDvDNS5c1un3hZZb2kIZTomn/gU= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+93958+1787277+3901457@groups.io; dmarc=fail header.from= (p=none dis=none) Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by mx.zohomail.com with SMTPS id 1663615383466944.015450710111; Mon, 19 Sep 2022 12:23:03 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id 5DV9YY1788612xVZLByanTje; Mon, 19 Sep 2022 12:23:03 -0700 X-Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by mx.groups.io with SMTP id smtpd.web10.3218.1663615382440928545 for ; Mon, 19 Sep 2022 12:23:02 -0700 X-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 962F3143D; Mon, 19 Sep 2022 12:23:08 -0700 (PDT) X-Received: from pierre123.arm.com (unknown [172.31.20.19]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 95BA53F73B; Mon, 19 Sep 2022 12:22:59 -0700 (PDT) From: "PierreGondois" To: devel@edk2.groups.io Cc: Sami Mujawar , Leif Lindholm , Ard Biesheuvel , Rebecca Cran , Michael D Kinney , Liming Gao , Jiewen Yao , Jian J Wang Subject: [edk2-devel] [PATCH v5 15/21] SecurityPkg/RngDxe: Documentation/include/parameter cleanup Date: Mon, 19 Sep 2022 21:22:01 +0200 Message-Id: <20220919192207.637786-16-Pierre.Gondois@arm.com> In-Reply-To: <20220919192207.637786-1-Pierre.Gondois@arm.com> References: <20220919192207.637786-1-Pierre.Gondois@arm.com> MIME-Version: 1.0 Precedence: Bulk List-Unsubscribe: List-Subscribe: List-Help: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,pierre.gondois@arm.com X-Gm-Message-State: amZmH3pC7d8rtLKuUJVIK0h2x1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1663615383; bh=fu8QSyIbCLu84zEr3j5bMaJnk5zothHAwqU5140Ig5k=; h=Cc:Date:From:Reply-To:Subject:To; b=k8oqP9FTkjkTeEDNeUqBJMGbhbBwlMBrLrsEQpyA9UkETrHdOsaA9SCDkcbV0GLMW3q 2/DrJfU0dO8VBcWB40KIlKnsOj2qM1/QO9YhZ7dQaankoxxFu0ByTcv/oGsdeXUtrQtvj 5hpl5+3b8dSmiu0WtKZvr7cfNrj1DpInpPs= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1663615385004100010 Content-Type: text/plain; charset="utf-8" From: Pierre Gondois This patch: -Update RngGetBytes() documentation to align the function definition and declaration. -Improve input parameter checking. Even though 'This' it is not used, the parameter should always point to the current EFI_RNG_PROTOCOL. -Removes TimerLib inclusion as unused. Signed-off-by: Pierre Gondois --- SecurityPkg/RandomNumberGenerator/RngDxe/AArch64/RngDxe.c | 3 +-- SecurityPkg/RandomNumberGenerator/RngDxe/Rand/RngDxe.c | 2 +- SecurityPkg/RandomNumberGenerator/RngDxe/RngDxe.c | 3 +-- 3 files changed, 3 insertions(+), 5 deletions(-) diff --git a/SecurityPkg/RandomNumberGenerator/RngDxe/AArch64/RngDxe.c b/Se= curityPkg/RandomNumberGenerator/RngDxe/AArch64/RngDxe.c index 6d989f7ea376..f9c740d761ff 100644 --- a/SecurityPkg/RandomNumberGenerator/RngDxe/AArch64/RngDxe.c +++ b/SecurityPkg/RandomNumberGenerator/RngDxe/AArch64/RngDxe.c @@ -23,7 +23,6 @@ #include #include #include -#include #include =20 #include "RngDxeInternals.h" @@ -61,7 +60,7 @@ RngGetRNG ( { EFI_STATUS Status; =20 - if ((RNGValueLength =3D=3D 0) || (RNGValue =3D=3D NULL)) { + if ((This =3D=3D NULL) || (RNGValueLength =3D=3D 0) || (RNGValue =3D=3D = NULL)) { return EFI_INVALID_PARAMETER; } =20 diff --git a/SecurityPkg/RandomNumberGenerator/RngDxe/Rand/RngDxe.c b/Secur= ityPkg/RandomNumberGenerator/RngDxe/Rand/RngDxe.c index b2d2236380fd..8f5d8e740f5e 100644 --- a/SecurityPkg/RandomNumberGenerator/RngDxe/Rand/RngDxe.c +++ b/SecurityPkg/RandomNumberGenerator/RngDxe/Rand/RngDxe.c @@ -59,7 +59,7 @@ RngGetRNG ( { EFI_STATUS Status; =20 - if ((RNGValueLength =3D=3D 0) || (RNGValue =3D=3D NULL)) { + if ((This =3D=3D NULL) || (RNGValueLength =3D=3D 0) || (RNGValue =3D=3D = NULL)) { return EFI_INVALID_PARAMETER; } =20 diff --git a/SecurityPkg/RandomNumberGenerator/RngDxe/RngDxe.c b/SecurityPk= g/RandomNumberGenerator/RngDxe/RngDxe.c index 6608ca8804a5..d7905a7f4d72 100644 --- a/SecurityPkg/RandomNumberGenerator/RngDxe/RngDxe.c +++ b/SecurityPkg/RandomNumberGenerator/RngDxe/RngDxe.c @@ -23,7 +23,6 @@ SPDX-License-Identifier: BSD-2-Clause-Patent #include #include #include -#include #include =20 #include "RngDxeInternals.h" @@ -72,7 +71,7 @@ RngDriverEntry ( } =20 /** - Calls RDRAND to fill a buffer of arbitrary size with random bytes. + Runs CPU RNG instruction to fill a buffer of arbitrary size with random = bytes. =20 @param[in] Length Size of the buffer, in bytes, to fill with. @param[out] RandBuffer Pointer to the buffer to store the random res= ult. --=20 2.25.1 -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#93958): https://edk2.groups.io/g/devel/message/93958 Mute This Topic: https://groups.io/mt/93788890/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- From nobody Fri Apr 19 21:37:27 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) client-ip=66.175.222.108; envelope-from=bounce+27952+93959+1787277+3901457@groups.io; helo=mail02.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+93959+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=arm.com ARC-Seal: i=1; a=rsa-sha256; t=1663615386; cv=none; d=zohomail.com; s=zohoarc; b=jwNp4yOlzvov9bBnEpiwN9W0dxgk/+LCRw9svPkrKjt+ec1JubcYQSZrCrOCaftT7i6qKr6LPqVEgkJ+IU5EsF5M4az+hjxJ8Hw0bh6kJ3whPRiWEoOMTlWBasRxL8e63Cow5aw82gralBZUeZWOe6QxUwOBhn9533vWXJrYQyo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1663615386; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:References:Sender:Subject:To; bh=W1WR1jmZeFLRUE7QgWBYSGIQq2Fg49j//M6vcNHdRpc=; b=WZAqkJbg+7Qf+1w75bTCGj4HIpRrAAvuMhAAieGbFmpO6ppXdzueGX4m5DVr0yol9KJx2DStmkCXFr/nPAlfsn/wvUgqNQi04uaawvnggqAvfFV7Ka07lK4NzJ3/T1h8Ss7ec+ntb8Kf3D9CZCG2bMGqdbQQI5IJyygVS9i9mx0= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+93959+1787277+3901457@groups.io; dmarc=fail header.from= (p=none dis=none) Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by mx.zohomail.com with SMTPS id 1663615386425492.2518565829546; Mon, 19 Sep 2022 12:23:06 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id ic9HYY1788612xVzDeOWUgez; Mon, 19 Sep 2022 12:23:06 -0700 X-Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by mx.groups.io with SMTP id smtpd.web11.3352.1663615385469225046 for ; Mon, 19 Sep 2022 12:23:05 -0700 X-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 A52AE1424; Mon, 19 Sep 2022 12:23:11 -0700 (PDT) X-Received: from pierre123.arm.com (unknown [172.31.20.19]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 97C113F73B; Mon, 19 Sep 2022 12:23:02 -0700 (PDT) From: "PierreGondois" To: devel@edk2.groups.io Cc: Sami Mujawar , Leif Lindholm , Ard Biesheuvel , Rebecca Cran , Michael D Kinney , Liming Gao , Jiewen Yao , Jian J Wang Subject: [edk2-devel] [PATCH v5 16/21] SecurityPkg/RngDxe: Check before advertising Cpu Rng algo Date: Mon, 19 Sep 2022 21:22:02 +0200 Message-Id: <20220919192207.637786-17-Pierre.Gondois@arm.com> In-Reply-To: <20220919192207.637786-1-Pierre.Gondois@arm.com> References: <20220919192207.637786-1-Pierre.Gondois@arm.com> MIME-Version: 1.0 Precedence: Bulk List-Unsubscribe: List-Subscribe: List-Help: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,pierre.gondois@arm.com X-Gm-Message-State: yCP6KQMgeXU64pNOWS1JqziSx1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1663615386; bh=3a3T/39JRtrQv2N56yAzKHbMKkhllImcryyzTZ+rcA0=; h=Cc:Date:From:Reply-To:Subject:To; b=txXSe0Owmma+7OSjaSeHxvAXw16DI71N3+3O4Nat9sPAGP7VOuylezuIMnAbAvMXAIG mxNgcQbj670XAT1LLTRowv2RlMWcQhRkGDIQBqYGStZA/Q+5dxhfHIUv3sjbF3UmAlXLs PTfiZiC/KnIqup51WBi79iWxVCGp62XKzow= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1663615387079100013 Content-Type: text/plain; charset="utf-8" From: Pierre Gondois RngGetBytes() relies on the RngLib. The RngLib might use the RNDR instruction if the FEAT_RNG feature is present. RngGetInfo and RngGetRNG both must check that RngGetBytes() is working before advertising/using it. To do so, allocate an array storing the available algorithms. The Rng algorithm at the lowest index will be the default Rng algorithm. The array is shared between RngGetInfo and RngGetRNG. This array is allocated when the driver is loaded, and freed when unloaded. This patch also prevents from having PcdCpuRngSupportedAlgorithm let to a zero GUID, but let the possibility to have no valid Rng algorithm in such case. Signed-off-by: Pierre Gondois --- .../RngDxe/AArch64/RngDxe.c | 87 +++++++++++++++++-- .../RngDxe/Rand/RngDxe.c | 26 ++++++ .../RandomNumberGenerator/RngDxe/RngDxe.c | 40 ++++++++- .../RandomNumberGenerator/RngDxe/RngDxe.inf | 1 + .../RngDxe/RngDxeInternals.h | 27 ++++++ 5 files changed, 172 insertions(+), 9 deletions(-) diff --git a/SecurityPkg/RandomNumberGenerator/RngDxe/AArch64/RngDxe.c b/Se= curityPkg/RandomNumberGenerator/RngDxe/AArch64/RngDxe.c index f9c740d761ff..09a5924a699b 100644 --- a/SecurityPkg/RandomNumberGenerator/RngDxe/AArch64/RngDxe.c +++ b/SecurityPkg/RandomNumberGenerator/RngDxe/AArch64/RngDxe.c @@ -22,11 +22,63 @@ =20 #include #include +#include +#include #include +#include #include =20 #include "RngDxeInternals.h" =20 +// Maximum number of Rng algorithms. +#define RNG_AVAILABLE_ALGO_MAX 1 + +/** Allocate and initialize mAvailableAlgoArray with the available + Rng algorithms. Also update mAvailableAlgoArrayCount. + + @retval EFI_SUCCESS The function completed successfully. + @retval EFI_OUT_OF_RESOURCES Could not allocate memory. +**/ +EFI_STATUS +EFIAPI +GetAvailableAlgorithms ( + VOID + ) +{ + UINT64 DummyRand; + + // Allocate RNG_AVAILABLE_ALGO_MAX entries to avoid evaluating + // Rng algorithms 2 times, one for the allocation, one to populate. + mAvailableAlgoArray =3D AllocateZeroPool (RNG_AVAILABLE_ALGO_MAX); + if (mAvailableAlgoArray =3D=3D NULL) { + return EFI_OUT_OF_RESOURCES; + } + + // Check RngGetBytes() before advertising PcdCpuRngSupportedAlgorithm. + if (!EFI_ERROR (RngGetBytes (sizeof (DummyRand), (UINT8 *)&DummyRand))) { + CopyMem ( + &mAvailableAlgoArray[mAvailableAlgoArrayCount], + PcdGetPtr (PcdCpuRngSupportedAlgorithm), + sizeof (EFI_RNG_ALGORITHM) + ); + mAvailableAlgoArrayCount++; + } + + return EFI_SUCCESS; +} + +/** Free mAvailableAlgoArray. +**/ +VOID +EFIAPI +FreeAvailableAlgorithms ( + VOID + ) +{ + FreePool (mAvailableAlgoArray); + return; +} + /** Produces and returns an RNG value using either the default or specified = RNG algorithm. =20 @@ -59,6 +111,7 @@ RngGetRNG ( ) { EFI_STATUS Status; + UINTN Index; =20 if ((This =3D=3D NULL) || (RNGValueLength =3D=3D 0) || (RNGValue =3D=3D = NULL)) { return EFI_INVALID_PARAMETER; @@ -68,9 +121,21 @@ RngGetRNG ( // // Use the default RNG algorithm if RNGAlgorithm is NULL. // - RNGAlgorithm =3D PcdGetPtr (PcdCpuRngSupportedAlgorithm); + for (Index =3D 0; Index < mAvailableAlgoArrayCount; Index++) { + if (!IsZeroGuid (&mAvailableAlgoArray[Index])) { + RNGAlgorithm =3D &mAvailableAlgoArray[Index]; + goto FoundAlgo; + } + } + + if (Index =3D=3D mAvailableAlgoArrayCount) { + // No algorithm available. + ASSERT (Index !=3D mAvailableAlgoArrayCount); + return EFI_DEVICE_ERROR; + } } =20 +FoundAlgo: if (CompareGuid (RNGAlgorithm, PcdGetPtr (PcdCpuRngSupportedAlgorithm)))= { Status =3D RngGetBytes (RNGValueLength, RNGValue); return Status; @@ -113,24 +178,30 @@ RngGetInfo ( OUT EFI_RNG_ALGORITHM *RNGAlgorithmList ) { - UINTN RequiredSize; - EFI_RNG_ALGORITHM *CpuRngSupportedAlgorithm; - - RequiredSize =3D sizeof (EFI_RNG_ALGORITHM); + UINTN RequiredSize; =20 if ((This =3D=3D NULL) || (RNGAlgorithmListSize =3D=3D NULL)) { return EFI_INVALID_PARAMETER; } =20 + RequiredSize =3D mAvailableAlgoArrayCount * sizeof (EFI_RNG_ALGORITHM); + + if (RequiredSize =3D=3D 0) { + // No supported algorithms found. + return EFI_UNSUPPORTED; + } + if (*RNGAlgorithmListSize < RequiredSize) { *RNGAlgorithmListSize =3D RequiredSize; return EFI_BUFFER_TOO_SMALL; } =20 - CpuRngSupportedAlgorithm =3D PcdGetPtr (PcdCpuRngSupportedAlgorithm); - - CopyMem (&RNGAlgorithmList[0], CpuRngSupportedAlgorithm, sizeof (EFI_RNG= _ALGORITHM)); + if (RNGAlgorithmList =3D=3D NULL) { + return EFI_INVALID_PARAMETER; + } =20 + // There is no gap in the array, so copy the block. + CopyMem (RNGAlgorithmList, mAvailableAlgoArray, RequiredSize); *RNGAlgorithmListSize =3D RequiredSize; return EFI_SUCCESS; } diff --git a/SecurityPkg/RandomNumberGenerator/RngDxe/Rand/RngDxe.c b/Secur= ityPkg/RandomNumberGenerator/RngDxe/Rand/RngDxe.c index 8f5d8e740f5e..677600bed7ab 100644 --- a/SecurityPkg/RandomNumberGenerator/RngDxe/Rand/RngDxe.c +++ b/SecurityPkg/RandomNumberGenerator/RngDxe/Rand/RngDxe.c @@ -26,6 +26,32 @@ =20 #include "RngDxeInternals.h" =20 +/** Allocate and initialize mAvailableAlgoArray with the available + Rng algorithms. Also update mAvailableAlgoArrayCount. + + @retval EFI_SUCCESS The function completed successfully. + @retval EFI_OUT_OF_RESOURCES Could not allocate memory. +**/ +EFI_STATUS +EFIAPI +GetAvailableAlgorithms ( + VOID + ) +{ + return EFI_SUCCESS; +} + +/** Free mAvailableAlgoArray. +**/ +VOID +EFIAPI +FreeAvailableAlgorithms ( + VOID + ) +{ + return; +} + /** Produces and returns an RNG value using either the default or specified = RNG algorithm. =20 diff --git a/SecurityPkg/RandomNumberGenerator/RngDxe/RngDxe.c b/SecurityPk= g/RandomNumberGenerator/RngDxe/RngDxe.c index d7905a7f4d72..421abb52b8bf 100644 --- a/SecurityPkg/RandomNumberGenerator/RngDxe/RngDxe.c +++ b/SecurityPkg/RandomNumberGenerator/RngDxe/RngDxe.c @@ -27,6 +27,13 @@ SPDX-License-Identifier: BSD-2-Clause-Patent =20 #include "RngDxeInternals.h" =20 +// +// Array containing the validated Rng algorithm. +// The entry with the lowest index will be the default algorithm. +// +UINTN mAvailableAlgoArrayCount; +EFI_RNG_ALGORITHM *mAvailableAlgoArray; + // // The Random Number Generator (RNG) protocol // @@ -66,8 +73,39 @@ RngDriverEntry ( &mRngRdRand, NULL ); + if (EFI_ERROR (Status)) { + return Status; + } =20 - return Status; + // + // Get the list of available algorithm. + // + return GetAvailableAlgorithms (); +} + +/** + This is the unload handle for RndgDxe module. + + Disconnect the driver specified by ImageHandle from all the devices in t= he handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RngDriverUnLoad ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Free the list of available algorithm. + // + FreeAvailableAlgorithms (); + return EFI_SUCCESS; } =20 /** diff --git a/SecurityPkg/RandomNumberGenerator/RngDxe/RngDxe.inf b/Security= Pkg/RandomNumberGenerator/RngDxe/RngDxe.inf index 60efb5562ee0..1985dfbb4619 100644 --- a/SecurityPkg/RandomNumberGenerator/RngDxe/RngDxe.inf +++ b/SecurityPkg/RandomNumberGenerator/RngDxe/RngDxe.inf @@ -22,6 +22,7 @@ [Defines] MODULE_TYPE =3D DXE_DRIVER VERSION_STRING =3D 1.0 ENTRY_POINT =3D RngDriverEntry + UNLOAD_IMAGE =3D RngDriverUnLoad MODULE_UNI_FILE =3D RngDxe.uni =20 # diff --git a/SecurityPkg/RandomNumberGenerator/RngDxe/RngDxeInternals.h b/S= ecurityPkg/RandomNumberGenerator/RngDxe/RngDxeInternals.h index 7ecab140483d..f75140260820 100644 --- a/SecurityPkg/RandomNumberGenerator/RngDxe/RngDxeInternals.h +++ b/SecurityPkg/RandomNumberGenerator/RngDxe/RngDxeInternals.h @@ -12,6 +12,33 @@ =20 #include =20 +// +// Array containing the validated Rng algorithm. +// The entry with the lowest index will be the default algorithm. +// +extern UINTN mAvailableAlgoArrayCount; +extern EFI_RNG_ALGORITHM *mAvailableAlgoArray; + +/** Allocate and initialize mAvailableAlgoArray with the available + Rng algorithms. Also update mAvailableAlgoArrayCount. + + @retval EFI_SUCCESS The function completed successfully. + @retval EFI_OUT_OF_RESOURCES Could not allocate memory. +**/ +EFI_STATUS +EFIAPI +GetAvailableAlgorithms ( + VOID + ); + +/** Free mAvailableAlgoArray. +**/ +VOID +EFIAPI +FreeAvailableAlgorithms ( + VOID + ); + /** Returns information about the random number generation implementation. =20 --=20 2.25.1 -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#93959): https://edk2.groups.io/g/devel/message/93959 Mute This Topic: https://groups.io/mt/93788893/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- From nobody Fri Apr 19 21:37:27 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) client-ip=66.175.222.108; envelope-from=bounce+27952+93960+1787277+3901457@groups.io; helo=mail02.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+93960+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=arm.com ARC-Seal: i=1; a=rsa-sha256; t=1663615389; cv=none; d=zohomail.com; s=zohoarc; b=HDmviD5DMVXOSh13eMfps9C0ZU7qiEP+K8NMlHRvd7+XyHieU9kok3MX/75tyeQZmFy6ZO7fSDu7jIHelyNE+hlcwvz34V0F1eRWtjLF/515MNnMVJaw7D4zrL/YaIUsSwxGPROYF2ywwg371iJXSfA41ew8km+xXeTRCVgCS0Y= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1663615389; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:References:Sender:Subject:To; bh=aN+/bUrsCoTli5h+c/ytHBVvRAJ6BGfcTFBhZWUuex0=; b=YwzuLR9Hgdq/eA83ygff8d1R5iSwwxC+qUuIatCLBmh5TBIEcx8wGhlcuVu5y3IVv7GKeNQ5YTLCfEn2w+GbmyySaALVi7NH59cHDnMrSA3lDKdMr2uYlTC9jonkcQ2FPRHZ+tZ59E18r0tBKNgVRSmMVDDKglx338qmXdNy5OE= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+93960+1787277+3901457@groups.io; dmarc=fail header.from= (p=none dis=none) Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by mx.zohomail.com with SMTPS id 1663615389691748.6067296208522; Mon, 19 Sep 2022 12:23:09 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id EZY1YY1788612xyxr5YoCvXx; Mon, 19 Sep 2022 12:23:09 -0700 X-Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by mx.groups.io with SMTP id smtpd.web09.3298.1663615388417347288 for ; Mon, 19 Sep 2022 12:23:08 -0700 X-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 A1B28143D; Mon, 19 Sep 2022 12:23:14 -0700 (PDT) X-Received: from pierre123.arm.com (unknown [172.31.20.19]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id B2D5E3F73B; Mon, 19 Sep 2022 12:23:05 -0700 (PDT) From: "PierreGondois" To: devel@edk2.groups.io Cc: Sami Mujawar , Leif Lindholm , Ard Biesheuvel , Rebecca Cran , Michael D Kinney , Liming Gao , Jiewen Yao , Jian J Wang Subject: [edk2-devel] [PATCH v5 17/21] SecurityPkg/RngDxe: Add AArch64 RawAlgorithm support through TrngLib Date: Mon, 19 Sep 2022 21:22:03 +0200 Message-Id: <20220919192207.637786-18-Pierre.Gondois@arm.com> In-Reply-To: <20220919192207.637786-1-Pierre.Gondois@arm.com> References: <20220919192207.637786-1-Pierre.Gondois@arm.com> MIME-Version: 1.0 Precedence: Bulk List-Unsubscribe: List-Subscribe: List-Help: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,pierre.gondois@arm.com X-Gm-Message-State: iMJYx8saScPdPUWOXko7XWMZx1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1663615389; bh=WaxoLjSHz5vGPEK5NKMQjPG0soA6E0yt4AZi4s9kuNs=; h=Cc:Date:From:Reply-To:Subject:To; b=dU4/8b+FoNRjJxQT1JajCBqnNH3Rl7b3Wo6EYBqsz803TryC1Qyc8cP68v0cc0Ig9xs wPPmTXOQ87w6hhgs+Cdd4tq1hi09MdO2Uv+549pu2f7LKaiPubxgzL0e5Bvyj78aaIXIn EBTwdjvpFQ71SlYngi1hE1OrLcl16hw0P1Q= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1663615391002100017 Content-Type: text/plain; charset="utf-8" From: Sami Mujawar Bugzilla: 3668 (https://bugzilla.tianocore.org/show_bug.cgi?id=3D3668) RawAlgorithm is used to provide access to entropy that is suitable for cryptographic applications. Therefore, add RawAlgorithm support that provides access to entropy using the TrngLib. Also remove unused UefiBootServicesTableLib library inclusion and Status variable. Signed-off-by: Sami Mujawar --- .../RngDxe/AArch64/RngDxe.c | 28 ++++++-- .../RandomNumberGenerator/RngDxe/ArmTrng.c | 71 +++++++++++++++++++ .../RandomNumberGenerator/RngDxe/RngDxe.inf | 5 ++ SecurityPkg/SecurityPkg.dsc | 3 + 4 files changed, 103 insertions(+), 4 deletions(-) create mode 100644 SecurityPkg/RandomNumberGenerator/RngDxe/ArmTrng.c diff --git a/SecurityPkg/RandomNumberGenerator/RngDxe/AArch64/RngDxe.c b/Se= curityPkg/RandomNumberGenerator/RngDxe/AArch64/RngDxe.c index 09a5924a699b..f5910e3b999f 100644 --- a/SecurityPkg/RandomNumberGenerator/RngDxe/AArch64/RngDxe.c +++ b/SecurityPkg/RandomNumberGenerator/RngDxe/AArch64/RngDxe.c @@ -1,11 +1,13 @@ /** @file RNG Driver to produce the UEFI Random Number Generator protocol. =20 - The driver will use the RNDR instruction to produce random numbers. + The driver can use RNDR instruction (through the RngLib and if FEAT_RNG = is + present) to produce random numbers. It also uses the Arm FW-TRNG interfa= ce + to implement EFI_RNG_ALGORITHM_RAW. =20 RNG Algorithms defined in UEFI 2.4: - EFI_RNG_ALGORITHM_SP800_90_CTR_256_GUID - - EFI_RNG_ALGORITHM_RAW - Unsupported + - EFI_RNG_ALGORITHM_RAW - EFI_RNG_ALGORITHM_SP800_90_HMAC_256_GUID - EFI_RNG_ALGORITHM_SP800_90_HASH_256_GUID - EFI_RNG_ALGORITHM_X9_31_3DES_GUID - Unsupported @@ -26,12 +28,14 @@ #include #include #include +#include +#include #include =20 #include "RngDxeInternals.h" =20 // Maximum number of Rng algorithms. -#define RNG_AVAILABLE_ALGO_MAX 1 +#define RNG_AVAILABLE_ALGO_MAX 2 =20 /** Allocate and initialize mAvailableAlgoArray with the available Rng algorithms. Also update mAvailableAlgoArrayCount. @@ -46,8 +50,9 @@ GetAvailableAlgorithms ( ) { UINT64 DummyRand; + UINT16 MajorRevision; + UINT16 MinorRevision; =20 - // Allocate RNG_AVAILABLE_ALGO_MAX entries to avoid evaluating // Rng algorithms 2 times, one for the allocation, one to populate. mAvailableAlgoArray =3D AllocateZeroPool (RNG_AVAILABLE_ALGO_MAX); if (mAvailableAlgoArray =3D=3D NULL) { @@ -64,6 +69,16 @@ GetAvailableAlgorithms ( mAvailableAlgoArrayCount++; } =20 + // Raw algorithm (Trng) + if (!EFI_ERROR (GetTrngVersion (&MajorRevision, &MinorRevision))) { + CopyMem ( + &mAvailableAlgoArray[mAvailableAlgoArrayCount], + &gEfiRngAlgorithmRaw, + sizeof (EFI_RNG_ALGORITHM) + ); + mAvailableAlgoArrayCount++; + } + return EFI_SUCCESS; } =20 @@ -141,6 +156,11 @@ FoundAlgo: return Status; } =20 + // Raw algorithm (Trng) + if (CompareGuid (RNGAlgorithm, &gEfiRngAlgorithmRaw)) { + return GenerateEntropy (RNGValueLength, RNGValue); + } + // // Other algorithms are unsupported by this driver. // diff --git a/SecurityPkg/RandomNumberGenerator/RngDxe/ArmTrng.c b/SecurityP= kg/RandomNumberGenerator/RngDxe/ArmTrng.c new file mode 100644 index 000000000000..6100e02b32b0 --- /dev/null +++ b/SecurityPkg/RandomNumberGenerator/RngDxe/ArmTrng.c @@ -0,0 +1,71 @@ +/** @file + RNG Driver to produce the UEFI Random Number Generator protocol. + + The driver implements the EFI_RNG_ALGORITHM_RAW using the FW-TRNG + interface to provide entropy. + + Copyright (c) 2021 - 2022, Arm Limited. All rights reserved.
+ + SPDX-License-Identifier: BSD-2-Clause-Patent + +**/ + +#include +#include +#include +#include +#include + +#include "RngDxeInternals.h" + +/** + Generate high-quality entropy source using a TRNG or through RDRAND. + + @param[in] Length Size of the buffer, in bytes, to fill with. + @param[out] Entropy Pointer to the buffer to store the entropy da= ta. + + @retval RETURN_SUCCESS The function completed successfully. + @retval RETURN_INVALID_PARAMETER Invalid parameter. + @retval RETURN_UNSUPPORTED Function not implemented. + @retval RETURN_BAD_BUFFER_SIZE Buffer size is too small. + @retval RETURN_NOT_READY No Entropy available. +**/ +EFI_STATUS +EFIAPI +GenerateEntropy ( + IN UINTN Length, + OUT UINT8 *Entropy + ) +{ + EFI_STATUS Status; + UINTN CollectedEntropyBits; + UINTN RequiredEntropyBits; + UINTN EntropyBits; + UINTN Index; + UINTN MaxBits; + + ZeroMem (Entropy, Length); + + RequiredEntropyBits =3D (Length << 3); + Index =3D 0; + CollectedEntropyBits =3D 0; + MaxBits =3D GetTrngMaxSupportedEntropyBits (); + while (CollectedEntropyBits < RequiredEntropyBits) { + EntropyBits =3D MIN ((RequiredEntropyBits - CollectedEntropyBits), Max= Bits); + Status =3D GetTrngEntropy ( + EntropyBits, + (Length - Index), + &Entropy[Index] + ); + if (EFI_ERROR (Status)) { + // Discard the collected bits. + ZeroMem (Entropy, Length); + return Status; + } + + CollectedEntropyBits +=3D EntropyBits; + Index +=3D (EntropyBits >> 3); + } // while + + return Status; +} diff --git a/SecurityPkg/RandomNumberGenerator/RngDxe/RngDxe.inf b/Security= Pkg/RandomNumberGenerator/RngDxe/RngDxe.inf index 1985dfbb4619..f6e08da96140 100644 --- a/SecurityPkg/RandomNumberGenerator/RngDxe/RngDxe.inf +++ b/SecurityPkg/RandomNumberGenerator/RngDxe/RngDxe.inf @@ -43,8 +43,10 @@ [Sources.IA32, Sources.X64] =20 [Sources.AARCH64] AArch64/RngDxe.c + ArmTrng.c =20 [Packages] + MdeModulePkg/MdeModulePkg.dec MdePkg/MdePkg.dec SecurityPkg/SecurityPkg.dec =20 @@ -57,6 +59,9 @@ [LibraryClasses] TimerLib RngLib =20 +[LibraryClasses.AARCH64] + TrngLib + [Guids] gEfiRngAlgorithmSp80090Hash256Guid ## SOMETIMES_PRODUCES ## GUID = # Unique ID of the algorithm for RNG gEfiRngAlgorithmSp80090Hmac256Guid ## SOMETIMES_PRODUCES ## GUID = # Unique ID of the algorithm for RNG diff --git a/SecurityPkg/SecurityPkg.dsc b/SecurityPkg/SecurityPkg.dsc index f48187650f2f..690a45e89728 100644 --- a/SecurityPkg/SecurityPkg.dsc +++ b/SecurityPkg/SecurityPkg.dsc @@ -3,6 +3,7 @@ # # Copyright (c) 2009 - 2021, Intel Corporation. All rights reserved.
# (C) Copyright 2015-2020 Hewlett Packard Enterprise Development LP
+# Copyright (c) 2021 - 2022, Arm Limited. All rights reserved.
# SPDX-License-Identifier: BSD-2-Clause-Patent # ## @@ -88,6 +89,8 @@ [LibraryClasses.ARM, LibraryClasses.AARCH64] =20 ArmSoftFloatLib|ArmPkg/Library/ArmSoftFloatLib/ArmSoftFloatLib.inf =20 + TrngLib|MdePkg/Library/BaseTrngLibNull/BaseTrngLibNull.inf + [LibraryClasses.ARM] RngLib|MdePkg/Library/BaseRngLibTimerLib/BaseRngLibTimerLib.inf =20 --=20 2.25.1 -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#93960): https://edk2.groups.io/g/devel/message/93960 Mute This Topic: https://groups.io/mt/93788895/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- From nobody Fri Apr 19 21:37:27 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) client-ip=66.175.222.108; envelope-from=bounce+27952+93961+1787277+3901457@groups.io; helo=mail02.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+93961+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=arm.com ARC-Seal: i=1; a=rsa-sha256; t=1663615392; cv=none; d=zohomail.com; s=zohoarc; b=E2Zk9FZe1zSQmEbXRDQYz8ieEqv36LTeIma4gsF2j59RvjM3eM6TI4ODNNNDGPEhK1jaioiw4NmA9cRi2k9ttGMRJnfwvPx2wDI0l2PyrcLtWaxG9qWewoWqjuLxcAT3D9dwnM6g5r/DyjpRR1fu5rYzCu8ceQ/0CFFUZOESzFk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1663615392; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:References:Sender:Subject:To; bh=/xyLRj8qal5Pr3TU7YwJMQu+niBUBNb8bE1xg3RzxSM=; b=bQ4mUEJmWbOubXc8mVZXr1wtrs0CpnBAH9Jq8gKs/Hwg5JRbs7Zr5cMhpS/X8E+OZlUu/h9CGjqdwQNeX/kE8WwRIAEbIb9kmfbQ6rFdrbW8LCUY6ypsdKKM1/KUdAYI7gn9vemaYPTVpz/7uD1Gp1zZc5nenYQwSYhdv+XVSQk= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+93961+1787277+3901457@groups.io; dmarc=fail header.from= (p=none dis=none) Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by mx.zohomail.com with SMTPS id 1663615392058136.3366399618261; Mon, 19 Sep 2022 12:23:12 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id BL51YY1788612xr4G1knWgsj; Mon, 19 Sep 2022 12:23:11 -0700 X-Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by mx.groups.io with SMTP id smtpd.web08.3246.1663615390959792513 for ; Mon, 19 Sep 2022 12:23:11 -0700 X-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 324871424; Mon, 19 Sep 2022 12:23:17 -0700 (PDT) X-Received: from pierre123.arm.com (unknown [172.31.20.19]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 94B623F73B; Mon, 19 Sep 2022 12:23:08 -0700 (PDT) From: "PierreGondois" To: devel@edk2.groups.io Cc: Sami Mujawar , Leif Lindholm , Ard Biesheuvel , Rebecca Cran , Michael D Kinney , Liming Gao , Jiewen Yao , Jian J Wang Subject: [edk2-devel] [PATCH v5 18/21] SecurityPkg/RngDxe: Add debug warning for NULL PcdCpuRngSupportedAlgorithm Date: Mon, 19 Sep 2022 21:22:04 +0200 Message-Id: <20220919192207.637786-19-Pierre.Gondois@arm.com> In-Reply-To: <20220919192207.637786-1-Pierre.Gondois@arm.com> References: <20220919192207.637786-1-Pierre.Gondois@arm.com> MIME-Version: 1.0 Precedence: Bulk List-Unsubscribe: List-Subscribe: List-Help: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,pierre.gondois@arm.com X-Gm-Message-State: 3Hrz7BzXk8Ly00vmlAhdpJkJx1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1663615391; bh=WuWS5CX2hIS6GrVzJkF4B9pzDN17rxGcBaIHTrpr9Lc=; h=Cc:Date:From:Reply-To:Subject:To; b=hqmWyM77YXuqC7J2pDvlEB1CQZdPJH5zyWCKgd857Xs5Ev8wknpg3ui8yWE6j7BqJwx 28twTeI1RYECzY6RJWvOxADy4yPzo34CRgvwmjZg+NNxEk0vVN6acD3htGkAF/OQXQcwB UbKjxW3qUrDrn5IOzK9XI7/I5/zt3Dc6kuc= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1663615392973100021 Content-Type: text/plain; charset="utf-8" From: Pierre Gondois PcdCpuRngSupportedAlgorithm should allow to identify the the algorithm used by the RNDR CPU instruction to generate a random number. Add a debug warning if the Pcd is not set. Signed-off-by: Pierre Gondois --- .../RandomNumberGenerator/RngDxe/AArch64/RngDxe.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/SecurityPkg/RandomNumberGenerator/RngDxe/AArch64/RngDxe.c b/Se= curityPkg/RandomNumberGenerator/RngDxe/AArch64/RngDxe.c index f5910e3b999f..0d853720ecb1 100644 --- a/SecurityPkg/RandomNumberGenerator/RngDxe/AArch64/RngDxe.c +++ b/SecurityPkg/RandomNumberGenerator/RngDxe/AArch64/RngDxe.c @@ -67,6 +67,16 @@ GetAvailableAlgorithms ( sizeof (EFI_RNG_ALGORITHM) ); mAvailableAlgoArrayCount++; + + DEBUG_CODE_BEGIN (); + if (IsZeroGuid (PcdGetPtr (PcdCpuRngSupportedAlgorithm))) { + DEBUG (( + DEBUG_WARN, + "PcdCpuRngSupportedAlgorithm should be a non-zero GUID\n" + )); + } + + DEBUG_CODE_END (); } =20 // Raw algorithm (Trng) --=20 2.25.1 -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#93961): https://edk2.groups.io/g/devel/message/93961 Mute This Topic: https://groups.io/mt/93788897/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- From nobody Fri Apr 19 21:37:27 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) client-ip=66.175.222.108; envelope-from=bounce+27952+93962+1787277+3901457@groups.io; helo=mail02.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+93962+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=arm.com ARC-Seal: i=1; a=rsa-sha256; t=1663615395; cv=none; d=zohomail.com; s=zohoarc; b=D4EXdRgBZQFeWn2CYuaM4zTRCDrkQWwLRo1DrNyCdj9p8hSbHgnkd1e5BWlj0HGTVUbbDm5YUhcUkEMWm1IIK52FOU8FHJbXljR92i2sfGhjjCid9p5x0kIkPdoGUtXKnHMWAjvlKl/oJUlwJ9IH5POBQL4WQQUgaeR76cWX00U= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1663615395; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:References:Sender:Subject:To; bh=ihAf6dC7Rmf5neTZ+ComyKSMndXT3qmxjJVL+/2fiZ4=; b=g0MW7P74h78nNwfALje/4HTxzNPRd15x9xIUEqFFZ03Ez8LvQxkBI1JQjpucgGc/h/TSRVjMMIY9Kd7JJckkLAfHAxvQfYAIR//YkdmXBhV98GkNO9vbykQ/087H6jwYnALTSSrQwgPV5XswFOtgMwyzJZ1RGZSpyfEqE/pRXRo= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+93962+1787277+3901457@groups.io; dmarc=fail header.from= (p=none dis=none) Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by mx.zohomail.com with SMTPS id 1663615395694453.05495895979914; Mon, 19 Sep 2022 12:23:15 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id F9xoYY1788612x1BBfX9P1MX; Mon, 19 Sep 2022 12:23:14 -0700 X-Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by mx.groups.io with SMTP id smtpd.web08.3247.1663615393620256710 for ; Mon, 19 Sep 2022 12:23:13 -0700 X-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 CB82B143D; Mon, 19 Sep 2022 12:23:19 -0700 (PDT) X-Received: from pierre123.arm.com (unknown [172.31.20.19]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 0F5B13F73B; Mon, 19 Sep 2022 12:23:10 -0700 (PDT) From: "PierreGondois" To: devel@edk2.groups.io Cc: Sami Mujawar , Leif Lindholm , Ard Biesheuvel , Rebecca Cran , Michael D Kinney , Liming Gao , Jiewen Yao , Jian J Wang Subject: [edk2-devel] [PATCH v5 19/21] SecurityPkg/RngDxe: Rename AArch64/RngDxe.c Date: Mon, 19 Sep 2022 21:22:05 +0200 Message-Id: <20220919192207.637786-20-Pierre.Gondois@arm.com> In-Reply-To: <20220919192207.637786-1-Pierre.Gondois@arm.com> References: <20220919192207.637786-1-Pierre.Gondois@arm.com> MIME-Version: 1.0 Precedence: Bulk List-Unsubscribe: List-Subscribe: List-Help: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,pierre.gondois@arm.com X-Gm-Message-State: rZF6hr5iia5AH6r4KEw7OVn8x1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1663615394; bh=WaM0TIm0X9M6v/qoPCxgYopDFr6PgYOQDQAjoSWxLu4=; h=Cc:Date:From:Reply-To:Subject:To; b=X0I2uMsyVnXMWDHmJcH0H6o0GZuFN7q3uEB++0jf9joTd+gLtGcO+KICk1Z2MG5Z+0h kr9lF3gs8aiQLaxyy/C75jllOS38VoDMX04U9M60gppO7KN0bEf0iHduinc4Ox54lZKFz S6PgP6qg1jx/5fxzHZq8eT/ivD4cw8EBW9Y= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1663615396986100027 Content-Type: text/plain; charset="utf-8" From: Pierre Gondois To re-use the AArch64/RngDxe.c for an Arm implementation, rename AArch64/RngDxe.c to ArmRngDxe.c. Signed-off-by: Pierre Gondois --- .../RngDxe/{AArch64/RngDxe.c =3D> ArmRngDxe.c} | 0 SecurityPkg/RandomNumberGenerator/RngDxe/RngDxe.inf | 2 +- 2 files changed, 1 insertion(+), 1 deletion(-) rename SecurityPkg/RandomNumberGenerator/RngDxe/{AArch64/RngDxe.c =3D> Arm= RngDxe.c} (100%) diff --git a/SecurityPkg/RandomNumberGenerator/RngDxe/AArch64/RngDxe.c b/Se= curityPkg/RandomNumberGenerator/RngDxe/ArmRngDxe.c similarity index 100% rename from SecurityPkg/RandomNumberGenerator/RngDxe/AArch64/RngDxe.c rename to SecurityPkg/RandomNumberGenerator/RngDxe/ArmRngDxe.c diff --git a/SecurityPkg/RandomNumberGenerator/RngDxe/RngDxe.inf b/Security= Pkg/RandomNumberGenerator/RngDxe/RngDxe.inf index f6e08da96140..337becf5224f 100644 --- a/SecurityPkg/RandomNumberGenerator/RngDxe/RngDxe.inf +++ b/SecurityPkg/RandomNumberGenerator/RngDxe/RngDxe.inf @@ -42,7 +42,7 @@ [Sources.IA32, Sources.X64] Rand/AesCore.h =20 [Sources.AARCH64] - AArch64/RngDxe.c + ArmRngDxe.c ArmTrng.c =20 [Packages] --=20 2.25.1 -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#93962): https://edk2.groups.io/g/devel/message/93962 Mute This Topic: https://groups.io/mt/93788898/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- From nobody Fri Apr 19 21:37:27 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) client-ip=66.175.222.108; envelope-from=bounce+27952+93963+1787277+3901457@groups.io; helo=mail02.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+93963+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=arm.com ARC-Seal: i=1; a=rsa-sha256; t=1663615396; cv=none; d=zohomail.com; s=zohoarc; b=DYcio2OWGBwYLbVyRteEzReJmnw8X2j+X2Q1uPVIMLWgfmxUsAewKPX71YBLH18MEqK1w7wZZUbI+9cEB/Ztbb1x3gc2RjBA23cWL2VMeXvnvryuIwyI58fJYtW8BorkjqnpR6uD/X2Fh9wu5kJwz47IvYry2lH1eLuJyQZYgn8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1663615396; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:References:Sender:Subject:To; bh=oi8GnFbhBMeBZ10f6N0oo4A9SVJRjy7S1u1YwNP91aA=; b=Zremr/ETIUOsf61ivFfbiufl/MLKEdAcMAxZnzFFTB7df5et49HXrVC8eDCbAsmcgl2x3sBVult9Xq0U79cS++qfF+XDPWdCBKU4uC6vxcKQJGPkmSmyiXkURgXPJPZpa/0QawOEI+tDSThjOP0KpNOzHgJrEFXmZoVUGExrEO0= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+93963+1787277+3901457@groups.io; dmarc=fail header.from= (p=none dis=none) Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by mx.zohomail.com with SMTPS id 1663615396877158.420115223758; Mon, 19 Sep 2022 12:23:16 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id R71ZYY1788612xUSmhIDCBy7; Mon, 19 Sep 2022 12:23:16 -0700 X-Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by mx.groups.io with SMTP id smtpd.web11.3354.1663615395981240424 for ; Mon, 19 Sep 2022 12:23:16 -0700 X-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 2E27B1424; Mon, 19 Sep 2022 12:23:22 -0700 (PDT) X-Received: from pierre123.arm.com (unknown [172.31.20.19]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 992783F73B; Mon, 19 Sep 2022 12:23:13 -0700 (PDT) From: "PierreGondois" To: devel@edk2.groups.io Cc: Sami Mujawar , Leif Lindholm , Ard Biesheuvel , Rebecca Cran , Michael D Kinney , Liming Gao , Jiewen Yao , Jian J Wang Subject: [edk2-devel] [PATCH v5 20/21] SecurityPkg/RngDxe: Add Arm support of RngDxe Date: Mon, 19 Sep 2022 21:22:06 +0200 Message-Id: <20220919192207.637786-21-Pierre.Gondois@arm.com> In-Reply-To: <20220919192207.637786-1-Pierre.Gondois@arm.com> References: <20220919192207.637786-1-Pierre.Gondois@arm.com> MIME-Version: 1.0 Precedence: Bulk List-Unsubscribe: List-Subscribe: List-Help: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,pierre.gondois@arm.com X-Gm-Message-State: vMfP8R0Fw8TQtHI59vPIeLOix1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1663615396; bh=P9E2d4yUaVc2GJygEX9rVbPK2wVFkBwIzRVNqHDeByk=; h=Cc:Date:From:Reply-To:Subject:To; b=aL74IpYxCH57IbXq3zDfWjSSmoKPx41Ej2ABgRlCEB7NRKNi7OQfn5R3aiRcTsvTJzi 9hHtkbEYbMAln4iwac7KsX4oKJ6WFGB5wHJfOj3TlC/iDjnSm8xRJZculDS9M13r3H966 6edycEeLYGSf+06gsQNzAMvN5BsLOwkW1Eg= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1663615397024100028 Content-Type: text/plain; charset="utf-8" From: Pierre Gondois Bugzilla: 3668 (https://bugzilla.tianocore.org/show_bug.cgi?id=3D3668) Add RngDxe support for Arm. This implementation uses the TrngLib to support the RawAlgorithm and doens't support the RNDR instruction. To re-use the RngGetRNG(), RngGetInfo() and FreeAvailableAlgorithms() functions, create Arm/AArch64 files which implement the arch specific function GetAvailableAlgorithms(). Indeed, FEAT_RNG instruction is not supported on Arm. Signed-off-by: Pierre Gondois --- .../RngDxe/AArch64/AArch64Algo.c | 72 +++++++++++++++++++ .../RngDxe/Arm/ArmAlgo.c | 51 +++++++++++++ .../RandomNumberGenerator/RngDxe/ArmRngDxe.c | 60 ---------------- .../RandomNumberGenerator/RngDxe/RngDxe.inf | 12 +++- SecurityPkg/SecurityPkg.dsc | 2 +- 5 files changed, 133 insertions(+), 64 deletions(-) create mode 100644 SecurityPkg/RandomNumberGenerator/RngDxe/AArch64/AArch6= 4Algo.c create mode 100644 SecurityPkg/RandomNumberGenerator/RngDxe/Arm/ArmAlgo.c diff --git a/SecurityPkg/RandomNumberGenerator/RngDxe/AArch64/AArch64Algo.c= b/SecurityPkg/RandomNumberGenerator/RngDxe/AArch64/AArch64Algo.c new file mode 100644 index 000000000000..d7e80a0d0d0d --- /dev/null +++ b/SecurityPkg/RandomNumberGenerator/RngDxe/AArch64/AArch64Algo.c @@ -0,0 +1,72 @@ +/** @file + Aarch64 specific code. + + Copyright (c) 2022, Arm Limited. All rights reserved.
+ SPDX-License-Identifier: BSD-2-Clause-Patent +**/ + +#include +#include +#include +#include +#include + +#include "RngDxeInternals.h" + +// Maximum number of Rng algorithms. +#define RNG_AVAILABLE_ALGO_MAX 2 + +/** Allocate and initialize mAvailableAlgoArray with the available + Rng algorithms. Also update mAvailableAlgoArrayCount. + + @retval EFI_SUCCESS The function completed successfully. + @retval EFI_OUT_OF_RESOURCES Could not allocate memory. +**/ +EFI_STATUS +EFIAPI +GetAvailableAlgorithms ( + VOID + ) +{ + UINT64 DummyRand; + UINT16 MajorRevision; + UINT16 MinorRevision; + + // Rng algorithms 2 times, one for the allocation, one to populate. + mAvailableAlgoArray =3D AllocateZeroPool (RNG_AVAILABLE_ALGO_MAX); + if (mAvailableAlgoArray =3D=3D NULL) { + return EFI_OUT_OF_RESOURCES; + } + + // Check RngGetBytes() before advertising PcdCpuRngSupportedAlgorithm. + if (!EFI_ERROR (RngGetBytes (sizeof (DummyRand), (UINT8 *)&DummyRand))) { + CopyMem ( + &mAvailableAlgoArray[mAvailableAlgoArrayCount], + PcdGetPtr (PcdCpuRngSupportedAlgorithm), + sizeof (EFI_RNG_ALGORITHM) + ); + mAvailableAlgoArrayCount++; + + DEBUG_CODE_BEGIN (); + if (IsZeroGuid (PcdGetPtr (PcdCpuRngSupportedAlgorithm))) { + DEBUG (( + DEBUG_WARN, + "PcdCpuRngSupportedAlgorithm should be a non-zero GUID\n" + )); + } + + DEBUG_CODE_END (); + } + + // Raw algorithm (Trng) + if (!EFI_ERROR (GetTrngVersion (&MajorRevision, &MinorRevision))) { + CopyMem ( + &mAvailableAlgoArray[mAvailableAlgoArrayCount], + &gEfiRngAlgorithmRaw, + sizeof (EFI_RNG_ALGORITHM) + ); + mAvailableAlgoArrayCount++; + } + + return EFI_SUCCESS; +} diff --git a/SecurityPkg/RandomNumberGenerator/RngDxe/Arm/ArmAlgo.c b/Secur= ityPkg/RandomNumberGenerator/RngDxe/Arm/ArmAlgo.c new file mode 100644 index 000000000000..5acef91fe3b2 --- /dev/null +++ b/SecurityPkg/RandomNumberGenerator/RngDxe/Arm/ArmAlgo.c @@ -0,0 +1,51 @@ +/** @file + Arm specific code. + + Copyright (c) 2022, Arm Limited. All rights reserved.
+ SPDX-License-Identifier: BSD-2-Clause-Patent +**/ + +#include +#include +#include +#include +#include + +#include "RngDxeInternals.h" + +// Maximum number of Rng algorithms. +#define RNG_AVAILABLE_ALGO_MAX 1 + +/** Allocate and initialize mAvailableAlgoArray with the available + Rng algorithms. Also update mAvailableAlgoArrayCount. + + @retval EFI_SUCCESS The function completed successfully. + @retval EFI_OUT_OF_RESOURCES Could not allocate memory. +**/ +EFI_STATUS +EFIAPI +GetAvailableAlgorithms ( + VOID + ) +{ + UINT16 MajorRevision; + UINT16 MinorRevision; + + // Rng algorithms 2 times, one for the allocation, one to populate. + mAvailableAlgoArray =3D AllocateZeroPool (RNG_AVAILABLE_ALGO_MAX); + if (mAvailableAlgoArray =3D=3D NULL) { + return EFI_OUT_OF_RESOURCES; + } + + // Raw algorithm (Trng) + if (!EFI_ERROR (GetTrngVersion (&MajorRevision, &MinorRevision))) { + CopyMem ( + &mAvailableAlgoArray[mAvailableAlgoArrayCount], + &gEfiRngAlgorithmRaw, + sizeof (EFI_RNG_ALGORITHM) + ); + mAvailableAlgoArrayCount++; + } + + return EFI_SUCCESS; +} diff --git a/SecurityPkg/RandomNumberGenerator/RngDxe/ArmRngDxe.c b/Securit= yPkg/RandomNumberGenerator/RngDxe/ArmRngDxe.c index 0d853720ecb1..5ba319899ce9 100644 --- a/SecurityPkg/RandomNumberGenerator/RngDxe/ArmRngDxe.c +++ b/SecurityPkg/RandomNumberGenerator/RngDxe/ArmRngDxe.c @@ -28,70 +28,10 @@ #include #include #include -#include -#include #include =20 #include "RngDxeInternals.h" =20 -// Maximum number of Rng algorithms. -#define RNG_AVAILABLE_ALGO_MAX 2 - -/** Allocate and initialize mAvailableAlgoArray with the available - Rng algorithms. Also update mAvailableAlgoArrayCount. - - @retval EFI_SUCCESS The function completed successfully. - @retval EFI_OUT_OF_RESOURCES Could not allocate memory. -**/ -EFI_STATUS -EFIAPI -GetAvailableAlgorithms ( - VOID - ) -{ - UINT64 DummyRand; - UINT16 MajorRevision; - UINT16 MinorRevision; - - // Rng algorithms 2 times, one for the allocation, one to populate. - mAvailableAlgoArray =3D AllocateZeroPool (RNG_AVAILABLE_ALGO_MAX); - if (mAvailableAlgoArray =3D=3D NULL) { - return EFI_OUT_OF_RESOURCES; - } - - // Check RngGetBytes() before advertising PcdCpuRngSupportedAlgorithm. - if (!EFI_ERROR (RngGetBytes (sizeof (DummyRand), (UINT8 *)&DummyRand))) { - CopyMem ( - &mAvailableAlgoArray[mAvailableAlgoArrayCount], - PcdGetPtr (PcdCpuRngSupportedAlgorithm), - sizeof (EFI_RNG_ALGORITHM) - ); - mAvailableAlgoArrayCount++; - - DEBUG_CODE_BEGIN (); - if (IsZeroGuid (PcdGetPtr (PcdCpuRngSupportedAlgorithm))) { - DEBUG (( - DEBUG_WARN, - "PcdCpuRngSupportedAlgorithm should be a non-zero GUID\n" - )); - } - - DEBUG_CODE_END (); - } - - // Raw algorithm (Trng) - if (!EFI_ERROR (GetTrngVersion (&MajorRevision, &MinorRevision))) { - CopyMem ( - &mAvailableAlgoArray[mAvailableAlgoArrayCount], - &gEfiRngAlgorithmRaw, - sizeof (EFI_RNG_ALGORITHM) - ); - mAvailableAlgoArrayCount++; - } - - return EFI_SUCCESS; -} - /** Free mAvailableAlgoArray. **/ VOID diff --git a/SecurityPkg/RandomNumberGenerator/RngDxe/RngDxe.inf b/Security= Pkg/RandomNumberGenerator/RngDxe/RngDxe.inf index 337becf5224f..9f1630161032 100644 --- a/SecurityPkg/RandomNumberGenerator/RngDxe/RngDxe.inf +++ b/SecurityPkg/RandomNumberGenerator/RngDxe/RngDxe.inf @@ -28,7 +28,7 @@ [Defines] # # The following information is for reference only and not required by the = build tools. # -# VALID_ARCHITECTURES =3D IA32 X64 AARCH64 +# VALID_ARCHITECTURES =3D IA32 X64 AARCH64 ARM # =20 [Sources.common] @@ -41,10 +41,16 @@ [Sources.IA32, Sources.X64] Rand/AesCore.c Rand/AesCore.h =20 -[Sources.AARCH64] +[Sources.AARCH64, Sources.ARM] ArmRngDxe.c ArmTrng.c =20 +[Sources.AARCH64] + AArch64/AArch64Algo.c + +[Sources.ARM] + Arm/ArmAlgo.c + [Packages] MdeModulePkg/MdeModulePkg.dec MdePkg/MdePkg.dec @@ -59,7 +65,7 @@ [LibraryClasses] TimerLib RngLib =20 -[LibraryClasses.AARCH64] +[LibraryClasses.AARCH64, LibraryClasses.ARM] TrngLib =20 [Guids] diff --git a/SecurityPkg/SecurityPkg.dsc b/SecurityPkg/SecurityPkg.dsc index 690a45e89728..55d17e64efd8 100644 --- a/SecurityPkg/SecurityPkg.dsc +++ b/SecurityPkg/SecurityPkg.dsc @@ -290,7 +290,7 @@ [Components.IA32, Components.X64, Components.ARM, Compo= nents.AARCH64] SecurityPkg/EnrollFromDefaultKeysApp/EnrollFromDefaultKeysApp.inf SecurityPkg/VariableAuthenticated/SecureBootDefaultKeysDxe/SecureBootDef= aultKeysDxe.inf =20 -[Components.IA32, Components.X64, Components.AARCH64] +[Components.IA32, Components.X64, Components.AARCH64, Components.ARM] # # Random Number Generator # --=20 2.25.1 -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#93963): https://edk2.groups.io/g/devel/message/93963 Mute This Topic: https://groups.io/mt/93788899/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- From nobody Fri Apr 19 21:37:27 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) client-ip=66.175.222.108; envelope-from=bounce+27952+93964+1787277+3901457@groups.io; helo=mail02.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+93964+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=arm.com ARC-Seal: i=1; a=rsa-sha256; t=1663615399; cv=none; d=zohomail.com; s=zohoarc; b=lGCliSaK7fp77el4lJXMGbhoF7Drv3bSFiNXmaJgMoNmPYR6d2TIYn7wTlCv4spclRaX3wEQ/KuGn5BAJDKL19obrw0IYXrgR8rrQLNG85IpdHsPXlsQCghbUwRHORLX0GBeMWf6LRDkZKXWGn5FjBn4kfFUUQXFkHYFgZE8xuc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1663615399; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:References:Sender:Subject:To; bh=K85mjNSUGTrycIcFgUnQeNNdz6MYY6Sgq8bJMnaGv/s=; b=kXGjZLJ3QEXmKENyiQ/HLOKtN4OfDTXNEVH66x49tqf88BVuGm3I1sZ4PolCK4UjHZ8DhdkDgJ3mMhwD8TTg9TBUe0+u9GR4ibq6doR6A/LE34YUuNJO5vhFLJlUMFGfp4VEi0zT4178vZNtQEuCq/ZFqHZCyDE5QIkPGSY5o9w= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+93964+1787277+3901457@groups.io; dmarc=fail header.from= (p=none dis=none) Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by mx.zohomail.com with SMTPS id 1663615399747158.42199623305862; Mon, 19 Sep 2022 12:23:19 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id qyPnYY1788612xlFGARfrYNQ; Mon, 19 Sep 2022 12:23:19 -0700 X-Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by mx.groups.io with SMTP id smtpd.web12.3269.1663615398528095202 for ; Mon, 19 Sep 2022 12:23:18 -0700 X-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 BD099143D; Mon, 19 Sep 2022 12:23:24 -0700 (PDT) X-Received: from pierre123.arm.com (unknown [172.31.20.19]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id EEB473F73B; Mon, 19 Sep 2022 12:23:15 -0700 (PDT) From: "PierreGondois" To: devel@edk2.groups.io Cc: Sami Mujawar , Leif Lindholm , Ard Biesheuvel , Rebecca Cran , Michael D Kinney , Liming Gao , Jiewen Yao , Jian J Wang Subject: [edk2-devel] [PATCH v5 21/21] ArmVirtPkg: Kvmtool: Add RNG support using FW-TRNG interface Date: Mon, 19 Sep 2022 21:22:07 +0200 Message-Id: <20220919192207.637786-22-Pierre.Gondois@arm.com> In-Reply-To: <20220919192207.637786-1-Pierre.Gondois@arm.com> References: <20220919192207.637786-1-Pierre.Gondois@arm.com> MIME-Version: 1.0 Precedence: Bulk List-Unsubscribe: List-Subscribe: List-Help: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,pierre.gondois@arm.com X-Gm-Message-State: OG6sDigtcg2S8mLXC2HZNjA3x1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1663615399; bh=6hmxMMorfSGlo8A4CQguZEmEKtOKDg3UKaxrmNudGHE=; h=Cc:Date:From:Reply-To:Subject:To; b=kv5njRgqjTulds2xB1hXnR+DFEO/lXoCA5NW/C2qghxDDiCikidgf3ONefuft25PTZC beEd+Kt0/5ri6T5Qm1pi2l0yOKhgw7YLTcxsiEVv/LVq13we3LolvSCtcbejNELB9VXiC Q4+5ORQf7Ben/8c0qiGM/bBMnDuefsliGjI= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1663615401003100003 Content-Type: text/plain; charset="utf-8" From: Sami Mujawar Bugzilla: 3668 (https://bugzilla.tianocore.org/show_bug.cgi?id=3D3668) The EFI_RNG_PROTOCOL published by RngDxe has been updated to implement the EFI_RNG_ALGORITHM_RAW using the Arm FW-TRNG interface to provide access to entropy. Therefore, enable EFI_RNG_PROTOCOL for the Kvmtool guest/virtual firmware. Signed-off-by: Sami Mujawar --- ArmVirtPkg/ArmVirtKvmTool.dsc | 10 ++++++++++ ArmVirtPkg/ArmVirtKvmTool.fdf | 5 +++++ 2 files changed, 15 insertions(+) diff --git a/ArmVirtPkg/ArmVirtKvmTool.dsc b/ArmVirtPkg/ArmVirtKvmTool.dsc index 3bd3ebd6e0b3..847dbdd2af2b 100644 --- a/ArmVirtPkg/ArmVirtKvmTool.dsc +++ b/ArmVirtPkg/ArmVirtKvmTool.dsc @@ -81,6 +81,9 @@ [LibraryClasses.common] HwInfoParserLib|DynamicTablesPkg/Library/FdtHwInfoParserLib/FdtHwInfoPar= serLib.inf DynamicPlatRepoLib|DynamicTablesPkg/Library/Common/DynamicPlatRepoLib/Dy= namicPlatRepoLib.inf =20 + ArmMonitorLib|ArmPkg/Library/ArmMonitorLib/ArmMonitorLib.inf + TrngLib|ArmPkg/Library/ArmFwTrngLib/ArmFwTrngLib.inf + [LibraryClasses.common.SEC, LibraryClasses.common.PEI_CORE, LibraryClasses= .common.PEIM] PciExpressLib|MdePkg/Library/BasePciExpressLib/BasePciExpressLib.inf PlatformHookLib|ArmVirtPkg/Library/Fdt16550SerialPortHookLib/EarlyFdt165= 50SerialPortHookLib.inf @@ -112,6 +115,8 @@ [PcdsFeatureFlag.common] # Use MMIO for accessing RTC controller registers. gPcAtChipsetPkgTokenSpaceGuid.PcdRtcUseMmio|TRUE =20 + gArmTokenSpaceGuid.PcdMonitorConduitHvc|TRUE + [PcdsFixedAtBuild.common] gEfiMdePkgTokenSpaceGuid.PcdDebugPrintErrorLevel|0x8000000F =20 @@ -362,6 +367,11 @@ [Components.common] OvmfPkg/VirtioPciDeviceDxe/VirtioPciDeviceDxe.inf OvmfPkg/Virtio10Dxe/Virtio10.inf =20 + # + # Rng Support + # + SecurityPkg/RandomNumberGenerator/RngDxe/RngDxe.inf + !if $(ARCH) =3D=3D AARCH64 # # ACPI Support diff --git a/ArmVirtPkg/ArmVirtKvmTool.fdf b/ArmVirtPkg/ArmVirtKvmTool.fdf index 9e006e83ee5c..4b5c99ef6700 100644 --- a/ArmVirtPkg/ArmVirtKvmTool.fdf +++ b/ArmVirtPkg/ArmVirtKvmTool.fdf @@ -224,6 +224,11 @@ [FV.FvMain] # INF MdeModulePkg/Universal/Disk/RamDiskDxe/RamDiskDxe.inf =20 + # + # Rng Support + # + INF SecurityPkg/RandomNumberGenerator/RngDxe/RngDxe.inf + [FV.FVMAIN_COMPACT] FvAlignment =3D 16 ERASE_POLARITY =3D 1 --=20 2.25.1 -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#93964): https://edk2.groups.io/g/devel/message/93964 Mute This Topic: https://groups.io/mt/93788902/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-