Skip to content

Commit 56563f5

Browse files
konradwilkKAGA-KOKO
authored andcommitted
x86/bugs: Move the l1tf function and define pr_fmt properly
The pr_warn in l1tf_select_mitigation would have used the prior pr_fmt which was defined as "Spectre V2 : ". Move the function to be past SSBD and also define the pr_fmt. Fixes: 17dbca1 ("x86/speculation/l1tf: Add sysfs reporting for l1tf") Signed-off-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com> Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
1 parent 377eeaa commit 56563f5

File tree

1 file changed

+29
-26
lines changed

1 file changed

+29
-26
lines changed

arch/x86/kernel/cpu/bugs.c

Lines changed: 29 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -209,32 +209,6 @@ static void x86_amd_ssb_disable(void)
209209
wrmsrl(MSR_AMD64_LS_CFG, msrval);
210210
}
211211

212-
static void __init l1tf_select_mitigation(void)
213-
{
214-
u64 half_pa;
215-
216-
if (!boot_cpu_has_bug(X86_BUG_L1TF))
217-
return;
218-
219-
#if CONFIG_PGTABLE_LEVELS == 2
220-
pr_warn("Kernel not compiled for PAE. No mitigation for L1TF\n");
221-
return;
222-
#endif
223-
224-
/*
225-
* This is extremely unlikely to happen because almost all
226-
* systems have far more MAX_PA/2 than RAM can be fit into
227-
* DIMM slots.
228-
*/
229-
half_pa = (u64)l1tf_pfn_limit() << PAGE_SHIFT;
230-
if (e820__mapped_any(half_pa, ULLONG_MAX - half_pa, E820_TYPE_RAM)) {
231-
pr_warn("System has more than MAX_PA/2 memory. L1TF mitigation not effective.\n");
232-
return;
233-
}
234-
235-
setup_force_cpu_cap(X86_FEATURE_L1TF_PTEINV);
236-
}
237-
238212
#ifdef RETPOLINE
239213
static bool spectre_v2_bad_module;
240214

@@ -681,6 +655,35 @@ void x86_spec_ctrl_setup_ap(void)
681655
x86_amd_ssb_disable();
682656
}
683657

658+
#undef pr_fmt
659+
#define pr_fmt(fmt) "L1TF: " fmt
660+
static void __init l1tf_select_mitigation(void)
661+
{
662+
u64 half_pa;
663+
664+
if (!boot_cpu_has_bug(X86_BUG_L1TF))
665+
return;
666+
667+
#if CONFIG_PGTABLE_LEVELS == 2
668+
pr_warn("Kernel not compiled for PAE. No mitigation for L1TF\n");
669+
return;
670+
#endif
671+
672+
/*
673+
* This is extremely unlikely to happen because almost all
674+
* systems have far more MAX_PA/2 than RAM can be fit into
675+
* DIMM slots.
676+
*/
677+
half_pa = (u64)l1tf_pfn_limit() << PAGE_SHIFT;
678+
if (e820__mapped_any(half_pa, ULLONG_MAX - half_pa, E820_TYPE_RAM)) {
679+
pr_warn("System has more than MAX_PA/2 memory. L1TF mitigation not effective.\n");
680+
return;
681+
}
682+
683+
setup_force_cpu_cap(X86_FEATURE_L1TF_PTEINV);
684+
}
685+
#undef pr_fmt
686+
684687
#ifdef CONFIG_SYSFS
685688

686689
static ssize_t cpu_show_common(struct device *dev, struct device_attribute *attr,

0 commit comments

Comments
 (0)