From patchwork Fri Oct 20 11:23:25 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 116482 Delivered-To: patch@linaro.org Received: by 10.80.163.170 with SMTP id s39csp33394edb; Fri, 20 Oct 2017 04:23:37 -0700 (PDT) X-Received: by 10.99.56.19 with SMTP id f19mr4236295pga.328.1508498617608; Fri, 20 Oct 2017 04:23:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1508498617; cv=none; d=google.com; s=arc-20160816; b=YTgV9rfILPqJr77465pbTA3Y+8GUcMRGm0n0W0T6+I7zzhgNCV4mn6At16Ke71epky xi6hmRj57IwgnGgKoB2evOndp/odWGj7Nzm1G6F05PAiRIFIPxLi+X86E8npRpZZClZJ FioPOvKO64TWPGdHXJ3xzHMVXriJquiYOernCxDXjVJLBiDrH2OGdd/P5T7I2U+gsDNZ EoHq3ZO+ZtluoZV9TZ7YNqxX9Osq3Br76EusltafsX6mUhvqsQz395Ere2mwPxaxqs6S aay4K7YHpiUMc39ipCa7QQWEXYPc7Yj+u9sS9BE+NQ7/bArgf5jMwSewIHidOROGrHVO NSgQ== 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=zm4HaoA5JRD5mI0K/G4Et4ONapB9hyTNnQH3mVV1gDI=; b=k15zcrljd28/QqcD6YAOakrgKDnNSQqZ4xlxkOPZM4+q1aylwApMNsY9VkZjtx355S CShXPvirIFd4txbxMyEmoTxStSKItGhsv3tCwKmn7f6Bb+KXJhkiJQFnvUt04kIvjzmf jEc7NDwklkTm3VUwkUOqpzzi9gKeeffy3B5JucFJst+k4EL3F37TMuR7ITvdTEOsdgRF Oa1mmXaYhRNpZDKLNeMQnftBgt10asBvWNNTy6OzVkLaIexWX3XUZM5qC3ZD40ZSRSEo Ka94BbvBwIATeYYflTQdvXXNDyu0t6VdjZBe+uFDlP+BkkYWWX5ukX1Cs4tFYYCBx4Zg 0hdA== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=gk5mCVdq; 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 h71si593086pgc.408.2017.10.20.04.23.36 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 20 Oct 2017 04:23:37 -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=gk5mCVdq; 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 2FF822034716E; Fri, 20 Oct 2017 04:19:57 -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::241; helo=mail-wr0-x241.google.com; envelope-from=ard.biesheuvel@linaro.org; receiver=edk2-devel@lists.01.org Received: from mail-wr0-x241.google.com (mail-wr0-x241.google.com [IPv6:2a00:1450:400c:c0c::241]) (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 B41A0202E5CD3 for ; Fri, 20 Oct 2017 04:19:55 -0700 (PDT) Received: by mail-wr0-x241.google.com with SMTP id u5so11072715wrc.5 for ; Fri, 20 Oct 2017 04:23:34 -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=1CyZB/CMEOYrtwpXA+3sor6SmN2gxFU8PYpMFeZuU1g=; b=gk5mCVdqva8wlT/768Q8Va7EQRzYQ/C5y51ZAOxmB7MmH2rpnh8RL+T5zz9FQqAa47 4PMfUfSem8c6Cd8jfgRt5vSF/1NTmOd9M1iMgnIu3/UWEtu20+17TQbyxam2kCj4CGdv tQP/qfr+Ql4L4YJ2f7MgNlHTu5rGQk6QSFaWc= 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=1CyZB/CMEOYrtwpXA+3sor6SmN2gxFU8PYpMFeZuU1g=; b=ICCRvLhWnhcfkgG334p1BOaRLOHHqFguNAZAaQavYe7dSnTQXUyKxASo34hrCRR9wC QxWN3UEoaO9RLCH0tD0cQEk+ZTC40i0/jRWmHXxd1sP7GR0zmtD34fWpdqgqzp9sEfA2 7cSsA+en1j3Iroljei+MKMpHYa+lDT7WpLnHykspdMK287TZz8RifAM2TgpS14nqA0Wf coH4U2bBg16l8OHbx/MTjL7wgHi0oJBLBRa3QVog6j/4+OxjDB4SM40/iU7MvPdgekMs ewYQgzVPW/D44pY/lyLu4cJEq/I9eXp6pce5x0B/0LmoUk2z0IHKj1daM8XfHkqC30nm XPIg== X-Gm-Message-State: AMCzsaWnus0WqjX7wvaUF4TopVV+S3wJ4D9oBY4SmClAATjAMIUgu2eu vLgaW6X55/rGdmC1F+Ty+Paf6ChEajU= X-Google-Smtp-Source: ABhQp+QgTNlMSGO/vF63Ie0rUPzD9FLe7B3lpVAP5idc134glfJyNDB3apBDgziVB98HM/8ES5s+oA== X-Received: by 10.223.187.79 with SMTP id x15mr4122190wrg.146.1508498612658; Fri, 20 Oct 2017 04:23:32 -0700 (PDT) Received: from localhost.localdomain ([154.145.244.244]) by smtp.gmail.com with ESMTPSA id l96sm1257354wrc.21.2017.10.20.04.23.31 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 20 Oct 2017 04:23:31 -0700 (PDT) From: Ard Biesheuvel To: edk2-devel@lists.01.org Date: Fri, 20 Oct 2017 12:23:25 +0100 Message-Id: <20171020112325.10814-1-ard.biesheuvel@linaro.org> X-Mailer: git-send-email 2.11.0 Subject: [edk2] [PATCH] 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: lersek@redhat.com, leif.lindholm@linaro.org, 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. Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Ard Biesheuvel --- ArmPlatformPkg/PrePeiCore/AArch64/PrePeiCoreEntryPoint.S | 7 +++++++ ArmPlatformPkg/PrePeiCore/Arm/PrePeiCoreEntryPoint.S | 10 ++++++++++ ArmPlatformPkg/PrePeiCore/Arm/PrePeiCoreEntryPoint.asm | 10 ++++++++++ 3 files changed, 27 insertions(+) -- 2.11.0 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel Acked-by: Laszlo Ersek diff --git a/ArmPlatformPkg/PrePeiCore/AArch64/PrePeiCoreEntryPoint.S b/ArmPlatformPkg/PrePeiCore/AArch64/PrePeiCoreEntryPoint.S index aab5edab0c42..7a33e2754869 100644 --- a/ArmPlatformPkg/PrePeiCore/AArch64/PrePeiCoreEntryPoint.S +++ b/ArmPlatformPkg/PrePeiCore/AArch64/PrePeiCoreEntryPoint.S @@ -13,6 +13,8 @@ #include +#define INIT_CAR_VALUE 0x5AA55AA55AA55AA5 + ASM_FUNC(_ModuleEntryPoint) // Do early platform specific actions bl ASM_PFX(ArmPlatformPeiBootAction) @@ -84,4 +86,9 @@ _PrepareArguments: _SetupPrimaryCoreStack: mov sp, x1 + MOV64 (x8, FixedPcdGet64(PcdCPUCoresStackBase)) + MOV64 (x9, INIT_CAR_VALUE) +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..7342e49bea59 100644 --- a/ArmPlatformPkg/PrePeiCore/Arm/PrePeiCoreEntryPoint.S +++ b/ArmPlatformPkg/PrePeiCore/Arm/PrePeiCoreEntryPoint.S @@ -13,6 +13,8 @@ #include +#define INIT_CAR_VALUE 0x5AA55AA5 + ASM_FUNC(_ModuleEntryPoint) // Do early platform specific actions bl ASM_PFX(ArmPlatformPeiBootAction) @@ -65,6 +67,14 @@ _PrepareArguments: _SetupPrimaryCoreStack: mov sp, r1 + MOV32 (r8, FixedPcdGet64(PcdCPUCoresStackBase)) + MOV32 (r9, INIT_CAR_VALUE) + 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..7455de8aa66e 100644 --- a/ArmPlatformPkg/PrePeiCore/Arm/PrePeiCoreEntryPoint.asm +++ b/ArmPlatformPkg/PrePeiCore/Arm/PrePeiCoreEntryPoint.asm @@ -13,6 +13,8 @@ #include +#define INIT_CAR_VALUE 0x5AA55AA5 + INCLUDE AsmMacroIoLib.inc IMPORT CEntryPoint @@ -79,6 +81,14 @@ _PrepareArguments _SetupPrimaryCoreStack mov sp, r1 + mov32 r8, FixedPcdGet64(PcdCPUCoresStackBase) + mov32 r9, INIT_CAR_VALUE + mov r10, r9 + mov r11, r9 + mov r12, r9 +0:stm r8!, {r9-r12} + cmp r8, r1 + blt 0b b _PrepareArguments _NeverReturn