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:
Olivier Martin 2014-03-26 19:34:32 +00:00 committed by oliviermartin
parent cf02da5203
commit 19dc108b65
1 changed files with 22 additions and 6 deletions

View File

@ -1,7 +1,7 @@
/** @file /** @file
* File managing the MMU for ARMv8 architecture * 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 * This program and the accompanying materials
* are licensed and made available under the terms and conditions of the BSD License * are licensed and made available under the terms and conditions of the BSD License
@ -264,13 +264,22 @@ GetBlockEntryListFromAddress (
BlockEntry = NULL; BlockEntry = NULL;
// Ensure the parameters are valid // 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 // 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 // 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 // Calculate LastBlockEntry from T0SZ - this is the last block entry of the root Translation table
@ -427,7 +436,10 @@ FillTranslationTable (
UINTN TableLevel; UINTN TableLevel;
// Ensure the Length is aligned on 4KB boundary // 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 // Variable initialization
Attributes = ArmMemoryAttributeToPageAttribute (MemoryRegion->Attributes) | TT_AF; Attributes = ArmMemoryAttributeToPageAttribute (MemoryRegion->Attributes) | TT_AF;
@ -519,7 +531,11 @@ ArmConfigureMmu (
UINT64 TCR; UINT64 TCR;
RETURN_STATUS Status; RETURN_STATUS Status;
ASSERT (MemoryTable != NULL); if(MemoryTable == NULL)
{
ASSERT (MemoryTable != NULL);
return RETURN_INVALID_PARAMETER;
}
// Identify the highest address of the memory table // Identify the highest address of the memory table
MaxAddress = MemoryTable->PhysicalBase + MemoryTable->Length - 1; MaxAddress = MemoryTable->PhysicalBase + MemoryTable->Length - 1;