From: Konrad Rzeszutek Wilk Date: Thu, 1 Feb 2018 15:43:41 +0000 (-0500) Subject: x86/spectre_v2: Add disable_ibrs_and_friends X-Git-Tag: v4.1.12-124.31.3~1185 X-Git-Url: https://www.infradead.org/git/?a=commitdiff_plain;h=79a6584613716f5531f7c2f05e8a73f190de2c97;p=users%2Fjedix%2Flinux-maple.git x86/spectre_v2: Add disable_ibrs_and_friends Instead of having the three calls to set_{ibrs,ibpb,lfence}_disabled. Orabug: 27477743 CVE: CVE-2017-5715 Signed-off-by: Konrad Rzeszutek Wilk Reviewed-by: Darren Kenny Reviewed-by: Pavel Tatashin --- diff --git a/arch/x86/kernel/cpu/bugs_64.c b/arch/x86/kernel/cpu/bugs_64.c index db4f8410d59a..44a2177a4b62 100644 --- a/arch/x86/kernel/cpu/bugs_64.c +++ b/arch/x86/kernel/cpu/bugs_64.c @@ -197,6 +197,13 @@ static enum spectre_v2_mitigation __init ibrs_select(void) return mode; } +static void __init disable_ibrs_and_friends(void) +{ + set_ibrs_disabled(); + set_ibpb_disabled(); + set_lfence_disabled(); +} + static void __init spectre_v2_select_mitigation(void) { enum spectre_v2_mitigation_cmd cmd = spectre_v2_parse_cmdline(); @@ -208,17 +215,13 @@ static void __init spectre_v2_select_mitigation(void) */ if (!boot_cpu_has_bug(X86_BUG_SPECTRE_V2) && (cmd == SPECTRE_V2_CMD_NONE || cmd == SPECTRE_V2_CMD_AUTO)) { - set_ibrs_disabled(); - set_ibpb_disabled(); - set_lfence_disabled(); + disable_ibrs_and_friends(); return; } switch (cmd) { case SPECTRE_V2_CMD_NONE: - set_ibrs_disabled(); - set_ibpb_disabled(); - set_lfence_disabled(); + disable_ibrs_and_friends(); return; case SPECTRE_V2_CMD_FORCE: @@ -283,9 +286,7 @@ display: /* IBRS is unnecessary with retpoline mitigation. */ if (mode == SPECTRE_V2_RETPOLINE_GENERIC || mode == SPECTRE_V2_RETPOLINE_AMD) { - set_ibrs_disabled(); - set_ipbp_disabled(); - set_lfence_disabled(); + disable_ibrs_and_friends(); } }