summaryrefslogtreecommitdiffstats
path: root/SecurityPkg
diff options
context:
space:
mode:
authorEric Dong <eric.dong@intel.com>2016-04-22 15:36:36 +0800
committerJiewen Yao <jiewen.yao@intel.com>2016-04-29 12:49:23 +0800
commit83681c74f07978adbb621a467fe391ae901e2515 (patch)
tree640edf367102a9de9fd637628fa5b3f4cf14b27e /SecurityPkg
parentde2459d66d87eb526e3a21f1e6682fac8e1926c5 (diff)
downloadedk2-83681c74f07978adbb621a467fe391ae901e2515.tar.gz
edk2-83681c74f07978adbb621a467fe391ae901e2515.tar.bz2
edk2-83681c74f07978adbb621a467fe391ae901e2515.zip
SecurityPkg-Opal(1): Use fixed SMM communication buffer in OPAL password lib.
This patch enhance OPAL password lib SMM communication by using fixed SMM communication buffer. Update OPAL password lib to consume EDKII_PI_SMM_COMMUNICATION_REGION_TABLE as fixed communication buffer for SMM communication. This is designed to meet Microsoft WSMT table definition on FIXED_COMM_BUFFERS requirement. Cc: Eric Dong <eric.dong@intel.com> Cc: Feng Tian <feng.tian@intel.com> Cc: Laszlo Ersek <lersek@redhat.com> Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Eric Dong <eric.dong@intel.com> Reviewed-by: Feng Tian <feng.tian@intel.com>
Diffstat (limited to 'SecurityPkg')
-rw-r--r--SecurityPkg/Library/OpalPasswordSupportLib/OpalPasswordSupportLib.c32
-rw-r--r--SecurityPkg/Library/OpalPasswordSupportLib/OpalPasswordSupportLib.inf4
-rw-r--r--SecurityPkg/Library/OpalPasswordSupportLib/OpalPasswordSupportNotify.h2
3 files changed, 34 insertions, 4 deletions
diff --git a/SecurityPkg/Library/OpalPasswordSupportLib/OpalPasswordSupportLib.c b/SecurityPkg/Library/OpalPasswordSupportLib/OpalPasswordSupportLib.c
index eead27fbe0..837582359e 100644
--- a/SecurityPkg/Library/OpalPasswordSupportLib/OpalPasswordSupportLib.c
+++ b/SecurityPkg/Library/OpalPasswordSupportLib/OpalPasswordSupportLib.c
@@ -401,8 +401,36 @@ OpalInitCommunicateBuffer (
EFI_SMM_COMMUNICATE_HEADER *SmmCommunicateHeader;
OPAL_SMM_COMMUNICATE_HEADER *SmmFunctionHeader;
VOID *Buffer;
+ EDKII_PI_SMM_COMMUNICATION_REGION_TABLE *SmmCommRegionTable;
+ EFI_MEMORY_DESCRIPTOR *SmmCommMemRegion;
+ UINTN Index;
+ UINTN Size;
+ EFI_STATUS Status;
+
+ Buffer = NULL;
+ Status = EfiGetSystemConfigurationTable (
+ &gEdkiiPiSmmCommunicationRegionTableGuid,
+ (VOID **) &SmmCommRegionTable
+ );
+ if (EFI_ERROR (Status)) {
+ return NULL;
+ }
- Buffer = AllocateZeroPool (DataSize + OFFSET_OF (EFI_SMM_COMMUNICATE_HEADER, Data) + OFFSET_OF (OPAL_SMM_COMMUNICATE_HEADER, Data));
+ ASSERT (SmmCommRegionTable != NULL);
+ SmmCommMemRegion = (EFI_MEMORY_DESCRIPTOR *) (SmmCommRegionTable + 1);
+ Size = 0;
+ for (Index = 0; Index < SmmCommRegionTable->NumberOfEntries; Index++) {
+ if (SmmCommMemRegion->Type == EfiConventionalMemory) {
+ Size = EFI_PAGES_TO_SIZE ((UINTN) SmmCommMemRegion->NumberOfPages);
+ if (Size >= (DataSize + OFFSET_OF (EFI_SMM_COMMUNICATE_HEADER, Data) + OFFSET_OF (OPAL_SMM_COMMUNICATE_HEADER, Data))) {
+ break;
+ }
+ }
+ SmmCommMemRegion = (EFI_MEMORY_DESCRIPTOR *) ((UINT8 *) SmmCommMemRegion + SmmCommRegionTable->DescriptorSize);
+ }
+ ASSERT (Index < SmmCommRegionTable->NumberOfEntries);
+
+ Buffer = (VOID*)(UINTN)SmmCommMemRegion->PhysicalStart;
ASSERT (Buffer != NULL);
SmmCommunicateHeader = (EFI_SMM_COMMUNICATE_HEADER *) Buffer;
@@ -513,8 +541,6 @@ OpalSupportSendPasword(
EXIT:
ZeroMem(Parameter, Length);
- FreePool(Buffer);
-
return Status;
}
diff --git a/SecurityPkg/Library/OpalPasswordSupportLib/OpalPasswordSupportLib.inf b/SecurityPkg/Library/OpalPasswordSupportLib/OpalPasswordSupportLib.inf
index 274366bcf9..b7831356e5 100644
--- a/SecurityPkg/Library/OpalPasswordSupportLib/OpalPasswordSupportLib.inf
+++ b/SecurityPkg/Library/OpalPasswordSupportLib/OpalPasswordSupportLib.inf
@@ -43,9 +43,13 @@
[Packages]
MdePkg/MdePkg.dec
+ MdeModulePkg/MdeModulePkg.dec
SecurityPkg/SecurityPkg.dec
[Protocols]
gEfiStorageSecurityCommandProtocolGuid ## CONSUMES
gEfiSmmCommunicationProtocolGuid ## CONSUMES
gEfiSmmBase2ProtocolGuid ## CONSUMES # only for SMM version
+
+[Guids]
+ gEdkiiPiSmmCommunicationRegionTableGuid ## CONSUMES ## SystemTable
diff --git a/SecurityPkg/Library/OpalPasswordSupportLib/OpalPasswordSupportNotify.h b/SecurityPkg/Library/OpalPasswordSupportLib/OpalPasswordSupportNotify.h
index 59c1214d8c..f0ad3a1136 100644
--- a/SecurityPkg/Library/OpalPasswordSupportLib/OpalPasswordSupportNotify.h
+++ b/SecurityPkg/Library/OpalPasswordSupportLib/OpalPasswordSupportNotify.h
@@ -19,7 +19,7 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
#include <PiSmm.h>
#include <Uefi/UefiAcpiDataTable.h>
-
+#include <Guid/PiSmmCommunicationRegionTable.h>
#include <Library/DebugLib.h>
#include <Library/BaseMemoryLib.h>
#include <Library/UefiBootServicesTableLib.h>