StandaloneMmPkg: Apply uncrustify changes
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3737 Apply uncrustify changes to .c/.h files in the StandaloneMmPkg package Cc: Andrew Fish <afish@apple.com> Cc: Leif Lindholm <leif@nuviainc.com> Cc: Michael D Kinney <michael.d.kinney@intel.com> Signed-off-by: Michael Kubacki <michael.kubacki@microsoft.com> Reviewed-by: Sami Mujawar <sami.mujawar@arm.com>
This commit is contained in:
committed by
mergify[bot]
parent
c1e126b119
commit
91415a36ae
@@ -21,10 +21,10 @@
|
||||
extern EFI_PHYSICAL_ADDRESS mMmMemLibInternalMaximumSupportAddress;
|
||||
|
||||
#ifdef MDE_CPU_AARCH64
|
||||
#define ARM_PHYSICAL_ADDRESS_BITS 36
|
||||
#define ARM_PHYSICAL_ADDRESS_BITS 36
|
||||
#endif
|
||||
#ifdef MDE_CPU_ARM
|
||||
#define ARM_PHYSICAL_ADDRESS_BITS 32
|
||||
#define ARM_PHYSICAL_ADDRESS_BITS 32
|
||||
#endif
|
||||
|
||||
/**
|
||||
@@ -36,7 +36,7 @@ MmMemLibInternalCalculateMaximumSupportAddress (
|
||||
VOID
|
||||
)
|
||||
{
|
||||
UINT8 PhysicalAddressBits;
|
||||
UINT8 PhysicalAddressBits;
|
||||
|
||||
PhysicalAddressBits = ARM_PHYSICAL_ADDRESS_BITS;
|
||||
|
||||
@@ -74,4 +74,3 @@ MmMemLibInternalFreeMmramRanges (
|
||||
{
|
||||
// Not implemented for AARCH64.
|
||||
}
|
||||
|
||||
|
@@ -13,15 +13,14 @@
|
||||
|
||||
**/
|
||||
|
||||
|
||||
#include <PiMm.h>
|
||||
|
||||
#include <Library/BaseLib.h>
|
||||
#include <Library/BaseMemoryLib.h>
|
||||
#include <Library/DebugLib.h>
|
||||
|
||||
EFI_MMRAM_DESCRIPTOR *mMmMemLibInternalMmramRanges;
|
||||
UINTN mMmMemLibInternalMmramCount;
|
||||
EFI_MMRAM_DESCRIPTOR *mMmMemLibInternalMmramRanges;
|
||||
UINTN mMmMemLibInternalMmramCount;
|
||||
|
||||
//
|
||||
// Maximum support address used to check input buffer
|
||||
@@ -82,7 +81,8 @@ MmIsBufferOutsideMmValid (
|
||||
//
|
||||
if ((Length > mMmMemLibInternalMaximumSupportAddress) ||
|
||||
(Buffer > mMmMemLibInternalMaximumSupportAddress) ||
|
||||
((Length != 0) && (Buffer > (mMmMemLibInternalMaximumSupportAddress - (Length - 1)))) ) {
|
||||
((Length != 0) && (Buffer > (mMmMemLibInternalMaximumSupportAddress - (Length - 1)))))
|
||||
{
|
||||
//
|
||||
// Overflow happen
|
||||
//
|
||||
@@ -96,11 +96,12 @@ MmIsBufferOutsideMmValid (
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
for (Index = 0; Index < mMmMemLibInternalMmramCount; Index ++) {
|
||||
for (Index = 0; Index < mMmMemLibInternalMmramCount; Index++) {
|
||||
if (((Buffer >= mMmMemLibInternalMmramRanges[Index].CpuStart) &&
|
||||
(Buffer < mMmMemLibInternalMmramRanges[Index].CpuStart + mMmMemLibInternalMmramRanges[Index].PhysicalSize)) ||
|
||||
((mMmMemLibInternalMmramRanges[Index].CpuStart >= Buffer) &&
|
||||
(mMmMemLibInternalMmramRanges[Index].CpuStart < Buffer + Length))) {
|
||||
(mMmMemLibInternalMmramRanges[Index].CpuStart < Buffer + Length)))
|
||||
{
|
||||
DEBUG ((
|
||||
DEBUG_ERROR,
|
||||
"MmIsBufferOutsideMmValid: Overlap: Buffer (0x%lx) - Length (0x%lx), ",
|
||||
@@ -149,6 +150,7 @@ MmCopyMemToMmram (
|
||||
DEBUG ((DEBUG_ERROR, "MmCopyMemToMmram: Security Violation: Source (0x%x), Length (0x%x)\n", SourceBuffer, Length));
|
||||
return EFI_SECURITY_VIOLATION;
|
||||
}
|
||||
|
||||
CopyMem (DestinationBuffer, SourceBuffer, Length);
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
@@ -179,10 +181,15 @@ MmCopyMemFromMmram (
|
||||
)
|
||||
{
|
||||
if (!MmIsBufferOutsideMmValid ((EFI_PHYSICAL_ADDRESS)(UINTN)DestinationBuffer, Length)) {
|
||||
DEBUG ((DEBUG_ERROR, "MmCopyMemFromMmram: Security Violation: Destination (0x%x), Length (0x%x)\n",
|
||||
DestinationBuffer, Length));
|
||||
DEBUG ((
|
||||
DEBUG_ERROR,
|
||||
"MmCopyMemFromMmram: Security Violation: Destination (0x%x), Length (0x%x)\n",
|
||||
DestinationBuffer,
|
||||
Length
|
||||
));
|
||||
return EFI_SECURITY_VIOLATION;
|
||||
}
|
||||
|
||||
CopyMem (DestinationBuffer, SourceBuffer, Length);
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
@@ -214,14 +221,20 @@ MmCopyMem (
|
||||
)
|
||||
{
|
||||
if (!MmIsBufferOutsideMmValid ((EFI_PHYSICAL_ADDRESS)(UINTN)DestinationBuffer, Length)) {
|
||||
DEBUG ((DEBUG_ERROR, "MmCopyMem: Security Violation: Destination (0x%x), Length (0x%x)\n",
|
||||
DestinationBuffer, Length));
|
||||
DEBUG ((
|
||||
DEBUG_ERROR,
|
||||
"MmCopyMem: Security Violation: Destination (0x%x), Length (0x%x)\n",
|
||||
DestinationBuffer,
|
||||
Length
|
||||
));
|
||||
return EFI_SECURITY_VIOLATION;
|
||||
}
|
||||
|
||||
if (!MmIsBufferOutsideMmValid ((EFI_PHYSICAL_ADDRESS)(UINTN)SourceBuffer, Length)) {
|
||||
DEBUG ((DEBUG_ERROR, "MmCopyMem: Security Violation: Source (0x%x), Length (0x%x)\n", SourceBuffer, Length));
|
||||
return EFI_SECURITY_VIOLATION;
|
||||
}
|
||||
|
||||
CopyMem (DestinationBuffer, SourceBuffer, Length);
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
@@ -254,6 +267,7 @@ MmSetMem (
|
||||
DEBUG ((DEBUG_ERROR, "MmSetMem: Security Violation: Source (0x%x), Length (0x%x)\n", Buffer, Length));
|
||||
return EFI_SECURITY_VIOLATION;
|
||||
}
|
||||
|
||||
SetMem (Buffer, Length, Value);
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
@@ -270,11 +284,11 @@ MmSetMem (
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
MemLibConstructor (
|
||||
IN EFI_HANDLE ImageHandle,
|
||||
IN EFI_MM_SYSTEM_TABLE *MmSystemTable
|
||||
IN EFI_HANDLE ImageHandle,
|
||||
IN EFI_MM_SYSTEM_TABLE *MmSystemTable
|
||||
)
|
||||
{
|
||||
EFI_STATUS Status;
|
||||
EFI_STATUS Status;
|
||||
|
||||
//
|
||||
// Calculate and save maximum support address
|
||||
@@ -301,11 +315,10 @@ MemLibConstructor (
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
MemLibDestructor (
|
||||
IN EFI_HANDLE ImageHandle,
|
||||
IN EFI_MM_SYSTEM_TABLE *MmSystemTable
|
||||
IN EFI_HANDLE ImageHandle,
|
||||
IN EFI_MM_SYSTEM_TABLE *MmSystemTable
|
||||
)
|
||||
{
|
||||
|
||||
//
|
||||
// Deinitialize cached Mmram Ranges.
|
||||
//
|
||||
|
@@ -27,7 +27,7 @@
|
||||
// Maximum support address used to check input buffer
|
||||
//
|
||||
extern EFI_PHYSICAL_ADDRESS mMmMemLibInternalMaximumSupportAddress;
|
||||
extern EFI_MMRAM_DESCRIPTOR *mMmMemLibInternalMmramRanges;
|
||||
extern EFI_MMRAM_DESCRIPTOR *mMmMemLibInternalMmramRanges;
|
||||
extern UINTN mMmMemLibInternalMmramCount;
|
||||
|
||||
/**
|
||||
@@ -39,25 +39,26 @@ MmMemLibInternalCalculateMaximumSupportAddress (
|
||||
VOID
|
||||
)
|
||||
{
|
||||
VOID *Hob;
|
||||
UINT32 RegEax;
|
||||
UINT8 PhysicalAddressBits;
|
||||
VOID *Hob;
|
||||
UINT32 RegEax;
|
||||
UINT8 PhysicalAddressBits;
|
||||
|
||||
//
|
||||
// Get physical address bits supported.
|
||||
//
|
||||
Hob = GetFirstHob (EFI_HOB_TYPE_CPU);
|
||||
if (Hob != NULL) {
|
||||
PhysicalAddressBits = ((EFI_HOB_CPU *) Hob)->SizeOfMemorySpace;
|
||||
PhysicalAddressBits = ((EFI_HOB_CPU *)Hob)->SizeOfMemorySpace;
|
||||
} else {
|
||||
AsmCpuid (0x80000000, &RegEax, NULL, NULL, NULL);
|
||||
if (RegEax >= 0x80000008) {
|
||||
AsmCpuid (0x80000008, &RegEax, NULL, NULL, NULL);
|
||||
PhysicalAddressBits = (UINT8) RegEax;
|
||||
PhysicalAddressBits = (UINT8)RegEax;
|
||||
} else {
|
||||
PhysicalAddressBits = 36;
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// IA-32e paging translates 48-bit linear addresses to 52-bit physical addresses.
|
||||
//
|
||||
@@ -108,32 +109,34 @@ MmMemLibInternalPopulateMmramRanges (
|
||||
}
|
||||
|
||||
MmramRangesHobData = GET_GUID_HOB_DATA (MmramRangesHob);
|
||||
if (MmramRangesHobData == NULL || MmramRangesHobData->Descriptor == NULL) {
|
||||
if ((MmramRangesHobData == NULL) || (MmramRangesHobData->Descriptor == NULL)) {
|
||||
return EFI_UNSUPPORTED;
|
||||
}
|
||||
|
||||
mMmMemLibInternalMmramCount = MmramRangesHobData->NumberOfMmReservedRegions;
|
||||
MmramDescriptors = MmramRangesHobData->Descriptor;
|
||||
MmramDescriptors = MmramRangesHobData->Descriptor;
|
||||
} else {
|
||||
DataInHob = GET_GUID_HOB_DATA (GuidHob);
|
||||
if (DataInHob == NULL) {
|
||||
return EFI_UNSUPPORTED;
|
||||
}
|
||||
|
||||
MmCorePrivateData = (MM_CORE_PRIVATE_DATA *) (UINTN) DataInHob->Address;
|
||||
if (MmCorePrivateData == NULL || MmCorePrivateData->MmramRanges == 0) {
|
||||
MmCorePrivateData = (MM_CORE_PRIVATE_DATA *)(UINTN)DataInHob->Address;
|
||||
if ((MmCorePrivateData == NULL) || (MmCorePrivateData->MmramRanges == 0)) {
|
||||
return EFI_UNSUPPORTED;
|
||||
}
|
||||
|
||||
mMmMemLibInternalMmramCount = (UINTN) MmCorePrivateData->MmramRangeCount;
|
||||
MmramDescriptors = (EFI_MMRAM_DESCRIPTOR *) (UINTN) MmCorePrivateData->MmramRanges;
|
||||
mMmMemLibInternalMmramCount = (UINTN)MmCorePrivateData->MmramRangeCount;
|
||||
MmramDescriptors = (EFI_MMRAM_DESCRIPTOR *)(UINTN)MmCorePrivateData->MmramRanges;
|
||||
}
|
||||
|
||||
mMmMemLibInternalMmramRanges = AllocatePool (mMmMemLibInternalMmramCount * sizeof (EFI_MMRAM_DESCRIPTOR));
|
||||
if (mMmMemLibInternalMmramRanges) {
|
||||
CopyMem (mMmMemLibInternalMmramRanges,
|
||||
MmramDescriptors,
|
||||
mMmMemLibInternalMmramCount * sizeof (EFI_MMRAM_DESCRIPTOR));
|
||||
CopyMem (
|
||||
mMmMemLibInternalMmramRanges,
|
||||
MmramDescriptors,
|
||||
mMmMemLibInternalMmramCount * sizeof (EFI_MMRAM_DESCRIPTOR)
|
||||
);
|
||||
}
|
||||
|
||||
return EFI_SUCCESS;
|
||||
@@ -152,4 +155,3 @@ MmMemLibInternalFreeMmramRanges (
|
||||
FreePool (mMmMemLibInternalMmramRanges);
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user