Received: by 2002:ad5:4acb:0:0:0:0:0 with SMTP id n11csp4701174imw; Tue, 12 Jul 2022 12:41:23 -0700 (PDT) X-Google-Smtp-Source: AGRyM1vSElBmHU2fNnnCM240+ky2IC/+/Altyvyftbk+I+e122fq/8RvfJR8AZAbn8fvL/0N+HlC X-Received: by 2002:a17:90b:693:b0:1ef:4d94:412d with SMTP id m19-20020a17090b069300b001ef4d94412dmr6080433pjz.27.1657654883010; Tue, 12 Jul 2022 12:41:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1657654883; cv=none; d=google.com; s=arc-20160816; b=Ipx3Nx2NkobYt9GZoMeNe7HdnYn4ZDLJedtYac279tHY8CsrINDeKMAM2t1uNB5bWo Pattoe7Sy7+GC8Ar8T3h5L4dzDQdRH/XaG4wFdEqkHYhQXB5VLZXrleMU5/T9SZDzuZH dsQlXMElikXfT+v1nXPr2jhtiea/Xen9VRXYUh2D7GWBTmHH/YNvss8W0WkzlDp6fqpj G85zf/epCr1UvcrwXxKrVTNW9Rd0bbhvuoYHD2oNRDzIoILKr/S5mPknM0xVefzoNWS2 vVUAZTPbz8mea6N8ssuPzKAjTtcPiQZC7wB6iTe8DH4FAbopR/JNKJ6vygrP/KfZ6gkM mKSQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=iGo69DXoe0QchfyW2nvHxW0aQX951QafvKFYewWclmw=; b=e2Kl2KEhyaWYq1EX8VqMfePHQErOcIU7hrXauGNS0jxPqjzoU3M7T512nfU4ky+hDR iQtTs4O6U/yzS0ZNWakVzok+y7U6bptrTUJ4/ygfDE1mzSmeVu0vK1sYuV9mhGoNHEFG akh1k9T2Xxjfm2BVpNnNn0SL8cMpmMeDTcyzbpLJ3XirJuOVDzbP5avFgEVo4huc/J/b /eKnk9noJhK2sEi1zqfEOMTWHEgb5B8pds3DShqzDZftOu0hf6l8pI1vzx0eXxy6DUSV c0VNaln2ZdvNmcRA1LjqLkx0B9+Ib8t4MRhMLDNLzID/pHwcGGHZK4Ke5KUIHGgQALU3 JrXw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=LDU5hcgN; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id oo13-20020a17090b1c8d00b001efaa456f88si20941316pjb.78.2022.07.12.12.41.10; Tue, 12 Jul 2022 12:41:23 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=LDU5hcgN; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234554AbiGLSyg (ORCPT + 99 others); Tue, 12 Jul 2022 14:54:36 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57578 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234745AbiGLSyB (ORCPT ); Tue, 12 Jul 2022 14:54:01 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2B01FD514E; Tue, 12 Jul 2022 11:45:41 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 30C6860AC3; Tue, 12 Jul 2022 18:45:31 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 3C1DCC3411C; Tue, 12 Jul 2022 18:45:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1657651530; bh=aLjl1sz+9TKvEHYRGFyleZovb2+KqWCsBPr2RrNcDeM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=LDU5hcgNvLDJY1dIRP6U/jZbWbI8LP8CpajyLOxXovtUJEZlh4ytuFOD3KlQWg/3y 1zB7ctLEI9xoBeveKoPxrydaQZeXyynA7NJvX3IzxtB+MYmFVYKMPEfrSmkeMl2BmX dkKOoiewAXm/Hk6dRWj7jqLqLw9hNXRTHa40JpJU= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, "Peter Zijlstra (Intel)" , Borislav Petkov , Josh Poimboeuf , Thadeu Lima de Souza Cascardo , Ben Hutchings Subject: [PATCH 5.10 103/130] x86/bugs: Split spectre_v2_select_mitigation() and spectre_v2_user_select_mitigation() Date: Tue, 12 Jul 2022 20:39:09 +0200 Message-Id: <20220712183251.225898476@linuxfoundation.org> X-Mailer: git-send-email 2.37.0 In-Reply-To: <20220712183246.394947160@linuxfoundation.org> References: <20220712183246.394947160@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.7 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Peter Zijlstra commit 166115c08a9b0b846b783088808a27d739be6e8d upstream. retbleed will depend on spectre_v2, while spectre_v2_user depends on retbleed. Break this cycle. Signed-off-by: Peter Zijlstra (Intel) Signed-off-by: Borislav Petkov Reviewed-by: Josh Poimboeuf Signed-off-by: Borislav Petkov Signed-off-by: Thadeu Lima de Souza Cascardo Signed-off-by: Ben Hutchings Signed-off-by: Greg Kroah-Hartman --- arch/x86/kernel/cpu/bugs.c | 25 +++++++++++++++++-------- 1 file changed, 17 insertions(+), 8 deletions(-) --- a/arch/x86/kernel/cpu/bugs.c +++ b/arch/x86/kernel/cpu/bugs.c @@ -37,8 +37,9 @@ #include "cpu.h" static void __init spectre_v1_select_mitigation(void); -static void __init retbleed_select_mitigation(void); static void __init spectre_v2_select_mitigation(void); +static void __init retbleed_select_mitigation(void); +static void __init spectre_v2_user_select_mitigation(void); static void __init ssb_select_mitigation(void); static void __init l1tf_select_mitigation(void); static void __init mds_select_mitigation(void); @@ -137,13 +138,19 @@ void __init check_bugs(void) /* Select the proper CPU mitigations before patching alternatives: */ spectre_v1_select_mitigation(); + spectre_v2_select_mitigation(); + /* + * retbleed_select_mitigation() relies on the state set by + * spectre_v2_select_mitigation(); specifically it wants to know about + * spectre_v2=ibrs. + */ retbleed_select_mitigation(); /* - * spectre_v2_select_mitigation() relies on the state set by + * spectre_v2_user_select_mitigation() relies on the state set by * retbleed_select_mitigation(); specifically the STIBP selection is * forced for UNRET. */ - spectre_v2_select_mitigation(); + spectre_v2_user_select_mitigation(); ssb_select_mitigation(); l1tf_select_mitigation(); md_clear_select_mitigation(); @@ -969,13 +976,15 @@ static void __init spec_v2_user_print_co pr_info("spectre_v2_user=%s forced on command line.\n", reason); } +static __ro_after_init enum spectre_v2_mitigation_cmd spectre_v2_cmd; + static enum spectre_v2_user_cmd __init -spectre_v2_parse_user_cmdline(enum spectre_v2_mitigation_cmd v2_cmd) +spectre_v2_parse_user_cmdline(void) { char arg[20]; int ret, i; - switch (v2_cmd) { + switch (spectre_v2_cmd) { case SPECTRE_V2_CMD_NONE: return SPECTRE_V2_USER_CMD_NONE; case SPECTRE_V2_CMD_FORCE: @@ -1010,7 +1019,7 @@ static inline bool spectre_v2_in_ibrs_mo } static void __init -spectre_v2_user_select_mitigation(enum spectre_v2_mitigation_cmd v2_cmd) +spectre_v2_user_select_mitigation(void) { enum spectre_v2_user_mitigation mode = SPECTRE_V2_USER_NONE; bool smt_possible = IS_ENABLED(CONFIG_SMP); @@ -1023,7 +1032,7 @@ spectre_v2_user_select_mitigation(enum s cpu_smt_control == CPU_SMT_NOT_SUPPORTED) smt_possible = false; - cmd = spectre_v2_parse_user_cmdline(v2_cmd); + cmd = spectre_v2_parse_user_cmdline(); switch (cmd) { case SPECTRE_V2_USER_CMD_NONE: goto set_mode; @@ -1347,7 +1356,7 @@ static void __init spectre_v2_select_mit } /* Set up IBPB and STIBP depending on the general spectre V2 command */ - spectre_v2_user_select_mitigation(cmd); + spectre_v2_cmd = cmd; } static void update_stibp_msr(void * __unused)