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 <ruiyu.ni@intel.com>
Reviewed-by: Eric Dong <eric.dong@intel.com>
Cc: Laszlo Ersek <lersek@redhat.com>
This commit is contained in:
Ruiyu Ni 2018-11-06 17:04:39 +08:00
parent 328409ce8d
commit 1ed6498c4a
1 changed files with 10 additions and 1 deletions

View File

@ -1,7 +1,7 @@
/** @file /** @file
Features in MSR_IA32_FEATURE_CONTROL register. 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 This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License 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 which accompanies this distribution. The full text of the license may be found at
@ -184,6 +184,15 @@ LockFeatureControlRegisterInitialize (
{ {
MSR_IA32_FEATURE_CONTROL_REGISTER *MsrRegister; 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 // 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 // below processor type, only program MSR_IA32_FEATURE_CONTROL for thread 0 in each