summaryrefslogtreecommitdiff
path: root/src/cpu
diff options
context:
space:
mode:
authorMichael Niewöhner <foss@mniewoehner.de>2020-10-11 15:56:21 +0200
committerNico Huber <nico.h@gmx.de>2020-10-19 21:01:53 +0000
commit13b9149bab28c24798507b152c4d212dd9512175 (patch)
treee7a5ec3b802b5f2667988fe81b1a85bf6e50412d /src/cpu
parent8b4a9380b54220a352cbc5eb55f600f5dce8475b (diff)
downloadcoreboot-13b9149bab28c24798507b152c4d212dd9512175.tar.xz
cpu/intel/common: rework AES-NI locking
Simplify the AES-NI code by using msr_set and correct the comment. Change-Id: Ib2cda433bbec0192277839c02a1862b8f41340cb Signed-off-by: Michael Niewöhner <foss@mniewoehner.de> Reviewed-on: https://review.coreboot.org/c/coreboot/+/46275 Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Tim Wawrzynczak <twawrzynczak@chromium.org> Reviewed-by: Nico Huber <nico.h@gmx.de>
Diffstat (limited to 'src/cpu')
-rw-r--r--src/cpu/intel/common/common.h4
-rw-r--r--src/cpu/intel/common/common_init.c12
2 files changed, 6 insertions, 10 deletions
diff --git a/src/cpu/intel/common/common.h b/src/cpu/intel/common/common.h
index aaeca1da10..57a51e5538 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 e532c975cb..f189c598ac 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);
}