summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorvanjeff <vanjeff@6f19259b-4bc3-4df7-8a09-765794883524>2010-11-11 06:33:12 +0000
committervanjeff <vanjeff@6f19259b-4bc3-4df7-8a09-765794883524>2010-11-11 06:33:12 +0000
commit5f14feed8e8f57f1fa8637a14e2c98776a218dd8 (patch)
tree203da6dbc8676d7e6ed21a511b5bc542609ec04b
parent8a046ef0ddf05a379eca74cea4b081e294d229fb (diff)
downloadedk2-5f14feed8e8f57f1fa8637a14e2c98776a218dd8.tar.gz
sync patch r11013, r11022, r11023 from main trunk.
1. Prevent infinite recursion when ASSERT(), DEBUG(), or any other use of ReportStatusCode is performed at > TPL_NOTIFY or there is not enough memory to allocate a buffer for the ExtendedData associated with the status code being reported. 2. Replaced MAX_EXTENDED_DATA_SIZE by EFI_STATUS_CODE_DATA_MAX_SIZE. git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/branches/UDK2008@11040 6f19259b-4bc3-4df7-8a09-765794883524
-rw-r--r--IntelFrameworkModulePkg/Library/DxeReportStatusCodeLibFramework/ReportStatusCodeLib.c32
-rw-r--r--IntelFrameworkModulePkg/Library/PeiReportStatusCodeLib/ReportStatusCodeLib.c14
2 files changed, 35 insertions, 11 deletions
diff --git a/IntelFrameworkModulePkg/Library/DxeReportStatusCodeLibFramework/ReportStatusCodeLib.c b/IntelFrameworkModulePkg/Library/DxeReportStatusCodeLibFramework/ReportStatusCodeLib.c
index ac29009c74..90e631e5dd 100644
--- a/IntelFrameworkModulePkg/Library/DxeReportStatusCodeLibFramework/ReportStatusCodeLib.c
+++ b/IntelFrameworkModulePkg/Library/DxeReportStatusCodeLibFramework/ReportStatusCodeLib.c
@@ -487,6 +487,8 @@ ReportStatusCodeEx (
{
EFI_STATUS Status;
EFI_STATUS_CODE_DATA *StatusCodeData;
+ EFI_TPL Tpl;
+ UINT64 Buffer[EFI_STATUS_CODE_DATA_MAX_SIZE / sizeof (UINT64)];
ASSERT (!((ExtendedData == NULL) && (ExtendedDataSize != 0)));
ASSERT (!((ExtendedData != NULL) && (ExtendedDataSize == 0)));
@@ -496,12 +498,32 @@ ReportStatusCodeEx (
}
//
- // Allocate space for the Status Code Header and its buffer
+ // Retrieve the current TPL
//
+ Tpl = gBS->RaiseTPL (TPL_HIGH_LEVEL);
+ gBS->RestoreTPL (Tpl);
+
StatusCodeData = NULL;
- gBS->AllocatePool (EfiBootServicesData, sizeof (EFI_STATUS_CODE_DATA) + ExtendedDataSize, (VOID **)&StatusCodeData);
+ if (Tpl <= TPL_NOTIFY) {
+ //
+ // Allocate space for the Status Code Header and its buffer
+ //
+ gBS->AllocatePool (EfiBootServicesData, sizeof (EFI_STATUS_CODE_DATA) + ExtendedDataSize, (VOID **)&StatusCodeData);
+ }
+
if (StatusCodeData == NULL) {
- return EFI_OUT_OF_RESOURCES;
+ //
+ // If a buffer could not be allocated, then see if the local variable Buffer can be used
+ //
+ if (ExtendedDataSize > (EFI_STATUS_CODE_DATA_MAX_SIZE - sizeof (EFI_STATUS_CODE_DATA))) {
+ //
+ // The local variable Buffer not large enough to hold the extended data associated
+ // with the status code being reported.
+ //
+ ASSERT (FALSE);
+ return EFI_OUT_OF_RESOURCES;
+ }
+ StatusCodeData = (EFI_STATUS_CODE_DATA *)Buffer;
}
//
@@ -532,7 +554,9 @@ ReportStatusCodeEx (
//
// Free the allocated buffer
//
- gBS->FreePool (StatusCodeData);
+ if (StatusCodeData != (EFI_STATUS_CODE_DATA *)Buffer) {
+ gBS->FreePool (StatusCodeData);
+ }
return Status;
}
diff --git a/IntelFrameworkModulePkg/Library/PeiReportStatusCodeLib/ReportStatusCodeLib.c b/IntelFrameworkModulePkg/Library/PeiReportStatusCodeLib/ReportStatusCodeLib.c
index 41b7b8dc26..6836919267 100644
--- a/IntelFrameworkModulePkg/Library/PeiReportStatusCodeLib/ReportStatusCodeLib.c
+++ b/IntelFrameworkModulePkg/Library/PeiReportStatusCodeLib/ReportStatusCodeLib.c
@@ -25,11 +25,6 @@
#include <Library/OemHookStatusCodeLib.h>
#include <Library/PcdLib.h>
-//
-// Define the maximum extended data size that is supported in the PEI phase
-//
-#define MAX_EXTENDED_DATA_SIZE 0x200
-
/**
Internal worker function that reports a status code through the PEI Status Code Service or
OEM Hook Status Code Library.
@@ -460,7 +455,7 @@ ReportStatusCodeEx (
)
{
EFI_STATUS_CODE_DATA *StatusCodeData;
- UINT64 Buffer[MAX_EXTENDED_DATA_SIZE / sizeof (UINT64)];
+ UINT64 Buffer[EFI_STATUS_CODE_DATA_MAX_SIZE / sizeof (UINT64)];
//
// If ExtendedData is NULL and ExtendedDataSize is not zero, then ASSERT().
@@ -471,7 +466,12 @@ ReportStatusCodeEx (
//
ASSERT (!((ExtendedData != NULL) && (ExtendedDataSize == 0)));
- if (ExtendedDataSize > (MAX_EXTENDED_DATA_SIZE - sizeof (EFI_STATUS_CODE_DATA))) {
+ if (ExtendedDataSize > (EFI_STATUS_CODE_DATA_MAX_SIZE - sizeof (EFI_STATUS_CODE_DATA))) {
+ //
+ // The local variable Buffer not large enough to hold the extended data associated
+ // with the status code being reported.
+ //
+ ASSERT (FALSE);
return EFI_OUT_OF_RESOURCES;
}
StatusCodeData = (EFI_STATUS_CODE_DATA *)Buffer;