From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: mx.groups.io; dkim=missing; spf=fail (domain: intel.com, ip: , mailfrom: eric.dong@intel.com) Received: from mga01.intel.com (mga01.intel.com []) by groups.io with SMTP; Tue, 07 May 2019 01:01:40 -0700 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga006.fm.intel.com ([10.253.24.20]) by fmsmga101.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 07 May 2019 01:01:40 -0700 X-ExtLoop1: 1 Received: from ydong10-win10.ccr.corp.intel.com ([10.239.158.133]) by fmsmga006.fm.intel.com with ESMTP; 07 May 2019 01:01:39 -0700 From: "Dong, Eric" To: devel@edk2.groups.io Subject: [Patch 3/3] SecurityPkg/OpalPassword: Fix "Enable Feature" Menu disappear issue. Date: Tue, 7 May 2019 16:00:53 +0800 Message-Id: <20190507080053.15056-4-eric.dong@intel.com> X-Mailer: git-send-email 2.21.0.windows.1 In-Reply-To: <20190507080053.15056-1-eric.dong@intel.com> References: <20190507080053.15056-1-eric.dong@intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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 --- SecurityPkg/Tcg/Opal/OpalPassword/OpalDriver.c | 11 ++++++ SecurityPkg/Tcg/Opal/OpalPassword/OpalDriver.h | 1 + SecurityPkg/Tcg/Opal/OpalPassword/OpalHii.c | 46 ++++++++++++++++++++------ SecurityPkg/Tcg/Opal/OpalPassword/OpalHii.h | 15 +++++++++ 4 files changed, 63 insertions(+), 10 deletions(-) diff --git a/SecurityPkg/Tcg/Opal/OpalPassword/OpalDriver.c b/SecurityPkg/Tcg/Opal/OpalPassword/OpalDriver.c index a3d4350c67..847749be66 100644 --- a/SecurityPkg/Tcg/Opal/OpalPassword/OpalDriver.c +++ b/SecurityPkg/Tcg/Opal/OpalPassword/OpalDriver.c @@ -608,6 +608,11 @@ SendBlockSidCommand ( DEBUG ((DEBUG_ERROR, "OpalBlockSid fail\n")); break; } + + // + // Record BlockSID command has been sent. + // + Itr->OpalDisk.SentBlockSID = TRUE; } Itr = Itr->Next; @@ -2310,6 +2315,12 @@ ProcessOpalRequest ( ProcessOpalRequestEnableFeature (Dev, L"Enable Feature:"); } + // + // Update Device ownership. + // Later BlockSID command may block the update. + // + OpalDiskUpdateOwnerShip (&Dev->OpalDisk); + break; } diff --git a/SecurityPkg/Tcg/Opal/OpalPassword/OpalDriver.h b/SecurityPkg/Tcg/Opal/OpalPassword/OpalDriver.h index 2bca770620..1b1e372c51 100644 --- a/SecurityPkg/Tcg/Opal/OpalPassword/OpalDriver.h +++ b/SecurityPkg/Tcg/Opal/OpalPassword/OpalDriver.h @@ -149,6 +149,7 @@ typedef struct { UINT8 Password[OPAL_MAX_PASSWORD_SIZE]; UINT32 EstimateTimeCost; + BOOLEAN SentBlockSID; // Check whether BlockSid command has been sent. } OPAL_DISK; // diff --git a/SecurityPkg/Tcg/Opal/OpalPassword/OpalHii.c b/SecurityPkg/Tcg/Opal/OpalPassword/OpalHii.c index 4336604d0d..6587e0dd1a 100644 --- a/SecurityPkg/Tcg/Opal/OpalPassword/OpalHii.c +++ b/SecurityPkg/Tcg/Opal/OpalPassword/OpalHii.c @@ -1220,6 +1220,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; +} + /** Update the device info. @@ -1228,6 +1262,7 @@ OpalDiskInitialize ( @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. **/ EFI_STATUS @@ -1248,15 +1283,6 @@ OpalDiskUpdateStatus ( 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); } diff --git a/SecurityPkg/Tcg/Opal/OpalPassword/OpalHii.h b/SecurityPkg/Tcg/Opal/OpalPassword/OpalHii.h index a4bb19ad60..6d01d3e614 100644 --- a/SecurityPkg/Tcg/Opal/OpalPassword/OpalHii.h +++ b/SecurityPkg/Tcg/Opal/OpalPassword/OpalHii.h @@ -385,4 +385,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_ -- 2.15.0.windows.1