Received: by 2002:a05:7412:40d:b0:e2:908c:2ebd with SMTP id 13csp541472rdf; Tue, 21 Nov 2023 09:14:06 -0800 (PST) X-Google-Smtp-Source: AGHT+IGA2OiTahZaZ8JhCLKvMF+86HACpfDW1vCofgrUfhLEBVy8WvppA9Qfmo5TyhQ6I5Xx0raW X-Received: by 2002:a17:902:c40c:b0:1cd:f823:456d with SMTP id k12-20020a170902c40c00b001cdf823456dmr5256761plk.20.1700586845855; Tue, 21 Nov 2023 09:14:05 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1700586845; cv=none; d=google.com; s=arc-20160816; b=Ktxj1NmgzAMc9hgXEeDGmaxVh/Q6Iy0S5a8cN+wMJUSKNLe3UVByA1MKJkIREJg8HW 4xiKBA3IMp9XNhPySKNGxFYKKl2ZmWyEk/C4AiybyGID1lcdXtrOsLiCGvobu9Ly0241 gpc2mC+VATEZuNm77US950xuHvem2JElxeeydH+r8t/DbcKvkcXmjzLVtSOjXCZzuMg8 LR/7KPNXF649k1dGgXzjwqS/YfT6ygRapJ8LuIh/nViFHxwc3H0Y4iBa7Pa7XvpsCrnq HCX1zuqBfgmyF3RmQtCnXYVBmn9iQ0uWg2LHjayAM0mwtCvklZOYNjryqVQ8aUr+QEv1 ldwA== 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=UyQP3CLH+UgiYNt7ar9Le/i9ANxBjXIZotdCtvdYulE=; fh=Z5jXuzkmn3l7IHBxliTKwNO/8Yh7AhmQojunj9pzw+k=; b=JT5jQOBpTlSYRHgF4xjBSAPDMyS+AHmfsFHNHzKSy1sOGC/IBkg0ehZRB0VN3zSuYw pepus8oKxjl04YLFWZhN3JhUfPGxaBMLHQbq/b2WZhiptEr3yF+C8mNORASGdpf5ue4S Ik0tWfpv+BL1lzjSFQlcM5Ai14joB7ywJx1iRJ0CwvcdrYkkZ7Oe+cchjAhcfGhagTs2 qWwTlvH2SYhb4YN+BL55GxHDomrLVdOl+Vm2aBi3I48iwn57YhUyb8gT87wdIwCaJgO5 wTRIo2S+P8w9RSsPYfMBnru/m8vatedSTDxxX4Dpgu9gOLLe5GUq6FJtS5MLUHkvIMAM lTuA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from snail.vger.email (snail.vger.email. [23.128.96.37]) by mx.google.com with ESMTPS id ix14-20020a170902f80e00b001c9ff461649si377462plb.581.2023.11.21.09.13.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 21 Nov 2023 09:14:05 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) client-ip=23.128.96.37; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 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 snail.vger.email (Postfix) with ESMTP id 20B2D80D31DB; Tue, 21 Nov 2023 09:13:31 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234325AbjKURND (ORCPT + 99 others); Tue, 21 Nov 2023 12:13:03 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50584 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234303AbjKURMy (ORCPT ); Tue, 21 Nov 2023 12:12:54 -0500 Received: from mail-ej1-f44.google.com (mail-ej1-f44.google.com [209.85.218.44]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2059E10CF for ; Tue, 21 Nov 2023 09:12:48 -0800 (PST) Received: by mail-ej1-f44.google.com with SMTP id a640c23a62f3a-9fa2714e828so472101066b.1 for ; Tue, 21 Nov 2023 09:12:48 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1700586766; x=1701191566; 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=UyQP3CLH+UgiYNt7ar9Le/i9ANxBjXIZotdCtvdYulE=; b=fobVewVqHZrW4qNm7js+THnvNaF5aSqNFfkZ95tUhp7KL5BrqIWhSAymHgPwqnwDJd fizFOK7L/4H8c0yC3EoqJMEU/BxWAQJHeRWylAatl3hnPm1BFSSACZV32PdnbeKzk5E/ RGcsV+cjkp9dw4XrMJAFqq8DWGycivpzBAjCb/vWN2AnzyMLf1hV4BavjUiQpekzOO2E nbvvYhx1Pc2KcAqR1DYh0sljmdgjEFCSCAgdIdDH3fr/i+ULu6R4Vamuzkv+fQrst/7l 6PElO4+PCuUgvIvghUvI8b1xoh79XbHGJ8TW7EmrjUjyE19Jlx0ZaBz91hUmz9xnOwGP GOsQ== X-Gm-Message-State: AOJu0YweSpIM0m4kAJbAjueIgfM/H5jpWutIvOVHgz6GBgIwRG1oukYb I5QKcZ3L6X5KHQU77SvnZXg= X-Received: by 2002:a17:906:10c:b0:a01:1cee:53cc with SMTP id 12-20020a170906010c00b00a011cee53ccmr2552111eje.66.1700586766579; Tue, 21 Nov 2023 09:12:46 -0800 (PST) Received: from localhost (fwdproxy-cln-012.fbsv.net. [2a03:2880:31ff:c::face:b00c]) by smtp.gmail.com with ESMTPSA id lh3-20020a170906f8c300b009dd7097ca22sm5530302ejb.194.2023.11.21.09.12.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 21 Nov 2023 09:12:46 -0800 (PST) From: Breno Leitao To: jpoimboe@kernel.org, mingo@redhat.com, tglx@linutronix.de, bp@alien8.de, Dave Hansen , x86@kernel.org, "H. Peter Anvin" , Peter Zijlstra , Pawan Gupta Cc: leit@meta.com, linux-kernel@vger.kernel.org Subject: [PATCH v6 11/13] x86/bugs: Create a way to disable GDS mitigation Date: Tue, 21 Nov 2023 08:07:38 -0800 Message-Id: <20231121160740.1249350-12-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=-1.4 required=5.0 tests=BAYES_00, FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS, RCVD_IN_DNSWL_BLOCKED,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=no 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 X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (snail.vger.email [0.0.0.0]); Tue, 21 Nov 2023 09:13:31 -0800 (PST) Currently there is no way to disable GDS mitigation at build time. The current config option (GDS_MITIGATION_FORCE) just enables a more drastic mitigation. Create a new kernel config that allows GDS to be completely disabled, similarly to the "gather_data_sampling=off" or "mitigations=off" kernel command-line. Move the GDS_MITIGATION_FORCE under this new mitigation. Suggested-by: Josh Poimboeuf Signed-off-by: Breno Leitao --- arch/x86/Kconfig | 18 +++++++++++++----- arch/x86/kernel/cpu/bugs.c | 7 ++++--- 2 files changed, 17 insertions(+), 8 deletions(-) diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig index ee939de1bb05..b1a59e5d6fb6 100644 --- a/arch/x86/Kconfig +++ b/arch/x86/Kconfig @@ -2590,15 +2590,23 @@ config MITIGATION_SLS against straight line speculation. The kernel image might be slightly larger. +config MITIGATION_GDS + bool "Mitigate Gather Data Sampling" + depends on CPU_SUP_INTEL + default y + help + Enable mitigation for Gather Data Sampling (GDS). GDS is a hardware + vulnerability which allows unprivileged speculative access to data + which was previously stored in vector registers. The attacker uses + gather instructions to infer the stale vector register data. + See also + + config MITIGATION_GDS_FORCE bool "Force GDS Mitigation" - depends on CPU_SUP_INTEL + depends on MITIGATION_GDS default n help - Gather Data Sampling (GDS) is a hardware vulnerability which allows - unprivileged speculative access to data which was previously stored in - vector registers. - This option is equivalent to setting gather_data_sampling=force on the command line. The microcode mitigation is used if present, otherwise AVX is disabled as a mitigation. On affected systems that are missing diff --git a/arch/x86/kernel/cpu/bugs.c b/arch/x86/kernel/cpu/bugs.c index f2775417bda2..0172bb0f61fe 100644 --- a/arch/x86/kernel/cpu/bugs.c +++ b/arch/x86/kernel/cpu/bugs.c @@ -671,10 +671,11 @@ enum gds_mitigations { GDS_MITIGATION_HYPERVISOR, }; -#if IS_ENABLED(CONFIG_MITIGATION_GDS_FORCE) -static enum gds_mitigations gds_mitigation __ro_after_init = GDS_MITIGATION_FORCE; +#if IS_ENABLED(CONFIG_MITIGATION_GDS) +static enum gds_mitigations gds_mitigation __ro_after_init = + IS_ENABLED(CONFIG_MITIGATION_GDS_FORCE) ? GDS_MITIGATION_FORCE : GDS_MITIGATION_FULL; #else -static enum gds_mitigations gds_mitigation __ro_after_init = GDS_MITIGATION_FULL; +static enum gds_mitigations gds_mitigation __ro_after_init = GDS_MITIGATION_OFF; #endif static const char * const gds_strings[] = { -- 2.34.1