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:39 -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:39 -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:38 -0700 From: "Dong, Eric" To: devel@edk2.groups.io Subject: [Patch 2/3] SecurityPkg/OpalPassword: Change send BlockSID policy. Date: Tue, 7 May 2019 16:00:52 +0800 Message-Id: <20190507080053.15056-3-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 Change SendBlockSID command time from ReadyToBoot to EndOfDxe. Signed-off-by: Eric Dong --- SecurityPkg/Tcg/Opal/OpalPassword/OpalDriver.c | 104 +++++++++++-------------- 1 file changed, 46 insertions(+), 58 deletions(-) diff --git a/SecurityPkg/Tcg/Opal/OpalPassword/OpalDriver.c b/SecurityPkg/Tcg/Opal/OpalPassword/OpalDriver.c index e3f5056953..a3d4350c67 100644 --- a/SecurityPkg/Tcg/Opal/OpalPassword/OpalDriver.c +++ b/SecurityPkg/Tcg/Opal/OpalPassword/OpalDriver.c @@ -574,6 +574,47 @@ BuildOpalDeviceInfoNvme ( FreePool (DevInfoNvme); } +/** + + Send BlockSid command if needed. + +**/ +VOID +SendBlockSidCommand ( + VOID + ) +{ + OPAL_DRIVER_DEVICE *Itr; + TCG_RESULT Result; + OPAL_SESSION Session; + UINT32 PpStorageFlag; + + PpStorageFlag = Tcg2PhysicalPresenceLibGetManagementFlags (); + if ((PpStorageFlag & TCG2_BIOS_STORAGE_MANAGEMENT_FLAG_ENABLE_BLOCK_SID) != 0) { + // + // Send BlockSID command to each Opal disk + // + Itr = mOpalDriver.DeviceList; + while (Itr != NULL) { + if (Itr->OpalDisk.SupportedAttributes.BlockSid) { + ZeroMem(&Session, sizeof(Session)); + Session.Sscp = Itr->OpalDisk.Sscp; + Session.MediaId = Itr->OpalDisk.MediaId; + Session.OpalBaseComId = Itr->OpalDisk.OpalBaseComId; + + DEBUG ((DEBUG_INFO, "OpalPassword: EndOfDxe point, send BlockSid command to device!\n")); + Result = OpalBlockSid (&Session, TRUE); // HardwareReset must always be TRUE + if (Result != TcgResultSuccess) { + DEBUG ((DEBUG_ERROR, "OpalBlockSid fail\n")); + break; + } + } + + Itr = Itr->Next; + } + } +} + /** Notification function of EFI_END_OF_DXE_EVENT_GROUP_GUID event group. @@ -645,6 +686,11 @@ OpalEndOfDxeEventNotify ( TmpDev = TmpDev->Next; } + // + // Send BlockSid command if needed. + // + SendBlockSidCommand (); + DEBUG ((DEBUG_INFO, "%a() - exit\n", __FUNCTION__)); gBS->CloseEvent (Event); @@ -2368,53 +2414,6 @@ OpalDriverGetDeviceList( return mOpalDriver.DeviceList; } -/** - ReadyToBoot callback to send BlockSid command. - - @param Event Pointer to this event - @param Context Event handler private Data - -**/ -VOID -EFIAPI -ReadyToBootCallback ( - IN EFI_EVENT Event, - IN VOID *Context - ) -{ - OPAL_DRIVER_DEVICE *Itr; - TCG_RESULT Result; - OPAL_SESSION Session; - UINT32 PpStorageFlag; - - gBS->CloseEvent (Event); - - PpStorageFlag = Tcg2PhysicalPresenceLibGetManagementFlags (); - if ((PpStorageFlag & TCG2_BIOS_STORAGE_MANAGEMENT_FLAG_ENABLE_BLOCK_SID) != 0) { - // - // Send BlockSID command to each Opal disk - // - Itr = mOpalDriver.DeviceList; - while (Itr != NULL) { - if (Itr->OpalDisk.SupportedAttributes.BlockSid) { - ZeroMem(&Session, sizeof(Session)); - Session.Sscp = Itr->OpalDisk.Sscp; - Session.MediaId = Itr->OpalDisk.MediaId; - Session.OpalBaseComId = Itr->OpalDisk.OpalBaseComId; - - DEBUG ((DEBUG_INFO, "OpalPassword: ReadyToBoot point, send BlockSid command to device!\n")); - Result = OpalBlockSid (&Session, TRUE); // HardwareReset must always be TRUE - if (Result != TcgResultSuccess) { - DEBUG ((DEBUG_ERROR, "OpalBlockSid fail\n")); - break; - } - } - - Itr = Itr->Next; - } - } -} - /** Stop this Controller. @@ -2677,7 +2676,6 @@ EfiDriverEntryPoint( ) { EFI_STATUS Status; - EFI_EVENT ReadyToBootEvent; EFI_EVENT EndOfDxeEvent; Status = EfiLibInstallDriverBindingComponentName2 ( @@ -2710,16 +2708,6 @@ EfiDriverEntryPoint( ); ASSERT_EFI_ERROR (Status); - // - // register a ReadyToBoot event callback for sending BlockSid command - // - Status = EfiCreateEventReadyToBootEx ( - TPL_CALLBACK, - ReadyToBootCallback, - (VOID *) &ImageHandle, - &ReadyToBootEvent - ); - // // Install Hii packages. // -- 2.15.0.windows.1