public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
From: Jagadeesh Ujja <jagadeesh.ujja@arm.com>
To: edk2-devel@lists.01.org, liming.gao@intel.com,
	chao.b.zhang@intel.com, lersek@readhat.com,
	leif.lindholm@linaro.org, ard.biesheuvel@linaro.org
Subject: [RFC PATCH v2 11/11] CryptoPkg/BaseCryptLib: Hack to get time in MM Standalone mode
Date: Tue, 27 Nov 2018 16:56:26 +0530	[thread overview]
Message-ID: <20181127112626.7854-12-jagadeesh.ujja@arm.com> (raw)
In-Reply-To: <20181127112626.7854-1-jagadeesh.ujja@arm.com>

This is hack to get the time when executing in MM Standalone mode. It is
not clear how to implement a function that gets the current time. So
using this as a hack for now.

Change-Id: I5b86a31c3023f31f04985e82a1089cf4d022f060
Signed-off-by: Jagadeesh Ujja <jagadeesh.ujja@arm.com>
Signed-off-by: Thomas Abraham <thomas.abraham@arm.com>
---
 .../Library/BaseCryptLib/BaseCryptLib.inf     |  5 ++++
 .../Library/BaseCryptLib/RuntimeCryptLib.inf  |  5 ++++
 .../BaseCryptLib/SysCall/TimerWrapper.c       | 27 ++++++++++++++-----
 3 files changed, 31 insertions(+), 6 deletions(-)

diff --git a/CryptoPkg/Library/BaseCryptLib/BaseCryptLib.inf b/CryptoPkg/Library/BaseCryptLib/BaseCryptLib.inf
index c8aafefbab..df4aca6c20 100644
--- a/CryptoPkg/Library/BaseCryptLib/BaseCryptLib.inf
+++ b/CryptoPkg/Library/BaseCryptLib/BaseCryptLib.inf
@@ -76,6 +76,7 @@
 [Packages]
   MdePkg/MdePkg.dec
   CryptoPkg/CryptoPkg.dec
+  StandaloneMmPkg/StandaloneMmPkg.dec
 
 [LibraryClasses]
   BaseLib
@@ -86,6 +87,10 @@
   OpensslLib
   IntrinsicLib
   PrintLib
+  PcdLib
+
+[FeaturePcd]
+  gStandaloneMmPkgTokenSpaceGuid.PcdStandaloneMmEnable
 
 #
 # Remove these [BuildOptions] after this library is cleaned up
diff --git a/CryptoPkg/Library/BaseCryptLib/RuntimeCryptLib.inf b/CryptoPkg/Library/BaseCryptLib/RuntimeCryptLib.inf
index 32628c8835..651a6736ba 100644
--- a/CryptoPkg/Library/BaseCryptLib/RuntimeCryptLib.inf
+++ b/CryptoPkg/Library/BaseCryptLib/RuntimeCryptLib.inf
@@ -80,6 +80,7 @@
 [Packages]
   MdePkg/MdePkg.dec
   CryptoPkg/CryptoPkg.dec
+  StandaloneMmPkg/StandaloneMmPkg.dec
 
 [LibraryClasses]
   BaseLib
@@ -91,6 +92,10 @@
   OpensslLib
   IntrinsicLib
   PrintLib
+  PcdLib
+
+[FeaturePcd]
+  gStandaloneMmPkgTokenSpaceGuid.PcdStandaloneMmEnable
 
 #
 # Remove these [BuildOptions] after this library is cleaned up
diff --git a/CryptoPkg/Library/BaseCryptLib/SysCall/TimerWrapper.c b/CryptoPkg/Library/BaseCryptLib/SysCall/TimerWrapper.c
index 5f9b0c20d7..d01b5c5fc1 100644
--- a/CryptoPkg/Library/BaseCryptLib/SysCall/TimerWrapper.c
+++ b/CryptoPkg/Library/BaseCryptLib/SysCall/TimerWrapper.c
@@ -3,6 +3,7 @@
   for OpenSSL-based Cryptographic Library (used in DXE & RUNTIME).
 
 Copyright (c) 2010 - 2018, Intel Corporation. All rights reserved.<BR>
+Copyright (c) 2018, ARM Limited. All rights reserved.<BR>
 This program and the accompanying materials
 are licensed and made available under the terms and conditions of the BSD License
 which accompanies this distribution.  The full text of the license may be found at
@@ -77,12 +78,26 @@ time_t time (time_t *timer)
   time_t      CalTime;
   UINTN       Year;
 
-  //
-  // Get the current time and date information
-  //
-  Status = gRT->GetTime (&Time, NULL);
-  if (EFI_ERROR (Status) || (Time.Year < 1970)) {
-    return 0;
+  if (!PcdGetBool (PcdStandaloneMmEnable)) {
+    //
+    // Get the current time and date information
+    //
+    Status = gRT->GetTime (&Time, NULL);
+    if (EFI_ERROR (Status) || (Time.Year < 1970)) {
+      return 0;
+    }
+  } else {
+    //
+    //[ToDo] Find out a way to get the current time for code executing as MM_STANDALONE
+    //
+    Time.Year = 2007;
+    Time.Month = 11;
+    Time.Day = 29;
+    Time.Hour = 17;
+    Time.Minute = 43;
+    Time.Second = 30;
+
+    Year  = (UINTN) (Time.Year % 100);
   }
 
   //
-- 
2.19.1



      parent reply	other threads:[~2018-11-27 11:27 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-11-27 11:26 [RFC PATCH v2 00/11] Extend secure variable service to be usable from Standalone MM Jagadeesh Ujja
2018-11-27 11:26 ` [RFC PATCH v2 01/11] MdeModulePkg/Variable: replace all uses of AsmLfence with MemoryFence Jagadeesh Ujja
2018-11-27 11:26 ` [RFC PATCH v2 02/11] StandaloneMmPkg: Pull in additonal libraries from staging branch Jagadeesh Ujja
2018-11-27 11:26 ` [RFC PATCH v2 03/11] MdeModulePkg/Library: Add StandaloneMmRuntimeDxe library Jagadeesh Ujja
2018-11-27 11:26 ` [RFC PATCH v2 04/11] ArmPlatformPkg/NorFlashDxe: allow reusability as a MM driver Jagadeesh Ujja
2018-11-27 11:52   ` Leif Lindholm
2018-11-27 11:26 ` [RFC PATCH v2 05/11] MdeModulePkg/FaultTolerantWriteDxe: " Jagadeesh Ujja
2018-11-27 11:26 ` [RFC PATCH v2 06/11] MdeModulePkg/Variable/RuntimeDxe: adapt for usability with MM Standalone Jagadeesh Ujja
2018-11-27 11:26 ` [RFC PATCH v2 07/11] MdeModulePkg/Variable/RuntimeDxe: adapt as a MM Standalone driver Jagadeesh Ujja
2018-11-27 11:26 ` [RFC PATCH v2 08/11] SecurityPkg/AuthVariableLib: allow MM_STANDALONE drivers to use this library Jagadeesh Ujja
2018-11-27 11:26 ` [RFC PATCH v2 09/11] MdeModulePkg/VarCheckLib: " Jagadeesh Ujja
2018-11-27 11:26 ` [RFC PATCH v2 10/11] CryptoPkg/BaseCryptLib: " Jagadeesh Ujja
2018-11-27 11:26 ` Jagadeesh Ujja [this message]

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=20181127112626.7854-12-jagadeesh.ujja@arm.com \
    --to=devel@edk2.groups.io \
    /path/to/YOUR_REPLY

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

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