From 1ed6498c4a0210204bf4b95cc0c0cd6623ad6a0b Mon Sep 17 00:00:00 2001 From: Ruiyu Ni Date: Tue, 6 Nov 2018 17:04:39 +0800 Subject: UefiCpuPkg/CommonFeature: Skip locking when the feature is disabled REF: https://bugzilla.tianocore.org/show_bug.cgi?id=1305 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 Reviewed-by: Eric Dong Cc: Laszlo Ersek --- UefiCpuPkg/Library/CpuCommonFeaturesLib/FeatureControl.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'UefiCpuPkg') diff --git a/UefiCpuPkg/Library/CpuCommonFeaturesLib/FeatureControl.c b/UefiCpuPkg/Library/CpuCommonFeaturesLib/FeatureControl.c index 8c1eb5e..631c836 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.
+ Copyright (c) 2017 - 2018, Intel Corporation. All rights reserved.
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 @@ -185,6 +185,15 @@ LockFeatureControlRegisterInitialize ( MSR_IA32_FEATURE_CONTROL_REGISTER *MsrRegister; // + // When Lock Feature Control Register feature is disabled, + // just skip the MSR lock bit setting. + // The MSR lock bit is cleared by default and write-once in a boot. + // + 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 // core. -- cgit v1.1