From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pl1-f181.google.com (mail-pl1-f181.google.com [209.85.214.181]) by mx.groups.io with SMTP id smtpd.web10.33095.1688670093833451369 for ; Thu, 06 Jul 2023 12:01:33 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@gmail.com header.s=20221208 header.b=sXNy77YB; spf=pass (domain: gmail.com, ip: 209.85.214.181, mailfrom: kuqin12@gmail.com) Received: by mail-pl1-f181.google.com with SMTP id d9443c01a7336-1b8062c1ee1so6721645ad.3 for ; Thu, 06 Jul 2023 12:01:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1688670093; x=1691262093; h=in-reply-to:from:references:cc:to:content-language:subject :user-agent:mime-version:date:message-id:from:to:cc:subject:date :message-id:reply-to; bh=1O43iP60YkHIoBbqzrw5VwttNUpiYNW9di4Q6Tom8pk=; b=sXNy77YBkB4rMaNjUl4KlLNc0OQsrpuCWddti+zjOxaU1s7EXNkBK06KdbcPXo2eKw fy1j5yk33+8ywOaKwf5kjaNvuW5PGo9mp89not0bCfcncp78qqFQdeAIUAv3u+wFVcMx BgGiOJJ4hUsYwQ0YhF5hoHlqZbfR3fmJhGZvU20+uyRozv+O4bl9UNSS169sz/3RJ+eP FwSqJ0XE0xgt2Sx33y2WhOaLV4SO0yyB7lDv26DqQcbsS9djCaw538JM5CwQgl/1l2Nb UZk5KdE+p2jlbdmghslEc1gJKbJFS+G7le7Y/Fi4qQUmkkxc3bL9v+rh63ERIu3dJFn+ 4Mgg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1688670093; x=1691262093; h=in-reply-to:from:references:cc:to:content-language:subject :user-agent:mime-version:date:message-id:x-gm-message-state:from:to :cc:subject:date:message-id:reply-to; bh=1O43iP60YkHIoBbqzrw5VwttNUpiYNW9di4Q6Tom8pk=; b=WLrh3C5Ck7FvrwFOefOtjEBtKoAiK/Wp22/kCAOQEmYbH0lbeO5QgTbq5QOq8WHRD9 CgBMhdSkcbUphbqa1ho3a/Eo+28A5uzHgFznkmYVhuJRNXJwfN29y2VHfOR9S5tRSYKm 2D3FPlIIlkyhi+5oF96yOCTJ+vcK9bu2XAmGGjq+9pHq/NH7X8aQa4l6BKV0ikfQqN3f dpPebPeIIAEskns4Jbqo2c0fIEkbk90Y7HBDTXeTFDxFavEHmG3rDxszGRIIhcxWsP2Q u0sDiXoucV9u3ySbn6R2CNRUFbv+UKWKc20mrOsL45o3ADLpzKr9t5krpPCsn6v9jFu8 Ux1A== X-Gm-Message-State: ABy/qLYxQCdlrRfbWJeU35KBiqU8+0Eq8jPmoqnRJuFH3HUvbBXJvbQv NSKaTYj+BiimFg/2YRTBuSQ= X-Google-Smtp-Source: APBJJlHFOZlioI/tf/8ZZBZHmKFKOs+2zBJ3RcepQMSLzVJUG66WKCP8C1lZheso1vH9+npLnUko+Q== X-Received: by 2002:a17:902:9f98:b0:1b8:8223:8bdd with SMTP id g24-20020a1709029f9800b001b882238bddmr2487400plq.59.1688670092745; Thu, 06 Jul 2023 12:01:32 -0700 (PDT) Return-Path: Received: from ?IPV6:2001:4898:d8:33:2469:1417:9567:eca0? ([2001:4898:80e8:f:a47c:1417:9567:eca0]) by smtp.gmail.com with ESMTPSA id l1-20020a170902f68100b001b88178b1b7sm1771654plg.34.2023.07.06.12.01.31 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 06 Jul 2023 12:01:32 -0700 (PDT) Message-ID: <1f4f3d6c-be22-4961-570e-86ffb9d36a61@gmail.com> Date: Thu, 6 Jul 2023 12:01:31 -0700 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101 Thunderbird/102.12.0 Subject: Re: [PATCH v3 0/6] SecurityPkg/MdePkg: Update RngLib GUID identification To: pierre.gondois@arm.com, devel@edk2.groups.io Cc: Michael D Kinney , Liming Gao , Zhiguang Liu , Jiewen Yao , Jian J Wang , Ard Biesheuvel , Sami Mujawar , Jose Marinho References: <20230706085159.626374-1-pierre.gondois@arm.com> From: "Kun Qin" In-Reply-To: <20230706085159.626374-1-pierre.gondois@arm.com> Content-Type: multipart/alternative; boundary="------------r5m8u8RV98Nstx0CEaS2uTgh" Content-Language: en-US --------------r5m8u8RV98Nstx0CEaS2uTgh Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Hi Pierre, Thanks for sending the update. I tested on QEMU with this change (no TRNG from TFA), it works for me. Tested-by: Kun Qin Please note that the change below is still needed to avoid data abortion exception. It will be helpful if one of the maintainers can help merging it. [PATCH v2 1/1] SecurityPkg: RngDxe: Fixing mAvailableAlgoArray allocator (groups.io) Regards, Kun On 7/6/2023 1:51 AM, pierre.gondois@arm.com wrote: > From: Pierre Gondois > > v3: > - As the unsafe algorithm GUID will not be added to the UEFI > specification, rename: > - gEfiRngAlgorithmUnSafe to gEdkiiRngAlgorithmUnSafe > - EFI_RNG_ALGORITHM_UNSAFE to EDKII_RNG_ALGORITHM_UNSAFE > > v2: > [1/8] MdePkg/ArmTrngLib: Remove ASSERTs in Null implementation > - Dropped > [2/8] MdePkg/MdePkg.dec: Move PcdCpuRngSupportedAlgorithm to MdePkg > - Change gEfiMdePkgTokenSpaceGuid.PcdCpuRngSupportedAlgorithm > token number > - Rename to SecurityPkg/SecurityPkg.dec: Move > PcdCpuRngSupportedAlgorithm to MdePkg > [5/8] MdePkg/Rng: Add GetRngGuid() to RngLib > - Remove gEfiRngAlgorithmUnSafe from inf file > - Split Guids definitions in arch specific sections > [6/8] SecurityPkg/RngDxe: Use GetRngGuid() when probing RngLib > - Remove RngFindDefaultAlgo() and change logic accordingly. > [7/8] SecurityPkg/RngDxe: Select safe default Rng algorithm > - Dropped due to changes in [6/8] > > This patch also requires the following patch on top of the serie: > -https://edk2.groups.io/g/devel/message/106546 > > This patchset follows the 'code first' approach and relates to [1]. > This patchset follows the thread at [3] that aims to solve [2]. > [1] and [2] are bound and this patchset aims to solve both. > > In this patchset: > a- > The RngDxe can rely on the RngLib. However the RngLib has no > interface allowing to describe which Rng algorithm is implemented. > The RngDxe must advertise the algorithm that are available through > the RngGetInfo() callback. > Add a GetRngGuid() for interface to the RngLib. > > b- > The Arm Architecture states the RNDR that the DRBG algorithm should > be compliant with NIST SP800-90A, while not mandating a particular > algorithm, so as to be inclusive of different geographies. > The RngLib can rely on this Arm RNDR instruction. In order to > accurately describe the implementation using the RNDR instruction, > add a EFI_RNG_ALGORITHM_ARM_RNDR GUID [1]. > > c- > For the same reason as a/b, add a GUID describing unsafe RNG > algorithms, allowing to accurately describe the BaseRngLibTimerLib. > > d- > Use a/b/c mechanisms/GUIDs to select a safe Rng algorithm in the > Arm implementation of the RngDxe. > > [1] BZ:https://bugzilla.tianocore.org/show_bug.cgi?id=4441 > [2] BZ:https://bugzilla.tianocore.org/show_bug.cgi?id=4151 > [3]https://edk2.groups.io/g/devel/message/100806 > > Pierre Gondois (6): > SecurityPkg/SecurityPkg.dec: Move PcdCpuRngSupportedAlgorithm to > MdePkg > MdePkg/DxeRngLib: Request raw algorithm instead of default > MdePkg/Rng: Add GUIDs to describe Rng algorithms > MdePkg/Rng: Add GetRngGuid() to RngLib > SecurityPkg/RngDxe: Use GetRngGuid() when probing RngLib > SecurityPkg/RngDxe: Simplify Rng algorithm selection for Arm > > MdePkg/Include/Library/RngLib.h | 17 ++++++ > MdePkg/Include/Protocol/Rng.h | 20 +++++++ > MdePkg/Library/BaseRngLib/AArch64/Rndr.c | 42 +++++++++++++++ > MdePkg/Library/BaseRngLib/BaseRngLib.inf | 10 ++++ > MdePkg/Library/BaseRngLib/Rand/RdRand.c | 26 +++++++++ > .../Library/BaseRngLibNull/BaseRngLibNull.c | 22 ++++++++ > .../BaseRngLibTimerLib/BaseRngLibTimerLib.inf | 3 ++ > .../Library/BaseRngLibTimerLib/RngLibTimer.c | 28 ++++++++++ > MdePkg/Library/DxeRngLib/DxeRngLib.c | 36 ++++++++++++- > MdePkg/MdePkg.dec | 7 +++ > .../RngDxe/AArch64/AArch64Algo.c | 54 +++++++++++++------ > .../RandomNumberGenerator/RngDxe/ArmRngDxe.c | 23 ++++---- > .../RandomNumberGenerator/RngDxe/RngDxe.inf | 5 +- > SecurityPkg/SecurityPkg.dec | 2 - > 14 files changed, 258 insertions(+), 37 deletions(-) > --------------r5m8u8RV98Nstx0CEaS2uTgh Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: 7bit

