From patchwork Fri Nov 3 11:33:52 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 117876 Delivered-To: patch@linaro.org Received: by 10.140.22.164 with SMTP id 33csp3344946qgn; Fri, 3 Nov 2017 04:34:06 -0700 (PDT) X-Google-Smtp-Source: ABhQp+St3TgHPdVbfp8o0XmYkj0alf+bVzBBANGHo40vro3IDZ0P0L8MJLyAbmCeinQdKqxZMv1u X-Received: by 10.84.215.9 with SMTP id k9mr6316639pli.284.1509708846734; Fri, 03 Nov 2017 04:34:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1509708846; cv=none; d=google.com; s=arc-20160816; b=kW/Il43U4bhAvqmEC5ngq2DkUxXNh+cLCTUdDg++qycqoVKBkhy+CPYY3/okgaupum xlWsWx60DVF6ESytQ2sTeT3Cv8EPeVCB2MQ/bIybId45mwDX+KqPzyqXRJNImb11Jkyp xUhz6M5RU42u74bhRL7Iw1WioXJvbWStllDg2W1n+X901Kp0f9HbI9h7scBpOxQgvFAC w+QSEw8qf/Oq68xFIrS3/56F4j9ZojJGpJTsDNPs9JezejUe/0t5z1DKuHQHK0NdqXdB oUfoqWZYKWHfquiuLDu9tFixeeqbpgiQBLWpIFFJUb5R6foC6OTQ0jSDeHJY1HyjK7zD rgnQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:mime-version:cc :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:message-id:date:to:from:dkim-signature :delivered-to:arc-authentication-results; bh=WJZ+ymcCCnulWM5kwRkLuM5Sp7JgsAEJUKnX7zBr394=; b=Hxnoln3yfqJNeuxds89DviRlefX6vmjgjQ/ixwmbWM/ALGWVR622L2LwbLa4DMG7K4 B3WfmcMIv0L0Thq+Q2OtC4H+qS8hT2BK9AxXeEhH1a526Kj7Gu3+FdiBmJkVMVI67Ymy xafCLDPeVblYD+gD3ygm7GnTEWNEKuP6DLIDeNEuw1ocUgE+Ly2XrwYTv6AMnI/hB801 TkHmekFhjyi8su/s376OOco9wIuXcGSvFC+ZGcntkEUBh8jfCSG5ydyE44HBticMLKMO a8HXkoWeEaokQOQDDE0Sr44J4odfoAbzZEnV25XgbnLX341/1Jea6ZQq8TpCmecQVIru Nf/Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=ibiANLpJ; spf=pass (google.com: best guess record for domain of edk2-devel-bounces@lists.01.org designates 198.145.21.10 as permitted sender) smtp.mailfrom=edk2-devel-bounces@lists.01.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from ml01.01.org (ml01.01.org. [198.145.21.10]) by mx.google.com with ESMTPS id n7si5968245pgq.39.2017.11.03.04.34.06 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 03 Nov 2017 04:34:06 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of edk2-devel-bounces@lists.01.org designates 198.145.21.10 as permitted sender) client-ip=198.145.21.10; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=ibiANLpJ; spf=pass (google.com: best guess record for domain of edk2-devel-bounces@lists.01.org designates 198.145.21.10 as permitted sender) smtp.mailfrom=edk2-devel-bounces@lists.01.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id 85771202E5E40; Fri, 3 Nov 2017 04:30:10 -0700 (PDT) X-Original-To: edk2-devel@lists.01.org Delivered-To: edk2-devel@lists.01.org Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=2a00:1450:400c:c0c::242; helo=mail-wr0-x242.google.com; envelope-from=ard.biesheuvel@linaro.org; receiver=edk2-devel@lists.01.org Received: from mail-wr0-x242.google.com (mail-wr0-x242.google.com [IPv6:2a00:1450:400c:c0c::242]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id 6CB872035561A for ; Fri, 3 Nov 2017 04:30:08 -0700 (PDT) Received: by mail-wr0-x242.google.com with SMTP id z55so2246328wrz.1 for ; Fri, 03 Nov 2017 04:34:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id; bh=D4STN1Xs3uPKTG47Z3+XHmWb8ISeKVBhuZHdkKKa0cY=; b=ibiANLpJyp4pKw92JuNiqpth5nXKIWJW0RcfrvEpOuG9hXqVHll/9jHd4qhrm8aCCU 4aI7edeHE+UcC7mQJwym1x6vdadsXkgh7J27wX2lIIqZIsDc0B5StqRIdJyIeTjheFpQ F+aQX6BYkvmBntPIRZ8axBmTYVgl+cWq8GDhE= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=D4STN1Xs3uPKTG47Z3+XHmWb8ISeKVBhuZHdkKKa0cY=; b=GL0Qb3IQnRlbliVBWfgszb1E0/hVEkCmcm7OEwmyFk2rD5NksU+vpPu88AyeSqkzWx bJ4+68judAi5okUYtEXrVlgEMMkqw86ojIwxpaRxJOcUAa+m9fAeWwkWqkWjHqUEgTA7 PX7ETOkUaIAsJuYl7fK4J82bHyINubS/x+lQVmhZEULqqT85E5GluQbmELv9W/el/9QS iFFfuUkeca3j3hSvRTINATHMpKYJ0aV0/2YuEyaKpLnVpQdfvsXZDkzeFcqOJHp3jjJi 98bNB8lMlXZy1yM3JfaHTmUMhN2T1Vk3C3KjOsqJs4F0cmpONTsHKhLT+Inxuz0MrU88 J1hg== X-Gm-Message-State: AMCzsaXDLU6352ppU3SZyALbB60qLjcBwTnL+rcmJ4u3oN0bGLJXcZc7 X9L59VeC5/HXsEwdd1xbe5W7RMx58Aw= X-Received: by 10.223.147.135 with SMTP id 7mr5904902wrp.237.1509708841468; Fri, 03 Nov 2017 04:34:01 -0700 (PDT) Received: from localhost.localdomain ([105.129.222.2]) by smtp.gmail.com with ESMTPSA id j4sm2925435wrg.11.2017.11.03.04.33.59 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 03 Nov 2017 04:34:00 -0700 (PDT) From: Ard Biesheuvel To: edk2-devel@lists.01.org, leif.lindholm@linaro.org, lersek@redhat.com, liming.gao@intel.com Date: Fri, 3 Nov 2017 11:33:52 +0000 Message-Id: <20171103113352.8604-1-ard.biesheuvel@linaro.org> X-Mailer: git-send-email 2.11.0 Subject: [edk2] [PATCH v2] ArmPlatformPkg/PrePeiCore: seed temporary stack before entering PEI core X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Ard Biesheuvel MIME-Version: 1.0 Errors-To: edk2-devel-bounces@lists.01.org Sender: "edk2-devel" DEBUG builds of PEI code will print a diagnostic message regarding the utilization of temporary RAM before switching to permanent RAM. For example, Total temporary memory: 16352 bytes. temporary memory stack ever used: 4820 bytes. temporary memory heap used for HobList: 4720 bytes. Tracking stack utilization like this requires the stack to be seeded with a known magic value, and this needs to occur before entering C code, given that it uses the stack. Currently, only Nt32Pkg appears to implement this feature, but it is useful nonetheless, so let's wire it up for PrePeiCore as well. Ref: https://bugzilla.tianocore.org/show_bug.cgi?id=748 Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Ard Biesheuvel --- v2: switch to newly introduced PCD ArmPlatformPkg/PrePeiCore/AArch64/PrePeiCoreEntryPoint.S | 6 ++++++ ArmPlatformPkg/PrePeiCore/Arm/PrePeiCoreEntryPoint.S | 8 ++++++++ ArmPlatformPkg/PrePeiCore/Arm/PrePeiCoreEntryPoint.asm | 8 ++++++++ ArmPlatformPkg/PrePeiCore/PrePeiCoreMPCore.inf | 2 ++ ArmPlatformPkg/PrePeiCore/PrePeiCoreUniCore.inf | 2 ++ 5 files changed, 26 insertions(+) -- 2.11.0 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel Reviewed-by: Liming Gao Acked-by: Laszlo Ersek Reviewed-by: Leif Lindholm diff --git a/ArmPlatformPkg/PrePeiCore/AArch64/PrePeiCoreEntryPoint.S b/ArmPlatformPkg/PrePeiCore/AArch64/PrePeiCoreEntryPoint.S index aab5edab0c42..0950fd0c0cdb 100644 --- a/ArmPlatformPkg/PrePeiCore/AArch64/PrePeiCoreEntryPoint.S +++ b/ArmPlatformPkg/PrePeiCore/AArch64/PrePeiCoreEntryPoint.S @@ -84,4 +84,10 @@ _PrepareArguments: _SetupPrimaryCoreStack: mov sp, x1 + MOV64 (x8, FixedPcdGet64 (PcdCPUCoresStackBase)) + MOV64 (x9, FixedPcdGet32 (PcdInitValueInTempStack) |\ + FixedPcdGet32 (PcdInitValueInTempStack) << 32) +0:stp x9, x9, [x8], #16 + cmp x8, x1 + b.lt 0b b _PrepareArguments diff --git a/ArmPlatformPkg/PrePeiCore/Arm/PrePeiCoreEntryPoint.S b/ArmPlatformPkg/PrePeiCore/Arm/PrePeiCoreEntryPoint.S index 14344425ad4c..a491af30a048 100644 --- a/ArmPlatformPkg/PrePeiCore/Arm/PrePeiCoreEntryPoint.S +++ b/ArmPlatformPkg/PrePeiCore/Arm/PrePeiCoreEntryPoint.S @@ -65,6 +65,14 @@ _PrepareArguments: _SetupPrimaryCoreStack: mov sp, r1 + MOV32 (r8, FixedPcdGet64 (PcdCPUCoresStackBase)) + MOV32 (r9, FixedPcdGet32 (PcdInitValueInTempStack)) + mov r10, r9 + mov r11, r9 + mov r12, r9 +0:stm r8!, {r9-r12} + cmp r8, r1 + blt 0b b _PrepareArguments _NeverReturn: diff --git a/ArmPlatformPkg/PrePeiCore/Arm/PrePeiCoreEntryPoint.asm b/ArmPlatformPkg/PrePeiCore/Arm/PrePeiCoreEntryPoint.asm index abea675828df..dc1ad8144492 100644 --- a/ArmPlatformPkg/PrePeiCore/Arm/PrePeiCoreEntryPoint.asm +++ b/ArmPlatformPkg/PrePeiCore/Arm/PrePeiCoreEntryPoint.asm @@ -79,6 +79,14 @@ _PrepareArguments _SetupPrimaryCoreStack mov sp, r1 + mov32 r8, FixedPcdGet64 (PcdCPUCoresStackBase) + mov32 r9, FixedPcdGet32 (PcdInitValueInTempStack) + mov r10, r9 + mov r11, r9 + mov r12, r9 +0:stm r8!, {r9-r12} + cmp r8, r1 + blt 0b b _PrepareArguments _NeverReturn diff --git a/ArmPlatformPkg/PrePeiCore/PrePeiCoreMPCore.inf b/ArmPlatformPkg/PrePeiCore/PrePeiCoreMPCore.inf index ecdbccb8d620..8e0456f8dc2a 100644 --- a/ArmPlatformPkg/PrePeiCore/PrePeiCoreMPCore.inf +++ b/ArmPlatformPkg/PrePeiCore/PrePeiCoreMPCore.inf @@ -75,3 +75,5 @@ [FixedPcd] gArmTokenSpaceGuid.PcdGicDistributorBase gArmTokenSpaceGuid.PcdGicInterruptInterfaceBase gArmTokenSpaceGuid.PcdGicSgiIntId + + gEfiMdeModulePkgTokenSpaceGuid.PcdInitValueInTempStack diff --git a/ArmPlatformPkg/PrePeiCore/PrePeiCoreUniCore.inf b/ArmPlatformPkg/PrePeiCore/PrePeiCoreUniCore.inf index b5d4e389b2a4..ec83cec2d879 100644 --- a/ArmPlatformPkg/PrePeiCore/PrePeiCoreUniCore.inf +++ b/ArmPlatformPkg/PrePeiCore/PrePeiCoreUniCore.inf @@ -69,3 +69,5 @@ [FixedPcd] gArmPlatformTokenSpaceGuid.PcdCPUCoresStackBase gArmPlatformTokenSpaceGuid.PcdCPUCorePrimaryStackSize gArmPlatformTokenSpaceGuid.PcdCPUCoreSecondaryStackSize + + gEfiMdeModulePkgTokenSpaceGuid.PcdInitValueInTempStack