]> git.proxmox.com Git - mirror_edk2.git/commitdiff
SecurityPkg OpalPasswordSmm: Enhance BlockSid Logic.
authorEric Dong <eric.dong@intel.com>
Wed, 4 May 2016 04:48:50 +0000 (12:48 +0800)
committerLiming Gao <liming.gao@intel.com>
Thu, 5 May 2016 04:52:47 +0000 (12:52 +0800)
BlockSid feature can be retrieve from the header info.
Update the logic, check BlockSid capability before use it.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Eric Dong <eric.dong@intel.com>
Reviewed-by: Feng Tian <feng.tian@intel.com>
SecurityPkg/Tcg/Opal/OpalPasswordSmm/OpalPasswordSmm.c

index b7e2d552d5c2f25dd0e3ccecdc450e2779925d5b..46311bd8a0d98f98d686625813c29a3e7e829a2a 100644 (file)
@@ -180,12 +180,14 @@ ExtractDeviceInfoFromDevicePath (
   TRUE means that the device is partially or fully locked.\r
   This will perform a Level 0 Discovery and parse the locking feature descriptor\r
 \r
-  @param[in]      OpalDev        Opal object to determine if locked\r
+  @param[in]      OpalDev             Opal object to determine if locked\r
+  @param[out]     BlockSidSupported   Whether device support BlockSid feature.\r
 \r
 **/\r
 BOOLEAN\r
 IsOpalDeviceLocked(\r
-  OPAL_SMM_DEVICE    *OpalDev\r
+  OPAL_SMM_DEVICE    *OpalDev,\r
+  BOOLEAN            *BlockSidSupported\r
   )\r
 {\r
   OPAL_SESSION                   Session;\r
@@ -203,7 +205,8 @@ IsOpalDeviceLocked(
   }\r
 \r
   OpalDev->OpalBaseComId = OpalBaseComId;\r
-  Session.OpalBaseComId = OpalBaseComId;\r
+  Session.OpalBaseComId  = OpalBaseComId;\r
+  *BlockSidSupported     = SupportedAttributes.BlockSid == 1 ? TRUE : FALSE;\r
 \r
   Ret = OpalGetLockingInfo(&Session, &LockingFeature);\r
   if (Ret != TcgResultSuccess) {\r
@@ -346,6 +349,7 @@ SmmUnlockOpalPassword (
   UINTN                          MemoryBase;\r
   UINTN                          MemoryLength;\r
   OPAL_SESSION                   Session;\r
+  BOOLEAN                        BlockSidSupport;\r
 \r
   ZeroMem (StorePcieConfDataList, sizeof (StorePcieConfDataList));\r
   Status = EFI_DEVICE_ERROR;\r
@@ -431,13 +435,14 @@ SmmUnlockOpalPassword (
     }\r
 \r
     Status = EFI_DEVICE_ERROR;\r
-    if (IsOpalDeviceLocked(OpalDev)) {\r
+    BlockSidSupport = FALSE;\r
+    if (IsOpalDeviceLocked (OpalDev, &BlockSidSupport)) {\r
       ZeroMem(&Session, sizeof(Session));\r
       Session.Sscp = &OpalDev->Sscp;\r
       Session.MediaId = 0;\r
       Session.OpalBaseComId = OpalDev->OpalBaseComId;\r
 \r
-      if (mSendBlockSID) {\r
+      if (mSendBlockSID && BlockSidSupport) {\r
         Result = OpalBlockSid (&Session, TRUE);\r
         if (Result != TcgResultSuccess) {\r
           break;\r