summaryrefslogtreecommitdiff
path: root/ArmPkg
diff options
context:
space:
mode:
authorOlivier Martin <olivier.martin@arm.com>2014-03-26 19:34:32 +0000
committeroliviermartin <oliviermartin@6f19259b-4bc3-4df7-8a09-765794883524>2014-03-26 19:34:32 +0000
commit19dc108b65f6049c10663b713cea4bca83f9d801 (patch)
treec5d6938157b3f4f8d4e3edd10ee34e383b0d35c0 /ArmPkg
parentcf02da5203db848a4ddcd6e33c2dec28c4ca4b74 (diff)
downloadedk2-platforms-19dc108b65f6049c10663b713cea4bca83f9d801.tar.xz
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
Diffstat (limited to 'ArmPkg')
-rw-r--r--ArmPkg/Library/ArmLib/AArch64/AArch64Mmu.c28
1 files changed, 22 insertions, 6 deletions
diff --git a/ArmPkg/Library/ArmLib/AArch64/AArch64Mmu.c b/ArmPkg/Library/ArmLib/AArch64/AArch64Mmu.c
index 9bc984f0bf..bababab880 100644
--- a/ArmPkg/Library/ArmLib/AArch64/AArch64Mmu.c
+++ b/ArmPkg/Library/ArmLib/AArch64/AArch64Mmu.c
@@ -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;
- ASSERT (MemoryTable != NULL);
+ if(MemoryTable == NULL)
+ {
+ ASSERT (MemoryTable != NULL);
+ return RETURN_INVALID_PARAMETER;
+ }
// Identify the highest address of the memory table
MaxAddress = MemoryTable->PhysicalBase + MemoryTable->Length - 1;