From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: mx.groups.io; dkim=missing; spf=pass (domain: intel.com, ip: 134.134.136.65, mailfrom: liming.gao@intel.com) Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) by groups.io with SMTP; Wed, 10 Apr 2019 22:55:34 -0700 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by orsmga103.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 10 Apr 2019 22:55:34 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.60,336,1549958400"; d="scan'208";a="160174804" Received: from fmsmsx108.amr.corp.intel.com ([10.18.124.206]) by fmsmga002.fm.intel.com with ESMTP; 10 Apr 2019 22:55:33 -0700 Received: from fmsmsx121.amr.corp.intel.com (10.18.125.36) by FMSMSX108.amr.corp.intel.com (10.18.124.206) with Microsoft SMTP Server (TLS) id 14.3.408.0; Wed, 10 Apr 2019 22:55:33 -0700 Received: from shsmsx103.ccr.corp.intel.com (10.239.4.69) by fmsmsx121.amr.corp.intel.com (10.18.125.36) with Microsoft SMTP Server (TLS) id 14.3.408.0; Wed, 10 Apr 2019 22:55:33 -0700 Received: from shsmsx104.ccr.corp.intel.com ([169.254.5.92]) by SHSMSX103.ccr.corp.intel.com ([169.254.4.93]) with mapi id 14.03.0415.000; Thu, 11 Apr 2019 13:55:31 +0800 From: "Liming Gao" To: "Zhang, Shenglei" , "devel@edk2.groups.io" CC: "Kinney, Michael D" Subject: Re: [PATCH] MdePkg/BaseLib: Remove LongJump.c and SetJump.c Thread-Topic: [PATCH] MdePkg/BaseLib: Remove LongJump.c and SetJump.c Thread-Index: AQHU7oNo9Q/eHfLfckqqhwn9WTujl6Y2eRyg Date: Thu, 11 Apr 2019 05:55:30 +0000 Message-ID: <4A89E2EF3DFEDB4C8BFDE51014F606A14E422577@SHSMSX104.ccr.corp.intel.com> References: <20190409032200.7332-1-shenglei.zhang@intel.com> In-Reply-To: <20190409032200.7332-1-shenglei.zhang@intel.com> Accept-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [10.239.127.40] MIME-Version: 1.0 Return-Path: liming.gao@intel.com Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Reviewed-by: Liming Gao >-----Original Message----- >From: Zhang, Shenglei >Sent: Tuesday, April 09, 2019 11:22 AM >To: devel@edk2.groups.io >Cc: Kinney, Michael D ; Gao, Liming > >Subject: [PATCH] MdePkg/BaseLib: Remove LongJump.c and SetJump.c > >MdePkg BaseLib still uses the inline X86 assembly code >in C code files.For now, inline SetJump/LongJump() can be removed. >https://bugzilla.tianocore.org/show_bug.cgi?id=3D1163 > >Cc: Michael D Kinney >Cc: Liming Gao >Contributed-under: TianoCore Contribution Agreement 1.1 >Signed-off-by: Shenglei Zhang >--- > MdePkg/Library/BaseLib/BaseLib.inf | 8 +- > MdePkg/Library/BaseLib/Ia32/LongJump.c | 76 ------------------- > MdePkg/Library/BaseLib/Ia32/SetJump.c | 101 ------------------------- > 3 files changed, 2 insertions(+), 183 deletions(-) > delete mode 100644 MdePkg/Library/BaseLib/Ia32/LongJump.c > delete mode 100644 MdePkg/Library/BaseLib/Ia32/SetJump.c > >diff --git a/MdePkg/Library/BaseLib/BaseLib.inf >b/MdePkg/Library/BaseLib/BaseLib.inf >index 16829deeb4..344cb58249 100644 >--- a/MdePkg/Library/BaseLib/BaseLib.inf >+++ b/MdePkg/Library/BaseLib/BaseLib.inf >@@ -96,7 +96,6 @@ > Ia32/WriteCr0.c | MSFT > Ia32/WriteMsr64.c | MSFT > Ia32/SwapBytes64.c | MSFT >- Ia32/SetJump.c | MSFT > Ia32/RRotU64.c | MSFT > Ia32/RShiftU64.c | MSFT > Ia32/ReadPmc.c | MSFT >@@ -140,7 +139,6 @@ > Ia32/MultU64x32.c | MSFT > Ia32/LShiftU64.c | MSFT > Ia32/LRotU64.c | MSFT >- Ia32/LongJump.c | MSFT > Ia32/Invd.c | MSFT > Ia32/FxRestore.c | MSFT > Ia32/FxSave.c | MSFT >@@ -190,7 +188,6 @@ > Ia32/WriteCr0.nasm| INTEL > Ia32/WriteMsr64.nasm| INTEL > Ia32/SwapBytes64.nasm| INTEL >- Ia32/SetJump.nasm| INTEL > Ia32/RRotU64.nasm| INTEL > Ia32/RShiftU64.nasm| INTEL > Ia32/ReadPmc.nasm| INTEL >@@ -234,7 +231,6 @@ > Ia32/MultU64x32.nasm| INTEL > Ia32/LShiftU64.nasm| INTEL > Ia32/LRotU64.nasm| INTEL >- Ia32/LongJump.nasm| INTEL > Ia32/Invd.nasm| INTEL > Ia32/FxRestore.nasm| INTEL > Ia32/FxSave.nasm| INTEL >@@ -268,8 +264,8 @@ > Ia32/Monitor.nasm| GCC > Ia32/CpuIdEx.nasm| GCC > Ia32/CpuId.nasm| GCC >- Ia32/LongJump.nasm| GCC >- Ia32/SetJump.nasm| GCC >+ Ia32/LongJump.nasm >+ Ia32/SetJump.nasm > Ia32/SwapBytes64.nasm| GCC > Ia32/DivU64x64Remainder.nasm| GCC > Ia32/DivU64x32Remainder.nasm| GCC >diff --git a/MdePkg/Library/BaseLib/Ia32/LongJump.c >b/MdePkg/Library/BaseLib/Ia32/LongJump.c >deleted file mode 100644 >index 2c1feb8373..0000000000 >--- a/MdePkg/Library/BaseLib/Ia32/LongJump.c >+++ /dev/null >@@ -1,76 +0,0 @@ >-/** @file >- Implementation of _LongJump() on IA-32. >- >- Copyright (c) 2006 - 2019, Intel Corporation. All rights reserved.
>- This program and the accompanying materials >- are licensed and made available under the terms and conditions of the B= SD >License >- which accompanies this distribution. The full text of the license may = be >found at >- http://opensource.org/licenses/bsd-license.php. >- >- THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" >BASIS, >- WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER >EXPRESS OR IMPLIED. >- >-**/ >- >- >-#include "BaseLibInternals.h" >- >- >-/** >- Restores the CPU context that was saved with SetJump(). >- >- Restores the CPU context from the buffer specified by JumpBuffer. >- This function never returns to the caller. >- Instead is resumes execution based on the state of JumpBuffer. >- >- @param JumpBuffer A pointer to CPU context buffer. >- @param Value The value to return when the SetJump() context is >restored. >- >-**/ >-__declspec (naked) >-VOID >-EFIAPI >-InternalLongJump ( >- IN BASE_LIBRARY_JUMP_BUFFER *JumpBuffer, >- IN UINTN Value >- ) >-{ >- _asm { >- mov eax, [PcdGet32 (PcdControlFlowEnforcementPropertyMask)] >- test eax, eax >- jz CetDone >- _emit 0x0F >- _emit 0x20 >- _emit 0xE0 ; mov eax, cr4 >- bt eax, 23 ; check if CET is enabled >- jnc CetDone >- >- mov edx, [esp + 4] ; edx =3D JumpBuffer >- mov edx, [edx + 24] ; edx =3D target SSP >- _emit 0xF3 >- _emit 0x0F >- _emit 0x1E >- _emit 0xC8 ; READSSP EAX >- sub edx, eax ; edx =3D delta >- mov eax, edx ; eax =3D delta >- >- shr eax, 2 ; eax =3D delta/sizeof(UINT32) >- _emit 0xF3 >- _emit 0x0F >- _emit 0xAE >- _emit 0xE8 ; INCSSP EAX >- >-CetDone: >- >- pop eax ; skip return address >- pop edx ; edx <- JumpBuffer >- pop eax ; eax <- Value >- mov ebx, [edx] >- mov esi, [edx + 4] >- mov edi, [edx + 8] >- mov ebp, [edx + 12] >- mov esp, [edx + 16] >- jmp dword ptr [edx + 20] >- } >-} >- >diff --git a/MdePkg/Library/BaseLib/Ia32/SetJump.c >b/MdePkg/Library/BaseLib/Ia32/SetJump.c >deleted file mode 100644 >index d608fd9ccb..0000000000 >--- a/MdePkg/Library/BaseLib/Ia32/SetJump.c >+++ /dev/null >@@ -1,101 +0,0 @@ >-/** @file >- Implementation of SetJump() on IA-32. >- >- Copyright (c) 2006 - 2019, Intel Corporation. All rights reserved.
>- This program and the accompanying materials >- are licensed and made available under the terms and conditions of the B= SD >License >- which accompanies this distribution. The full text of the license may = be >found at >- http://opensource.org/licenses/bsd-license.php. >- >- THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" >BASIS, >- WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER >EXPRESS OR IMPLIED. >- >-**/ >- >- >-#include "BaseLibInternals.h" >- >-/** >- Worker function that checks ASSERT condition for JumpBuffer >- >- Checks ASSERT condition for JumpBuffer. >- >- If JumpBuffer is NULL, then ASSERT(). >- For IPF CPUs, if JumpBuffer is not aligned on a 16-byte boundary, then >ASSERT(). >- >- @param JumpBuffer A pointer to CPU context buffer. >- >-**/ >-VOID >-EFIAPI >-InternalAssertJumpBuffer ( >- IN BASE_LIBRARY_JUMP_BUFFER *JumpBuffer >- ); >- >-/** >- Saves the current CPU context that can be restored with a call to LongJ= ump() >- and returns 0. >- >- Saves the current CPU context in the buffer specified by JumpBuffer and >- returns 0. The initial call to SetJump() must always return 0. Subseque= nt >- calls to LongJump() cause a non-zero value to be returned by SetJump(). >- >- If JumpBuffer is NULL, then ASSERT(). >- For IPF CPUs, if JumpBuffer is not aligned on a 16-byte boundary, then >ASSERT(). >- >- @param JumpBuffer A pointer to CPU context buffer. >- >- @retval 0 Indicates a return from SetJump(). >- >-**/ >-_declspec (naked) >-RETURNS_TWICE >-UINTN >-EFIAPI >-SetJump ( >- OUT BASE_LIBRARY_JUMP_BUFFER *JumpBuffer >- ) >-{ >- _asm { >- push [esp + 4] >- call InternalAssertJumpBuffer >- pop ecx >- pop ecx >- mov edx, [esp] >- >- xor eax, eax >- mov [edx + 24], eax ; save 0 to SSP >- >- mov eax, [PcdGet32 (PcdControlFlowEnforcementPropertyMask)] >- test eax, eax >- jz CetDone >- _emit 0x0F >- _emit 0x20 >- _emit 0xE0 ; mov eax, cr4 >- bt eax, 23 ; check if CET is enabled >- jnc CetDone >- >- mov eax, 1 >- _emit 0xF3 >- _emit 0x0F >- _emit 0xAE >- _emit 0xE8 ; INCSSP EAX to read original SSP >- _emit 0xF3 >- _emit 0x0F >- _emit 0x1E >- _emit 0xC8 ; READSSP EAX >- mov [edx + 0x24], eax ; save SSP >- >-CetDone: >- >- mov [edx], ebx >- mov [edx + 4], esi >- mov [edx + 8], edi >- mov [edx + 12], ebp >- mov [edx + 16], esp >- mov [edx + 20], ecx >- xor eax, eax >- jmp ecx >- } >-} >- >-- >2.18.0.windows.1