public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
From: "Benjamin Doron" <benjamin.doron00@gmail.com>
To: devel@edk2.groups.io
Cc: Guo Dong <guo.dong@intel.com>, Ray Ni <ray.ni@intel.com>,
	Sean Rhodes <sean@starlabs.systems>,
	James Lu <james.lu@intel.com>, Gua Guo <gua.guo@intel.com>
Subject: [edk2-devel][PATCH v1 1/2] UefiPayloadPkg: Define RngLibTimerLib for systems without RDRAND
Date: Tue, 25 Apr 2023 13:09:27 -0400	[thread overview]
Message-ID: <7edb8c7baae2fc58034a62f50f5f4000fb5bd102.1682442501.git.benjamin.doron00@gmail.com> (raw)

From: Benjamin Doron <benjamin.doron@9elements.com>

Presently, `ArchIsRngSupported()` always returns TRUE, per
https://github.com/tianocore/edk2/blob/1eeca0750af5af2f0e78437bf791ac2de74bde74/MdePkg/Library/BaseRngLib/Rand/RdRand.c#L124-L125.
Therefore, `BaseRngLibConstructor()` should continue to assert RDRAND
support.

However, older platforms do not support RDRAND, such as QEMU in some
configurations. Therefore, define an RngLib library class for such
systems, using a new flag. Maintain current behaviour by default.

Note that this is less secure behaviour, and should be avoided in
production.

Cc: Guo Dong <guo.dong@intel.com>
Cc: Ray Ni <ray.ni@intel.com>
Cc: Sean Rhodes <sean@starlabs.systems>
Cc: James Lu <james.lu@intel.com>
Cc: Gua Guo <gua.guo@intel.com>
Signed-off-by: Benjamin Doron <benjamin.doron@9elements.com>
---
 UefiPayloadPkg/UefiPayloadPkg.dsc | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/UefiPayloadPkg/UefiPayloadPkg.dsc b/UefiPayloadPkg/UefiPayloadPkg.dsc
index 9847f189fff5..1e803ba01567 100644
--- a/UefiPayloadPkg/UefiPayloadPkg.dsc
+++ b/UefiPayloadPkg/UefiPayloadPkg.dsc
@@ -130,6 +130,7 @@
   # This is how BaseCpuTimerLib works, and a recommended way to get Frequence, so set the default value as TRUE.
   # Note: for emulation platform such as QEMU, this may not work and should set it as FALSE
   DEFINE CPU_TIMER_LIB_ENABLE  = TRUE
+  DEFINE CPU_RNG_ENABLE        = TRUE
 
   DEFINE MULTIPLE_DEBUG_PORT_SUPPORT = FALSE
 
@@ -204,7 +205,11 @@
 !endif
   IntrinsicLib|CryptoPkg/Library/IntrinsicLib/IntrinsicLib.inf
   OpensslLib|CryptoPkg/Library/OpensslLib/OpensslLib.inf
+!if $(CPU_RNG_ENABLE) == TRUE
   RngLib|MdePkg/Library/BaseRngLib/BaseRngLib.inf
+!else
+  RngLib|MdePkg/Library/BaseRngLibTimerLib/BaseRngLibTimerLib.inf
+!endif
   HobLib|UefiPayloadPkg/Library/DxeHobLib/DxeHobLib.inf
 
   #
-- 
2.39.2


             reply	other threads:[~2023-04-25 17:09 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-04-25 17:09 Benjamin Doron [this message]
2023-04-25 17:09 ` [edk2-devel][PATCH v1 2/2] UefiPayloadPkg: Enable RNG support Benjamin Doron
2023-04-26 12:33   ` Sean Rhodes
2023-04-26 12:55     ` Guo, Gua
2023-04-26 13:10       ` Sheng Lean Tan
2023-04-26 22:43         ` Guo, Gua
2023-04-26 13:09     ` [edk2-devel] [PATCH " Sheng Lean Tan
2023-04-26 18:07   ` [edk2-devel][PATCH " Pedro Falcato
2023-04-26 21:24     ` [edk2-devel] [PATCH " Benjamin Doron
2023-04-26 12:33 ` [edk2-devel][PATCH v1 1/2] UefiPayloadPkg: Define RngLibTimerLib for systems without RDRAND Sean Rhodes

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-list from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=7edb8c7baae2fc58034a62f50f5f4000fb5bd102.1682442501.git.benjamin.doron00@gmail.com \
    --to=devel@edk2.groups.io \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox