x86/cpu: Add 'table' argument to cpu_matches()
commit 93920f61c2ad7edb01e63323832585796af75fc9 upstream To make cpu_matches() reusable for other matching tables, have it take a pointer to a x86_cpu_id table as an argument. [ bp: Flip arguments order. ] Signed-off-by: Mark Gross <mgross@linux.intel.com> Signed-off-by: Borislav Petkov <bp@suse.de> Signed-off-by: Thomas Gleixner <tglx@linutronix.de> Reviewed-by: Josh Poimboeuf <jpoimboe@redhat.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
parent
ebb9e39670
commit
4ebffa4b0a
1 changed files with 13 additions and 10 deletions
|
@ -912,9 +912,9 @@ static const __initconst struct x86_cpu_id cpu_vuln_whitelist[] = {
|
||||||
{}
|
{}
|
||||||
};
|
};
|
||||||
|
|
||||||
static bool __init cpu_matches(unsigned long which)
|
static bool __init cpu_matches(const struct x86_cpu_id *table, unsigned long which)
|
||||||
{
|
{
|
||||||
const struct x86_cpu_id *m = x86_match_cpu(cpu_vuln_whitelist);
|
const struct x86_cpu_id *m = x86_match_cpu(table);
|
||||||
|
|
||||||
return m && !!(m->driver_data & which);
|
return m && !!(m->driver_data & which);
|
||||||
}
|
}
|
||||||
|
@ -934,29 +934,32 @@ static void __init cpu_set_bug_bits(struct cpuinfo_x86 *c)
|
||||||
u64 ia32_cap = x86_read_arch_cap_msr();
|
u64 ia32_cap = x86_read_arch_cap_msr();
|
||||||
|
|
||||||
/* Set ITLB_MULTIHIT bug if cpu is not in the whitelist and not mitigated */
|
/* Set ITLB_MULTIHIT bug if cpu is not in the whitelist and not mitigated */
|
||||||
if (!cpu_matches(NO_ITLB_MULTIHIT) && !(ia32_cap & ARCH_CAP_PSCHANGE_MC_NO))
|
if (!cpu_matches(cpu_vuln_whitelist, NO_ITLB_MULTIHIT) &&
|
||||||
|
!(ia32_cap & ARCH_CAP_PSCHANGE_MC_NO))
|
||||||
setup_force_cpu_bug(X86_BUG_ITLB_MULTIHIT);
|
setup_force_cpu_bug(X86_BUG_ITLB_MULTIHIT);
|
||||||
|
|
||||||
if (cpu_matches(NO_SPECULATION))
|
if (cpu_matches(cpu_vuln_whitelist, NO_SPECULATION))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
setup_force_cpu_bug(X86_BUG_SPECTRE_V1);
|
setup_force_cpu_bug(X86_BUG_SPECTRE_V1);
|
||||||
setup_force_cpu_bug(X86_BUG_SPECTRE_V2);
|
setup_force_cpu_bug(X86_BUG_SPECTRE_V2);
|
||||||
|
|
||||||
if (!cpu_matches(NO_SSB) && !(ia32_cap & ARCH_CAP_SSB_NO) &&
|
if (!cpu_matches(cpu_vuln_whitelist, NO_SSB) &&
|
||||||
|
!(ia32_cap & ARCH_CAP_SSB_NO) &&
|
||||||
!cpu_has(c, X86_FEATURE_AMD_SSB_NO))
|
!cpu_has(c, X86_FEATURE_AMD_SSB_NO))
|
||||||
setup_force_cpu_bug(X86_BUG_SPEC_STORE_BYPASS);
|
setup_force_cpu_bug(X86_BUG_SPEC_STORE_BYPASS);
|
||||||
|
|
||||||
if (ia32_cap & ARCH_CAP_IBRS_ALL)
|
if (ia32_cap & ARCH_CAP_IBRS_ALL)
|
||||||
setup_force_cpu_cap(X86_FEATURE_IBRS_ENHANCED);
|
setup_force_cpu_cap(X86_FEATURE_IBRS_ENHANCED);
|
||||||
|
|
||||||
if (!cpu_matches(NO_MDS) && !(ia32_cap & ARCH_CAP_MDS_NO)) {
|
if (!cpu_matches(cpu_vuln_whitelist, NO_MDS) &&
|
||||||
|
!(ia32_cap & ARCH_CAP_MDS_NO)) {
|
||||||
setup_force_cpu_bug(X86_BUG_MDS);
|
setup_force_cpu_bug(X86_BUG_MDS);
|
||||||
if (cpu_matches(MSBDS_ONLY))
|
if (cpu_matches(cpu_vuln_whitelist, MSBDS_ONLY))
|
||||||
setup_force_cpu_bug(X86_BUG_MSBDS_ONLY);
|
setup_force_cpu_bug(X86_BUG_MSBDS_ONLY);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!cpu_matches(NO_SWAPGS))
|
if (!cpu_matches(cpu_vuln_whitelist, NO_SWAPGS))
|
||||||
setup_force_cpu_bug(X86_BUG_SWAPGS);
|
setup_force_cpu_bug(X86_BUG_SWAPGS);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -974,7 +977,7 @@ static void __init cpu_set_bug_bits(struct cpuinfo_x86 *c)
|
||||||
(ia32_cap & ARCH_CAP_TSX_CTRL_MSR)))
|
(ia32_cap & ARCH_CAP_TSX_CTRL_MSR)))
|
||||||
setup_force_cpu_bug(X86_BUG_TAA);
|
setup_force_cpu_bug(X86_BUG_TAA);
|
||||||
|
|
||||||
if (cpu_matches(NO_MELTDOWN))
|
if (cpu_matches(cpu_vuln_whitelist, NO_MELTDOWN))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
/* Rogue Data Cache Load? No! */
|
/* Rogue Data Cache Load? No! */
|
||||||
|
@ -983,7 +986,7 @@ static void __init cpu_set_bug_bits(struct cpuinfo_x86 *c)
|
||||||
|
|
||||||
setup_force_cpu_bug(X86_BUG_CPU_MELTDOWN);
|
setup_force_cpu_bug(X86_BUG_CPU_MELTDOWN);
|
||||||
|
|
||||||
if (cpu_matches(NO_L1TF))
|
if (cpu_matches(cpu_vuln_whitelist, NO_L1TF))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
setup_force_cpu_bug(X86_BUG_L1TF);
|
setup_force_cpu_bug(X86_BUG_L1TF);
|
||||||
|
|
Loading…
Add table
Reference in a new issue