From nobody Sun Feb 8 18:18:37 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+81721+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+81721+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1633801532; cv=none; d=zohomail.com; s=zohoarc; b=HN1TxsHkQJswhvxy+z+imyPXotMRQJrISbNeJm2F3R+8u+QL+UFF0fUMnSuYdwW67OnKtyTn40UIXwn9fbk2b2xz6FEjv83V/uwy2RRTvzd5YqB6QQEtCiaLnOoIM7R3iJGqbQOexZu3uZuqgrmeIZefSNrEEqDuHC/7UbHrsWI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1633801532; 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=zOd2Fn6eMkrnP+HXuJ/tphRxgHUd4AXlOWXKUkqhr9I=; b=Lp7NL5q+5gNEBUleL2njyrBeqeqDLS77TK6tS9YHUmw2Yjtl0fywxl3eHusXWMSEKJfO2rA3NNzq3QDXVMzslCL82a6r1xq6sWfxHhleY9jekSa/3iRV2lgatkjkfQs8ZU5g0j1MSLqAwTUWFEJ87+mV+/mzHSSQOM+Z6NWolCM= 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+81721+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 1633801532208909.730353972931; Sat, 9 Oct 2021 10:45:32 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id hdl0YY1788612xieAnKWREU7; Sat, 09 Oct 2021 10:45:31 -0700 X-Received: from mail-pl1-f181.google.com (mail-pl1-f181.google.com [209.85.214.181]) by mx.groups.io with SMTP id smtpd.web09.8107.1633794638978202275 for ; Sat, 09 Oct 2021 08:50:39 -0700 X-Received: by mail-pl1-f181.google.com with SMTP id t11so8132003plq.11 for ; Sat, 09 Oct 2021 08:50:38 -0700 (PDT) X-Gm-Message-State: BLyNjeroang1HqI88i9cJkMex1787277AA= X-Google-Smtp-Source: ABdhPJz+I8eg+bpTb27AJVpn/8cWsFNCZWcI4a6116t+HbUOkLofK7AUm6J2mY1SiduHNlZKI3J04w== X-Received: by 2002:a17:90a:fb4a:: with SMTP id iq10mr4378177pjb.117.1633794638591; Sat, 09 Oct 2021 08:50:38 -0700 (PDT) X-Received: from localhost.localdomain ([240d:1a:ada:4400:d496:915d:ba15:739a]) by smtp.gmail.com with ESMTPSA id z2sm2633255pfe.210.2021.10.09.08.50.37 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Sat, 09 Oct 2021 08:50:38 -0700 (PDT) From: "Akira Moroo" To: devel@edk2.groups.io Cc: afish@apple.com, ray.ni@intel.com, Akira Moroo Subject: [edk2-devel] [RFC PATCH 2/4] EmulatorPkg/Sec: Add AArch64 support Date: Sun, 10 Oct 2021 00:49:16 +0900 Message-Id: <963e9d53c9011af94afeeea1ddb39ec171329ab5.1633789833.git.retrage01@gmail.com> In-Reply-To: References: 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,retrage01@gmail.com Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1633801531; bh=mNuK0y0thnMBXnHaphFoG4Rsy8Gj9K/ci7y/ZQJwfp0=; h=Cc:Date:From:Reply-To:Subject:To; b=rM7Hs2J0E9r38MOQ5HseMQUHDJGlryJmHHCYfYwh31pDThYqTgZfSY4Twyzy0oGZFpG WOhQfP2LQEPB1Sgb7Z8WSlbXqem0os1wQjevXKmtOLdNlZ817oFlUW9pNjTqdD3I7WPXn mBfEcfQ+ICe7xoaUbMooae43zdNz6bBPwMs= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1633801533136100005 Content-Type: text/plain; charset="utf-8" This commit adds AArch64 support to EmulatorPkg/Sec. The architecture specific part is switching stack from temporary to permanent. Signed-off-by: Akira Moroo --- EmulatorPkg/Sec/AArch64/SwitchRam.S | 22 +++++++++++ EmulatorPkg/Sec/AArch64/TempRam.c | 58 +++++++++++++++++++++++++++++ EmulatorPkg/Sec/Sec.inf | 4 ++ 3 files changed, 84 insertions(+) create mode 100644 EmulatorPkg/Sec/AArch64/SwitchRam.S create mode 100644 EmulatorPkg/Sec/AArch64/TempRam.c diff --git a/EmulatorPkg/Sec/AArch64/SwitchRam.S b/EmulatorPkg/Sec/AArch64/= SwitchRam.S new file mode 100644 index 0000000000..9ec8ddd627 --- /dev/null +++ b/EmulatorPkg/Sec/AArch64/SwitchRam.S @@ -0,0 +1,22 @@ +#-------------------------------------------------------------------------= ----- +# +# Copyright (c) 2006 - 2011, Intel Corporation. All rights reserved.
+# Portions copyright (c) 2011, Apple Inc. All rights reserved. +# SPDX-License-Identifier: BSD-2-Clause-Patent +# +#-------------------------------------------------------------------------= ----- + + +// VOID +// EFIAPI +// SecSwitchStack ( +// VOID *StackDelta +// ) +// +ASM_GLOBAL ASM_PFX(SecSwitchStack) +ASM_PFX(SecSwitchStack): + mov x1, sp + add x1, x0, x1 + mov sp, x1 + ret + diff --git a/EmulatorPkg/Sec/AArch64/TempRam.c b/EmulatorPkg/Sec/AArch64/Te= mpRam.c new file mode 100644 index 0000000000..cce1dc559a --- /dev/null +++ b/EmulatorPkg/Sec/AArch64/TempRam.c @@ -0,0 +1,58 @@ +/*++ @file + Temp RAM PPI + +Copyright (c) 2011, Apple Inc. All rights reserved.
+SPDX-License-Identifier: BSD-2-Clause-Patent + +**/ + +#include +#include +#include + +#include + +VOID +EFIAPI +SecSwitchStack ( + VOID *StackDelta + ); + + +EFI_STATUS +EFIAPI +SecTemporaryRamSupport ( + IN CONST EFI_PEI_SERVICES **PeiServices, + IN EFI_PHYSICAL_ADDRESS TemporaryMemoryBase, + IN EFI_PHYSICAL_ADDRESS PermanentMemoryBase, + IN UINTN CopySize + ) +{ + // + // Migrate the whole temporary memory to permanent memory. + // + CopyMem ( + (VOID*)(UINTN)PermanentMemoryBase, + (VOID*)(UINTN)TemporaryMemoryBase, + CopySize + ); + + // + // SecSwitchStack function must be invoked after the memory migration + // immediately, also we need fixup the stack change caused by new call i= nto + // permanent memory. + // + SecSwitchStack ((VOID *)(PermanentMemoryBase - TemporaryMemoryBase)); + + // + // We need *not* fix the return address because currently, + // The PeiCore is executed in flash. + // + + // + // Simulate to invalid temporary memory, terminate temporary memory + // + ZeroMem ((VOID*)(UINTN)TemporaryMemoryBase, CopySize); + + return EFI_SUCCESS; +} diff --git a/EmulatorPkg/Sec/Sec.inf b/EmulatorPkg/Sec/Sec.inf index 2f9e3d4780..83248fbaca 100644 --- a/EmulatorPkg/Sec/Sec.inf +++ b/EmulatorPkg/Sec/Sec.inf @@ -30,6 +30,10 @@ Ia32/SwitchRam.asm Ia32/SwitchRam.S =20 +[Sources.AARCH64] + AArch64/TempRam.c + AArch64/SwitchRam.S + [Packages] MdePkg/MdePkg.dec EmulatorPkg/EmulatorPkg.dec --=20 2.33.0 -=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 (#81721): https://edk2.groups.io/g/devel/message/81721 Mute This Topic: https://groups.io/mt/86198794/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-