From nobody Sat Dec 28 12:36:08 2024 Delivered-To: importer@patchew.org Received-SPF: none (zoho.com: 198.145.21.10 is neither permitted nor denied by domain of lists.01.org) client-ip=198.145.21.10; envelope-from=edk2-devel-bounces@lists.01.org; helo=ml01.01.org; Authentication-Results: mx.zoho.com; spf=none (zoho.com: 198.145.21.10 is neither permitted nor denied by domain of lists.01.org) smtp.mailfrom=edk2-devel-bounces@lists.01.org; Return-Path: Received: from ml01.01.org (ml01.01.org [198.145.21.10]) by mx.zohomail.com with SMTPS id 1495393496916525.7253246448108; Sun, 21 May 2017 12:04:56 -0700 (PDT) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id 1ABE721AF0338; Sun, 21 May 2017 12:04:55 -0700 (PDT) Received: from mga04.intel.com (mga04.intel.com [192.55.52.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id 7B29621AF0334 for ; Sun, 21 May 2017 12:04:54 -0700 (PDT) Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by fmsmga104.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 21 May 2017 12:04:54 -0700 Received: from mdkinney-mobl.amr.corp.intel.com ([10.252.129.206]) by fmsmga002.fm.intel.com with ESMTP; 21 May 2017 12:04:53 -0700 X-Original-To: edk2-devel@lists.01.org X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.38,376,1491289200"; d="scan'208";a="1172420310" From: Michael Kinney To: edk2-devel@lists.01.org Date: Sun, 21 May 2017 12:04:50 -0700 Message-Id: <1495393490-16884-1-git-send-email-michael.d.kinney@intel.com> X-Mailer: git-send-email 2.6.3.windows.1 Subject: [edk2] [Patch] UefiCpuPkg/MpInitLib: Fix X64 XCODE5/NASM compatibility issues X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Michael D Kinney , Andrew Fish , Jeff Fan MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Errors-To: edk2-devel-bounces@lists.01.org Sender: "edk2-devel" X-ZohoMail: RSF_4 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" https://bugzilla.tianocore.org/show_bug.cgi?id=3D565 Fix NASM compatibility issues with XCODE5 tool chain. The XCODE5 tool chain for X64 builds using PIE (Position Independent Executable). For most assembly sources using PIE mode does not cause any issues. However, if assembly code is copied to a different address (such as AP startup code in the MpInitLib), then the X64 assembly source must be implemented to be compatible with PIE mode that uses RIP relative addressing. The specific changes in this patch are: * Use LEA instruction instead of MOV instruction to lookup the addresses of functions. * The assembly function RendezvousFunnelProc() is copied below 1MB so it can be executed as part of the MpInitLib AP startup sequence. RendezvousFunnelProc() calls the external function InitializeFloatingPointUnits(). The absolute address of InitializeFloatingPointUnits() must resolved and saved to a data element that is part of RendezvousFunnelProc() before RendezvousFunnelProc() is copied below 1MB. This work is done in AsmGetAddressMap(). Cc: Andrew Fish Cc: Jeff Fan Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Michael D Kinney --- UefiCpuPkg/Library/MpInitLib/X64/MpFuncs.nasm | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/UefiCpuPkg/Library/MpInitLib/X64/MpFuncs.nasm b/UefiCpuPkg/Lib= rary/MpInitLib/X64/MpFuncs.nasm index fa54d01..c943a09 100644 --- a/UefiCpuPkg/Library/MpInitLib/X64/MpFuncs.nasm +++ b/UefiCpuPkg/Library/MpInitLib/X64/MpFuncs.nasm @@ -1,5 +1,5 @@ ;-------------------------------------------------------------------------= ----- ; -; Copyright (c) 2015 - 2016, Intel Corporation. All rights reserved.
+; Copyright (c) 2015 - 2017, Intel Corporation. All rights reserved.
; This program and the accompanying materials ; are licensed and made available under the terms and conditions of the BS= D License ; which accompanies this distribution. The full text of the license may b= e found at @@ -201,7 +201,8 @@ CProcedureInvoke: push rbp mov rbp, rsp =20 - mov rax, ASM_PFX(InitializeFloatingPointUnits) + lea rax, [InitialzeFloatingPointUnitsAddress] + mov rax, qword [rax] sub rsp, 20h call rax ; Call assembly function to initialize FP= U per UEFI spec add rsp, 20h @@ -219,6 +220,10 @@ CProcedureInvoke: add rsp, 20h jmp $ ; Should never reach here =20 +InitialzeFloatingPointUnitsAddress: + DQ 0 ; Provide storage for absolute adddress of + ; the InitializeFloatingPointUnits() func= tion + RendezvousFunnelProcEnd: =20 ;-------------------------------------------------------------------------= ------------ @@ -282,11 +287,18 @@ AsmRelocateApLoopEnd: ;-------------------------------------------------------------------------= ------------ global ASM_PFX(AsmGetAddressMap) ASM_PFX(AsmGetAddressMap): - mov rax, ASM_PFX(RendezvousFunnelProc) + ; Save absolute address of InitializeFloatingPointUnits() in data elem= ent + ; within the RendezvousFunnelProc template. This provides the address= of + ; the InitializeFloatingPointUnits() function to the RendezvousFunnelP= roc + ; after it has been copied below 1MB + lea rax, [ASM_PFX(InitializeFloatingPointUnits)] + mov qword [InitialzeFloatingPointUnitsAddress], rax + + lea rax, [ASM_PFX(RendezvousFunnelProc)] mov qword [rcx], rax mov qword [rcx + 8h], LongModeStart - RendezvousFunnelProcStart mov qword [rcx + 10h], RendezvousFunnelProcEnd - RendezvousFunn= elProcStart - mov rax, ASM_PFX(AsmRelocateApLoop) + lea rax, [ASM_PFX(AsmRelocateApLoop)] mov qword [rcx + 18h], rax mov qword [rcx + 20h], AsmRelocateApLoopEnd - AsmRelocateApLoop= Start ret --=20 2.6.3.windows.1 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel