From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: mx.groups.io; dkim=missing; spf=pass (domain: hpe.com, ip: 148.163.143.35, mailfrom: brian.johnson@hpe.com) Received: from mx0b-002e3701.pphosted.com (mx0b-002e3701.pphosted.com [148.163.143.35]) by groups.io with SMTP; Tue, 30 Apr 2019 15:24:48 -0700 Received: from pps.filterd (m0134423.ppops.net [127.0.0.1]) by mx0b-002e3701.pphosted.com (8.16.0.27/8.16.0.27) with SMTP id x3UMFwgg009110; Tue, 30 Apr 2019 22:24:47 GMT Received: from g2t2353.austin.hpe.com (g2t2353.austin.hpe.com [15.233.44.26]) by mx0b-002e3701.pphosted.com with ESMTP id 2s6xh109b7-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 30 Apr 2019 22:24:46 +0000 Received: from g2t2360.austin.hpecorp.net (g2t2360.austin.hpecorp.net [16.196.225.135]) by g2t2353.austin.hpe.com (Postfix) with ESMTP id 9247877; Tue, 30 Apr 2019 22:24:46 +0000 (UTC) Received: from [10.33.152.19] (bjj-laptop2.americas.hpqcorp.net [10.33.152.19]) by g2t2360.austin.hpecorp.net (Postfix) with ESMTP id 5682440; Tue, 30 Apr 2019 22:24: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: "Brian J. Johnson" Message-ID: <7406e149-8ab2-95a9-2294-d2d9740dc7cd@hpe.com> Date: Tue, 30 Apr 2019 17:24:46 -0500 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.6.1 MIME-Version: 1.0 In-Reply-To: <20190430013012.24008-3-michael.d.kinney@intel.com> X-HPE-SCL: -1 X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:,, definitions=2019-04-30_12:,, signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 malwarescore=0 suspectscore=0 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 mlxscore=0 impostorscore=0 mlxlogscore=811 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1810050000 definitions=main-1904300131 Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit 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 > 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 > 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); > + } > } > Looks good. I'm not a maintainer, but FWIW: Reviewed-by: Brian J. Johnson -- Brian J. Johnson Enterprise X86 Lab Hewlett Packard Enterprise brian.johnson@hpe.com +1 651 683 7521 Office Eagan, MN hpe.com