From: Alejandro Jimenez Date: Tue, 22 Jan 2019 21:40:04 +0000 (-0500) Subject: x86/speculation: Clean up retpoline code in bugs.c X-Git-Tag: v4.1.12-124.31.3~288 X-Git-Url: https://www.infradead.org/git/?a=commitdiff_plain;h=0ce7a636075aaf7c6e6dcb0b3d3d72a3ae405e42;p=users%2Fjedix%2Flinux-maple.git x86/speculation: Clean up retpoline code in bugs.c Now that the minimal retpoline modes are removed, also remove unnecessary checks to simplify retpoline code. Orabug: 29211617 Signed-off-by: Alejandro Jimenez Reviewed-by: Boris Ostrovsky Signed-off-by: Brian Maly --- diff --git a/arch/x86/kernel/cpu/bugs_64.c b/arch/x86/kernel/cpu/bugs_64.c index a4c824ce0994..e5251bfc606e 100644 --- a/arch/x86/kernel/cpu/bugs_64.c +++ b/arch/x86/kernel/cpu/bugs_64.c @@ -457,26 +457,22 @@ static void retpoline_init(void) setup_force_cpu_cap(X86_FEATURE_RETPOLINE); if (boot_cpu_data.x86_vendor == X86_VENDOR_AMD) { - if (!boot_cpu_has(X86_FEATURE_LFENCE_RDTSC)) - pr_err("Spectre mitigation: LFENCE not serializing, setting up generic retpoline\n"); - else + if (boot_cpu_has(X86_FEATURE_LFENCE_RDTSC)) { setup_force_cpu_cap(X86_FEATURE_RETPOLINE_AMD); + retpoline_mode = SPECTRE_V2_RETPOLINE_AMD; + return; + } + pr_err("Spectre mitigation: LFENCE not serializing, setting up generic retpoline\n"); } - if (boot_cpu_data.x86_vendor == X86_VENDOR_AMD && - boot_cpu_has(X86_FEATURE_LFENCE_RDTSC)) - retpoline_mode = SPECTRE_V2_RETPOLINE_AMD; - else - retpoline_mode = SPECTRE_V2_RETPOLINE_GENERIC; + retpoline_mode = SPECTRE_V2_RETPOLINE_GENERIC; } static void __init retpoline_activate(enum spectre_v2_mitigation mode) { retpoline_enable(); /* IBRS is unnecessary with retpoline mitigation. */ - if (mode == SPECTRE_V2_RETPOLINE_GENERIC || - mode == SPECTRE_V2_RETPOLINE_AMD) - disable_ibrs_and_friends(false); + disable_ibrs_and_friends(false); } static void spec_ctrl_flush_all_cpus(u32 msr_nr, u64 val)