From c7ce516971c74a9786134a9427c6c97097445c9c Mon Sep 17 00:00:00 2001 From: andrewfish Date: Mon, 29 Aug 2011 20:47:22 +0000 Subject: Fix issue with SMBIOS driver assumming memory exists below 4GB. approved-by: andrewfish reviewed-by: li-elvin git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@12220 6f19259b-4bc3-4df7-8a09-765794883524 --- MdeModulePkg/Universal/SmbiosDxe/SmbiosDxe.c | 37 ++++++++++++++++++++-------- 1 file changed, 27 insertions(+), 10 deletions(-) (limited to 'MdeModulePkg') diff --git a/MdeModulePkg/Universal/SmbiosDxe/SmbiosDxe.c b/MdeModulePkg/Universal/SmbiosDxe/SmbiosDxe.c index c15ecb54fa..596e8b2d8b 100644 --- a/MdeModulePkg/Universal/SmbiosDxe/SmbiosDxe.c +++ b/MdeModulePkg/Universal/SmbiosDxe/SmbiosDxe.c @@ -103,6 +103,7 @@ SMBIOS_TABLE_ENTRY_POINT EntryPointStructureData = { }; + /** Get the full size of SMBIOS structure including optional strings that follow the formatted structure. @@ -889,7 +890,11 @@ SmbiosCreateTable ( // SmbiosProtocol = &mPrivateData.Smbios; - PreAllocatedPages = EFI_SIZE_TO_PAGES (EntryPointStructure->TableLength); + if (EntryPointStructure->TableAddress == 0) { + PreAllocatedPages = 0; + } else { + PreAllocatedPages = EFI_SIZE_TO_PAGES (EntryPointStructure->TableLength); + } // // Make some statistics about all the structures @@ -957,9 +962,12 @@ SmbiosCreateTable ( &PhysicalAddress ); if (EFI_ERROR (Status)) { + DEBUG ((EFI_D_ERROR, "SmbiosCreateTable() could not allocate SMBIOS table < 4GB\n")); + EntryPointStructure->TableAddress = 0; return EFI_OUT_OF_RESOURCES; + } else { + EntryPointStructure->TableAddress = (UINT32) PhysicalAddress; } - EntryPointStructure->TableAddress = (UINT32) PhysicalAddress; } // @@ -1061,7 +1069,16 @@ SmbiosDriverEntryPoint ( &PhysicalAddress ); if (EFI_ERROR (Status)) { - return EFI_OUT_OF_RESOURCES; + DEBUG ((EFI_D_ERROR, "SmbiosDriverEntryPoint() could not allocate EntryPointStructure < 4GB\n")); + Status = gBS->AllocatePages ( + AllocateAnyPages, + EfiReservedMemoryType, + EFI_SIZE_TO_PAGES (sizeof (SMBIOS_TABLE_ENTRY_POINT)), + &PhysicalAddress + ); + if (EFI_ERROR (Status)) { + return EFI_OUT_OF_RESOURCES; + } } EntryPointStructure = (SMBIOS_TABLE_ENTRY_POINT *) (UINTN) PhysicalAddress; @@ -1086,14 +1103,14 @@ SmbiosDriverEntryPoint ( &PhysicalAddress ); if (EFI_ERROR (Status)) { - FreePages ((VOID*) EntryPointStructure, EFI_SIZE_TO_PAGES (sizeof (SMBIOS_TABLE_ENTRY_POINT))); - EntryPointStructure = NULL; - return EFI_OUT_OF_RESOURCES; + DEBUG ((EFI_D_ERROR, "SmbiosDriverEntryPoint() could not allocate SMBIOS table < 4GB\n")); + EntryPointStructure->TableAddress = 0; + EntryPointStructure->TableLength = 0; + } else { + EntryPointStructure->TableAddress = (UINT32) PhysicalAddress; + EntryPointStructure->TableLength = EFI_PAGES_TO_SIZE (1); } - - EntryPointStructure->TableAddress = (UINT32) PhysicalAddress; - EntryPointStructure->TableLength = EFI_PAGES_TO_SIZE (1); - + // // Make a new handle and install the protocol // -- cgit v1.2.3