From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: mx.groups.io; dkim=missing; spf=fail (domain: intel.com, ip: , mailfrom: jordan.l.justen@intel.com) Received: from mga11.intel.com (mga11.intel.com []) by groups.io with SMTP; Wed, 10 Apr 2019 01:41:49 -0700 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga007.jf.intel.com ([10.7.209.58]) by fmsmga102.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 10 Apr 2019 01:41:12 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.60,332,1549958400"; d="scan'208";a="130116387" Received: from askirtik-mobl1.amr.corp.intel.com (HELO jljusten-skl.amr.corp.intel.com) ([10.254.188.249]) by orsmga007.jf.intel.com with ESMTP; 10 Apr 2019 01:41:12 -0700 From: "Jordan Justen" To: devel@edk2.groups.io Cc: Jordan Justen , Jian J Wang , Hao Wu , Ray Ni , Star Zeng Subject: [PATCH v2 5/6] MdeModulePkg/Core/Pei: Add X64 assembly for TemporaryRamMigration Date: Wed, 10 Apr 2019 01:39:59 -0700 Message-Id: <20190410084000.19660-6-jordan.l.justen@intel.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190410084000.19660-1-jordan.l.justen@intel.com> References: <20190410084000.19660-1-jordan.l.justen@intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Some compilers may optimize register usage in ways that are incompatible with the TemporaryRamSupport PPI. Using assembly code to call the TemporaryRamMigration function prevents this issue. Signed-off-by: Jordan Justen Cc: Jian J Wang Cc: Hao Wu Cc: Ray Ni Cc: Star Zeng --- .../Dispatcher/X64/TemporaryRamMigration.nasm | 74 +++++++++++++++++++ MdeModulePkg/Core/Pei/PeiMain.inf | 3 + 2 files changed, 77 insertions(+) create mode 100644 MdeModulePkg/Core/Pei/Dispatcher/X64/TemporaryRamMigration.nasm diff --git a/MdeModulePkg/Core/Pei/Dispatcher/X64/TemporaryRamMigration.nasm b/MdeModulePkg/Core/Pei/Dispatcher/X64/TemporaryRamMigration.nasm new file mode 100644 index 0000000000..5de8acdf34 --- /dev/null +++ b/MdeModulePkg/Core/Pei/Dispatcher/X64/TemporaryRamMigration.nasm @@ -0,0 +1,74 @@ +;------------------------------------------------------------------------------ +; +; Copyright (c) 2018, Intel Corporation. All rights reserved.
+; SPDX-License-Identifier: BSD-2-Clause-Patent +; +;------------------------------------------------------------------------------ + +#include + + SECTION .text + +extern ASM_PFX(PeiTemporaryRamMigrated) + +;------------------------------------------------------------------------------ +; VOID +; EFIAPI +; PeiTemporaryRamMigration ( +; IN PEI_CORE_TEMPORARY_RAM_TRANSITION *TempRamTransitionData +; ); +; +; @param[in] RCX Pointer to PEI_CORE_TEMPORARY_RAM_TRANSITION +; +; @return None This routine does not return +;------------------------------------------------------------------------------ +global ASM_PFX(PeiTemporaryRamMigration) +ASM_PFX(PeiTemporaryRamMigration): + + ; + ; We never return from this call + ; + add rsp, 8 + + ; + ; (rax) Pointer to PEI_CORE_TEMPORARY_RAM_TRANSITION + ; + mov rax, rcx + + ; + ; We store the TempRamTransitionData pointer in rbx. By the X64 + ; calling convention we should normally save rbx, but we won't be + ; returning to the caller, so we don't need to save it. By the + ; same rule, the TemporaryRamMigration PPI call should preserve + ; rbx for us. + ; + mov rbx, rcx + + ; + ; Setup parameters and call TemporaryRamSupport->TemporaryRamMigration + ; (rcx) PeiServices + ; (rdx) TemporaryMemoryBase + ; (r8) PermanentMemoryBase + ; (r9) CopySize + ; + mov rcx, [rax + 0x08] + mov rdx, [rax + 0x10] + mov r8, [rax + 0x18] + mov r9, [rax + 0x20] + + ; + ; (rbx) Pointer to PEI_CORE_TEMPORARY_RAM_TRANSITION on stack + ; + ; Adjusted based on stack change made during + ; TemporaryRamSupport->TemporaryRamMigration call + ; + sub rbx, rsp + call [rax + 0x00] + add rbx, rsp + + ; + ; Setup parameters and call PeiTemporaryRamMigrated + ; (rcx) Pointer to PEI_CORE_TEMPORARY_RAM_TRANSITION + ; + mov rcx, rbx + call ASM_PFX(PeiTemporaryRamMigrated) diff --git a/MdeModulePkg/Core/Pei/PeiMain.inf b/MdeModulePkg/Core/Pei/PeiMain.inf index 918c4a0df8..fb643a9dd5 100644 --- a/MdeModulePkg/Core/Pei/PeiMain.inf +++ b/MdeModulePkg/Core/Pei/PeiMain.inf @@ -59,6 +59,9 @@ [Sources.Ia32] Dispatcher/Ia32/TemporaryRamMigration.nasm +[Sources.X64] + Dispatcher/X64/TemporaryRamMigration.nasm + [Packages] MdePkg/MdePkg.dec MdeModulePkg/MdeModulePkg.dec -- 2.20.1