зеркало из https://github.com/microsoft/mu_plus.git
Merged PR 5979: AdvLoggerPkg: Add support for Mm in Arm.
## Description Add support for early logging in Mm for Arm - specifically for platforms with the capability to carve out a fixed region of memory for the log, prior to UEFI starting. - [ No] Breaking change? - This is new function for a new platform. ## How This Was Tested ## Integration Instructions
This commit is contained in:
Родитель
c2a6bc7e36
Коммит
20592be58c
|
@ -18,6 +18,7 @@
|
|||
## options defined ci/Plugin/DependencyCheck
|
||||
"DependencyCheck": {
|
||||
"AcceptableDependencies": [
|
||||
"ArmPkg/ArmPkg.dec",
|
||||
"MdePkg/MdePkg.dec",
|
||||
"MdeModulePkg/MdeModulePkg.dec",
|
||||
"AdvLoggerPkg/AdvLoggerPkg.dec",
|
||||
|
@ -70,7 +71,8 @@
|
|||
DEADLOOP,
|
||||
LOGTELEMETRY,
|
||||
DEBUGAGENT,
|
||||
POSTMEM
|
||||
POSTMEM,
|
||||
MMARM
|
||||
]
|
||||
}
|
||||
}
|
|
@ -60,6 +60,11 @@
|
|||
|
||||
|
||||
[PcdsFeatureFlag]
|
||||
## PcdAdvancedLoggerFixedInRAM - Tells the Advanced Logger that the memory is preallocated at
|
||||
# a fixed addres set in PcdAdvancedLoggerBase
|
||||
#
|
||||
gAdvLoggerPkgTokenSpaceGuid.PcdAdvancedLoggerFixedInRAM|FALSE|BOOLEAN|0x00010189
|
||||
|
||||
## PcdAdvancedLoggerPeiInRAM - Tells the PEI Advanced Logger that this PEI can allocate memory
|
||||
# and there is no need for a temporary memory buffer
|
||||
#
|
||||
|
|
|
@ -154,6 +154,10 @@
|
|||
AdvLoggerPkg/Library/AssertTelemetryLib/AssertLib.inf
|
||||
AdvLoggerPkg/Library/AdvLoggerMmAccessLib/AdvLoggerMmAccessLib.inf
|
||||
|
||||
[Components.AARCH64]
|
||||
AdvLoggerPkg/Library/AdvancedLoggerLib/BaseArm/AdvancedLoggerLib.inf
|
||||
AdvLoggerPkg/Library/AdvancedLoggerLib/MmCoreArm/AdvancedLoggerLib.inf
|
||||
|
||||
[BuildOptions]
|
||||
#force deprecated interfaces off
|
||||
*_*_*_CC_FLAGS = -D DISABLE_NEW_DEPRECATED_INTERFACES
|
||||
|
|
|
@ -17,13 +17,16 @@ The following configurations are supported:
|
|||
| PEI | Uses PeiCore and Pei AdvancedLoggerLib libraries. Creates the Advanced Logger Hob if PcdAdvancedLoggerPeiInRAM is set. |
|
||||
| SEC | Uses the Sec Advanced Logger Library. SEC requires a fixed load address, so it piggy backs on the Temporary RAM PCD information. Produces a Fixed Address temporary RAM log. When memory is added, the Sec Advanced Logger library converts the Temporary RAM logging information to the PEI Advanced Logger Hob. |
|
||||
| PEI64 | Uses Pei64 Advanced Logger Library. Requires the SEC fixed address temporary log information in order to log Pei64 bit DEBUG messages. |
|
||||
| MM | Standalone MM - Loads during PEI phase. |
|
||||
| MMARM | Standalone MM that loads prior to UEFI with a fixed memory block shared with UEFI. |
|
||||
|
||||
PCD's used by Advanced Logger
|
||||
|
||||
| PCD | Function of the PCD|
|
||||
| --- | --- |
|
||||
|PcdAdvancedLoggerForceEnable | The default operation is to check if a Logs directory is present in the root of the filesystem. If the UefiLogs directory is present, logging is enabled. When PcdAdvancedLoggerForceEnable is TRUE, and the device is not a USB device, a UefiLogs directory will be created and logging is enabled. When logging is enabled, the proper log files will be created if not already preset.|
|
||||
|PcdAdvancedLoggerPeiInRAM | For system that have memory at PeiCore entry. The full in memory log buffer if PcdAdvancedLoggerPages is allocated in the Pei Core constructor and PcdAdvancedLoggerPreMemPages is ignored.|
|
||||
|PcdAdvancedLoggerPeiInRAM | For systems that have memory at PeiCore entry. The full in memory log buffer if PcdAdvancedLoggerPages is allocated in the Pei Core constructor and PcdAdvancedLoggerPreMemPages is ignored.|
|
||||
|PcdAdvancedLoggerFixedInRAM | For systems that have a fixed memory buffer prior to UEFI. The full in memory log buffer is assumed.|
|
||||
|PcdAdvancedHdwLoggerDebugPrintErrorLevel | The standard debug flags filter which log messages are produced. This PCD allow a subset of log messages to be forwarded to the Hdw Port Lib.|
|
||||
|PcdAdvancedHdwLoggerDisable | Specifies when to disable writing to the Hdw Port.|
|
||||
|PcdAdvancedLoggerPreMemPages | Amount of temporary RAM used for the debug log.|
|
||||
|
@ -46,12 +49,19 @@ The following libraries are used with AdvancedLogger:
|
|||
|
||||
## Platform notes
|
||||
|
||||
### IA32/X64
|
||||
|
||||
The SEC version of the Advanced Logger uses the temporary RAM block. This block is fixed in size
|
||||
and location, and these need to be adjusted to make room for the Advanced Logger buffer.
|
||||
and location, and this temporary RAM block needs to be adjusted to make room for the Advanced
|
||||
Logger buffer.
|
||||
There may be cases where the processor cache size is too small to enable the Advanced Logger
|
||||
during SEC.
|
||||
|
||||
The following changes are needed in the .dsc (Example assumes IA32/X64)
|
||||
The PEI versions of Advanced Logger work together to save space. Rather than have the Debug Print
|
||||
libraries linked in all the PEIM's, only PEI_CORE has the Debug Print libraries.
|
||||
The PEI version of AdvancedLoggerLib uses the IDT to access a pointer to the PEI_CORE routines.
|
||||
|
||||
The following changes are needed in the .dsc for IA32/X64.
|
||||
|
||||
```inf
|
||||
[LibraryClasses.common]
|
||||
|
@ -103,6 +113,107 @@ The following changes should be in the family .dsc where the processor specific
|
|||
```inf
|
||||
[PcdsFixedAtBuild.common]
|
||||
gAdvLoggerPkgTokenSpaceGuid.PcdAdvancedLoggerPreMemPages|24
|
||||
|
||||
#Advanced Logger configuration
|
||||
gAdvLoggerPkgTokenSpaceGuid.PcdAdvancedLoggerBase | 0xFA000000 # Must be TemporaryRamBase
|
||||
gAdvLoggerPkgTokenSpaceGuid.PcdAdvancedLoggerCarBase | 0xFA200000 # Address for CAR memory
|
||||
gAdvLoggerPkgTokenSpaceGuid.PcdAdvancedLoggerPreMemPages | 256 # Size is 1MB
|
||||
gAdvLoggerPkgTokenSpaceGuid.PcdAdvancedLoggerPages | 1024 # Size is 4MB
|
||||
|
||||
```
|
||||
|
||||
### ARM with Security Processor
|
||||
|
||||
#### UEFI
|
||||
|
||||
In this configuration, the Advanced Logger memory buffer is preallocated and setup from the BL31
|
||||
(secure partition loader) at a known address.
|
||||
This simplifies SEC and PEI as memory has already been configured.
|
||||
|
||||
Due to the memory block being at a known address, the SEC, PEI_CORE, and PEI modules link to
|
||||
the BaseArm version of AdvancedLoggerLib.
|
||||
While the BaseArm version includes the Debug Print libraries, it is assumed that there are few
|
||||
PEI components in the ARM with Security Processor configuration.
|
||||
|
||||
```inf
|
||||
################################################################
|
||||
#
|
||||
# Advanced Logger Configurations
|
||||
#
|
||||
################################################################
|
||||
[LibraryClasses.common]
|
||||
DebugLib|AdvLoggerPkg/Library/BaseDebugLibAdvancedLogger/BaseDebugLibAdvancedLogger.inf
|
||||
AssertLib|AdvLoggerPkg/Library/AssertLib/AssertLib.inf
|
||||
AdvancedLoggerHdwPortLib|AdvLoggerPkg/Library/AdvancedLoggerHdwPortLib/AdvancedLoggerHdwPortLib.inf
|
||||
AdvancedLoggerAccessLib|AdvLoggerPkg/Library/AdvancedLoggerAccessLib/AdvancedLoggerAccessLib.inf
|
||||
|
||||
[LibraryClasses.common.SEC]
|
||||
AdvancedLoggerLib|AdvLoggerPkg/Library/AdvancedLoggerLib/BaseArm/AdvancedLoggerLib.inf
|
||||
AssertLib|AdvLoggerPkg/Library/AssertLib/AssertLib.inf
|
||||
|
||||
[LibraryClasses.common.PEI_CORE]
|
||||
AdvancedLoggerLib|AdvLoggerPkg/Library/AdvancedLoggerLib/BaseArm/AdvancedLoggerLib.inf
|
||||
|
||||
[LibraryClasses.common.PEIM]
|
||||
AdvancedLoggerLib|AdvLoggerPkg/Library/AdvancedLoggerLib/Pei/AdvancedLoggerLib.inf
|
||||
DebugLib|AdvLoggerPkg/Library/PeiDebugLibAdvancedLogger/PeiDebugLibAdvancedLogger.inf
|
||||
|
||||
[LibraryClasses.common.DXE_DRIVER, LibraryClasses.common.UEFI_DRIVER, LibraryClasses.common.UEFI_APPLICATION]
|
||||
AdvancedLoggerLib|AdvLoggerPkg/Library/AdvancedLoggerLib/Dxe/AdvancedLoggerLib.inf
|
||||
|
||||
[LibraryClasses.common.DXE_CORE]
|
||||
AdvancedLoggerLib|AdvLoggerPkg/Library/AdvancedLoggerLib/DxeCore/AdvancedLoggerLib.inf
|
||||
|
||||
[LibraryClasses.common.DXE_RUNTIME_DRIVER]
|
||||
AdvancedLoggerLib|AdvLoggerPkg/Library/AdvancedLoggerLib/Runtime/AdvancedLoggerLib.inf
|
||||
|
||||
[PcdsFeatureFlag]
|
||||
gAdvLoggerPkgTokenSpaceGuid.PcdAdvancedFileLoggerForceEnable|FALSE
|
||||
gAdvLoggerPkgTokenSpaceGuid.PcdAdvancedLoggerLocator|TRUE
|
||||
gAdvLoggerPkgTokenSpaceGuid.PcdAdvancedLoggerFixedInRAM|TRUE
|
||||
|
||||
# Set AdvLogger to flush at ReadyToBoot (0x01) and at ExitBootServices (0x02).
|
||||
gAdvLoggerPkgTokenSpaceGuid.PcdAdvancedFileLoggerFlush|0x03
|
||||
```
|
||||
|
||||
The following changes should be in the family .dsc where the processor specific changes are specified
|
||||
|
||||
```inf
|
||||
[PcdsFixedAtBuild.common]
|
||||
#Advanced Logger configuration
|
||||
gAdvLoggerPkgTokenSpaceGuid.PcdAdvancedLoggerBase | 0xFF622000 # Buffer address
|
||||
gAdvLoggerPkgTokenSpaceGuid.PcdAdvancedLoggerPages | 0x400 # Size is 4MB
|
||||
```
|
||||
|
||||
#### MM Standalone Arm with security processor
|
||||
|
||||
In this configuration, the MM code needs to initialize the common buffer that was allocated from
|
||||
the BL31 (secure partition loader) in order to provide log messages prior to UEFI starting.
|
||||
|
||||
```inf
|
||||
[LibraryClasses.common]
|
||||
DebugLib|AdvLoggerPkg/Library/BaseDebugLibAdvancedLogger/BaseDebugLibAdvancedLogger.inf
|
||||
AssertLib|AdvLoggerPkg/Library/AssertLib/AssertLib.inf
|
||||
AdvancedLoggerHdwPortLib|AdvLoggerPkg/Library/AdvancedLoggerHdwPortLib/AdvancedLoggerHdwPortLib.inf
|
||||
|
||||
[LibraryClasses.common.MM_CORE_STANDALONE]
|
||||
AdvancedLoggerLib|AdvLoggerPkg/Library/AdvancedLoggerLib/MmCoreArm/AdvancedLoggerLib.inf
|
||||
|
||||
[LibraryClasses.common.MM_STANDALONE]
|
||||
AdvancedLoggerLib|AdvLoggerPkg/Library/AdvancedLoggerLib/BaseArm/AdvancedLoggerLib.inf
|
||||
AdvLoggerAccessLib|AdvLoggerPkg/Library/AdvLoggerMmAccessLib/AdvLoggerMmAccessLib.inf
|
||||
|
||||
[PcdsFeatureFlag]
|
||||
gAdvLoggerPkgTokenSpaceGuid.PcdAdvancedFileLoggerForceEnable|FALSE
|
||||
gAdvLoggerPkgTokenSpaceGuid.PcdAdvancedLoggerLocator|TRUE
|
||||
gAdvLoggerPkgTokenSpaceGuid.PcdAdvancedLoggerFixedInRAM|TRUE
|
||||
# Set AdvLogger to flush at ReadyToBoot (0x01) and at ExitBootServices (0x02).
|
||||
gAdvLoggerPkgTokenSpaceGuid.PcdAdvancedFileLoggerFlush|0x03
|
||||
|
||||
[PcdsFixedAtBuild.common]
|
||||
#Advanced Logger configuration
|
||||
gAdvLoggerPkgTokenSpaceGuid.PcdAdvancedLoggerBase | 0xFF622000 # Buffer address
|
||||
gAdvLoggerPkgTokenSpaceGuid.PcdAdvancedLoggerPages | 0x400 # Size is 4MB
|
||||
```
|
||||
|
||||
## Advanced File Logger
|
||||
|
@ -120,7 +231,7 @@ These files are pre allocated at one time to reduce interference with other user
|
|||
To enable the Advanced File Logger, the following change is needed in the .dsc:
|
||||
|
||||
```inf
|
||||
[Components.<ArchOfDXE>]
|
||||
[Components.<YourFvDXE>]
|
||||
AdvLoggerPkg/AdvancedFileLogger/AdvancedFileLogger.inf
|
||||
```
|
||||
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
|
||||
**/
|
||||
|
||||
#include <Base.h>
|
||||
#include <Uefi/UefiBaseType.h>
|
||||
|
||||
#include <AdvancedLoggerInternal.h>
|
||||
|
||||
|
|
|
@ -0,0 +1,118 @@
|
|||
/** @file
|
||||
MM_CORE Arm implementation of Advanced Logger Library.
|
||||
|
||||
Copyright (c) Microsoft Corporation. All rights reserved.<BR>
|
||||
SPDX-License-Identifier: BSD-2-Clause-Patent
|
||||
|
||||
**/
|
||||
|
||||
#include <Uefi/UefiBaseType.h>
|
||||
|
||||
#include <AdvancedLoggerInternal.h>
|
||||
|
||||
#include <Library/AdvancedLoggerLib.h>
|
||||
#include <Library/DebugLib.h>
|
||||
#include <Library/SynchronizationLib.h>
|
||||
|
||||
#include "../AdvancedLoggerCommon.h"
|
||||
|
||||
STATIC ADVANCED_LOGGER_INFO *mLoggerInfo = NULL;
|
||||
STATIC UINT32 mBufferSize = 0;
|
||||
STATIC EFI_PHYSICAL_ADDRESS mMaxAddress = 0;
|
||||
STATIC BOOLEAN mInitialized = FALSE;
|
||||
|
||||
/**
|
||||
Validate Info Blocks
|
||||
|
||||
The address of the ADVANCE_LOGGER_INFO block pointer is captured during the first DEBUG print. The
|
||||
pointers LogBuffer and LogCurrent, and LogBufferSize, could be written to by untrusted code. Here,
|
||||
we check that the pointers are within the allocated mLoggerInfo space, and that LogBufferSize, which
|
||||
is used in multiple places to see if a new message will fit into the log buffer, is valid.
|
||||
|
||||
@param NONE
|
||||
|
||||
@return BOOLEAN TRUE = mLoggerInfo Block passes security checks
|
||||
@return BOOLEAN FALSE= mLoggerInfo Block failed security checks
|
||||
|
||||
**/
|
||||
STATIC
|
||||
BOOLEAN
|
||||
ValidateInfoBlock (
|
||||
VOID
|
||||
)
|
||||
{
|
||||
if (mLoggerInfo == NULL) {
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if (mLoggerInfo->Signature != ADVANCED_LOGGER_SIGNATURE) {
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if (mLoggerInfo->LogBuffer != (PA_FROM_PTR (mLoggerInfo + 1))) {
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if ((mLoggerInfo->LogCurrent > mMaxAddress) ||
|
||||
(mLoggerInfo->LogCurrent < mLoggerInfo->LogBuffer))
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if (mBufferSize == 0) {
|
||||
mBufferSize = mLoggerInfo->LogBufferSize;
|
||||
} else if (mLoggerInfo->LogBufferSize != mBufferSize) {
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/**
|
||||
The logger Information Block is carved from the Trust Zone at a specific fixed address.
|
||||
|
||||
This address is obtained from the PcdAdvancedLoggerBase. The size of the Advanced Logger
|
||||
buffer is obtained from PcdAdvancedLoggerPages.
|
||||
|
||||
The following PCD settings are assumed:
|
||||
|
||||
PcdAdvancedLoggerPeiInRAM -- TRUE
|
||||
PcdAdvancedLoggerBase -- NOT NULL and pointer to memory to be used
|
||||
PcdAdvancedLoggerPages -- > 64KB of pages
|
||||
PcdAdvancedLoggerCarBase -- NOT USED, leave at default
|
||||
PcdAdvancedLoggerPreMemPages -- NOT USED, leave at default
|
||||
|
||||
NOTE: A DEBUG(()) statements here will cause recursion. Insure that the recursion will be
|
||||
a straight path just to return the existing mLoggerInfo.
|
||||
|
||||
@param - None
|
||||
|
||||
@returns - NULL - No valid Advanced Logger Info block available
|
||||
- Pointer to a Valid Advanced Logger Info block.
|
||||
|
||||
**/
|
||||
ADVANCED_LOGGER_INFO *
|
||||
EFIAPI
|
||||
AdvancedLoggerGetLoggerInfo (
|
||||
VOID
|
||||
)
|
||||
{
|
||||
if (!mInitialized) {
|
||||
mInitialized = TRUE; // Only allow initialization once
|
||||
mLoggerInfo = (ADVANCED_LOGGER_INFO *)(VOID *)FixedPcdGet64 (PcdAdvancedLoggerBase);
|
||||
ASSERT (mLoggerInfo != NULL);
|
||||
if (mLoggerInfo == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
mMaxAddress = mLoggerInfo->LogBuffer + mLoggerInfo->LogBufferSize;
|
||||
mBufferSize = mLoggerInfo->LogBufferSize;
|
||||
}
|
||||
|
||||
if (((mLoggerInfo) != NULL) && !ValidateInfoBlock ()) {
|
||||
mLoggerInfo = NULL;
|
||||
DEBUG ((DEBUG_ERROR, "%a: LoggerInfo marked invalid\n", __FUNCTION__));
|
||||
}
|
||||
|
||||
return mLoggerInfo;
|
||||
}
|
|
@ -0,0 +1,43 @@
|
|||
## @file
|
||||
# MM_STANDALONE instance of the Advanced Logger library.
|
||||
#
|
||||
# Copyright (c) Microsoft Corporation.
|
||||
#
|
||||
# SPDX-License-Identifier: BSD-2-Clause-Patent
|
||||
#
|
||||
##
|
||||
|
||||
[Defines]
|
||||
INF_VERSION = 1.27
|
||||
BASE_NAME = BaseAdvancedLoggerLib
|
||||
MODULE_UNI_FILE = AdvancedLoggerLib.uni
|
||||
FILE_GUID = 916f2e2d-1f55-4ca4-b229-18487e94c747
|
||||
MODULE_TYPE = BASE
|
||||
VERSION_STRING = 1.0
|
||||
LIBRARY_CLASS = AdvancedLoggerLib
|
||||
PI_SPECIFICATION_VERSION = 0x00010032
|
||||
|
||||
#
|
||||
# VALID_ARCHITECTURES = IA32 X64 AARCH64
|
||||
#
|
||||
|
||||
[Sources]
|
||||
AdvancedLoggerLib.c
|
||||
../AdvancedLoggerCommon.h
|
||||
../AdvancedLoggerCommon.c
|
||||
|
||||
[Packages]
|
||||
MdePkg/MdePkg.dec
|
||||
AdvLoggerPkg/AdvLoggerPkg.dec
|
||||
|
||||
[LibraryClasses]
|
||||
AdvancedLoggerHdwPortLib
|
||||
BaseLib
|
||||
DebugLib
|
||||
SynchronizationLib
|
||||
|
||||
[Pcd]
|
||||
gAdvLoggerPkgTokenSpaceGuid.PcdAdvancedLoggerBase
|
||||
|
||||
[Depex]
|
||||
TRUE
|
|
@ -0,0 +1,17 @@
|
|||
// /** @file
|
||||
// Base Arm Instance of Advanced Logger Library.
|
||||
//
|
||||
// Obtains the AdvLogger memory location.
|
||||
//
|
||||
//
|
||||
// Copyright (c) Microsoft Corporation
|
||||
//
|
||||
// SPDX-License-Identifier: BSD-2-Clause-Patent
|
||||
//
|
||||
// **/
|
||||
|
||||
|
||||
#string STR_MODULE_ABSTRACT #language en-US "Base Arm Instance of AdvancedLoggerLib"
|
||||
|
||||
#string STR_MODULE_DESCRIPTION #language en-US "Obtains access to the logger buffer."
|
||||
|
|
@ -33,6 +33,7 @@
|
|||
STATIC ADVANCED_LOGGER_INFO *mLoggerInfo = NULL;
|
||||
STATIC UINT32 mBufferSize = 0;
|
||||
STATIC EFI_PHYSICAL_ADDRESS mMaxAddress = 0;
|
||||
STATIC BOOLEAN mInitialized = FALSE;
|
||||
|
||||
VOID
|
||||
EFIAPI
|
||||
|
@ -111,12 +112,8 @@ ValidateInfoBlock (
|
|||
return FALSE;
|
||||
}
|
||||
|
||||
if (mBufferSize == 0) {
|
||||
mBufferSize = mLoggerInfo->LogBufferSize;
|
||||
} else {
|
||||
if (mLoggerInfo->LogBufferSize != mBufferSize) {
|
||||
return FALSE;
|
||||
}
|
||||
if (mLoggerInfo->LogBufferSize != mBufferSize) {
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
|
@ -135,26 +132,34 @@ AdvancedLoggerGetLoggerInfo (
|
|||
EFI_HOB_GUID_TYPE *GuidHob;
|
||||
ADVANCED_LOGGER_PTR *LogPtr;
|
||||
|
||||
if (mLoggerInfo == NULL) {
|
||||
if (!mInitialized) {
|
||||
mInitialized = TRUE;
|
||||
|
||||
//
|
||||
// Locate the Logger Information block.
|
||||
//
|
||||
GuidHob = GetFirstGuidHob (&gAdvancedLoggerHobGuid);
|
||||
if (GuidHob != NULL) {
|
||||
LogPtr = (ADVANCED_LOGGER_PTR *)GET_GUID_HOB_DATA (GuidHob);
|
||||
mLoggerInfo = ALI_FROM_PA (LogPtr->LogBuffer);
|
||||
if (!mLoggerInfo->HdwPortInitialized) {
|
||||
AdvancedLoggerHdwPortInitialize ();
|
||||
mLoggerInfo->HdwPortInitialized = TRUE;
|
||||
}
|
||||
|
||||
if (mLoggerInfo != NULL) {
|
||||
mMaxAddress = mLoggerInfo->LogBuffer + mLoggerInfo->LogBufferSize;
|
||||
if (FeaturePcdGet (PcdAdvancedLoggerFixedInRAM)) {
|
||||
mLoggerInfo = (ADVANCED_LOGGER_INFO *)FixedPcdGet64 (PcdAdvancedLoggerBase);
|
||||
} else {
|
||||
GuidHob = GetFirstGuidHob (&gAdvancedLoggerHobGuid);
|
||||
if (GuidHob != NULL) {
|
||||
LogPtr = (ADVANCED_LOGGER_PTR *)GET_GUID_HOB_DATA (GuidHob);
|
||||
mLoggerInfo = ALI_FROM_PA (LogPtr->LogBuffer);
|
||||
if (!mLoggerInfo->HdwPortInitialized) {
|
||||
AdvancedLoggerHdwPortInitialize ();
|
||||
mLoggerInfo->HdwPortInitialized = TRUE;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (mLoggerInfo != NULL) {
|
||||
mMaxAddress = mLoggerInfo->LogBuffer + mLoggerInfo->LogBufferSize;
|
||||
mBufferSize = mLoggerInfo->LogBufferSize;
|
||||
}
|
||||
}
|
||||
|
||||
if (!ValidateInfoBlock ()) {
|
||||
if (((mLoggerInfo) != NULL) && !ValidateInfoBlock ()) {
|
||||
mLoggerInfo = NULL;
|
||||
}
|
||||
|
||||
|
|
|
@ -56,3 +56,5 @@
|
|||
[Pcd]
|
||||
gAdvLoggerPkgTokenSpaceGuid.PcdAdvancedLoggerPages
|
||||
gAdvLoggerPkgTokenSpaceGuid.PcdAdvancedLoggerLocator
|
||||
gAdvLoggerPkgTokenSpaceGuid.PcdAdvancedLoggerFixedInRAM
|
||||
gAdvLoggerPkgTokenSpaceGuid.PcdAdvancedLoggerBase
|
|
@ -0,0 +1,141 @@
|
|||
/** @file
|
||||
MM_CORE Arm implementation of Advanced Logger Library.
|
||||
|
||||
Copyright (c) Microsoft Corporation. All rights reserved.<BR>
|
||||
SPDX-License-Identifier: BSD-2-Clause-Patent
|
||||
|
||||
**/
|
||||
|
||||
#include <PiDxe.h>
|
||||
|
||||
#include <AdvancedLoggerInternal.h>
|
||||
|
||||
#include <Library/AdvancedLoggerLib.h>
|
||||
#include <Library/AdvancedLoggerHdwPortLib.h>
|
||||
#include <Library/BaseMemoryLib.h>
|
||||
#include <Library/DebugLib.h>
|
||||
#include <Library/SynchronizationLib.h>
|
||||
#include <Library/ArmMmuLib.h>
|
||||
|
||||
#include "../AdvancedLoggerCommon.h"
|
||||
|
||||
#define ADV_LOGGER_MIN_SIZE (65536)
|
||||
|
||||
STATIC ADVANCED_LOGGER_INFO *mLoggerInfo = NULL;
|
||||
STATIC UINT32 mBufferSize = 0;
|
||||
STATIC EFI_PHYSICAL_ADDRESS mMaxAddress = 0;
|
||||
STATIC BOOLEAN mInitialized = FALSE;
|
||||
|
||||
/**
|
||||
Validate Info Blocks
|
||||
|
||||
The address of the ADVANCE_LOGGER_INFO block pointer is captured during the first debug print. The
|
||||
pointers LogBuffer and LogCurrent, and LogBufferSize, could be written to by untrusted code. Here,
|
||||
we check that the pointers are within the allocated mLoggerInfo space, and that LogBufferSize, which
|
||||
is used in multiple places to see if a new message will fit into the log buffer, is valid.
|
||||
|
||||
@param NONE
|
||||
|
||||
@return BOOLEAN TRUE = mLoggerInfo Block passes security checks
|
||||
@return BOOLEAN FALSE= mLoggerInfo Block failed security checks
|
||||
|
||||
**/
|
||||
STATIC
|
||||
BOOLEAN
|
||||
ValidateInfoBlock (
|
||||
VOID
|
||||
)
|
||||
{
|
||||
if (mLoggerInfo == NULL) {
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if (mLoggerInfo->Signature != ADVANCED_LOGGER_SIGNATURE) {
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if (mLoggerInfo->LogBuffer != (PA_FROM_PTR (mLoggerInfo + 1))) {
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if ((mLoggerInfo->LogCurrent > mMaxAddress) ||
|
||||
(mLoggerInfo->LogCurrent < mLoggerInfo->LogBuffer))
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if (mBufferSize == 0) {
|
||||
mBufferSize = mLoggerInfo->LogBufferSize;
|
||||
} else if (mLoggerInfo->LogBufferSize != mBufferSize) {
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/**
|
||||
The logger Information Block is carved from the Trust Zone at a specific fixed address.
|
||||
|
||||
This address is obtained from the PcdAdvancedLoggerBase. The size of the Advanced Logger
|
||||
buffer is obtained from PcdAdvancedLoggerPages.
|
||||
|
||||
The following PCD settings are assumed:
|
||||
|
||||
PcdAdvancedLoggerPeiInRAM -- TRUE
|
||||
PcdAdvancedLoggerBase -- NOT NULL and pointer to memory to be used
|
||||
PcdAdvancedLoggerPages -- > 64KB of pages
|
||||
PcdAdvancedLoggerCarBase -- NOT USED, leave at default
|
||||
PcdAdvancedLoggerPreMemPages -- NOT USED, leave at default
|
||||
|
||||
NOTE: A debug statement here will cause recursion. Insure that the recursion will be
|
||||
a straight path just to return the existing mLoggerInfo.
|
||||
|
||||
@param - None
|
||||
|
||||
@returns - NULL - No valid Advanced Logger Info block available
|
||||
- Pointer to a Valid Advanced Logger Info block.
|
||||
|
||||
**/
|
||||
ADVANCED_LOGGER_INFO *
|
||||
EFIAPI
|
||||
AdvancedLoggerGetLoggerInfo (
|
||||
VOID
|
||||
)
|
||||
{
|
||||
EFI_STATUS Status;
|
||||
EFI_PHYSICAL_ADDRESS Address;
|
||||
|
||||
ASSERT (FeaturePcdGet (PcdAdvancedLoggerFixedInRAM));
|
||||
if (!FeaturePcdGet (PcdAdvancedLoggerFixedInRAM)) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (!mInitialized) {
|
||||
// If this is the first time for MM core to get here, the memory attributes of this module
|
||||
// may not be fully set yet. Thus set the memory for global variables attributes to RW first.
|
||||
Address = ALIGN_VALUE ((EFI_PHYSICAL_ADDRESS)(UINTN)&mInitialized - EFI_PAGE_SIZE + 1, EFI_PAGE_SIZE);
|
||||
Status = ArmSetMemoryRegionNoExec (Address, EFI_PAGE_SIZE);
|
||||
Status = ArmClearMemoryRegionReadOnly (Address, EFI_PAGE_SIZE);
|
||||
|
||||
Address = ALIGN_VALUE ((EFI_PHYSICAL_ADDRESS)(UINTN)&mLoggerInfo - EFI_PAGE_SIZE + 1, EFI_PAGE_SIZE);
|
||||
Status = ArmSetMemoryRegionNoExec (Address, EFI_PAGE_SIZE);
|
||||
Status = ArmClearMemoryRegionReadOnly (Address, EFI_PAGE_SIZE);
|
||||
|
||||
mInitialized = TRUE; // Only allow initialization once
|
||||
mLoggerInfo = (ADVANCED_LOGGER_INFO *)(VOID *)FixedPcdGet64 (PcdAdvancedLoggerBase);
|
||||
ASSERT (mLoggerInfo != NULL);
|
||||
if (mLoggerInfo == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
mMaxAddress = mLoggerInfo->LogBuffer + mLoggerInfo->LogBufferSize;
|
||||
mBufferSize = mLoggerInfo->LogBufferSize;
|
||||
}
|
||||
|
||||
if (((mLoggerInfo) != NULL) && !ValidateInfoBlock ()) {
|
||||
mLoggerInfo = NULL;
|
||||
DEBUG ((DEBUG_ERROR, "%a: LoggerInfo marked invalid\n", __FUNCTION__));
|
||||
}
|
||||
|
||||
return mLoggerInfo;
|
||||
}
|
|
@ -0,0 +1,50 @@
|
|||
## @file
|
||||
# MM_STANDALONE ARM instance of the Advanced Logger library.
|
||||
#
|
||||
# Copyright (c) Microsoft Corporation.
|
||||
#
|
||||
# SPDX-License-Identifier: BSD-2-Clause-Patent
|
||||
#
|
||||
##
|
||||
|
||||
[Defines]
|
||||
INF_VERSION = 1.27
|
||||
BASE_NAME = MmAdvancedLoggerLib
|
||||
MODULE_UNI_FILE = AdvancedLoggerLib.uni
|
||||
FILE_GUID = f86cf2d7-1355-44ad-9cab-90f3247e3d67
|
||||
MODULE_TYPE = MM_STANDALONE
|
||||
VERSION_STRING = 1.0
|
||||
LIBRARY_CLASS = AdvancedLoggerLib | MM_CORE_STANDALONE MM_STANDALONE
|
||||
PI_SPECIFICATION_VERSION = 0x00010032
|
||||
|
||||
#
|
||||
# VALID_ARCHITECTURES = AARCH64
|
||||
#
|
||||
|
||||
[Sources]
|
||||
AdvancedLoggerLib.c
|
||||
../AdvancedLoggerCommon.h
|
||||
../AdvancedLoggerCommon.c
|
||||
|
||||
[Packages]
|
||||
MdePkg/MdePkg.dec
|
||||
AdvLoggerPkg/AdvLoggerPkg.dec
|
||||
ArmPkg/ArmPkg.dec
|
||||
|
||||
[LibraryClasses]
|
||||
AdvancedLoggerHdwPortLib
|
||||
BaseMemoryLib
|
||||
DebugLib
|
||||
SynchronizationLib
|
||||
ArmMmuLib
|
||||
|
||||
[Guids]
|
||||
gAdvancedLoggerHobGuid
|
||||
|
||||
[Pcd]
|
||||
gAdvLoggerPkgTokenSpaceGuid.PcdAdvancedLoggerBase
|
||||
gAdvLoggerPkgTokenSpaceGuid.PcdAdvancedLoggerPages
|
||||
gAdvLoggerPkgTokenSpaceGuid.PcdAdvancedLoggerFixedInRAM
|
||||
|
||||
[Depex]
|
||||
TRUE
|
|
@ -0,0 +1,17 @@
|
|||
// /** @file
|
||||
// MM_CORE Arm Instance of Advanced Logger Library.
|
||||
//
|
||||
// Obtains the AdvLogger memory location from AdvancedLoggerHob.
|
||||
//
|
||||
//
|
||||
// Copyright (c) Microsoft Corporation
|
||||
//
|
||||
// SPDX-License-Identifier: BSD-2-Clause-Patent
|
||||
//
|
||||
// **/
|
||||
|
||||
|
||||
#string STR_MODULE_ABSTRACT #language en-US "MM_CORE Arm Instance of AdvancedLoggerLib for Memory Logger"
|
||||
|
||||
#string STR_MODULE_DESCRIPTION #language en-US "Obtains access to the logger buffer."
|
||||
|
|
@ -36,7 +36,7 @@ AdvancedLoggerGetLoggerInfo (
|
|||
// The PCD AdvancedLoggerBase MAY be a 64 bit address. However, it is
|
||||
// trimmed to be a pointer the size of the actual platform - and the Pcd is expected
|
||||
// to be set accordingly.
|
||||
LogPtr = (ADVANCED_LOGGER_PTR *)(VOID *)(UINTN)FixedPcdGet64 (PcdAdvancedLoggerBase);
|
||||
LogPtr = (ADVANCED_LOGGER_PTR *)FixedPcdGet64 (PcdAdvancedLoggerBase);
|
||||
LoggerInfoSec = NULL;
|
||||
if ((LogPtr != NULL) &&
|
||||
(LogPtr->Signature == ADVANCED_LOGGER_PTR_SIGNATURE) &&
|
||||
|
|
|
@ -86,7 +86,8 @@
|
|||
"SERIALNUMBER",
|
||||
"VALIDATEBLOB",
|
||||
"malformatted",
|
||||
"nonced"
|
||||
"nonced",
|
||||
"eku's"
|
||||
],
|
||||
"AdditionalIncludePaths": [] # Additional paths to spell check relative to package root (wildcards supported)
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче