SecurityPkg/OpalPasswordSmm: Fix get BlockSid value error.
OpalDxe driver already enhanced to use TCG PP to send BlockSid request, so the old variable OPAL_EXTRA_INFO_VAR_NAME is not used by OpalDxe driver. But OpalSmm driver still consume this variable to decide whether need to send BlockSid when S3 resume. This patch fixed this issue by change OpalSmm driver to consume Tcg PP actions.
Signed-off-by: Eric Dong <eric.dong@intel.com>
diff --git a/SecurityPkg/Tcg/Opal/OpalPasswordSmm/OpalPasswordSmm.c b/SecurityPkg/Tcg/Opal/OpalPasswordSmm/OpalPasswordSmm.c
index 0ea92b1..5431b78 100644
--- a/SecurityPkg/Tcg/Opal/OpalPasswordSmm/OpalPasswordSmm.c
+++ b/SecurityPkg/Tcg/Opal/OpalPasswordSmm/OpalPasswordSmm.c
@@ -51,8 +51,6 @@
LIST_ENTRY *mOpalDeviceList;
LIST_ENTRY mSmmDeviceList = INITIALIZE_LIST_HEAD_VARIABLE (mSmmDeviceList);
-BOOLEAN mSendBlockSID = FALSE;
-
// AHCI
UINT32 mAhciBar = 0;
EFI_AHCI_REGISTERS mAhciRegisters;
@@ -347,10 +345,19 @@
UINTN MemoryLength;
OPAL_SESSION Session;
BOOLEAN BlockSidSupport;
+ UINT32 PpStorageFlag;
+ BOOLEAN BlockSIDEnabled;
ZeroMem (StorePcieConfDataList, sizeof (StorePcieConfDataList));
Status = EFI_DEVICE_ERROR;
+ PpStorageFlag = Tcg2PhysicalPresenceLibGetManagementFlags ();
+ if ((PpStorageFlag & TCG2_BIOS_STORAGE_MANAGEMENT_FLAG_ENABLE_BLOCK_SID) != 0) {
+ BlockSIDEnabled = TRUE;
+ } else {
+ BlockSIDEnabled = FALSE;
+ }
+
//
// try to unlock all locked hdd disks.
//
@@ -445,7 +452,7 @@
}
}
- if (mSendBlockSID && BlockSidSupport) {
+ if (BlockSIDEnabled && BlockSidSupport) {
Result = OpalBlockSid (&Session, TRUE);
if (Result != TcgResultSuccess) {
break;
@@ -667,9 +674,6 @@
EFI_SMM_SW_REGISTER_CONTEXT Context;
EFI_HANDLE S3SleepEntryHandle;
EFI_SMM_SX_REGISTER_CONTEXT EntryRegisterContext;
- EFI_SMM_VARIABLE_PROTOCOL *SmmVariable;
- OPAL_EXTRA_INFO_VAR OpalExtraInfo;
- UINTN DataSize;
EFI_PHYSICAL_ADDRESS Address;
mBuffer = NULL;
@@ -778,21 +782,6 @@
//
mSwSmiValue = (UINT8) Context.SwSmiInputValue;
- Status = gSmst->SmmLocateProtocol (&gEfiSmmVariableProtocolGuid, NULL, (VOID**)&SmmVariable);
- if (!EFI_ERROR (Status)) {
- DataSize = sizeof (OPAL_EXTRA_INFO_VAR);
- Status = SmmVariable->SmmGetVariable (
- OPAL_EXTRA_INFO_VAR_NAME,
- &gOpalExtraInfoVariableGuid,
- NULL,
- &DataSize,
- &OpalExtraInfo
- );
- if (!EFI_ERROR (Status)) {
- mSendBlockSID = OpalExtraInfo.EnableBlockSid;
- }
- }
-
return EFI_SUCCESS;
EXIT:
diff --git a/SecurityPkg/Tcg/Opal/OpalPasswordSmm/OpalPasswordSmm.h b/SecurityPkg/Tcg/Opal/OpalPasswordSmm/OpalPasswordSmm.h
index bc559f0..00ce41a 100644
--- a/SecurityPkg/Tcg/Opal/OpalPasswordSmm/OpalPasswordSmm.h
+++ b/SecurityPkg/Tcg/Opal/OpalPasswordSmm/OpalPasswordSmm.h
@@ -46,11 +46,10 @@
#include <Library/DevicePathLib.h>
#include <Library/DxeServicesTableLib.h>
#include <Library/SmmIoLib.h>
+#include <Library/Tcg2PhysicalPresenceLib.h>
#include <IndustryStandard/Pci22.h>
-#include <Guid/OpalPasswordExtraInfoVariable.h>
-
#include "OpalAhciMode.h"
#include "OpalIdeMode.h"
#include "OpalNvmeMode.h"
diff --git a/SecurityPkg/Tcg/Opal/OpalPasswordSmm/OpalPasswordSmm.inf b/SecurityPkg/Tcg/Opal/OpalPasswordSmm/OpalPasswordSmm.inf
index c62fa13..aa302e2 100644
--- a/SecurityPkg/Tcg/Opal/OpalPasswordSmm/OpalPasswordSmm.inf
+++ b/SecurityPkg/Tcg/Opal/OpalPasswordSmm/OpalPasswordSmm.inf
@@ -59,9 +59,7 @@
DevicePathLib
OpalPasswordSupportLib
SmmIoLib
-
-[Guids]
- gOpalExtraInfoVariableGuid ## CONSUMES ## GUID
+ Tcg2PhysicalPresenceLib
[Protocols]
gEfiSmmSwDispatch2ProtocolGuid ## CONSUMES