[edk2-devel] [Patch V2 2/6] MdePkg/BaseLib: Use PcdSpeculationBarrierType

Brian J. Johnson brian.johnson at hpe.com
Tue Apr 30 22:24:46 UTC 2019


On 4/29/19 8:30 PM, Michael D Kinney wrote:
> Use PcdSpeculationBarrierType in the x86 implementation
> of SpeculationBarrier() to select between AsmLfence(),
> AsmCpuid(), and no operation.
> 
> Cc: Liming Gao <liming.gao at intel.com>
> Signed-off-by: Michael D Kinney <michael.d.kinney at intel.com>
> ---
>   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.<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);
> +  }
>   }
> 

Looks good.  I'm not a maintainer, but FWIW:

Reviewed-by: Brian J. Johnson <brian.johnson at hpe.com>

-- 
Brian J. Johnson
Enterprise X86 Lab

Hewlett Packard Enterprise

brian.johnson at hpe.com
+1 651 683 7521  Office

Eagan, MN
hpe.com

-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.

View/Reply Online (#39883): https://edk2.groups.io/g/devel/message/39883
Mute This Topic: https://groups.io/mt/31415901/1813853
Group Owner: devel+owner at edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub  [edk2-devel-archive at redhat.com]
-=-=-=-=-=-=-=-=-=-=-=-




More information about the edk2-devel-archive mailing list