Hi Ray, I think we should add comments to mention that if the Lock bit is already set, driver can't disable it. So driver can directly return success if state is FALSE.
With that comments, Reviewed-by: Eric Dong <[email protected]> Thanks, Eric > -----Original Message----- > From: Ni, Ruiyu > Sent: Tuesday, November 6, 2018 5:06 PM > To: [email protected] > Cc: Dong, Eric <[email protected]>; Laszlo Ersek <[email protected]> > Subject: [PATCH] UefiCpuPkg/CommonFeature: Skip locking when the > feature is disabled > > Today's code unconditionally sets the IA32_FEATURE_CONTROL.Lock to 1 no > matter the feature is enabled or not. > > The patch fixes this issue by only setting the Lock bit to 1 when the feature > is > enabled. > > Contributed-under: TianoCore Contribution Agreement 1.1 > Signed-off-by: Ruiyu Ni <[email protected]> > Cc: Eric Dong <[email protected]> > Cc: Laszlo Ersek <[email protected]> > --- > UefiCpuPkg/Library/CpuCommonFeaturesLib/FeatureControl.c | 10 > +++++++++- > 1 file changed, 9 insertions(+), 1 deletion(-) > > diff --git a/UefiCpuPkg/Library/CpuCommonFeaturesLib/FeatureControl.c > b/UefiCpuPkg/Library/CpuCommonFeaturesLib/FeatureControl.c > index 8c1eb5eb4f..0b85f25f90 100644 > --- a/UefiCpuPkg/Library/CpuCommonFeaturesLib/FeatureControl.c > +++ b/UefiCpuPkg/Library/CpuCommonFeaturesLib/FeatureControl.c > @@ -1,7 +1,7 @@ > /** @file > Features in MSR_IA32_FEATURE_CONTROL register. > > - Copyright (c) 2017, Intel Corporation. All rights reserved.<BR> > + Copyright (c) 2017 - 2018, Intel Corporation. All rights > + reserved.<BR> > This program and the accompanying materials > are licensed and made available under the terms and conditions of the BSD > License > which accompanies this distribution. The full text of the license may be > found at @@ -184,6 +184,14 @@ LockFeatureControlRegisterInitialize ( { > MSR_IA32_FEATURE_CONTROL_REGISTER *MsrRegister; > > + // > + // When Lock Feature Control Register feature is disabled, // just > + skip the MSR lock bit setting. > + // > + if (!State) { > + return RETURN_SUCCESS; > + } > + > // > // The scope of Lock bit in the MSR_IA32_FEATURE_CONTROL is core for > // below processor type, only program MSR_IA32_FEATURE_CONTROL for > thread 0 in each > -- > 2.16.1.windows.1 _______________________________________________ edk2-devel mailing list [email protected] https://lists.01.org/mailman/listinfo/edk2-devel

