Received: by 2002:a05:7412:40d:b0:e2:908c:2ebd with SMTP id 13csp541441rdf; Tue, 21 Nov 2023 09:14:01 -0800 (PST) X-Google-Smtp-Source: AGHT+IHrJeRUDbzovUAekQ3yRqKLG1U0QWvtqGy5iXWNhyeqEYeTiTojmiid4uWQ8cRfNGFgyMiG X-Received: by 2002:a05:6a00:a25:b0:6c6:b5ae:15a4 with SMTP id p37-20020a056a000a2500b006c6b5ae15a4mr14058345pfh.20.1700586841532; Tue, 21 Nov 2023 09:14:01 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1700586841; cv=none; d=google.com; s=arc-20160816; b=haoiXOVhvjyJ66wWs8OOAcWbHOHpQH2aQL2CNYQF67ksQjv/o/ivs6OU9wV87N7AhQ 3VEGZAmym8rHQtYvvuIVHX+mmHfDwx1U4AqE4eZ0Sdw5seDlWVea7rkoz1XMSIUqldYB AmCNAvkD7+j713u1HUBgi+ul6newN23dx1skiAKFqiUwi6daNKHFszXk2HPNVuqU7PNu iUZSXyQxn6beka3x8kc0Yz4wp2Qk86DXtkHgZfLz8E3qzKPc9eXbfECB92+f5JDUl04/ QDub2yTRG/4OdmyiwG3PLDl06yXIpMkPp6iBTRdiElJL8wLDuFrjaDt1g0E4JYM3Z8Xp PQVw== 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 :references:in-reply-to:message-id:date:subject:cc:to:from; bh=MvoV//U7FVv1pKsj0pHVwZMcyaDGT7gkmJVz+LeD9vo=; fh=P/ZCIqQ1hL9htWDdLA48SPqbKElSBTWpnbzHABGMW5M=; b=IkZkGbD6ywXxLQ8ORQxsp9r5s/TwjjjQ/gK2zf6W6/9T5PNNmHnw7QPg1EKdlP0EEk E3c/zJselqIZaU0K/rxklDHK3pVQdX/2/DkRFmsED/15kht0SL8lvZwK056bkSEZgv/A Z3WptTnif4IkOpv0u78sP1mYkyklsaOaeapdtJeP9alSSg+LINfa+DuzQPSne9FEF34E HJUa9EgwY20R64Xk8EcgyppUh52b1M8QfgjW09jmCjid3+njn/Fh8frdcqSerMHVBMae BN/JVCtlrC5/f+nF+CAxE9Uf2xpx00RxGk0CmW06lDG2mBEmYZiMYHtdruo++sIaPmsr 53+A== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from fry.vger.email (fry.vger.email. [23.128.96.38]) by mx.google.com with ESMTPS id s26-20020a056a00179a00b006cb88a16f29si5402382pfg.161.2023.11.21.09.14.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 21 Nov 2023 09:14:01 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 as permitted sender) client-ip=23.128.96.38; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by fry.vger.email (Postfix) with ESMTP id BBD5080275A2; Tue, 21 Nov 2023 09:13:58 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at fry.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234303AbjKURNH (ORCPT + 99 others); Tue, 21 Nov 2023 12:13:07 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48758 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234290AbjKURM4 (ORCPT ); Tue, 21 Nov 2023 12:12:56 -0500 Received: from mail-ed1-f52.google.com (mail-ed1-f52.google.com [209.85.208.52]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 90D3310CE for ; Tue, 21 Nov 2023 09:12:49 -0800 (PST) Received: by mail-ed1-f52.google.com with SMTP id 4fb4d7f45d1cf-548d67d30bbso3067410a12.1 for ; Tue, 21 Nov 2023 09:12:49 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1700586768; x=1701191568; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=MvoV//U7FVv1pKsj0pHVwZMcyaDGT7gkmJVz+LeD9vo=; b=qaaz9VRO3ZRu8ruuf8RVehwlSkhB/yXMXD3wKqe8fNzwsUZ002qI71lbK+Mr49kT97 niXIz9etLnzFsj2E5QeXABMK5qCFmDEe68gsktNcpb6wuFQeib+xmFOqxYfTKdGKKyzS aAaVnjVf4h8u9PDao2mEJfeoXlQRt6j0xtVwhTYRGrZFoDqQmheT4BQ1E7Xjui1o9j+j J1mX93HVxcGl9z7wIEbOTfUu30AYYaK1BQpctr6aAdKDe1M1Ry0cSwHgEm9Yo/eXsG6T 0AMGghkb4Ikv2pbfBKvlB8MMAB2tSVJpiehNDgWzjz2NjNPp+3nfQ88JTTht/aqv9/rt gp4w== X-Gm-Message-State: AOJu0Yy7BpF3GUJbMsj5qd0aiawDZxR8SKrsXMWM9gHusT8z5xc8CWfu 3VpDGjs1xdSLv3Ub4V1QsfM= X-Received: by 2002:a17:906:159:b0:9f7:b6c2:cd3f with SMTP id 25-20020a170906015900b009f7b6c2cd3fmr8135322ejh.5.1700586767935; Tue, 21 Nov 2023 09:12:47 -0800 (PST) Received: from localhost (fwdproxy-cln-018.fbsv.net. [2a03:2880:31ff:12::face:b00c]) by smtp.gmail.com with ESMTPSA id q18-20020a1709060e5200b009f5b7b6f3c8sm5451328eji.56.2023.11.21.09.12.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 21 Nov 2023 09:12:47 -0800 (PST) From: Breno Leitao To: jpoimboe@kernel.org, mingo@redhat.com, tglx@linutronix.de, bp@alien8.de, Peter Zijlstra , Pawan Gupta , Dave Hansen , x86@kernel.org, "H. Peter Anvin" Cc: leit@meta.com, linux-kernel@vger.kernel.org Subject: [PATCH v6 12/13] x86/bugs: spectre_v2_user default mode depends on Kconfig Date: Tue, 21 Nov 2023 08:07:39 -0800 Message-Id: <20231121160740.1249350-13-leitao@debian.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231121160740.1249350-1-leitao@debian.org> References: <20231121160740.1249350-1-leitao@debian.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-0.8 required=5.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on fry.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (fry.vger.email [0.0.0.0]); Tue, 21 Nov 2023 09:13:58 -0800 (PST) Change the default value of spectre v2 in user mode to respect the CONFIG_MITIGATION_SPECTRE_V2 config option. Currently, user mode spectre v2 is set to auto (SPECTRE_V2_USER_CMD_AUTO) by default, even if CONFIG_MITIGATION_SPECTRE_V2 is disabled. Set the Spectre_v2 value to auto (SPECTRE_V2_USER_CMD_AUTO) if the Spectre v2 config (CONFIG_MITIGATION_SPECTRE_V2) is enabled, otherwise set the value to none (SPECTRE_V2_USER_CMD_NONE). Important to say the command line argument "spectre_v2_user" overwrites the default value in both cases. Signed-off-by: Breno Leitao --- arch/x86/kernel/cpu/bugs.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/arch/x86/kernel/cpu/bugs.c b/arch/x86/kernel/cpu/bugs.c index 0172bb0f61fe..a99f8c064682 100644 --- a/arch/x86/kernel/cpu/bugs.c +++ b/arch/x86/kernel/cpu/bugs.c @@ -1216,8 +1216,11 @@ static __ro_after_init enum spectre_v2_mitigation_cmd spectre_v2_cmd; static enum spectre_v2_user_cmd __init spectre_v2_parse_user_cmdline(void) { + int ret, i, mode; char arg[20]; - int ret, i; + + mode = IS_ENABLED(CONFIG_MITIGATION_SPECTRE_V2) ? + SPECTRE_V2_USER_CMD_AUTO : SPECTRE_V2_USER_CMD_NONE; switch (spectre_v2_cmd) { case SPECTRE_V2_CMD_NONE: @@ -1231,7 +1234,7 @@ spectre_v2_parse_user_cmdline(void) ret = cmdline_find_option(boot_command_line, "spectre_v2_user", arg, sizeof(arg)); if (ret < 0) - return SPECTRE_V2_USER_CMD_AUTO; + return mode; for (i = 0; i < ARRAY_SIZE(v2_user_options); i++) { if (match_option(arg, ret, v2_user_options[i].option)) { @@ -1241,8 +1244,8 @@ spectre_v2_parse_user_cmdline(void) } } - pr_err("Unknown user space protection option (%s). Switching to AUTO select\n", arg); - return SPECTRE_V2_USER_CMD_AUTO; + pr_err("Unknown user space protection option (%s). Switching to default\n", arg); + return mode; } static inline bool spectre_v2_in_ibrs_mode(enum spectre_v2_mitigation mode) -- 2.34.1