Received: by 2002:ac0:da4c:0:0:0:0:0 with SMTP id a12csp458808imi; Fri, 22 Jul 2022 02:50:48 -0700 (PDT) X-Google-Smtp-Source: AGRyM1s2jxMBZpDGrubDJmRBVAxhwtst/RhU4sHByKSjtM4xfXs2HhH8X4rzHSEZvK9YfPKUVtbC X-Received: by 2002:a63:f011:0:b0:41a:6262:bfcd with SMTP id k17-20020a63f011000000b0041a6262bfcdmr2420617pgh.40.1658483447944; Fri, 22 Jul 2022 02:50:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1658483447; cv=none; d=google.com; s=arc-20160816; b=A0OoOInfEHrCQAH8ri5zZ2XzmHGfZOGYu2EL9GVDRF8kgrV6v7+1zfD9HJ6UxNMTAJ PQJ9qBRRQUZzABCZp59WVBQveA2f7kOpmFT92TtRGW5JWEj71H1EIPQejXbWyMEYnVSS +NOiVhugXfeyGhMqXxgCw4/PQsmIUsM4Kw7sIGHA0oKrN/VRqdav+BRAGXTWSE8mp15l SroilWG/lRsk5HOOsQss0xwzAOcZMLqb+D+b7CbDQECy0FrtiE893yLRQGa//juKOQ3M 8+BvXJDm9ghNF9nDzh0uuzIELEwgmo1PlrolFQ9+dhqi9AYCxNdQNgdmOIHfkuVptMYY 3Eug== 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=g/nb/gYUPzEU1IRcwXaaVDz55Vb/h0VJ4Gm7neKCTt0=; b=xOUxKPWaxDJSxtJIaqssFLdpgErRrn6abvNkq/aqYJyS34/gLXCvTjACsTGz267hZW EdJdvyyFaC4l6Ahc+gUGbnGZLKnyW/1oHB5M9YfB9EM3l/ObKKniNdo05JIfkvrIdAeP cGS/6yxW+dZ0ny/YJgDOaNpImGUGgtCp2VUs5V8lDRzigOmEzZMwu7Emm/zxgEh2pJtO qKp3ZO3lp/YDRqRbAPIbeSuoLDqdTAkg9rMZi7lH7J5T5b//poUTEG+uCaK7kYiNkm2y G7lzx4W4LmvG6tSkpUujOrjzWNi49VFcNy3XwWAYG1RD3nxvCUiGuCZOI/E+jHD9A6Sg gdVw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=PtSxL2dH; 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 b14-20020a170903228e00b0016a147b8f68si6554513plh.177.2022.07.22.02.50.32; Fri, 22 Jul 2022 02:50:47 -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=PtSxL2dH; 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 S235318AbiGVJW1 (ORCPT + 99 others); Fri, 22 Jul 2022 05:22:27 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34274 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236016AbiGVJVn (ORCPT ); Fri, 22 Jul 2022 05:21:43 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4B0EEA874A; Fri, 22 Jul 2022 02:14:20 -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 DBD5B61FDF; Fri, 22 Jul 2022 09:14:19 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id DE3F6C341C6; Fri, 22 Jul 2022 09:14:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1658481259; bh=LkVA0xiAiMwnxQTu6pYRQJruQNd4vWhOLkXE1iKbhYc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=PtSxL2dHfPBaCaNV/rufxI3K21A7MhCC9yRMC75YRttsfuoEfTEc3FGJTtoL/IOL1 Hlxwx+2CGHtPJH+N8s7Vf0DeEC73TcCFkfb+AZrugSpBkSPLPnmQRflAW4uDFARs+N 4LhSpYnbqLMW2asnx4fNmlJSIp+/55x6SJBazYZs= 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 Subject: [PATCH 5.15 49/89] x86/bugs: Split spectre_v2_select_mitigation() and spectre_v2_user_select_mitigation() Date: Fri, 22 Jul 2022 11:11:23 +0200 Message-Id: <20220722091136.110453553@linuxfoundation.org> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20220722091133.320803732@linuxfoundation.org> References: <20220722091133.320803732@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.8 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 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: 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); @@ -145,13 +146,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(); @@ -1006,13 +1013,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: @@ -1047,7 +1056,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); @@ -1060,7 +1069,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; @@ -1384,7 +1393,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)