From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) by mx.groups.io with SMTP id smtpd.web10.22191.1678062132259075315 for ; Sun, 05 Mar 2023 16:22:13 -0800 Authentication-Results: mx.groups.io; dkim=fail reason="unable to parse pub key" header.i=@intel.com header.s=intel header.b=PSwvOdfa; spf=pass (domain: intel.com, ip: 134.134.136.65, mailfrom: nathaniel.l.desimone@intel.com) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1678062133; x=1709598133; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=tmWUpYPpTWpDx+YXarDfXSxp/TOdT1eYxprSlkhJROM=; b=PSwvOdfariUptV8i0+ktNBzyu71r8RYfcmyp/mfYDjuHcmtFFSB8auKr BhsbIegeovZg4N0YzI4v05SYjXGi3rzTtJM9vajXq7jr1WhinGPhZ2qza J5BMnZXKoghzb01s4QMmqWgnrZObg4axFyx48eeNpzYeT4LAtdPxFr3rj XKUPtniH6Uw2asWidGMmFVo8LvB/Jww+iLa9dHfVRYoG+UHLaz9t2icPb lMLwmW8ThRKhU5R04MNzTmCcVN3F77JlJ1O3vcyVOZ/NvTmqNViiODPOb 2D1piagfpo5HYDL8yM2b5k3QN7E+Cc8oJWFmYPmIAhfwbd8b6cYJm2o+/ Q==; X-IronPort-AV: E=McAfee;i="6500,9779,10640"; a="337758120" X-IronPort-AV: E=Sophos;i="5.98,236,1673942400"; d="scan'208";a="337758120" Received: from orsmga007.jf.intel.com ([10.7.209.58]) by orsmga103.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 05 Mar 2023 16:22:11 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6500,9779,10640"; a="669263323" X-IronPort-AV: E=Sophos;i="5.98,236,1673942400"; d="scan'208";a="669263323" Received: from nldesimo-desk.amr.corp.intel.com ([10.24.12.177]) by orsmga007-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 05 Mar 2023 16:22:11 -0800 From: "Nate DeSimone" To: devel@edk2.groups.io Cc: Andrew Fish , Ray Ni , Michael D Kinney , Chasel Chiu Subject: [PATCH v1 5/6] EmulatorPkg: Add ARM support to EmuSec Date: Sun, 5 Mar 2023 16:22:04 -0800 Message-Id: <20230306002205.1640-6-nathaniel.l.desimone@intel.com> X-Mailer: git-send-email 2.39.2.windows.1 In-Reply-To: <20230306002205.1640-1-nathaniel.l.desimone@intel.com> References: <20230306002205.1640-1-nathaniel.l.desimone@intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Adds ARM implementation of EFI_PEI_TEMPORARY_RAM_SUPPORT_PPI. Cc: Andrew Fish Cc: Ray Ni Cc: Michael D Kinney Cc: Chasel Chiu Signed-off-by: Nate DeSimone --- EmulatorPkg/Sec/Arm/SwitchRam.S | 32 ++++++++++++++++++ EmulatorPkg/Sec/Arm/TempRam.c | 58 +++++++++++++++++++++++++++++++++ EmulatorPkg/Sec/Sec.inf | 9 ++++- 3 files changed, 98 insertions(+), 1 deletion(-) create mode 100644 EmulatorPkg/Sec/Arm/SwitchRam.S create mode 100644 EmulatorPkg/Sec/Arm/TempRam.c diff --git a/EmulatorPkg/Sec/Arm/SwitchRam.S b/EmulatorPkg/Sec/Arm/SwitchRam.S new file mode 100644 index 0000000000..d64772b8ed --- /dev/null +++ b/EmulatorPkg/Sec/Arm/SwitchRam.S @@ -0,0 +1,32 @@ +#------------------------------------------------------------------------------ +# +# Copyright (c) 2006 - 2009, Intel Corporation. All rights reserved.
+# Portions copyright (c) 2008 - 2009, Apple Inc. All rights reserved.
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +#------------------------------------------------------------------------------ + +#include + +#/** +# This allows the caller to switch the stack and return +# +# @param StackDelta Signed amount by which to modify the stack pointer +# +# @return Nothing. Goes to the Entry Point passing in the new parameters +# +#**/ +#VOID +#EFIAPI +#SecSwitchStack ( +# VOID *StackDelta +# )# +# +ASM_FUNC(SecSwitchStack) + mov R1, R13 + add R1, R0, R1 + mov R13, R1 + bx LR + + + diff --git a/EmulatorPkg/Sec/Arm/TempRam.c b/EmulatorPkg/Sec/Arm/TempRam.c new file mode 100644 index 0000000000..0a6b215591 --- /dev/null +++ b/EmulatorPkg/Sec/Arm/TempRam.c @@ -0,0 +1,58 @@ +/*++ @file + Temp RAM PPI + + Copyright (c) 2011, Apple Inc. All rights reserved.
+ Copyright (c) 2023, Intel Corporation. All rights reserved.
+ + SPDX-License-Identifier: BSD-2-Clause-Patent + +**/ + +#include +#include +#include + +#include + +VOID +SecSwitchStack ( + INTN 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 into + // permanent memory. + // + SecSwitchStack ((UINTN)(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..264666f544 100644 --- a/EmulatorPkg/Sec/Sec.inf +++ b/EmulatorPkg/Sec/Sec.inf @@ -3,7 +3,7 @@ # # Main executable file of Unix Emulator that loads PEI core after initialization finished. # Portions copyright (c) 2011, Apple Inc. All rights reserved.
-# Copyright (c) 2012, Intel Corporation. All rights reserved.
+# Copyright (c) 2012 - 2023, Intel Corporation. All rights reserved.
# # SPDX-License-Identifier: BSD-2-Clause-Patent # @@ -30,10 +30,17 @@ Ia32/SwitchRam.asm Ia32/SwitchRam.S +[Sources.ARM] + Arm/TempRam.c + Arm/SwitchRam.S + [Packages] MdePkg/MdePkg.dec EmulatorPkg/EmulatorPkg.dec +[Packages.ARM] + ArmPkg/ArmPkg.dec + [LibraryClasses] DebugLib PeCoffGetEntryPointLib -- 2.30.2