From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mga04.intel.com (mga04.intel.com [192.55.52.120]) by mx.groups.io with SMTP id smtpd.web11.68805.1669962314921437954 for ; Thu, 01 Dec 2022 22:25:15 -0800 Authentication-Results: mx.groups.io; dkim=fail reason="unable to parse pub key" header.i=@intel.com header.s=intel header.b=KMucKs4P; spf=pass (domain: intel.com, ip: 192.55.52.120, mailfrom: zhiguang.liu@intel.com) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1669962314; x=1701498314; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=FLDigCLh8d82W7GOF2SiMkYqCvDnJ7uOX1md6WBb9fs=; b=KMucKs4PnTdig2wb7hRmVBOSWqxOHDl9tg5jSXQyrBSx6d/imJNq0Q9b BbwcPtwNW3XZzsCUIvaBxxe2c0lEjhM6YEy/arADrEfZ91nNE4CMur+Pj EFfub+t9UpupDH9qYoiq/T7HVW6GBVrPrhLcSCZdhy/YOwc0D7AEi4ol/ KCqVZkXDAY6dQmhJ6yEdhEPfOyuB31twyMCYBIxgDQvFaOqNd9ixgIaGq zY5ei32ubcSvnmUyfSSw4+M3ewpZUQij21Q0kMTGM2qQnpQO+Lvocklcu 8JbF93LBhUk7enDaNfQ0IpE+M5C8IA5p6h10GD7+jte1lX1woJEo7YGR9 g==; X-IronPort-AV: E=McAfee;i="6500,9779,10548"; a="314584992" X-IronPort-AV: E=Sophos;i="5.96,210,1665471600"; d="scan'208";a="314584992" Received: from fmsmga006.fm.intel.com ([10.253.24.20]) by fmsmga104.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 01 Dec 2022 22:25:14 -0800 X-IronPort-AV: E=McAfee;i="6500,9779,10548"; a="890035411" X-IronPort-AV: E=Sophos;i="5.96,210,1665471600"; d="scan'208";a="890035411" Received: from shwdesfp01.ccr.corp.intel.com ([10.239.158.151]) by fmsmga006-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 01 Dec 2022 22:25:13 -0800 From: "Zhiguang Liu" To: devel@edk2.groups.io Cc: Zhiguang Liu , Michael D Kinney , Liming Gao , Ray Ni Subject: [PATCH] MdePkg/BaseCpuLib: Remove assembly for CpuFlushTlb Date: Fri, 2 Dec 2022 14:25:01 +0800 Message-Id: <20221202062502.4429-1-zhiguang.liu@intel.com> X-Mailer: git-send-email 2.31.1.windows.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit For different compilers, both IA32 and X64 can use Ia32/CpuFlushTlbGcc.c, which is C code (no inline assembly code). To simplify, remove other assemly file for CpuFlushTlb, and rename Ia32/CpuFlushTlbGcc.c to Ia32/CpuFlushTlb.c. Cc: Michael D Kinney Cc: Liming Gao Signed-off-by: Ray Ni Signed-off-by: Zhiguang Liu --- MdePkg/Library/BaseCpuLib/BaseCpuLib.inf | 10 ++---- MdePkg/Library/BaseCpuLib/Ia32/CpuFlushTlb.c | 12 +++---- .../Library/BaseCpuLib/Ia32/CpuFlushTlb.nasm | 31 ------------------ .../Library/BaseCpuLib/Ia32/CpuFlushTlbGcc.c | 25 --------------- .../Library/BaseCpuLib/X64/CpuFlushTlb.nasm | 32 ------------------- 5 files changed, 9 insertions(+), 101 deletions(-) delete mode 100644 MdePkg/Library/BaseCpuLib/Ia32/CpuFlushTlb.nasm delete mode 100644 MdePkg/Library/BaseCpuLib/Ia32/CpuFlushTlbGcc.c delete mode 100644 MdePkg/Library/BaseCpuLib/X64/CpuFlushTlb.nasm diff --git a/MdePkg/Library/BaseCpuLib/BaseCpuLib.inf b/MdePkg/Library/BaseCpuLib/BaseCpuLib.inf index 6b230f6e6d..0feb592638 100644 --- a/MdePkg/Library/BaseCpuLib/BaseCpuLib.inf +++ b/MdePkg/Library/BaseCpuLib/BaseCpuLib.inf @@ -4,7 +4,7 @@ # CPU Library implemented using ASM functions for IA32, X64, ARM, AARCH64, # PAL CALLs for IPF, and empty functions for EBC. # -# Copyright (c) 2007 - 2018, Intel Corporation. All rights reserved.
+# Copyright (c) 2007 - 2022, Intel Corporation. All rights reserved.
# Portions copyright (c) 2008 - 2009, Apple Inc. All rights reserved.
# Portions copyright (c) 2011 - 2013, ARM Ltd. All rights reserved.
# Copyright (c) 2020, Hewlett Packard Enterprise Development LP. All rights reserved.
@@ -31,16 +31,12 @@ [Sources.IA32] Ia32/CpuSleep.c | MSFT - Ia32/CpuFlushTlb.c | MSFT - Ia32/CpuSleep.nasm| INTEL - Ia32/CpuFlushTlb.nasm| INTEL - Ia32/CpuSleepGcc.c | GCC - Ia32/CpuFlushTlbGcc.c | GCC + Ia32/CpuFlushTlb.c [Sources.X64] - X64/CpuFlushTlb.nasm + Ia32/CpuFlushTlb.c X64/CpuSleep.nasm diff --git a/MdePkg/Library/BaseCpuLib/Ia32/CpuFlushTlb.c b/MdePkg/Library/BaseCpuLib/Ia32/CpuFlushTlb.c index 549f4eb8a0..17a351d054 100644 --- a/MdePkg/Library/BaseCpuLib/Ia32/CpuFlushTlb.c +++ b/MdePkg/Library/BaseCpuLib/Ia32/CpuFlushTlb.c @@ -1,11 +1,14 @@ /** @file - CpuFlushTlb function. + CpuFlushTlb function for Ia32/X64. - Copyright (c) 2006 - 2008, Intel Corporation. All rights reserved.
+ Copyright (c) 2006 - 2022, Intel Corporation. All rights reserved.
+ Portions copyright (c) 2008 - 2009, Apple Inc. All rights reserved.
SPDX-License-Identifier: BSD-2-Clause-Patent **/ +#include + /** Flushes all the Translation Lookaside Buffers(TLB) entries in a CPU. @@ -18,8 +21,5 @@ CpuFlushTlb ( VOID ) { - _asm { - mov eax, cr3 - mov cr3, eax - } + AsmWriteCr3 (AsmReadCr3 ()); } diff --git a/MdePkg/Library/BaseCpuLib/Ia32/CpuFlushTlb.nasm b/MdePkg/Library/BaseCpuLib/Ia32/CpuFlushTlb.nasm deleted file mode 100644 index bc3b68e3f2..0000000000 --- a/MdePkg/Library/BaseCpuLib/Ia32/CpuFlushTlb.nasm +++ /dev/null @@ -1,31 +0,0 @@ -;------------------------------------------------------------------------------ ; -; Copyright (c) 2006, Intel Corporation. All rights reserved.
-; SPDX-License-Identifier: BSD-2-Clause-Patent -; -; Module Name: -; -; CpuFlushTlb.Asm -; -; Abstract: -; -; CpuFlushTlb function -; -; Notes: -; -;------------------------------------------------------------------------------ - - SECTION .text - -;------------------------------------------------------------------------------ -; VOID -; EFIAPI -; CpuFlushTlb ( -; VOID -; ); -;------------------------------------------------------------------------------ -global ASM_PFX(CpuFlushTlb) -ASM_PFX(CpuFlushTlb): - mov eax, cr3 - mov cr3, eax ; moving to CR3 flushes TLB - ret - diff --git a/MdePkg/Library/BaseCpuLib/Ia32/CpuFlushTlbGcc.c b/MdePkg/Library/BaseCpuLib/Ia32/CpuFlushTlbGcc.c deleted file mode 100644 index ee44f2ea6e..0000000000 --- a/MdePkg/Library/BaseCpuLib/Ia32/CpuFlushTlbGcc.c +++ /dev/null @@ -1,25 +0,0 @@ -/** @file - CpuFlushTlb function for Ia32/X64 GCC. - - Copyright (c) 2006 - 2008, Intel Corporation. All rights reserved.
- Portions copyright (c) 2008 - 2009, Apple Inc. All rights reserved.
- SPDX-License-Identifier: BSD-2-Clause-Patent - -**/ - -#include - -/** - Flushes all the Translation Lookaside Buffers(TLB) entries in a CPU. - - Flushes all the Translation Lookaside Buffers(TLB) entries in a CPU. - -**/ -VOID -EFIAPI -CpuFlushTlb ( - VOID - ) -{ - AsmWriteCr3 (AsmReadCr3 ()); -} diff --git a/MdePkg/Library/BaseCpuLib/X64/CpuFlushTlb.nasm b/MdePkg/Library/BaseCpuLib/X64/CpuFlushTlb.nasm deleted file mode 100644 index 8ddf7a2864..0000000000 --- a/MdePkg/Library/BaseCpuLib/X64/CpuFlushTlb.nasm +++ /dev/null @@ -1,32 +0,0 @@ -;------------------------------------------------------------------------------ ; -; Copyright (c) 2006, Intel Corporation. All rights reserved.
-; SPDX-License-Identifier: BSD-2-Clause-Patent -; -; Module Name: -; -; CpuFlushTlb.Asm -; -; Abstract: -; -; CpuFlushTlb function -; -; Notes: -; -;------------------------------------------------------------------------------ - - DEFAULT REL - SECTION .text - -;------------------------------------------------------------------------------ -; VOID -; EFIAPI -; CpuFlushTlb ( -; VOID -; ); -;------------------------------------------------------------------------------ -global ASM_PFX(CpuFlushTlb) -ASM_PFX(CpuFlushTlb): - mov rax, cr3 - mov cr3, rax - ret - -- 2.31.1.windows.1