Skip to content

Commit a026dc6

Browse files
dkaplan2bp3tk0v
authored andcommitted
x86/bugs: Print enabled attack vectors
Print the status of enabled attack vectors and SMT mitigation status in the boot log for easier reporting and debugging. This information will also be available through sysfs. Signed-off-by: David Kaplan <[email protected]> Signed-off-by: Borislav Petkov (AMD) <[email protected]> Link: https://lore.kernel.org/[email protected]
1 parent 6b21d2f commit a026dc6

File tree

1 file changed

+35
-0
lines changed

1 file changed

+35
-0
lines changed

arch/x86/kernel/cpu/bugs.c

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -189,6 +189,39 @@ DEFINE_STATIC_KEY_FALSE(switch_mm_cond_l1d_flush);
189189
DEFINE_STATIC_KEY_FALSE(cpu_buf_vm_clear);
190190
EXPORT_SYMBOL_GPL(cpu_buf_vm_clear);
191191

192+
#undef pr_fmt
193+
#define pr_fmt(fmt) "mitigations: " fmt
194+
195+
static void __init cpu_print_attack_vectors(void)
196+
{
197+
pr_info("Enabled attack vectors: ");
198+
199+
if (cpu_attack_vector_mitigated(CPU_MITIGATE_USER_KERNEL))
200+
pr_cont("user_kernel, ");
201+
202+
if (cpu_attack_vector_mitigated(CPU_MITIGATE_USER_USER))
203+
pr_cont("user_user, ");
204+
205+
if (cpu_attack_vector_mitigated(CPU_MITIGATE_GUEST_HOST))
206+
pr_cont("guest_host, ");
207+
208+
if (cpu_attack_vector_mitigated(CPU_MITIGATE_GUEST_GUEST))
209+
pr_cont("guest_guest, ");
210+
211+
pr_cont("SMT mitigations: ");
212+
213+
switch (smt_mitigations) {
214+
case SMT_MITIGATIONS_OFF:
215+
pr_cont("off\n");
216+
break;
217+
case SMT_MITIGATIONS_AUTO:
218+
pr_cont("auto\n");
219+
break;
220+
case SMT_MITIGATIONS_ON:
221+
pr_cont("on\n");
222+
}
223+
}
224+
192225
void __init cpu_select_mitigations(void)
193226
{
194227
/*
@@ -209,6 +242,8 @@ void __init cpu_select_mitigations(void)
209242

210243
x86_arch_cap_msr = x86_read_arch_cap_msr();
211244

245+
cpu_print_attack_vectors();
246+
212247
/* Select the proper CPU mitigations before patching alternatives: */
213248
spectre_v1_select_mitigation();
214249
spectre_v2_select_mitigation();

0 commit comments

Comments
 (0)