mirror of https://github.com/acidanthera/audk.git
ArmPkg/ArmLib: Correct Error Handling in AArch64
There are several instances of asserts which do not also handle the error condition in Release builds. Because these functions are called in different location of the code and their parameters might change during the execution, it is safer to handle the error. Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Olivier Martin <olivier.martin@arm.com> git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@15399 6f19259b-4bc3-4df7-8a09-765794883524
This commit is contained in:
parent
cf02da5203
commit
19dc108b65
|
@ -1,7 +1,7 @@
|
|||
/** @file
|
||||
* File managing the MMU for ARMv8 architecture
|
||||
*
|
||||
* Copyright (c) 2011-2013, ARM Limited. All rights reserved.
|
||||
* Copyright (c) 2011-2014, ARM Limited. All rights reserved.
|
||||
*
|
||||
* This program and the accompanying materials
|
||||
* are licensed and made available under the terms and conditions of the BSD License
|
||||
|
@ -264,13 +264,22 @@ GetBlockEntryListFromAddress (
|
|||
BlockEntry = NULL;
|
||||
|
||||
// Ensure the parameters are valid
|
||||
ASSERT (TableLevel && BlockEntrySize && LastBlockEntry);
|
||||
if (!(TableLevel && BlockEntrySize && LastBlockEntry)) {
|
||||
ASSERT_EFI_ERROR (EFI_INVALID_PARAMETER);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
// Ensure the Region is aligned on 4KB boundary
|
||||
ASSERT ((RegionStart & (SIZE_4KB - 1)) == 0);
|
||||
if ((RegionStart & (SIZE_4KB - 1)) != 0) {
|
||||
ASSERT_EFI_ERROR (EFI_INVALID_PARAMETER);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
// Ensure the required size is aligned on 4KB boundary
|
||||
ASSERT ((*BlockEntrySize & (SIZE_4KB - 1)) == 0);
|
||||
if ((*BlockEntrySize & (SIZE_4KB - 1)) != 0) {
|
||||
ASSERT_EFI_ERROR (EFI_INVALID_PARAMETER);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
//
|
||||
// Calculate LastBlockEntry from T0SZ - this is the last block entry of the root Translation table
|
||||
|
@ -427,7 +436,10 @@ FillTranslationTable (
|
|||
UINTN TableLevel;
|
||||
|
||||
// Ensure the Length is aligned on 4KB boundary
|
||||
ASSERT ((MemoryRegion->Length > 0) && ((MemoryRegion->Length & (SIZE_4KB - 1)) == 0));
|
||||
if ((MemoryRegion->Length == 0) || ((MemoryRegion->Length & (SIZE_4KB - 1)) != 0)) {
|
||||
ASSERT_EFI_ERROR (EFI_INVALID_PARAMETER);
|
||||
return RETURN_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
// Variable initialization
|
||||
Attributes = ArmMemoryAttributeToPageAttribute (MemoryRegion->Attributes) | TT_AF;
|
||||
|
@ -519,7 +531,11 @@ ArmConfigureMmu (
|
|||
UINT64 TCR;
|
||||
RETURN_STATUS Status;
|
||||
|
||||
if(MemoryTable == NULL)
|
||||
{
|
||||
ASSERT (MemoryTable != NULL);
|
||||
return RETURN_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
// Identify the highest address of the memory table
|
||||
MaxAddress = MemoryTable->PhysicalBase + MemoryTable->Length - 1;
|
||||
|
|
Loading…
Reference in New Issue