From 81514a8ad0a0456503663522536fec9395760311 Mon Sep 17 00:00:00 2001 From: Olivier Martin Date: Thu, 3 Apr 2014 20:05:30 +0000 Subject: [PATCH] ArmPlatformPkg/PrePi: Use the same calculation to declare the stack size as in the entrypoint The stack size in the entrypoint (ie: $ARCH/ModuleEntryPoint.S) is calculated such as StackSize = PrimaryCoreStack + (core_count - 1) * SecondaryCoreStack While we were declaring the stacksize into the stack hob as: StackSize = PrimaryCoreStack + (cluster * 8) * SecondaryCoreStack If the number of cluster (ie: PcdClusterCount) were not defined correctly then the stack size declaration were not correct. It could cause stack corruption if the allocator allocates memory in this range. Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Olivier Martin git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@15431 6f19259b-4bc3-4df7-8a09-765794883524 --- ArmPlatformPkg/PrePi/PeiMPCore.inf | 3 +-- ArmPlatformPkg/PrePi/PeiUniCore.inf | 3 +-- ArmPlatformPkg/PrePi/PrePi.c | 5 +++-- 3 files changed, 5 insertions(+), 6 deletions(-) diff --git a/ArmPlatformPkg/PrePi/PeiMPCore.inf b/ArmPlatformPkg/PrePi/PeiMPCore.inf index 276a37226d..45c00b8df0 100755 --- a/ArmPlatformPkg/PrePi/PeiMPCore.inf +++ b/ArmPlatformPkg/PrePi/PeiMPCore.inf @@ -1,6 +1,6 @@ #/** @file # -# Copyright (c) 2011-2012, ARM Ltd. All rights reserved.
+# Copyright (c) 2011-2014, ARM Ltd. All rights reserved.
# # This program and the accompanying materials # are licensed and made available under the terms and conditions of the BSD License @@ -98,7 +98,6 @@ gArmPlatformTokenSpaceGuid.PcdSystemMemoryUefiRegionSize gArmPlatformTokenSpaceGuid.PcdCoreCount - gArmPlatformTokenSpaceGuid.PcdClusterCount gArmTokenSpaceGuid.PcdArmPrimaryCore gEmbeddedTokenSpaceGuid.PcdPrePiCpuMemorySize diff --git a/ArmPlatformPkg/PrePi/PeiUniCore.inf b/ArmPlatformPkg/PrePi/PeiUniCore.inf index 160374eab4..6079ec506f 100755 --- a/ArmPlatformPkg/PrePi/PeiUniCore.inf +++ b/ArmPlatformPkg/PrePi/PeiUniCore.inf @@ -1,6 +1,6 @@ #/** @file # -# Copyright (c) 2011-2012, ARM Ltd. All rights reserved.
+# Copyright (c) 2011-2014, ARM Ltd. All rights reserved.
# # This program and the accompanying materials # are licensed and made available under the terms and conditions of the BSD License @@ -93,7 +93,6 @@ gArmPlatformTokenSpaceGuid.PcdSystemMemoryUefiRegionSize gArmPlatformTokenSpaceGuid.PcdCoreCount - gArmPlatformTokenSpaceGuid.PcdClusterCount gEmbeddedTokenSpaceGuid.PcdPrePiCpuMemorySize gEmbeddedTokenSpaceGuid.PcdPrePiCpuIoSize diff --git a/ArmPlatformPkg/PrePi/PrePi.c b/ArmPlatformPkg/PrePi/PrePi.c index d54ebf9337..84b01b3fbe 100755 --- a/ArmPlatformPkg/PrePi/PrePi.c +++ b/ArmPlatformPkg/PrePi/PrePi.c @@ -1,6 +1,6 @@ /** @file * -* 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 @@ -139,7 +139,8 @@ PrePiMain ( // Create the Stacks HOB (reserve the memory for all stacks) if (ArmIsMpCore ()) { - StacksSize = PcdGet32 (PcdCPUCorePrimaryStackSize) + (FixedPcdGet32(PcdClusterCount) * 4 * FixedPcdGet32(PcdCPUCoreSecondaryStackSize)); + StacksSize = PcdGet32 (PcdCPUCorePrimaryStackSize) + + ((FixedPcdGet32 (PcdCoreCount) - 1) * FixedPcdGet32 (PcdCPUCoreSecondaryStackSize)); } else { StacksSize = PcdGet32 (PcdCPUCorePrimaryStackSize); } -- 2.39.2