]> git.proxmox.com Git - mirror_edk2.git/commitdiff
MdePkg/BaseLib: Use PcdSpeculationBarrierType
authorMichael D Kinney <michael.d.kinney@intel.com>
Wed, 24 Apr 2019 21:06:32 +0000 (14:06 -0700)
committerMichael D Kinney <michael.d.kinney@intel.com>
Tue, 30 Apr 2019 23:39:15 +0000 (16:39 -0700)
Use PcdSpeculationBarrierType in the x86 implementation
of SpeculationBarrier() to select between AsmLfence(),
AsmCpuid(), and no operation.

Cc: Liming Gao <liming.gao@intel.com>
Signed-off-by: Michael D Kinney <michael.d.kinney@intel.com>
Reviewed-by: Laszlo Ersek <lersek@redhat.com>
Reviewed-by: Brian J. Johnson <brian.johnson@hpe.com>
MdePkg/Library/BaseLib/BaseLib.inf
MdePkg/Library/BaseLib/X86SpeculationBarrier.c

index 533e83e0b223738e9786905956a77ffb300b6132..3586beb0ab5c53646f2edcd05d751d33526d1ebc 100644 (file)
   gEfiMdePkgTokenSpaceGuid.PcdMaximumAsciiStringLength     ## SOMETIMES_CONSUMES\r
   gEfiMdePkgTokenSpaceGuid.PcdMaximumUnicodeStringLength   ## SOMETIMES_CONSUMES\r
   gEfiMdePkgTokenSpaceGuid.PcdControlFlowEnforcementPropertyMask   ## SOMETIMES_CONSUMES\r
+  gEfiMdePkgTokenSpaceGuid.PcdSpeculationBarrierType       ## SOMETIMES_CONSUMES\r
 \r
 [FeaturePcd]\r
   gEfiMdePkgTokenSpaceGuid.PcdVerifyNodeInList  ## CONSUMES\r
index 8e5f983bb813ca3267cc7e5f4a350c1da64e499b..b28fd8de9bcb8a0266d7c8246d50bffbdfd30cdf 100644 (file)
@@ -1,7 +1,7 @@
 /** @file\r
   SpeculationBarrier() function for IA32 and x64.\r
 \r
-  Copyright (C) 2018, Intel Corporation. All rights reserved.<BR>\r
+  Copyright (C) 2018 - 2019, Intel Corporation. All rights reserved.<BR>\r
 \r
   SPDX-License-Identifier: BSD-2-Clause-Patent\r
 \r
@@ -22,5 +22,9 @@ SpeculationBarrier (
   VOID\r
   )\r
 {\r
-  AsmLfence ();\r
+  if (PcdGet8 (PcdSpeculationBarrierType) == 0x01) {\r
+    AsmLfence ();\r
+  } else if (PcdGet8 (PcdSpeculationBarrierType) == 0x02) {\r
+    AsmCpuid (0x01, NULL, NULL, NULL, NULL);\r
+  }\r
 }\r