Hi Pierre,

Thanks for sending the update. I tested on QEMU with this change (no TRNG from TFA), it works for me.
Tested-by: Kun Qin <kun.qin@microsoft.com>

Please note that the change below is still needed to avoid data abortion exception. It will be helpful if one
of the maintainers can help merging it.
[PATCH v2 1/1] SecurityPkg: RngDxe: Fixing mAvailableAlgoArray allocator (groups.io)

Regards,
Kun

On 7/6/2023 1:51 AM, pierre.gondois@arm.com wrote:
From: Pierre Gondois <pierre.gondois@arm.com>

v3:
- As the unsafe algorithm GUID will not be added to the UEFI
  specification, rename:
  - gEfiRngAlgorithmUnSafe to gEdkiiRngAlgorithmUnSafe
  - EFI_RNG_ALGORITHM_UNSAFE to EDKII_RNG_ALGORITHM_UNSAFE

v2:
[1/8] MdePkg/ArmTrngLib: Remove ASSERTs in Null implementation
- Dropped
[2/8] MdePkg/MdePkg.dec: Move PcdCpuRngSupportedAlgorithm to MdePkg
- Change gEfiMdePkgTokenSpaceGuid.PcdCpuRngSupportedAlgorithm
  token number
- Rename to SecurityPkg/SecurityPkg.dec: Move
  PcdCpuRngSupportedAlgorithm to MdePkg
