]> git.proxmox.com Git - mirror_edk2.git/commitdiff
SecurityPkg/OpalPassword: Fix "Enable Feature" Menu disappear issue
authorEric Dong <eric.dong@intel.com>
Mon, 10 Dec 2018 06:58:43 +0000 (14:58 +0800)
committerEric Dong <eric.dong@intel.com>
Thu, 9 May 2019 06:32:52 +0000 (14:32 +0800)
https://bugzilla.tianocore.org/show_bug.cgi?id=1782

After change behavior to send BlockSid command at EndOfDxe point,
check device ownership command will return un-authority error, it
finally caused opal driver can't show "Enable Feature" menu.

Update the code logic to send detect device ownership command
before send BlockSID command.

Signed-off-by: Eric Dong <eric.dong@intel.com>
Reviewed-by: Hao A Wu <hao.a.wu@intel.com>
SecurityPkg/Tcg/Opal/OpalPassword/OpalDriver.c
SecurityPkg/Tcg/Opal/OpalPassword/OpalDriver.h
SecurityPkg/Tcg/Opal/OpalPassword/OpalHii.c
SecurityPkg/Tcg/Opal/OpalPassword/OpalHii.h

index 009a97f66fac1eece091e7ae9dcee525b4ec6e8f..965205c0b22447f46a6070018eed23a04379f0d5 100644 (file)
@@ -458,6 +458,11 @@ SendBlockSidCommand (
           DEBUG ((DEBUG_ERROR, "OpalBlockSid fail\n"));\r
           break;\r
         }\r
+\r
+        //\r
+        // Record BlockSID command has been sent.\r
+        //\r
+        Itr->OpalDisk.SentBlockSID = TRUE;\r
       }\r
 \r
       Itr = Itr->Next;\r
@@ -2204,6 +2209,12 @@ ProcessOpalRequest (
         ProcessOpalRequestEnableFeature (Dev, L"Enable Feature:");\r
       }\r
 \r
+      //\r
+      // Update Device ownership.\r
+      // Later BlockSID command may block the update.\r
+      //\r
+      OpalDiskUpdateOwnerShip (&Dev->OpalDisk);\r
+\r
       break;\r
     }\r
 \r
index a056e0610679ae7c48baa2887be5cd89ae8d65dc..beeabb1c0ae25a1795ef1ff32882e9db3dfee26a 100644 (file)
@@ -143,6 +143,7 @@ typedef struct {
   UINT8                                           Password[OPAL_MAX_PASSWORD_SIZE];\r
 \r
   UINT32                                          EstimateTimeCost;\r
+  BOOLEAN                                         SentBlockSID;           // Check whether BlockSid command has been sent.\r
 } OPAL_DISK;\r
 \r
 //\r
index d0f3eda1e8437e3ec908aa0bd8d77a5f13ca1602..f101ca1c200121b2159ae9811c19160bb48b4b58 100644 (file)
@@ -1215,6 +1215,40 @@ OpalDiskInitialize (
   return OpalDiskUpdateStatus (&Dev->OpalDisk);\r
 }\r
 \r
+/**\r
+  Update the device ownship\r
+\r
+  @param OpalDisk                The Opal device.\r
+\r
+  @retval EFI_SUCESS             Get ownership success.\r
+  @retval EFI_ACCESS_DENIED      Has send BlockSID command, can't change ownership.\r
+  @retval EFI_INVALID_PARAMETER  Not get Msid info before get ownership info.\r
+\r
+**/\r
+EFI_STATUS\r
+OpalDiskUpdateOwnerShip (\r
+  OPAL_DISK        *OpalDisk\r
+  )\r
+{\r\r
+  OPAL_SESSION  Session;\r
+\r
+  if (OpalDisk->MsidLength == 0) {\r
+    return EFI_INVALID_PARAMETER;\r
+  }\r
+\r
+  if (OpalDisk->SentBlockSID) {\r
+    return EFI_ACCESS_DENIED;\r
+  }\r
+\r
+  ZeroMem(&Session, sizeof(Session));\r
+  Session.Sscp = OpalDisk->Sscp;\r
+  Session.MediaId = OpalDisk->MediaId;\r
+  Session.OpalBaseComId = OpalDisk->OpalBaseComId;\r
+\r
+  OpalDisk->Owner = OpalUtilDetermineOwnership(&Session, OpalDisk->Msid, OpalDisk->MsidLength);\r\r
+  return EFI_SUCCESS;\r
+}\r
+\r
 /**\r
   Update the device info.\r
 \r
@@ -1223,6 +1257,7 @@ OpalDiskInitialize (
   @retval EFI_SUCESS             Initialize the device success.\r
   @retval EFI_DEVICE_ERROR       Get info from device failed.\r
   @retval EFI_INVALID_PARAMETER  Not get Msid info before get ownership info.\r
+  @retval EFI_ACCESS_DENIED      Has send BlockSID command, can't change ownership.\r
 \r
 **/\r
 EFI_STATUS\r
@@ -1243,15 +1278,6 @@ OpalDiskUpdateStatus (
     return EFI_DEVICE_ERROR;\r
   }\r
 \r
-  if (OpalDisk->MsidLength == 0) {\r
-    return EFI_INVALID_PARAMETER;\r
-  } else {\r
-    //\r
-    // Base on the Msid info to get the ownership, so Msid info must get first.\r
-    //\r
-    OpalDisk->Owner = OpalUtilDetermineOwnership(&Session, OpalDisk->Msid, OpalDisk->MsidLength);\r
-  }\r
-\r
-  return EFI_SUCCESS;\r
+  return OpalDiskUpdateOwnerShip (OpalDisk);\r
 }\r
 \r
index d3e236e2fea7ae0eded1ee3b348780f74931fc63..89c709df991ed248a35f694ff145ae16dd2d35d2 100644 (file)
@@ -357,4 +357,19 @@ OpalDiskInitialize (
   IN OPAL_DRIVER_DEVICE          *Dev\r
   );\r
 \r
+/**\r
+  Update the device ownership\r
+\r
+  @param OpalDisk                The Opal device.\r
+\r
+  @retval EFI_SUCESS             Get ownership success.\r
+  @retval EFI_ACCESS_DENIED      Has send BlockSID command, can't change ownership.\r
+  @retval EFI_INVALID_PARAMETER  Not get Msid info before get ownership info.\r
+\r
+**/\r
+EFI_STATUS\r
+OpalDiskUpdateOwnerShip (\r
+  OPAL_DISK        *OpalDisk\r
+  );\r
+\r
 #endif // _HII_H_\r