mirror of
				https://gitlab.com/qemu-project/edk2.git
				synced 2025-10-30 07:56:39 +08:00 
			
		
		
		
	SecurityPkg/OpalPassword: Fix "Enable Feature" Menu disappear issue
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>
This commit is contained in:
		| @ -458,6 +458,11 @@ SendBlockSidCommand ( | ||||
|           DEBUG ((DEBUG_ERROR, "OpalBlockSid fail\n")); | ||||
|           break; | ||||
|         } | ||||
|  | ||||
|         // | ||||
|         // Record BlockSID command has been sent. | ||||
|         // | ||||
|         Itr->OpalDisk.SentBlockSID = TRUE; | ||||
|       } | ||||
|  | ||||
|       Itr = Itr->Next; | ||||
| @ -2204,6 +2209,12 @@ ProcessOpalRequest ( | ||||
|         ProcessOpalRequestEnableFeature (Dev, L"Enable Feature:"); | ||||
|       } | ||||
|  | ||||
|       // | ||||
|       // Update Device ownership. | ||||
|       // Later BlockSID command may block the update. | ||||
|       // | ||||
|       OpalDiskUpdateOwnerShip (&Dev->OpalDisk); | ||||
|  | ||||
|       break; | ||||
|     } | ||||
|  | ||||
|  | ||||
| @ -143,6 +143,7 @@ typedef struct { | ||||
|   UINT8                                           Password[OPAL_MAX_PASSWORD_SIZE]; | ||||
|  | ||||
|   UINT32                                          EstimateTimeCost; | ||||
|   BOOLEAN                                         SentBlockSID;           // Check whether BlockSid command has been sent. | ||||
| } OPAL_DISK; | ||||
|  | ||||
| // | ||||
|  | ||||
| @ -1215,6 +1215,40 @@ OpalDiskInitialize ( | ||||
|   return OpalDiskUpdateStatus (&Dev->OpalDisk); | ||||
| } | ||||
|  | ||||
| /** | ||||
|   Update the device ownship | ||||
|  | ||||
|   @param OpalDisk                The Opal device. | ||||
|  | ||||
|   @retval EFI_SUCESS             Get ownership success. | ||||
|   @retval EFI_ACCESS_DENIED      Has send BlockSID command, can't change ownership. | ||||
|   @retval EFI_INVALID_PARAMETER  Not get Msid info before get ownership info. | ||||
|  | ||||
| **/ | ||||
| EFI_STATUS | ||||
| OpalDiskUpdateOwnerShip ( | ||||
|   OPAL_DISK        *OpalDisk | ||||
|   ) | ||||
| { | ||||
|  | ||||
|   OPAL_SESSION  Session; | ||||
|  | ||||
|   if (OpalDisk->MsidLength == 0) { | ||||
|     return EFI_INVALID_PARAMETER; | ||||
|   } | ||||
|  | ||||
|   if (OpalDisk->SentBlockSID) { | ||||
|     return EFI_ACCESS_DENIED; | ||||
|   } | ||||
|  | ||||
|   ZeroMem(&Session, sizeof(Session)); | ||||
|   Session.Sscp = OpalDisk->Sscp; | ||||
|   Session.MediaId = OpalDisk->MediaId; | ||||
|   Session.OpalBaseComId = OpalDisk->OpalBaseComId; | ||||
|  | ||||
|   OpalDisk->Owner = OpalUtilDetermineOwnership(&Session, OpalDisk->Msid, OpalDisk->MsidLength); | ||||
|  | ||||
|   return EFI_SUCCESS; | ||||
| } | ||||
|  | ||||
| /** | ||||
| @ -1223,6 +1257,7 @@ OpalDiskInitialize ( | ||||
|   @param OpalDisk                The Opal device. | ||||
|  | ||||
|   @retval EFI_SUCESS             Initialize the device success. | ||||
|   @retval EFI_DEVICE_ERROR       Get info from device failed. | ||||
|   @retval EFI_INVALID_PARAMETER  Not get Msid info before get ownership info. | ||||
|   @retval EFI_ACCESS_DENIED      Has send BlockSID command, can't change ownership. | ||||
|  | ||||
| @ -1243,15 +1278,6 @@ OpalDiskUpdateStatus ( | ||||
|   TcgResult = OpalGetLockingInfo(&Session, &OpalDisk->LockingFeature); | ||||
|   if (TcgResult != TcgResultSuccess) { | ||||
|     return EFI_DEVICE_ERROR; | ||||
|   if (OpalDisk->MsidLength == 0) { | ||||
|     return EFI_INVALID_PARAMETER; | ||||
|   } else { | ||||
|     // | ||||
|     // Base on the Msid info to get the ownership, so Msid info must get first. | ||||
|     // | ||||
|     OpalDisk->Owner = OpalUtilDetermineOwnership(&Session, OpalDisk->Msid, OpalDisk->MsidLength); | ||||
|   } | ||||
|  | ||||
|   return EFI_SUCCESS; | ||||
|   } | ||||
|  | ||||
|   return OpalDiskUpdateOwnerShip (OpalDisk); | ||||
|  | ||||
| @ -357,4 +357,19 @@ OpalDiskInitialize ( | ||||
|   IN OPAL_DRIVER_DEVICE          *Dev | ||||
|   ); | ||||
|  | ||||
| /** | ||||
|   Update the device ownership | ||||
|  | ||||
|   @param OpalDisk                The Opal device. | ||||
|  | ||||
|   @retval EFI_SUCESS             Get ownership success. | ||||
|   @retval EFI_ACCESS_DENIED      Has send BlockSID command, can't change ownership. | ||||
|   @retval EFI_INVALID_PARAMETER  Not get Msid info before get ownership info. | ||||
|  | ||||
| **/ | ||||
| EFI_STATUS | ||||
| OpalDiskUpdateOwnerShip ( | ||||
|   OPAL_DISK        *OpalDisk | ||||
|   ); | ||||
|  | ||||
| #endif // _HII_H_ | ||||
|  | ||||
		Reference in New Issue
	
	Block a user
	 Eric Dong
					Eric Dong