Skip to content

Commit

Permalink
Sync patches r13533, r14004, r14009, r14019 and r14020 main trunk.
Browse files Browse the repository at this point in the history
1. Update HobLib and Hob Service to avoid data over flow.
2. Add boot mode BOOT_WITH_MFG_MODE_SETTINGS.
3. Add PI1.2.1 EndOfDxe support..
4. Add ASSERT() for BitField operations to make sure the input value is valid.

git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/branches/UDK2010.SR1@14224 6f19259b-4bc3-4df7-8a09-765794883524
  • Loading branch information
vanjeff committed Mar 28, 2013
1 parent 4416c92 commit 274e15b
Show file tree
Hide file tree
Showing 41 changed files with 870 additions and 41 deletions.
42 changes: 41 additions & 1 deletion IntelFrameworkPkg/Library/DxeIoLibCpuIo/IoHighLevel.c
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
All assertions for bit field operations are handled bit field functions in the
Base Library.
Copyright (c) 2006, Intel Corporation. All rights reserved.<BR>
Copyright (c) 2006 - 2012, Intel Corporation. All rights reserved.<BR>
This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
which accompanies this distribution. The full text of the license may be found at
Expand Down Expand Up @@ -156,6 +156,7 @@ IoBitFieldRead8 (
If StartBit is greater than 7, then ASSERT().
If EndBit is greater than 7, then ASSERT().
If EndBit is less than StartBit, then ASSERT().
If Value is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
@param Port The I/O port to write.
@param StartBit The ordinal of the least significant bit in the bit field.
Expand Down Expand Up @@ -196,6 +197,7 @@ IoBitFieldWrite8 (
If StartBit is greater than 7, then ASSERT().
If EndBit is greater than 7, then ASSERT().
If EndBit is less than StartBit, then ASSERT().
If OrData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
@param Port The I/O port to write.
@param StartBit The ordinal of the least significant bit in the bit field.
Expand Down Expand Up @@ -236,6 +238,7 @@ IoBitFieldOr8 (
If StartBit is greater than 7, then ASSERT().
If EndBit is greater than 7, then ASSERT().
If EndBit is less than StartBit, then ASSERT().
If AndData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
@param Port The I/O port to write.
@param StartBit The ordinal of the least significant bit in the bit field.
Expand Down Expand Up @@ -278,6 +281,8 @@ IoBitFieldAnd8 (
If StartBit is greater than 7, then ASSERT().
If EndBit is greater than 7, then ASSERT().
If EndBit is less than StartBit, then ASSERT().
If AndData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
If OrData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
@param Port The I/O port to write.
@param StartBit The ordinal of the least significant bit in the bit field.
Expand Down Expand Up @@ -436,6 +441,7 @@ IoBitFieldRead16 (
If StartBit is greater than 15, then ASSERT().
If EndBit is greater than 15, then ASSERT().
If EndBit is less than StartBit, then ASSERT().
If Value is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
@param Port The I/O port to write.
@param StartBit The ordinal of the least significant bit in the bit field.
Expand Down Expand Up @@ -476,6 +482,7 @@ IoBitFieldWrite16 (
If StartBit is greater than 15, then ASSERT().
If EndBit is greater than 15, then ASSERT().
If EndBit is less than StartBit, then ASSERT().
If OrData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
@param Port The I/O port to write.
@param StartBit The ordinal of the least significant bit in the bit field.
Expand Down Expand Up @@ -516,6 +523,7 @@ IoBitFieldOr16 (
If StartBit is greater than 15, then ASSERT().
If EndBit is greater than 15, then ASSERT().
If EndBit is less than StartBit, then ASSERT().
If AndData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
@param Port The I/O port to write.
@param StartBit The ordinal of the least significant bit in the bit field.
Expand Down Expand Up @@ -558,6 +566,8 @@ IoBitFieldAnd16 (
If StartBit is greater than 15, then ASSERT().
If EndBit is greater than 15, then ASSERT().
If EndBit is less than StartBit, then ASSERT().
If AndData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
If OrData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
@param Port The I/O port to write.
@param StartBit The ordinal of the least significant bit in the bit field.
Expand Down Expand Up @@ -716,6 +726,7 @@ IoBitFieldRead32 (
If StartBit is greater than 31, then ASSERT().
If EndBit is greater than 31, then ASSERT().
If EndBit is less than StartBit, then ASSERT().
If Value is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
@param Port The I/O port to write.
@param StartBit The ordinal of the least significant bit in the bit field.
Expand Down Expand Up @@ -756,6 +767,7 @@ IoBitFieldWrite32 (
If StartBit is greater than 31, then ASSERT().
If EndBit is greater than 31, then ASSERT().
If EndBit is less than StartBit, then ASSERT().
If OrData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
@param Port The I/O port to write.
@param StartBit The ordinal of the least significant bit in the bit field.
Expand Down Expand Up @@ -796,6 +808,7 @@ IoBitFieldOr32 (
If StartBit is greater than 31, then ASSERT().
If EndBit is greater than 31, then ASSERT().
If EndBit is less than StartBit, then ASSERT().
If AndData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
@param Port The I/O port to write.
@param StartBit The ordinal of the least significant bit in the bit field.
Expand Down Expand Up @@ -838,6 +851,8 @@ IoBitFieldAnd32 (
If StartBit is greater than 31, then ASSERT().
If EndBit is greater than 31, then ASSERT().
If EndBit is less than StartBit, then ASSERT().
If AndData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
If OrData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
@param Port The I/O port to write.
@param StartBit The ordinal of the least significant bit in the bit field.
Expand Down Expand Up @@ -996,6 +1011,7 @@ IoBitFieldRead64 (
If StartBit is greater than 63, then ASSERT().
If EndBit is greater than 63, then ASSERT().
If EndBit is less than StartBit, then ASSERT().
If Value is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
@param Port The I/O port to write.
@param StartBit The ordinal of the least significant bit in the bit field.
Expand Down Expand Up @@ -1036,6 +1052,7 @@ IoBitFieldWrite64 (
If StartBit is greater than 63, then ASSERT().
If EndBit is greater than 63, then ASSERT().
If EndBit is less than StartBit, then ASSERT().
If OrData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
@param Port The I/O port to write.
@param StartBit The ordinal of the least significant bit in the bit field.
Expand Down Expand Up @@ -1076,6 +1093,7 @@ IoBitFieldOr64 (
If StartBit is greater than 63, then ASSERT().
If EndBit is greater than 63, then ASSERT().
If EndBit is less than StartBit, then ASSERT().
If AndData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
@param Port The I/O port to write.
@param StartBit The ordinal of the least significant bit in the bit field.
Expand Down Expand Up @@ -1118,6 +1136,8 @@ IoBitFieldAnd64 (
If StartBit is greater than 63, then ASSERT().
If EndBit is greater than 63, then ASSERT().
If EndBit is less than StartBit, then ASSERT().
If AndData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
If OrData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
@param Port The I/O port to write.
@param StartBit The ordinal of the least significant bit in the bit field.
Expand Down Expand Up @@ -1276,6 +1296,7 @@ MmioBitFieldRead8 (
If StartBit is greater than 7, then ASSERT().
If EndBit is greater than 7, then ASSERT().
If EndBit is less than StartBit, then ASSERT().
If Value is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
@param Address MMIO register to write.
@param StartBit The ordinal of the least significant bit in the bit field.
Expand Down Expand Up @@ -1317,6 +1338,7 @@ MmioBitFieldWrite8 (
If StartBit is greater than 7, then ASSERT().
If EndBit is greater than 7, then ASSERT().
If EndBit is less than StartBit, then ASSERT().
If OrData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
@param Address MMIO register to write.
@param StartBit The ordinal of the least significant bit in the bit field.
Expand Down Expand Up @@ -1358,6 +1380,7 @@ MmioBitFieldOr8 (
If StartBit is greater than 7, then ASSERT().
If EndBit is greater than 7, then ASSERT().
If EndBit is less than StartBit, then ASSERT().
If AndData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
@param Address MMIO register to write.
@param StartBit The ordinal of the least significant bit in the bit field.
Expand Down Expand Up @@ -1400,6 +1423,8 @@ MmioBitFieldAnd8 (
If StartBit is greater than 7, then ASSERT().
If EndBit is greater than 7, then ASSERT().
If EndBit is less than StartBit, then ASSERT().
If AndData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
If OrData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
@param Address MMIO register to write.
@param StartBit The ordinal of the least significant bit in the bit field.
Expand Down Expand Up @@ -1558,6 +1583,7 @@ MmioBitFieldRead16 (
If StartBit is greater than 15, then ASSERT().
If EndBit is greater than 15, then ASSERT().
If EndBit is less than StartBit, then ASSERT().
If Value is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
@param Address MMIO register to write.
@param StartBit The ordinal of the least significant bit in the bit field.
Expand Down Expand Up @@ -1599,6 +1625,7 @@ MmioBitFieldWrite16 (
If StartBit is greater than 15, then ASSERT().
If EndBit is greater than 15, then ASSERT().
If EndBit is less than StartBit, then ASSERT().
If OrData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
@param Address MMIO register to write.
@param StartBit The ordinal of the least significant bit in the bit field.
Expand Down Expand Up @@ -1640,6 +1667,7 @@ MmioBitFieldOr16 (
If StartBit is greater than 15, then ASSERT().
If EndBit is greater than 15, then ASSERT().
If EndBit is less than StartBit, then ASSERT().
If AndData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
@param Address MMIO register to write.
@param StartBit The ordinal of the least significant bit in the bit field.
Expand Down Expand Up @@ -1682,6 +1710,8 @@ MmioBitFieldAnd16 (
If StartBit is greater than 15, then ASSERT().
If EndBit is greater than 15, then ASSERT().
If EndBit is less than StartBit, then ASSERT().
If AndData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
If OrData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
@param Address MMIO register to write.
@param StartBit The ordinal of the least significant bit in the bit field.
Expand Down Expand Up @@ -1840,6 +1870,7 @@ MmioBitFieldRead32 (
If StartBit is greater than 31, then ASSERT().
If EndBit is greater than 31, then ASSERT().
If EndBit is less than StartBit, then ASSERT().
If Value is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
@param Address MMIO register to write.
@param StartBit The ordinal of the least significant bit in the bit field.
Expand Down Expand Up @@ -1881,6 +1912,7 @@ MmioBitFieldWrite32 (
If StartBit is greater than 31, then ASSERT().
If EndBit is greater than 31, then ASSERT().
If EndBit is less than StartBit, then ASSERT().
If OrData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
@param Address MMIO register to write.
@param StartBit The ordinal of the least significant bit in the bit field.
Expand Down Expand Up @@ -1922,6 +1954,7 @@ MmioBitFieldOr32 (
If StartBit is greater than 31, then ASSERT().
If EndBit is greater than 31, then ASSERT().
If EndBit is less than StartBit, then ASSERT().
If AndData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
@param Address MMIO register to write.
@param StartBit The ordinal of the least significant bit in the bit field.
Expand Down Expand Up @@ -1964,6 +1997,8 @@ MmioBitFieldAnd32 (
If StartBit is greater than 31, then ASSERT().
If EndBit is greater than 31, then ASSERT().
If EndBit is less than StartBit, then ASSERT().
If AndData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
If OrData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
@param Address MMIO register to write.
@param StartBit The ordinal of the least significant bit in the bit field.
Expand Down Expand Up @@ -2122,6 +2157,7 @@ MmioBitFieldRead64 (
If StartBit is greater than 63, then ASSERT().
If EndBit is greater than 63, then ASSERT().
If EndBit is less than StartBit, then ASSERT().
If Value is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
@param Address MMIO register to write.
@param StartBit The ordinal of the least significant bit in the bit field.
Expand Down Expand Up @@ -2163,6 +2199,7 @@ MmioBitFieldWrite64 (
If StartBit is greater than 63, then ASSERT().
If EndBit is greater than 63, then ASSERT().
If EndBit is less than StartBit, then ASSERT().
If OrData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
@param Address MMIO register to write.
@param StartBit The ordinal of the least significant bit in the bit field.
Expand Down Expand Up @@ -2204,6 +2241,7 @@ MmioBitFieldOr64 (
If StartBit is greater than 63, then ASSERT().
If EndBit is greater than 63, then ASSERT().
If EndBit is less than StartBit, then ASSERT().
If AndData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
@param Address MMIO register to write.
@param StartBit The ordinal of the least significant bit in the bit field.
Expand Down Expand Up @@ -2246,6 +2284,8 @@ MmioBitFieldAnd64 (
If StartBit is greater than 63, then ASSERT().
If EndBit is greater than 63, then ASSERT().
If EndBit is less than StartBit, then ASSERT().
If AndData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
If OrData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
@param Address MMIO register to write.
@param StartBit The ordinal of the least significant bit in the bit field.
Expand Down
8 changes: 7 additions & 1 deletion MdeModulePkg/Core/Pei/Hob/Hob.c
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/** @file
This module provide Hand-Off Block manupulation.
Copyright (c) 2006, Intel Corporation. All rights reserved.<BR>
Copyright (c) 2006 - 2012, Intel Corporation. All rights reserved.<BR>
This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
which accompanies this distribution. The full text of the license may be found at
Expand Down Expand Up @@ -89,6 +89,12 @@ PeiCreateHob (

HandOffHob = *Hob;

//
// Check Length to avoid data overflow.
//
if (0x10000 - Length <= 0x7) {
return EFI_INVALID_PARAMETER;
}
Length = (UINT16)((Length + 0x7) & (~0x7));

FreeMemory = HandOffHob->EfiFreeMemoryTop -
Expand Down
6 changes: 3 additions & 3 deletions MdeModulePkg/Core/Pei/Memory/MemoryServices.c
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/** @file
EFI PEI Core memory services
Copyright (c) 2006 - 2011, Intel Corporation. All rights reserved.<BR>
Copyright (c) 2006 - 2012, Intel Corporation. All rights reserved.<BR>
This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
which accompanies this distribution. The full text of the license may be found at
Expand Down Expand Up @@ -249,9 +249,9 @@ PeiAllocatePool (

//
// Generally, the size of heap in temporary memory does not exceed to 64K,
// so the maxmium size of pool is 0x10000 - sizeof (EFI_HOB_MEMORY_POOL)
// HobLength is multiples of 8 bytes, so the maxmium size of pool is 0xFFF8 - sizeof (EFI_HOB_MEMORY_POOL)
//
if (Size >= (0x10000 - sizeof (EFI_HOB_MEMORY_POOL))) {
if (Size > (0xFFF8 - sizeof (EFI_HOB_MEMORY_POOL))) {
return EFI_OUT_OF_RESOURCES;
}

Expand Down
41 changes: 41 additions & 0 deletions MdeModulePkg/Core/PiSmmCore/PiSmmCore.c
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ SMM_CORE_SMI_HANDLERS mSmmCoreSmiHandlers[] = {
{ SmmDriverDispatchHandler, &gEfiEventDxeDispatchGuid, NULL, TRUE },
{ SmmReadyToLockHandler, &gEfiDxeSmmReadyToLockProtocolGuid, NULL, FALSE },
{ SmmLegacyBootHandler, &gEfiEventLegacyBootGuid, NULL, FALSE },
{ SmmEndOfDxeHandler, &gEfiEndOfDxeEventGroupGuid, NULL, FALSE },
{ NULL, NULL, NULL, FALSE }
};

Expand Down Expand Up @@ -228,6 +229,46 @@ SmmReadyToLockHandler (
return Status;
}

/**
Software SMI handler that is called when the EndOfDxe event is signalled.
This function installs the SMM EndOfDxe Protocol so SMM Drivers are informed that
platform code will invoke 3rd part code.
@param DispatchHandle The unique handle assigned to this handler by SmiHandlerRegister().
@param Context Points to an optional handler context which was specified when the handler was registered.
@param CommBuffer A pointer to a collection of data in memory that will
be conveyed from a non-SMM environment into an SMM environment.
@param CommBufferSize The size of the CommBuffer.
@return Status Code
**/
EFI_STATUS
EFIAPI
SmmEndOfDxeHandler (
IN EFI_HANDLE DispatchHandle,
IN CONST VOID *Context, OPTIONAL
IN OUT VOID *CommBuffer, OPTIONAL
IN OUT UINTN *CommBufferSize OPTIONAL
)
{
EFI_STATUS Status;
EFI_HANDLE SmmHandle;

DEBUG ((EFI_D_INFO, "SmmEndOfDxeHandler\n"));
//
// Install SMM EndOfDxe protocol
//
SmmHandle = NULL;
Status = SmmInstallProtocolInterface (
&SmmHandle,
&gEfiSmmEndOfDxeProtocolGuid,
EFI_NATIVE_INTERFACE,
NULL
);
return EFI_SUCCESS;
}

/**
The main entry point to SMM Foundation.
Expand Down
Loading

0 comments on commit 274e15b

Please sign in to comment.