[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20240419-gds-lock-v1-1-adcbef6ce24b@linux.intel.com>
Date: Fri, 19 Apr 2024 10:47:09 -0700
From: Pawan Gupta <pawan.kumar.gupta@...ux.intel.com>
To: linux-kernel@...r.kernel.org
Cc: x86@...nel.org, dan.j.williams@...el.com, bernie.keany@...el.com,
charishma1.gairuboyina@...el.com, chang.seok.bae@...el.com,
Josh Poimboeuf <jpoimboe@...nel.org>,
daniel.sneddon@...ux.intel.com,
antonio.gomez.iglesias@...ux.intel.com
Subject: [PATCH 15/14] x86/gds: Lock GDS mitigation when keylocker feature is
present
In order to safely enable Intel Keylocker feature, Gather Data Sampling
(GDS) mitigation should be enabled and locked. Hardware provides a way to
lock the mitigation, such that the mitigation cannot be disabled until the
CPU is reset. Currently, GDS mitigation is enabled without the lock.
Below is the recommendation from Intel:
"Intel recommends that system software does not enable Key Locker (by
setting CR4.KL) unless the GDS mitigation is enabled (IA32_MCU_OPT_CTRL
[GDS_MITG_DIS] (bit 4) is 0) and locked (IA32_MCU_OPT_CTRL
[GDS_MITG_LOCK](bit 5) is 1). This will prevent an adversary that takes
control of the system from turning off the mitigation in order to infer
the keys behind Key Locker handles." [1]
When GDS mitigation is enabled, and Keylocker feature is present, also lock
the mitigation.
[1] Gather Data Sampling (ID# 785676)
https://www.intel.com/content/www/us/en/developer/articles/technical/software-security-guidance/technical-documentation/gather-data-sampling.html
Signed-off-by: Pawan Gupta <pawan.kumar.gupta@...ux.intel.com>
---
This should ideally go before the patch that enables Keylocker. It is
only compile tested.
arch/x86/kernel/cpu/bugs.c | 12 ++++++++++--
1 file changed, 10 insertions(+), 2 deletions(-)
diff --git a/arch/x86/kernel/cpu/bugs.c b/arch/x86/kernel/cpu/bugs.c
index ca295b0c1eee..2777a58110e0 100644
--- a/arch/x86/kernel/cpu/bugs.c
+++ b/arch/x86/kernel/cpu/bugs.c
@@ -755,8 +755,8 @@ EXPORT_SYMBOL_GPL(gds_ucode_mitigated);
void update_gds_msr(void)
{
- u64 mcu_ctrl_after;
- u64 mcu_ctrl;
+ u64 mcu_ctrl, mcu_ctrl_after;
+ u64 gds_lock = 0;
switch (gds_mitigation) {
case GDS_MITIGATION_OFF:
@@ -769,6 +769,8 @@ void update_gds_msr(void)
* the same state. Make sure the mitigation is enabled on all
* CPUs.
*/
+ gds_lock = GDS_MITG_LOCKED;
+ fallthrough;
case GDS_MITIGATION_FULL:
rdmsrl(MSR_IA32_MCU_OPT_CTRL, mcu_ctrl);
mcu_ctrl &= ~GDS_MITG_DIS;
@@ -779,6 +781,7 @@ void update_gds_msr(void)
return;
}
+ mcu_ctrl |= gds_lock;
wrmsrl(MSR_IA32_MCU_OPT_CTRL, mcu_ctrl);
/*
@@ -840,6 +843,11 @@ static void __init gds_select_mitigation(void)
gds_mitigation = GDS_MITIGATION_FULL_LOCKED;
}
+ /* Keylocker can only be enabled when GDS mitigation is locked */
+ if (boot_cpu_has(X86_FEATURE_KEYLOCKER) &&
+ gds_mitigation == GDS_MITIGATION_FULL)
+ gds_mitigation = GDS_MITIGATION_FULL_LOCKED;
+
update_gds_msr();
out:
pr_info("%s\n", gds_strings[gds_mitigation]);
---
base-commit: 0bbac3facb5d6cc0171c45c9873a2dc96bea9680
change-id: 20240418-gds-lock-26ecbce88470
Best regards,
--
Thanks,
Pawan
Powered by blists - more mailing lists