From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: mx.groups.io; dkim=missing; spf=pass (domain: redhat.com, ip: 209.132.183.28, mailfrom: lersek@redhat.com) Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by groups.io with SMTP; Tue, 30 Apr 2019 04:49:47 -0700 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 5D1013087940; Tue, 30 Apr 2019 11:49:47 +0000 (UTC) Received: from lacos-laptop-7.usersys.redhat.com (ovpn-121-42.rdu2.redhat.com [10.10.121.42]) by smtp.corp.redhat.com (Postfix) with ESMTP id 848F417AEC; Tue, 30 Apr 2019 11:49:46 +0000 (UTC) Subject: Re: [edk2-devel] [Patch V2 2/6] MdePkg/BaseLib: Use PcdSpeculationBarrierType To: devel@edk2.groups.io, michael.d.kinney@intel.com Cc: Liming Gao References: <20190430013012.24008-1-michael.d.kinney@intel.com> <20190430013012.24008-3-michael.d.kinney@intel.com> From: "Laszlo Ersek" Message-ID: <14c3be99-8187-39ab-2293-bc7aaa6b0abe@redhat.com> Date: Tue, 30 Apr 2019 13:49:45 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.9.1 MIME-Version: 1.0 In-Reply-To: <20190430013012.24008-3-michael.d.kinney@intel.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.45]); Tue, 30 Apr 2019 11:49:47 +0000 (UTC) Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit On 04/30/19 03:30, Michael D Kinney wrote: > 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 > --- > 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 So, based on the example of MdePkg/Library/SecPeiDxeTimerLibCpu/SecPeiDxeTimerLibCpu.inf and a few other INF files, I think we could use [Pcd.IA32, Pcd.X64] here as well. Just an idea. Reviewed-by: Laszlo Ersek Thanks Laszlo > 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); > + } > } >