From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from EUR04-HE1-obe.outbound.protection.outlook.com (EUR04-HE1-obe.outbound.protection.outlook.com [40.107.7.71]) by mx.groups.io with SMTP id smtpd.web10.28516.1684508161637454227 for ; Fri, 19 May 2023 07:56:02 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@armh.onmicrosoft.com header.s=selector2-armh-onmicrosoft-com header.b=Ky2BvWUS; spf=pass (domain: arm.com, ip: 40.107.7.71, mailfrom: sami.mujawar@arm.com) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=armh.onmicrosoft.com; s=selector2-armh-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=F9ccuwKbBV9NGPNWFJsDOfL86MDC5OW2PpxJJcJjRS4=; b=Ky2BvWUSYj6wkv09rjpXNNj99C2zL1Npk7c/dvR4Ni9xKZEvZ2jbp2K4pYiqp8LcNssATFuKd4Ap648+Lft/ejXgUbBGVgWFAl3HZzG930yoHh+l8Xvq1v5WdIP05UjRowaa/o8KyJpBLiDw6yCbidxc8Rfu3vWEkvTvJguPe2I= Received: from AS9PR06CA0204.eurprd06.prod.outlook.com (2603:10a6:20b:45d::30) by DB9PR08MB9778.eurprd08.prod.outlook.com (2603:10a6:10:45d::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6411.21; Fri, 19 May 2023 14:55:55 +0000 Received: from AM7EUR03FT022.eop-EUR03.prod.protection.outlook.com (2603:10a6:20b:45d:cafe::50) by AS9PR06CA0204.outlook.office365.com (2603:10a6:20b:45d::30) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6411.21 via Frontend Transport; Fri, 19 May 2023 14:55:54 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 63.35.35.123) smtp.mailfrom=arm.com; dkim=pass (signature was verified) header.d=armh.onmicrosoft.com;dmarc=pass action=none header.from=arm.com; Received-SPF: Pass (protection.outlook.com: domain of arm.com designates 63.35.35.123 as permitted sender) receiver=protection.outlook.com; client-ip=63.35.35.123; helo=64aa7808-outbound-1.mta.getcheckrecipient.com; pr=C Received: from 64aa7808-outbound-1.mta.getcheckrecipient.com (63.35.35.123) by AM7EUR03FT022.mail.protection.outlook.com (100.127.140.217) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6411.19 via Frontend Transport; Fri, 19 May 2023 14:55:54 +0000 Received: ("Tessian outbound 945aec65ec65:v136"); Fri, 19 May 2023 14:55:54 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: 042d1b1901a8a3c6 X-CR-MTA-TID: 64aa7808 Received: from 2e7a1254c0bb.2 by 64aa7808-outbound-1.mta.getcheckrecipient.com id F02006CA-A4CB-4A56-86F3-7410900AF464.1; Fri, 19 May 2023 14:55:46 +0000 Received: from EUR03-DBA-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id 2e7a1254c0bb.2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Fri, 19 May 2023 14:55:46 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=NZ+vUBQvQZ9Ry537Ll3BqiZbWdvTqpCTTseE6FyO0ufA7hpff1ESwAJxHVbQtyRiffpAkpdQ1SJwCePNzyubFwt1B7lloPgf2UvFpgdfuwvOlKARkI6uYb1EDcUZ/LWqNRStYhnVFZ3SChQyOgTREteljK8QOfXDpBlRy77+thW3xebFAMdSoCyNWXie9y6Yu1F8nV5pokd7NuX6d8/V2vJ56ZI6TmqZLRDAIIH/iUe8NJEgeY4JZOPVfv+3VSq86VLwWtJiG7Bo2LEim3hC9lL05GNvf5rIp+dQhKngSPSZ49jFtMSlYOKNrGS7qFTCZiIRYyMaQxItwdvAIx6huw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=F9ccuwKbBV9NGPNWFJsDOfL86MDC5OW2PpxJJcJjRS4=; b=mdhsxpyO6T/Vm8l6ZKbDPBYZwC0itodiT7+qivgbWS+O6+Ja1LCN5zuX6Bv/Y3+SnUy0Odp2lQW9hJ4bj38VesNBHHTpjJigGS3iglYnw0VSectHkEy/aMKEtHXKRfWZ1N43BORAjbahoS2tHa+MTZXVwYfYEIaf69nHelFX60uX1F9q0RP+E8+UBkLke0uATrdmobMWSWPqsiGk2vavjIhSf2Dj6MmY7b2qsZiCCNSRx9gWZ170dwjbFIYM8/pGwuCI6S+kmo+2C+la3MmY38FjkOGS6NLFGpEYgOenH9SGNHENdSolgPLobRFG9eRELWrpxrutCBujJKDbjRo9jA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 40.67.248.234) smtp.rcpttodomain=edk2.groups.io smtp.mailfrom=arm.com; dmarc=pass (p=none sp=none pct=100) action=none header.from=arm.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=armh.onmicrosoft.com; s=selector2-armh-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=F9ccuwKbBV9NGPNWFJsDOfL86MDC5OW2PpxJJcJjRS4=; b=Ky2BvWUSYj6wkv09rjpXNNj99C2zL1Npk7c/dvR4Ni9xKZEvZ2jbp2K4pYiqp8LcNssATFuKd4Ap648+Lft/ejXgUbBGVgWFAl3HZzG930yoHh+l8Xvq1v5WdIP05UjRowaa/o8KyJpBLiDw6yCbidxc8Rfu3vWEkvTvJguPe2I= Received: from DUZP191CA0037.EURP191.PROD.OUTLOOK.COM (2603:10a6:10:4f8::9) by AS8PR08MB6389.eurprd08.prod.outlook.com (2603:10a6:20b:33e::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6411.21; Fri, 19 May 2023 14:55:44 +0000 Received: from DBAEUR03FT019.eop-EUR03.prod.protection.outlook.com (2603:10a6:10:4f8:cafe::1d) by DUZP191CA0037.outlook.office365.com (2603:10a6:10:4f8::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6411.21 via Frontend Transport; Fri, 19 May 2023 14:55:44 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 40.67.248.234) smtp.mailfrom=arm.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=arm.com; Received-SPF: Pass (protection.outlook.com: domain of arm.com designates 40.67.248.234 as permitted sender) receiver=protection.outlook.com; client-ip=40.67.248.234; helo=nebula.arm.com; pr=C Received: from nebula.arm.com (40.67.248.234) by DBAEUR03FT019.mail.protection.outlook.com (100.127.142.129) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6411.21 via Frontend Transport; Fri, 19 May 2023 14:55:44 +0000 Received: from AZ-NEU-EX04.Arm.com (10.251.24.32) by AZ-NEU-EX04.Arm.com (10.251.24.32) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.23; Fri, 19 May 2023 14:55:44 +0000 Received: from E114225.Arm.com (10.1.196.36) by mail.arm.com (10.251.24.32) with Microsoft SMTP Server id 15.1.2507.23 via Frontend Transport; Fri, 19 May 2023 14:55:43 +0000 From: "Sami Mujawar" To: CC: Sami Mujawar , , , , , , , , , , Subject: [PATCH v2 5/5] ArmVirtPkg/PrePi: Allocate separate stack for Dxe phase Date: Fri, 19 May 2023 15:55:40 +0100 Message-ID: <20230519145540.46700-6-sami.mujawar@arm.com> X-Mailer: git-send-email 2.16.2.windows.1 In-Reply-To: <20230519145540.46700-1-sami.mujawar@arm.com> References: <20230519145540.46700-1-sami.mujawar@arm.com> MIME-Version: 1.0 X-EOPAttributedMessage: 1 X-MS-TrafficTypeDiagnostic: DBAEUR03FT019:EE_|AS8PR08MB6389:EE_|AM7EUR03FT022:EE_|DB9PR08MB9778:EE_ X-MS-Office365-Filtering-Correlation-Id: 9c5a953d-3047-4c1f-69f1-08db587925a7 x-checkrecipientrouted: true NoDisclaimer: true X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam-Untrusted: BCL:0; X-Microsoft-Antispam-Message-Info-Original: Kv+kCO/jfgf6z+cfR4/CBdW8uKIQ8xjCOpRN0KXbHmRlgPOEsflT/QPQd5H3YcRHFbrF0d3FFJyesmFArXlbpBVjJ3OaEg4oa7vGvgicsxN6P3zhhFh6POWOYnWaS3p+mHu2v3Gr0PHNHfh25nR+yK5ajWA62KegeKP+WiPbT0AflWFGf6m888AT1+QwOsGRPWszIQGOCJVZVCs01doWwnUrHM28A3AG3wUWXKFq93SMBaSy4CK5281eSlHjDZM4VGwPByz3UQFXGLpSOZNS/NcPr13P8Iod/Hl5nPuih9KOeaT07kFKxC+74GjvvDeXI+ZES3gOe3XuxCALJVqYo2wFH58cr+nVIE8I86PXEHQxVJakcxSrNLbO4InIgB5k7Ub8895kgt7N1PAej4ODr83ow0IWHYqybLPidkf0ZLcn/zbeg85dKR3EOXr9Aj4clzX+Uie9h9GAFtCzQkdwdS+SWvJxOwMWD/SDtTC5RcneU8MG77drA6titk7QcltSy+aYYGLohbcsl6NII41VBbamAt3Ru66nJ4kTbd3SzgLDXCoEp9LsvFAYYPniZWYbBNGouYpGaBpamc4K/xK17yLUVRePDQmT7WEjyCsUX9U28MH2R3FLy9+JoIENhNChq2QHlYZzO+uAzrF0gDmupQVGXkL0Np1Yz6S74b+veqndSRiDKtCFt/1jnQ41bAWJafXFrI8/h5ehKJgBJMf8srrEktFpFMIDzNbpFmI9w5GalUFRLJGGsMS4PAqZdEPcts2Hgg56R82xRO+7JPjCBQ== X-Forefront-Antispam-Report-Untrusted: CIP:40.67.248.234;CTRY:IE;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:nebula.arm.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230028)(4636009)(346002)(136003)(376002)(396003)(39860400002)(451199021)(40470700004)(46966006)(36840700001)(336012)(86362001)(36756003)(40480700001)(82310400005)(8936002)(26005)(8676002)(1076003)(2616005)(44832011)(426003)(5660300002)(186003)(316002)(54906003)(6916009)(70586007)(70206006)(41300700001)(4326008)(478600001)(7696005)(356005)(81166007)(82740400003)(83380400001)(47076005)(36860700001)(2906002)(40460700003)(36900700001);DIR:OUT;SFP:1101; X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS8PR08MB6389 Return-Path: Sami.Mujawar@arm.com X-MS-Exchange-Transport-CrossTenantHeadersStripped: AM7EUR03FT022.eop-EUR03.prod.protection.outlook.com X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id-Prvs: 402be40a-5549-4c97-bb83-08db58791f9f X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: QoFjNWQJiwZU7ix7U4Z1r/kmPyiB5s4EA+0h7MVIuMy+qXMyuK+cdWcpD0S8XJzHMu0DMnE8ZOYbC1Y2+4mPjiLuaNeY8UMauSOFQe3DdPVO90guQ2Alig+Gi0U4O3XNS5z3YWeU4rbkCoDNlu2McHiOeCNlO0cOpWy9uNi+eAb0kcshGstbZ/8SkhRUw0lehlmzF4UrC90t/DgO+YxLMRRd22Igbf9TeyR5qpWiMwfgWJqGQHaDHvF3GzW5vVXflN1LSoMWfbPnhqZohjjYrgSjbGi8FlDoCdnPZiqiTaEZssFWMPg7Cc0wxQ268GRf+/KxZLGIuwZFpRT+n/+8/oUcLCcQsMtSL4q/Dp5N0bWLLh0uXhG6BGcdme/PVQzzsMJUsG06D9S3app84Rz0ncquYM2250MjW+EfCst3ACaCqwjGInjGAaykiMkt7a2qXboijTd7lWiMC4KqJphDTEVerd8WMT24K5DLn7R1P2cJ0Vo/9bYiypIpL+9Jqt9Zv7DjOZh2T9uMtrS5gf07b5zk1buZCQfj0rDJKcDyy1jkQiYNoFOeDdCyGZRBboTwqKzINpwB0HceqMuMWYEfecXdrgtYZakGGc1WR9m8yPPEMRcC3JypIZbsc1yxbz4rsfnEvM0syFGdjl++XndHLFYdnRPQsusw1zh4o+F/4yqZ9yrLQzlKfNdZeD9QPPGA6AQvK3BO9Vfd03O+abGqqGp0sWoT8TE4yiAqozwfMkJ1hAnbqkmT5YRadTJzfZwa X-Forefront-Antispam-Report: CIP:63.35.35.123;CTRY:IE;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:64aa7808-outbound-1.mta.getcheckrecipient.com;PTR:ec2-63-35-35-123.eu-west-1.compute.amazonaws.com;CAT:NONE;SFS:(13230028)(4636009)(136003)(396003)(376002)(346002)(39860400002)(451199021)(36840700001)(40470700004)(46966006)(40460700003)(4326008)(6916009)(70586007)(478600001)(70206006)(54906003)(316002)(86362001)(36756003)(83380400001)(47076005)(426003)(336012)(2616005)(36860700001)(26005)(1076003)(186003)(5660300002)(41300700001)(8936002)(8676002)(7696005)(44832011)(2906002)(82310400005)(40480700001)(81166007)(82740400003);DIR:OUT;SFP:1101; X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 19 May 2023 14:55:54.8604 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 9c5a953d-3047-4c1f-69f1-08db587925a7 X-MS-Exchange-CrossTenant-Id: f34e5979-57d9-4aaa-ad4d-b122a662184d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=f34e5979-57d9-4aaa-ad4d-b122a662184d;Ip=[63.35.35.123];Helo=[64aa7808-outbound-1.mta.getcheckrecipient.com] X-MS-Exchange-CrossTenant-AuthSource: AM7EUR03FT022.eop-EUR03.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB9PR08MB9778 Content-Type: text/plain The patch "f07a9df9af60 ArmVirtPkg: Enable stack guard" enabled stack overflow detection for ArmVirtPkg. Following this patch, running UEFI shell command 'dmpstore' resulted in a crash indicating a stack overflow. Invoking 'dmpstore' results in recursive calls to CascadeProcessVariables () which apparently consumes the available stack space and overflows. Normally, SEC and PEI run off the initial stack, and the DxeIpl PEIM is in charge of launching the DxeCore with a full-sized stack and remapping it non-executable as well. PrePi platforms take some shortcuts and the DXE and BDS run off the initial stack which is relatively small. It is therefore desirable to allocate 128 KiB worth of boot services data memory as the stack for the Dxe phase. The PrePiMain () in ArmVirtPkg/PrePi/PrePi.c invokes the LoadDxeCoreFromFv () to load the Dxe core and transfers control. The second parameter to LoadDxeCoreFromFv () is the stack size, which is currently set to 0. LoadDxeCoreFromFv () is implemented in PrePiLib and if the stack size is 0, it continues to use the initial stack. However, if a stack size is specified in the call to LoadDxeCoreFromFv (), memory is allocated for a new stack and the stack is switched to use the newly allocated stack for the Dxe phase. Therefore, specify 128 KiB as the stack size in the call to LoadDxeCoreFromFv () so that a separate stack is allocated and used for the Dxe phase. Signed-off-by: Sami Mujawar --- ArmVirtPkg/PrePi/PrePi.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ArmVirtPkg/PrePi/PrePi.c b/ArmVirtPkg/PrePi/PrePi.c index 3d943b2138d3fe8a03322262111d5f7df3e39d39..ff51a757a21a19347c78b0936987c9f8cc283c0f 100755 --- a/ArmVirtPkg/PrePi/PrePi.c +++ b/ArmVirtPkg/PrePi/PrePi.c @@ -1,6 +1,6 @@ /** @file * -* Copyright (c) 2011-2014, ARM Limited. All rights reserved. +* Copyright (c) 2011-2023, Arm Limited. All rights reserved. * * SPDX-License-Identifier: BSD-2-Clause-Patent * @@ -101,7 +101,7 @@ PrePiMain ( ASSERT_EFI_ERROR (Status); // Load the DXE Core and transfer control to it - Status = LoadDxeCoreFromFv (NULL, 0); + Status = LoadDxeCoreFromFv (NULL, SIZE_128KB); ASSERT_EFI_ERROR (Status); } -- 'Guid(CE165669-3EF3-493F-B85D-6190EE5B9759)'