Explorar o código

MdePkg/BaseLib: Use PcdSpeculationBarrierType

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>
Michael D Kinney %!s(int64=5) %!d(string=hai) anos
pai
achega
aec7465689

+ 1 - 0
MdePkg/Library/BaseLib/BaseLib.inf

@@ -394,6 +394,7 @@
   gEfiMdePkgTokenSpaceGuid.PcdMaximumAsciiStringLength     ## SOMETIMES_CONSUMES
   gEfiMdePkgTokenSpaceGuid.PcdMaximumUnicodeStringLength   ## SOMETIMES_CONSUMES
   gEfiMdePkgTokenSpaceGuid.PcdControlFlowEnforcementPropertyMask   ## SOMETIMES_CONSUMES
+  gEfiMdePkgTokenSpaceGuid.PcdSpeculationBarrierType       ## SOMETIMES_CONSUMES
 
 [FeaturePcd]
   gEfiMdePkgTokenSpaceGuid.PcdVerifyNodeInList  ## CONSUMES

+ 6 - 2
MdePkg/Library/BaseLib/X86SpeculationBarrier.c

@@ -1,7 +1,7 @@
 /** @file
   SpeculationBarrier() function for IA32 and x64.
 
-  Copyright (C) 2018, Intel Corporation. All rights reserved.<BR>
+  Copyright (C) 2018 - 2019, Intel Corporation. All rights reserved.<BR>
 
   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);
+  }
 }