[5/8] MdePkg/Rng: Add GetRngGuid() to RngLib
- Remove gEfiRngAlgorithmUnSafe from inf file
- Split Guids definitions in arch specific sections
[6/8] SecurityPkg/RngDxe: Use GetRngGuid() when probing RngLib
- Remove RngFindDefaultAlgo() and change logic accordingly.
[7/8] SecurityPkg/RngDxe: Select safe default Rng algorithm
- Dropped due to changes in [6/8]

This patch also requires the following patch on top of the serie:
- https://edk2.groups.io/g/devel/message/106546

This patchset follows the 'code first' approach and relates to [1].
This patchset follows the thread at [3] that aims to solve [2].
[1] and [2] are bound and this patchset aims to solve both.

In this patchset:
a-
The RngDxe can rely on the RngLib. However the RngLib has no
interface allowing to describe which Rng algorithm is implemented.
The RngDxe must advertise the algorithm that are available through
the RngGetInfo() callback.
Add a GetRngGuid() for interface to the RngLib.

b-
The Arm Architecture states the RNDR that the DRBG algorithm should
be compliant with NIST SP800-90A, while not mandating a particular
algorithm, so as to be inclusive of different geographies.
The RngLib can rely on this Arm RNDR instruction. In order to
accurately describe the implementation using the RNDR instruction,
add a EFI_RNG_ALGORITHM_ARM_RNDR GUID [1].

c-
For the same reason as a/b, add a GUID describing unsafe RNG
algorithms, allowing to accurately describe the BaseRngLibTimerLib.

d-
Use a/b/c mechanisms/GUIDs to select a safe Rng algorithm in the
Arm implementation of the RngDxe.

[1] BZ: https://bugzilla.tianocore.org/show_bug.cgi?id=4441
[2] BZ: https://bugzilla.tianocore.org/show_bug.cgi?id=4151
[3] https://edk2.groups.io/g/devel/message/100806

Pierre Gondois (6):
  SecurityPkg/SecurityPkg.dec: Move PcdCpuRngSupportedAlgorithm to
    MdePkg
  MdePkg/DxeRngLib: Request raw algorithm instead of default
  MdePkg/Rng: Add GUIDs to describe Rng algorithms
  MdePkg/Rng: Add GetRngGuid() to RngLib
  SecurityPkg/RngDxe: Use GetRngGuid() when probing RngLib
  SecurityPkg/RngDxe: Simplify Rng algorithm selection for Arm

 MdePkg/Include/Library/RngLib.h               | 17 ++++++
 MdePkg/Include/Protocol/Rng.h                 | 20 +++++++
 MdePkg/Library/BaseRngLib/AArch64/Rndr.c      | 42 +++++++++++++++
 MdePkg/Library/BaseRngLib/BaseRngLib.inf      | 10 ++++
 MdePkg/Library/BaseRngLib/Rand/RdRand.c       | 26 +++++++++
 .../Library/BaseRngLibNull/BaseRngLibNull.c   | 22 ++++++++
 .../BaseRngLibTimerLib/BaseRngLibTimerLib.inf |  3 ++
 .../Library/BaseRngLibTimerLib/RngLibTimer.c  | 28 ++++++++++
 MdePkg/Library/DxeRngLib/DxeRngLib.c          | 36 ++++++++++++-
 MdePkg/MdePkg.dec                             |  7 +++
 .../RngDxe/AArch64/AArch64Algo.c              | 54 +++++++++++++------
 .../RandomNumberGenerator/RngDxe/ArmRngDxe.c  | 23 ++++----
 .../RandomNumberGenerator/RngDxe/RngDxe.inf   |  5 +-
 SecurityPkg/SecurityPkg.dec                   |  2 -
 14 files changed, 258 insertions(+), 37 deletions(-)

--------------r5m8u8RV98Nstx0CEaS2uTgh--