Received: by 2002:a05:7412:a9a2:b0:e2:908c:2ebd with SMTP id o34csp592251rdh; Thu, 26 Oct 2023 10:09:57 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGPFCcwIgLX6uGr2oqUwFDp7KvfDqGUV43jJc9xX0IawQs3KoQoNjsBUThFQ4nkNK45hdyq X-Received: by 2002:a25:374f:0:b0:da0:4d4d:da6a with SMTP id e76-20020a25374f000000b00da04d4dda6amr7693154yba.42.1698340197247; Thu, 26 Oct 2023 10:09:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1698340197; cv=none; d=google.com; s=arc-20160816; b=Apvjz05hbvDX1oJ0smeIwbh9qmkKkVjfG582oLuRNU7OSkKhuUXJUWGkQ9VV6nYhtX VNIOcaBAtsIixQkhjhlhOAh3WpOatJ6oTMKAG4y7M5xQ+j+k27K/6MTTb7rWci9Xpt2O O66l6b+QYfpNvaKlHckUrJeyzS5lxlIuIwSA/1XRnO3JnMKB3OPxagRZrJzvEoxbLreq Hy4ZOCgHygtCCGUjUcKRYjo4Md4VIBH+pUV0fbl5Uq/PPE0y+uUFFHbO2V4Pnsg4RTLw ntnkDoVsw7O3zbV4yezWJ9ZMmFfUmsMWV5H/sxu/WKSv1OY2frlTEDppxNxTpR3sSKpL d8+A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date; bh=e0o7jDaoKx4+0wnIpeEC5Hmyo14WMLzTeYk9uPnzim0=; fh=C1Jt1xn3xYgx3sJ5OxzmPL1uviROdcBxKCLzeiDIeNU=; b=Foa1ZElZwhsXJiThUtvtsUdgUpdKQYnLJfNxxzvtQ3kaq/NbIbg5bIo0ZUu9K3SK6U amwZHnRjMTyRl0o8z3DRQk3uf1Jbkd0bWxqxhcqw4TLhLgMgPDcfGxP1NKB22UfMSqIH 4IXL0DHjr2ctOvgs7zEIU7tk5r4cKZN9cgHvPHHB0xfESs6Lx9S7zvBPJr5TvwrEH1uT NEEd/TObv4ePBA6eLirsE9UJQQzLEPAVH5Nn3VqL7zXWTElrWJDBcdOS6ulxE+LIgEoS Aowj+4oyE2RfLH1GC7aRnzZREIgARm7yLzOekfQcQ8l/FOLjoZuZSkzs1CoOY2r/B8dV ICCw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from pete.vger.email (pete.vger.email. [23.128.96.36]) by mx.google.com with ESMTPS id g6-20020a252006000000b00da08e7ce4b2si4585195ybg.495.2023.10.26.10.09.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 26 Oct 2023 10:09:57 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 as permitted sender) client-ip=23.128.96.36; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 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 pete.vger.email (Postfix) with ESMTP id A8574818FBC7; Thu, 26 Oct 2023 10:09:53 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at pete.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1345272AbjJZRJ3 (ORCPT + 99 others); Thu, 26 Oct 2023 13:09:29 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48092 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231774AbjJZRJ2 (ORCPT ); Thu, 26 Oct 2023 13:09:28 -0400 Received: from mail-ed1-f48.google.com (mail-ed1-f48.google.com [209.85.208.48]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9F555116 for ; Thu, 26 Oct 2023 10:09:22 -0700 (PDT) Received: by mail-ed1-f48.google.com with SMTP id 4fb4d7f45d1cf-53ed4688b9fso1757375a12.0 for ; Thu, 26 Oct 2023 10:09:22 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1698340161; x=1698944961; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=e0o7jDaoKx4+0wnIpeEC5Hmyo14WMLzTeYk9uPnzim0=; b=l4jU/y/FdwslPLlOfTZblCepQrlX0k7mq6W/j75+ICjKJr2qbwxSMTrxB3NksKNNZI 8WNghW0KXhM+DYEohczgs8s2nM+E48xa33GxxPj1ocL5Hf2S7d4xktp0V+dHGasm1yK5 jbeeqAvpJ181OVKCEd7J5+sHb+bP2UQFN24lKrbhk68BSqQaJfKrmQN4w5vA3/oC/kUq y8s+Hlev6tTUhE8ciNXC0ypr26AbxBkOI15c660EG9VoGjM+/IyaqgFk3/pC+kz0ShZ8 FX+2PfwFyeT11q7Q2bsr0mzM9CLrG6v+txxB+zPDW41crsPUCb37jIe/jZ6O9gFCivpK hhnQ== X-Gm-Message-State: AOJu0YzLPGJfAodIE3gixD9rYMMEhPkzPmUDaLBkh7NmJuaujMn25yu/ QCdOBgPKgdzP3pQ2NPO2yqKEvCHcL+c= X-Received: by 2002:a05:6402:792:b0:53f:ba1a:800d with SMTP id d18-20020a056402079200b0053fba1a800dmr381395edy.14.1698340159898; Thu, 26 Oct 2023 10:09:19 -0700 (PDT) Received: from gmail.com (fwdproxy-cln-000.fbsv.net. [2a03:2880:31ff::face:b00c]) by smtp.gmail.com with ESMTPSA id h12-20020aa7de0c000000b0053e43492ef1sm11376792edv.65.2023.10.26.10.09.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 26 Oct 2023 10:09:19 -0700 (PDT) Date: Thu, 26 Oct 2023 10:09:17 -0700 From: Breno Leitao To: Josh Poimboeuf Cc: mingo@redhat.com, tglx@linutronix.de, bp@alien8.de, Dave Hansen , x86@kernel.org, "H. Peter Anvin" , Peter Zijlstra , Pawan Gupta , leit@meta.com, "open list:X86 ARCHITECTURE (32-BIT AND 64-BIT)" Subject: Re: [PATCH v5 12/12] x86/bugs: Add a separate config for missing mitigation Message-ID: References: <20231019181158.1982205-1-leitao@debian.org> <20231019181158.1982205-13-leitao@debian.org> <20231025162906.abnyb7xum7cpjwxy@treble> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20231025162906.abnyb7xum7cpjwxy@treble> X-Spam-Status: No, score=-0.8 required=5.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on pete.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 (pete.vger.email [0.0.0.0]); Thu, 26 Oct 2023 10:09:54 -0700 (PDT) Hello Josh, On Wed, Oct 25, 2023 at 09:29:06AM -0700, Josh Poimboeuf wrote: > On Thu, Oct 19, 2023 at 11:11:58AM -0700, Breno Leitao wrote: > > Currently, the CONFIG_SPECULATION_MITIGATIONS is halfway populated, > > where some mitigations have entries in Kconfig, and they could be > > modified, while others mitigations do not have Kconfig entries, and > > could not be controlled at build time. > > > > Create an entry for each CPU mitigation under > > CONFIG_SPECULATION_MITIGATIONS. This allow users to enable or disable > > them at compilation time. > > > > Signed-off-by: Breno Leitao > > We also probably need a CONFIG_MITIGATION_MELTDOWN. Isn't Meltdown covered by the MITIGATION_PAGE_TABLE_ISOLATION Kconfig entry? Would you mind clarifying what would be the difference between CONFIG_MITIGATION_MELTDOWN and MITIGATION_PAGE_TABLE_ISOLATION, and why do we want CONFIG_MITIGATION_MELTDOWN? > > --- > > arch/x86/Kconfig | 93 ++++++++++++++++++++++++++++++++++++++ > > arch/x86/kernel/cpu/bugs.c | 39 ++++++++++------ > > 2 files changed, 117 insertions(+), 15 deletions(-) > > +config MITIGATION_SRBDS > > + bool "Mitigate Special Register Buffer Data Sampling (SRBDS) hardware bug" > > + depends on CPU_SUP_INTEL > > + default y > > + help > > + Enable mitigation for Special Register Buffer Data Sampling (SRBDS). > > + SRBDS is a hardware vulnerability that allows Microarchitectural Data > > + Sampling (MDS) techniques to infer values returned from special > > + register accesses. An unprivileged user can extract values returned > > + from RDRAND and RDSEED executed on another core or sibling thread > > + using MDS techniques. > > Refer to Documentation/admin-guide/hw-vuln/special-register-buffer-data-sampling.rst Sure, I will update this and all the other suggestions that were cut above. Thanks! > > + cmd = IS_ENABLED(CONFIG_MITIGATION_SPECTRE_V2) ? SPECTRE_V2_CMD_AUTO : SPECTRE_V2_CMD_NONE; > > if (cmdline_find_option_bool(boot_command_line, "nospectre_v2") || > > cpu_mitigations_off()) > > return SPECTRE_V2_CMD_NONE; > > I'm thinking CONFIG_MITIGATION_SPECTRE_V2 should also affect whether the spectre v2 user > mitigation gets enabled. Makes sense, would something like this be enough? diff --git a/arch/x86/kernel/cpu/bugs.c b/arch/x86/kernel/cpu/bugs.c index 11ccbadd8800..cfcdbfa72a81 100644 --- a/arch/x86/kernel/cpu/bugs.c +++ b/arch/x86/kernel/cpu/bugs.c @@ -1221,8 +1221,10 @@ 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: @@ -1236,7 +1238,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)) { @@ -1246,8 +1248,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; }