From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-in24.apple.com (mail-out24.apple.com [17.171.2.34]) (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 EC36521A134BB for ; Mon, 22 May 2017 10:14:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; d=apple.com; s=mailout2048s; c=relaxed/simple; q=dns/txt; i=@apple.com; t=1495473276; h=From:Sender:Reply-To:Subject:Date:Message-id:To:Cc:MIME-version:Content-type: Content-transfer-encoding:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-reply-to:References:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=qV1HbMfYxK9VCXkjXXmHBdIeK6ISf5qOxSszkY+3cI0=; b=c2FFodT+7ivUuAwfKM1nhVvr0FsREFzkXz8nBoPYw9ViimZ1Zd2OHHpyfM+aG45x uBFv9dN4zru7HjfxkcwiTj6PtyfU3zCdXjkevYb1388eFlr7gAvG5nGGI+pEspx4 qgbqM5Gk3zQX8F4UuXIp5UCiRzpcLvDSzaJR97akkxavs3q9LYvV6CiuZDfAtpGu 3u9s2eHulToLV2Q6xqlZenvHRCno2lQTCYcP58qeNMHw6MRzlZE0YlMtD3Bni84q lVsQ3+9u92UlHiEs2rOJ0b8rgPM2YKLJoXoKCIQpKWx2B08yTgEHyesh0l5HRlmK qvEXLOkRV0e4LhXqEVnBow==; Received: from relay7.apple.com (relay7.apple.com [17.128.113.101]) (using TLS with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mail-in24.apple.com (Apple Secure Mail Relay) with SMTP id 28.C2.17842.C7C13295; Mon, 22 May 2017 10:14:36 -0700 (PDT) X-AuditID: 11ab0218-4df929a0000045b2-25-59231c7c2593 Received: from nwk-mmpp-sz09.apple.com (nwk-mmpp-sz09.apple.com [17.128.115.80]) by relay7.apple.com (Apple SCV relay) with SMTP id 85.8D.18088.C7C13295; Mon, 22 May 2017 10:14:36 -0700 (PDT) MIME-version: 1.0 Received: from [17.153.39.244] by nwk-mmpp-sz09.apple.com (Oracle Communications Messaging Server 8.0.1.2.20170210 64bit (built Feb 10 2017)) with ESMTPSA id <0OQD002VW6KBRL61@nwk-mmpp-sz09.apple.com>; Mon, 22 May 2017 10:14:36 -0700 (PDT) Sender: afish@apple.com From: Andrew Fish In-reply-to: <1495473154-18184-1-git-send-email-michael.d.kinney@intel.com> Date: Mon, 22 May 2017 10:14:34 -0700 Cc: edk2-devel@lists.01.org, Jeff Fan Message-id: References: <1495473154-18184-1-git-send-email-michael.d.kinney@intel.com> To: Mike Kinney X-Mailer: Apple Mail (2.3273) X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFtrLLMWRmVeSWpSXmKPExsUi2FCYqlsjoxxpcOiylcWeQ0eZLU6uX8Jo 0dHxj8mB2WPxnpdMHt2z/7EEMEVx2aSk5mSWpRbp2yVwZbyYP5+1YLJGxf/uJ8wNjA/kuxg5 OCQETCTu3nTrYuTkEBJYyyTRtdoAxAYJP5hyjLGLkQsofpBRYue3V4wgCV4BQYkfk++xgPQy C8hLHDwvCxJmFtCS+P6olQWi/iujxJcLJ5lAEsIC4hLvzmxihrAjJF4v2gEWZxNQllgx/wM7 iM0p4C1xYfNpNhCbRUBV4vqsHlaIoVYSsy/PZILYayMx7+13dpC9QgJeEu8a8kFMEQEdie6V 0RAny0rcmn2JGeQECYENbBKfWu+yTmAUnoXk6lkIV89CcvUCRuZVjMK5iZk5upl5RiZ6iQUF Oal6yfm5mxhB4b2aSWIH45fXhocYBTgYlXh4HX4oRQqxJpYVV+YeYpTmYFES573GohwpJJCe WJKanZpakFoUX1Sak1p8iJGJg1OqgVF4xzdG7x9ta1t121sWpdZtrXlzyl5jh+sOh6OX3WsE vKrS5rx/kHZQWv+T68Rz25f3RndKsoXW/uuWucld43TX5Ufd1nqBfmGBWxPONfw6c0zHoztx S+7E1PB73K2z5U3WL04Kc+bszRdIPLw98MqnXPEencQ/cXp3Xp24W/3hr0rq4cc/uZRYijMS DbWYi4oTATD+hN5QAgAA X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFprAIsWRmVeSWpSXmKPExsUi2FAcoFsjoxxp8PqxgsWeQ0eZLU6uX8Jo 0dHxj8mB2WPxnpdMHt2z/7EEMEVx2aSk5mSWpRbp2yVwZbyYP5+1YLJGxf/uJ8wNjA/kuxg5 OSQETCQeTDnG2MXIxSEkcJBRYue3V4wgCV4BQYkfk++xdDFycDALyEscPC8LEmYW0JL4/qiV BaL+K6PElwsnmUASwgLiEu/ObGKGsCMkXi/aARZnE1CWWDH/AzuIzSngLXFh82k2EJtFQFXi +qweVoihVhKzL89kgthrIzHv7Xd2kL1CAl4S7xryQUwRAR2J7pXRECfLStyafYl5AqPALCSH zkI4dBaSQxcwMq9iFChKzUmsNNdLLCjISdVLzs/dxAgOyMLUHYyNy60OMQpwMCrx8Go8VooU Yk0sK67MPcQowcGsJMKbx64cKcSbklhZlVqUH19UmpNafIixCuj6icxSosn5wGjJK4k3NDEx MDE2NjM2Njcxp4qwkjjvPBagzQLpiSWp2ampBalFMMuZODilGhjn2FtJ9hz7wfvMzbFd+YJE mVyN6rfSFwq/Nzb4fPdrEv3rFmS9tZRLhv/DqRUiR5okmKL1+d4s654YNqds6gbr9Ukc/xbl L+M/c1ZZbvbJo45r1mwsqw67Pb0pxDFG/GW9/66HnPIrk27w7FTed+3hScf1p7WkEzdlLeMX fbW/9eQlzrJbLLlKLMUZiYZazEXFiQAeOggcowIAAA== Subject: Re: [Patch V2] 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: , X-List-Received-Date: Mon, 22 May 2017 17:14:38 -0000 Content-transfer-encoding: 7BIT Content-type: text/plain; CHARSET=US-ASCII Reviewed-by: Andrew Fish > On May 22, 2017, at 10:12 AM, Michael Kinney wrote: > > https://bugzilla.tianocore.org/show_bug.cgi?id=565 > > 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() is > added to the MP_CPU_EXCHANGE_INFO structure that is passed > to RendezvousFunnelProc(). > > Cc: Andrew Fish > Cc: Jeff Fan > Contributed-under: TianoCore Contribution Agreement 1.0 > Signed-off-by: Michael D Kinney > --- > UefiCpuPkg/Library/MpInitLib/MpLib.c | 2 ++ > UefiCpuPkg/Library/MpInitLib/MpLib.h | 1 + > UefiCpuPkg/Library/MpInitLib/X64/MpEqu.inc | 1 + > UefiCpuPkg/Library/MpInitLib/X64/MpFuncs.nasm | 8 ++++---- > 4 files changed, 8 insertions(+), 4 deletions(-) > > diff --git a/UefiCpuPkg/Library/MpInitLib/MpLib.c b/UefiCpuPkg/Library/MpInitLib/MpLib.c > index 407c44c..735e099 100644 > --- a/UefiCpuPkg/Library/MpInitLib/MpLib.c > +++ b/UefiCpuPkg/Library/MpInitLib/MpLib.c > @@ -751,6 +751,8 @@ FillExchangeInfoData ( > > ExchangeInfo->EnableExecuteDisable = IsBspExecuteDisableEnabled (); > > + ExchangeInfo->InitializeFloatingPointUnitsAddress = (UINTN)InitializeFloatingPointUnits; > + > // > // Get the BSP's data of GDT and IDT > // > diff --git a/UefiCpuPkg/Library/MpInitLib/MpLib.h b/UefiCpuPkg/Library/MpInitLib/MpLib.h > index 989b3f8..ea56412 100644 > --- a/UefiCpuPkg/Library/MpInitLib/MpLib.h > +++ b/UefiCpuPkg/Library/MpInitLib/MpLib.h > @@ -177,6 +177,7 @@ typedef struct { > UINTN InitFlag; > CPU_INFO_IN_HOB *CpuInfo; > CPU_MP_DATA *CpuMpData; > + UINTN InitializeFloatingPointUnitsAddress; > } MP_CPU_EXCHANGE_INFO; > > #pragma pack() > diff --git a/UefiCpuPkg/Library/MpInitLib/X64/MpEqu.inc b/UefiCpuPkg/Library/MpInitLib/X64/MpEqu.inc > index a63cd23..852281a 100644 > --- a/UefiCpuPkg/Library/MpInitLib/X64/MpEqu.inc > +++ b/UefiCpuPkg/Library/MpInitLib/X64/MpEqu.inc > @@ -40,4 +40,5 @@ EnableExecuteDisableLocation equ LockLocation + 5Ch > Cr3Location equ LockLocation + 64h > InitFlagLocation equ LockLocation + 6Ch > CpuInfoLocation equ LockLocation + 74h > +InitializeFloatingPointUnitsAddress equ LockLocation + 84h > > diff --git a/UefiCpuPkg/Library/MpInitLib/X64/MpFuncs.nasm b/UefiCpuPkg/Library/MpInitLib/X64/MpFuncs.nasm > index fa54d01..0b14a53 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 BSD License > ; which accompanies this distribution. The full text of the license may be found at > @@ -201,7 +201,7 @@ CProcedureInvoke: > push rbp > mov rbp, rsp > > - mov rax, ASM_PFX(InitializeFloatingPointUnits) > + mov rax, qword [esi + InitializeFloatingPointUnitsAddress] > sub rsp, 20h > call rax ; Call assembly function to initialize FPU per UEFI spec > add rsp, 20h > @@ -282,11 +282,11 @@ AsmRelocateApLoopEnd: > ;------------------------------------------------------------------------------------- > global ASM_PFX(AsmGetAddressMap) > ASM_PFX(AsmGetAddressMap): > - mov rax, ASM_PFX(RendezvousFunnelProc) > + lea rax, [ASM_PFX(RendezvousFunnelProc)] > mov qword [rcx], rax > mov qword [rcx + 8h], LongModeStart - RendezvousFunnelProcStart > mov qword [rcx + 10h], RendezvousFunnelProcEnd - RendezvousFunnelProcStart > - mov rax, ASM_PFX(AsmRelocateApLoop) > + lea rax, [ASM_PFX(AsmRelocateApLoop)] > mov qword [rcx + 18h], rax > mov qword [rcx + 20h], AsmRelocateApLoopEnd - AsmRelocateApLoopStart > ret > -- > 2.6.3.windows.1 >