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>
This commit is contained in:
Michael D Kinney 2019-04-24 14:06:32 -07:00
parent a41b12574e
commit aec7465689
2 changed files with 7 additions and 2 deletions

View File

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

View File

@ -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);
}
}