From nobody Mon Feb 9 16:34:58 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) client-ip=66.175.222.108; envelope-from=bounce+27952+106794+1787277+3901457@groups.io; helo=mail02.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+106794+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=arm.com ARC-Seal: i=1; a=rsa-sha256; t=1689086237; cv=none; d=zohomail.com; s=zohoarc; b=ZO57fjwj/R8303EqgrLlQWIjqWWcBX42oPkvI27pFGmqEr+GEQbN6bP5W/THukWmpZeeFp411Tgro2BU2pS4h8iOaG6yHiXSMWn/ByzRPZ5abaMzUSj/nG3scH4Sy4vgVzjCaNP0bye6TdWB2Ym5W5Biy4WeQNsHsnCpJFRB11M= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1689086237; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:References:Sender:Subject:To; bh=i7bmNpNhB7K/7hKr7DAXNgpjmJuPMAyj90zFJslbZQE=; b=K0S5g3QBfwPHowhEnusM1QVC1dwv+qQ3gETihx4KD0gAIb0n9EWO9jj5Z97PbGNKdVlVhS3nEdOI04Vgw+eooXMy59L/BOBK4fvCsxCLqFxxLHf9snYM87/T6YAPMvIkjqpv7kIGRy/XvOCJ5Jm49o5rb9EnDwheghL6vfTqr+8= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+106794+1787277+3901457@groups.io; dmarc=fail header.from= (p=none dis=none) Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by mx.zohomail.com with SMTPS id 1689086237665884.4361990162558; Tue, 11 Jul 2023 07:37:17 -0700 (PDT) Return-Path: DKIM-Signature: a=rsa-sha256; bh=bpiQpWfeeiF71A50u0F6yVxNCA8Pr5oJaNsa7GVS1h0=; c=relaxed/simple; d=groups.io; h=X-Received:X-Received:X-Received:X-Received:From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References:MIME-Version:Precedence:List-Unsubscribe:List-Subscribe:List-Help:Sender:List-Id:Mailing-List:Delivered-To:Reply-To:X-Gm-Message-State:Content-Transfer-Encoding; s=20140610; t=1689086237; v=1; b=mVBzRb4IqXs7qi2nyvXjAsZQgmV81msHZp0RuhUyx72uukiY1/WU8E/xz7vdlaTwebukdMeU 3SkCJkuRD+TamzeQAG2Jd/f6Dcs/LCXWlf7Zxg+NBl7D2TVNuwMbZ8Wqz170jfeT9qCUNATijY7 kwTNdEHOj9TfjDTSL/OLKm80= X-Received: by 127.0.0.2 with SMTP id VJkIYY1788612x05Vh1zwHo1; Tue, 11 Jul 2023 07:37:17 -0700 X-Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by mx.groups.io with SMTP id smtpd.web11.1228.1689086236695707927 for ; Tue, 11 Jul 2023 07:37:16 -0700 X-Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 88C68C15; Tue, 11 Jul 2023 07:37:58 -0700 (PDT) X-Received: from usa.arm.com (iss-desktop02.cambridge.arm.com [10.1.196.79]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 6B07D3F740; Tue, 11 Jul 2023 07:37:15 -0700 (PDT) From: "Nishant Sharma" To: devel@edk2.groups.io Cc: Ard Biesheuvel , Sami Mujawar , Thomas Abraham , Sayanta Pattanayak , Achin Gupta Subject: [edk2-devel] [edk2-platforms][PATCH V1 02/20] StandaloneMmPkg: Allocate and initialise SP stack from internal memory Date: Tue, 11 Jul 2023 15:36:40 +0100 Message-Id: <20230711143658.781597-3-nishant.sharma@arm.com> In-Reply-To: <20230711143658.781597-1-nishant.sharma@arm.com> References: <20230711143658.781597-1-nishant.sharma@arm.com> MIME-Version: 1.0 Precedence: Bulk List-Unsubscribe: List-Subscribe: List-Help: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,nishant.sharma@arm.com X-Gm-Message-State: ocJI7Sa1OjS0Y7xGcTJ54DoJx1787277AA= Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1689086238798100006 Content-Type: text/plain; charset="utf-8" From: Achin Gupta This patch removes the dependency on the SPM to allocate and initialise stack memory for the StMM SP. This is done by reserving 8K worth of memory in the StMM image at a page aligned address in the data section. Then, instead of jumping directly to the C entrypoint, an assembler entrypoint is invoked. This entrypoint locates the stack memory, changes its permissions using FF-A ABIs, sets the stack pointer and invokes the C entrypoint. Signed-off-by: Achin Gupta Signed-off-by: Nishant Sharma --- StandaloneMmPkg/Library/StandaloneMmCoreEntryPoint/StandaloneMmCoreEntryPo= int.inf | 1 + StandaloneMmPkg/Library/StandaloneMmCoreEntryPoint/Arm/StandaloneMmCoreEnt= ryPoint.c | 2 +- StandaloneMmPkg/Library/StandaloneMmCoreEntryPoint/Arm/AArch64/ModuleEntry= Point.S | 68 ++++++++++++++++++++ 3 files changed, 70 insertions(+), 1 deletion(-) diff --git a/StandaloneMmPkg/Library/StandaloneMmCoreEntryPoint/StandaloneM= mCoreEntryPoint.inf b/StandaloneMmPkg/Library/StandaloneMmCoreEntryPoint/St= andaloneMmCoreEntryPoint.inf index dc6d3d859911..10fafa43ce59 100644 --- a/StandaloneMmPkg/Library/StandaloneMmCoreEntryPoint/StandaloneMmCoreEn= tryPoint.inf +++ b/StandaloneMmPkg/Library/StandaloneMmCoreEntryPoint/StandaloneMmCoreEn= tryPoint.inf @@ -25,6 +25,7 @@ Arm/StandaloneMmCoreEntryPoint.c Arm/SetPermissions.c Arm/CreateHobList.c + Arm/AArch64/ModuleEntryPoint.S =20 [Sources.X64] X64/StandaloneMmCoreEntryPoint.c diff --git a/StandaloneMmPkg/Library/StandaloneMmCoreEntryPoint/Arm/Standal= oneMmCoreEntryPoint.c b/StandaloneMmPkg/Library/StandaloneMmCoreEntryPoint/= Arm/StandaloneMmCoreEntryPoint.c index 5dd1d9747995..ce867fe85158 100644 --- a/StandaloneMmPkg/Library/StandaloneMmCoreEntryPoint/Arm/StandaloneMmCo= reEntryPoint.c +++ b/StandaloneMmPkg/Library/StandaloneMmCoreEntryPoint/Arm/StandaloneMmCo= reEntryPoint.c @@ -316,7 +316,7 @@ InitArmSvcArgs ( **/ VOID EFIAPI -_ModuleEntryPoint ( +ModuleEntryPoint ( IN VOID *SharedBufAddress, IN UINT64 SharedBufSize, IN UINT64 cookie1, diff --git a/StandaloneMmPkg/Library/StandaloneMmCoreEntryPoint/Arm/AArch64= /ModuleEntryPoint.S b/StandaloneMmPkg/Library/StandaloneMmCoreEntryPoint/Ar= m/AArch64/ModuleEntryPoint.S new file mode 100644 index 000000000000..174bc83ebd64 --- /dev/null +++ b/StandaloneMmPkg/Library/StandaloneMmCoreEntryPoint/Arm/AArch64/Module= EntryPoint.S @@ -0,0 +1,68 @@ +// +// Copyright (c) 2023, ARM Limited. All rights reserved. +// +// SPDX-License-Identifier: BSD-2-Clause-Patent +// +// + +#include + +#define FFA_DATA_RW 0x1 + +.align 12 +StackBase: +.space 8192 +StackEnd: + +.macro FfaMemPermSet start:req end:req perm:req +adrp x29, \start +add x29, x29, :lo12: \start + +adrp x30, \end +add x30, x30, :lo12:\end + +/* x30 =3D end - begin */ +sub x30, x30, x29 +/* x28 =3D x30 >> 12 (number of pages) */ +mov x28, #12 +lsrv x28, x30, x28 + +mov w0, #0x89 +movk w0, #0x8400, lsl #16 +mov x1, x29 +mov x2, x28 +mov w3, #\perm + +svc #0 + +mov w1, #0x61 +movk w1, #0x8400, lsl #16 +cmp w1, w0 +b.ne . +.endm + + ASM_FUNC(_ModuleEntryPoint) +MOV32 (w8, FixedPcdGet32(PcdFfaEnable)) + cbz w8, FfaNotEnabled + // Stash boot information registers from the SPMC + mov x8, x0 + mov x9, x1 + mov x10, x2 + mov x11, x3 + + // Set the correct permissions on stack memory + FfaMemPermSet StackBase StackEnd FFA_DATA_RW + + // Initialise SP + adr x0, StackEnd + mov sp, x0 + + // Restore boot information registers from the SPMC + mov x0, x8 + mov x1, x9 + mov x2, x10 + mov x3, x11 + + // Invoke the C entrypoint + FfaNotEnabled: + b ModuleEntryPoint --=20 2.34.1 -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#106794): https://edk2.groups.io/g/devel/message/106794 Mute This Topic: https://groups.io/mt/100079871/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-