From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: mx.groups.io; dkim=missing; spf=fail (domain: intel.com, ip: , mailfrom: michael.d.kinney@intel.com) Received: from mga14.intel.com (mga14.intel.com []) by groups.io with SMTP; Tue, 30 Apr 2019 12:31:13 -0700 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga005.jf.intel.com ([10.7.209.41]) by fmsmga103.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 30 Apr 2019 12:31:12 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.60,414,1549958400"; d="scan'208";a="320349801" Received: from unknown (HELO mdkinney-MOBL2.amr.corp.intel.com) ([10.241.111.157]) by orsmga005.jf.intel.com with ESMTP; 30 Apr 2019 12:31:11 -0700 From: "Michael D Kinney" To: devel@edk2.groups.io Cc: Liming Gao , Laszlo Ersek Subject: [Patch V3 2/8] MdePkg/BaseLib: Use PcdSpeculationBarrierType Date: Tue, 30 Apr 2019 12:31:02 -0700 Message-Id: <20190430193108.8544-3-michael.d.kinney@intel.com> X-Mailer: git-send-email 2.21.0.windows.1 In-Reply-To: <20190430193108.8544-1-michael.d.kinney@intel.com> References: <20190430193108.8544-1-michael.d.kinney@intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Use PcdSpeculationBarrierType in the x86 implementation of SpeculationBarrier() to select between AsmLfence(), AsmCpuid(), and no operation. Cc: Liming Gao Signed-off-by: Michael D Kinney Reviewed-by: Laszlo Ersek --- MdePkg/Library/BaseLib/BaseLib.inf | 1 + MdePkg/Library/BaseLib/X86SpeculationBarrier.c | 8 ++++++-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/MdePkg/Library/BaseLib/BaseLib.inf b/MdePkg/Library/BaseLib/BaseLib.inf index 533e83e0b2..3586beb0ab 100644 --- a/MdePkg/Library/BaseLib/BaseLib.inf +++ b/MdePkg/Library/BaseLib/BaseLib.inf @@ -394,6 +394,7 @@ [Pcd] gEfiMdePkgTokenSpaceGuid.PcdMaximumAsciiStringLength ## SOMETIMES_CONSUMES gEfiMdePkgTokenSpaceGuid.PcdMaximumUnicodeStringLength ## SOMETIMES_CONSUMES gEfiMdePkgTokenSpaceGuid.PcdControlFlowEnforcementPropertyMask ## SOMETIMES_CONSUMES + gEfiMdePkgTokenSpaceGuid.PcdSpeculationBarrierType ## SOMETIMES_CONSUMES [FeaturePcd] gEfiMdePkgTokenSpaceGuid.PcdVerifyNodeInList ## CONSUMES diff --git a/MdePkg/Library/BaseLib/X86SpeculationBarrier.c b/MdePkg/Library/BaseLib/X86SpeculationBarrier.c index 8e5f983bb8..b28fd8de9b 100644 --- a/MdePkg/Library/BaseLib/X86SpeculationBarrier.c +++ b/MdePkg/Library/BaseLib/X86SpeculationBarrier.c @@ -1,7 +1,7 @@ /** @file SpeculationBarrier() function for IA32 and x64. - Copyright (C) 2018, Intel Corporation. All rights reserved.
+ Copyright (C) 2018 - 2019, Intel Corporation. All rights reserved.
SPDX-License-Identifier: BSD-2-Clause-Patent @@ -22,5 +22,9 @@ SpeculationBarrier ( VOID ) { - AsmLfence (); + if (PcdGet8 (PcdSpeculationBarrierType) == 0x01) { + AsmLfence (); + } else if (PcdGet8 (PcdSpeculationBarrierType) == 0x02) { + AsmCpuid (0x01, NULL, NULL, NULL, NULL); + } } -- 2.21.0.windows.1