From 13b9149bab28c24798507b152c4d212dd9512175 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michael=20Niew=C3=B6hner?= Date: Sun, 11 Oct 2020 15:56:21 +0200 Subject: cpu/intel/common: rework AES-NI locking MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Simplify the AES-NI code by using msr_set and correct the comment. Change-Id: Ib2cda433bbec0192277839c02a1862b8f41340cb Signed-off-by: Michael Niewöhner Reviewed-on: https://review.coreboot.org/c/coreboot/+/46275 Tested-by: build bot (Jenkins) Reviewed-by: Tim Wawrzynczak Reviewed-by: Nico Huber --- src/cpu/intel/common/common.h | 4 ++-- src/cpu/intel/common/common_init.c | 12 ++++-------- 2 files changed, 6 insertions(+), 10 deletions(-) (limited to 'src/cpu') diff --git a/src/cpu/intel/common/common.h b/src/cpu/intel/common/common.h index aaeca1da109c..57a51e5538c5 100644 --- a/src/cpu/intel/common/common.h +++ b/src/cpu/intel/common/common.h @@ -28,8 +28,8 @@ bool intel_ht_supported(void); bool intel_ht_sibling(void); /* - * Lock AES-NI feature (MSR_FEATURE_CONFIG) to prevent unintended disabling - * as suggested in Intel document 325384-070US. + * Lock AES-NI feature (MSR_FEATURE_CONFIG) to prevent unintended changes + * to the enablement state as suggested in Intel document 325384-070US. */ void set_aesni_lock(void); diff --git a/src/cpu/intel/common/common_init.c b/src/cpu/intel/common/common_init.c index e532c975cb3e..f189c598ac68 100644 --- a/src/cpu/intel/common/common_init.c +++ b/src/cpu/intel/common/common_init.c @@ -266,10 +266,6 @@ void cpu_init_cppc_config(struct cppc_config *config, u32 version) } } -/* - * Lock AES-NI feature (MSR_FEATURE_CONFIG) to prevent unintended disabling - * as suggested in Intel document 325384-070US. - */ void set_aesni_lock(void) { msr_t msr; @@ -279,8 +275,8 @@ void set_aesni_lock(void) return; msr = rdmsr(MSR_FEATURE_CONFIG); - if ((msr.lo & 1) == 0) { - msr.lo |= 1; - wrmsr(MSR_FEATURE_CONFIG, msr); - } + if (msr.lo & AESNI_LOCK) + return; + + msr_set(MSR_FEATURE_CONFIG, AESNI_LOCK); } -- cgit v1.2.3