From patchwork Thu Oct 19 18:11:57 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Breno Leitao X-Patchwork-Id: 155684 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:2010:b0:403:3b70:6f57 with SMTP id fe16csp580737vqb; Thu, 19 Oct 2023 11:38:24 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFiCmHcgBJXdq1phx2/S2TMfzOKEV3nK/Dxfnblsfsu7HClZbiyijavQ3yHzreROQ5EcMeE X-Received: by 2002:a17:903:228d:b0:1c9:da1a:8b14 with SMTP id b13-20020a170903228d00b001c9da1a8b14mr3305496plh.1.1697740704212; Thu, 19 Oct 2023 11:38:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697740704; cv=none; d=google.com; s=arc-20160816; b=NR0aN0eBr9er29JLnQjGMq7QJGbTVt+xMtGdaPQLxYOgov+pj7eIhGz3WVEPqvokWS TJ4eW1DufgvsdaDKaO8oW01wkKvMNuXSDHhPtuf42t8vbwAvadt/NAJeQkemZ+XNSfP2 hBxNNuNEz/wvb0olQBIuy4DrjD3Us1hirzDQ96CxkL5T/wYM6rUmF8YZAsmdR9qaDk8H SgkSEsKYVuDMZTRu4PiXBs4/dP4u3RSo9a2GFEGLdVF29fGNX2QjkGyFe1RlC8KorNNQ TtEtW/VNgRkWLRFfilIS0PnPbv/IKBo807AOUU5qVeNpj968xnfnhX8nzam6dS3D0Y2S IMNw== 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=wupshIMCpdF3An7/GpORSd/SdDVEO5hCiOARToeFhp4=; fh=T/Na3StdsDt/Vl3W5ovSX6FCLua67DwAek6VvvDgcow=; b=D/FM2k1OyYo9B9flYi8/3UBc2kkQdjHJBDhbbBTn8zIDz9SR5T7XuYvr/NKuX9jF0O kx8ybJi+PVFf8RAlmdJsSHu9RiCP8+X4ZcWNT1JKX75xKhpFSatpKOBzUMbe/S0dhio7 lBvvEqqCSsQECUAzyQUs2x3whnPGpJLsNqEyQUO1Dujm+Zc+OrREMb0/eBBWrXBl/Jym HvKBqiSFPkuDlIbsT8t8TjFphPBfPl+l5BJl0wdMAwDj2wJqk6L+mKVosetcAQCdyzhH Uo9RvGuz6bsiT/854w8YEcOFYDFoBzNJV3WDQdt2mDqfCLlfDTu3YhqQQAj1svuEVgFH /y0A== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from agentk.vger.email (agentk.vger.email. [23.128.96.32]) by mx.google.com with ESMTPS id kg16-20020a170903061000b001b84335fb90si69464plb.286.2023.10.19.11.38.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 19 Oct 2023 11:38:24 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 as permitted sender) client-ip=23.128.96.32; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 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 agentk.vger.email (Postfix) with ESMTP id C55CE81B5D13; Thu, 19 Oct 2023 11:38:21 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at agentk.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1346449AbjJSSiG (ORCPT + 26 others); Thu, 19 Oct 2023 14:38:06 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51362 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235518AbjJSSiC (ORCPT ); Thu, 19 Oct 2023 14:38:02 -0400 Received: from mail-lf1-f46.google.com (mail-lf1-f46.google.com [209.85.167.46]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 58F5018D for ; Thu, 19 Oct 2023 11:37:55 -0700 (PDT) Received: by mail-lf1-f46.google.com with SMTP id 2adb3069b0e04-5079f9675c6so9476594e87.2 for ; Thu, 19 Oct 2023 11:37:55 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1697740673; x=1698345473; 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=wupshIMCpdF3An7/GpORSd/SdDVEO5hCiOARToeFhp4=; b=G4dN4T+iQ9RhfZgZo5JMAx8xp1JWxJgufdkEjDs2lnVQSQHAK2TmVvqAtF5vHLaLMn HCE5xN2Nh4xnEKi41SJ11dnBwU84zCtqrvsb97wPKz8NoATznNa08nFyMzRJmcNEJZzU lbV2hWaYXQNNEKW0IPh+6dsa2yffq8zOwwcD3lnCYVzclQmGAbtRl0olvWXcRunjEXtI zNDwdH7mGevbr9cCkpEqY5i4MzpYJKNytVYwe4ZxYgv6uZzhNdHzLK3aDx/Ah+Sme89M 5z9GvRZxGA+VXe0QNbYpNztuvW8IDQGw9nj8wzoWRdpi+4R8GdliaQCJ4NtTDGbyPW5b eIkg== X-Gm-Message-State: AOJu0YxOAE7yHkuWEYysa3NdvpEUwjAivwSuQCFwXOOuWUDsYoAU4wbD podlWgpCLbQeZVn+saO9lYg= X-Received: by 2002:ac2:4827:0:b0:4fe:347d:7c4b with SMTP id 7-20020ac24827000000b004fe347d7c4bmr2019060lft.7.1697740673276; Thu, 19 Oct 2023 11:37:53 -0700 (PDT) Received: from localhost (fwdproxy-cln-021.fbsv.net. [2a03:2880:31ff:15::face:b00c]) by smtp.gmail.com with ESMTPSA id i6-20020a17090671c600b009920a690cd9sm23712ejk.59.2023.10.19.11.37.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 19 Oct 2023 11:37:52 -0700 (PDT) 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 (open list:X86 ARCHITECTURE (32-BIT AND 64-BIT)) Subject: [PATCH v5 11/12] x86/bugs: Create a way to disable GDS mitigation Date: Thu, 19 Oct 2023 11:11:57 -0700 Message-Id: <20231019181158.1982205-12-leitao@debian.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231019181158.1982205-1-leitao@debian.org> References: <20231019181158.1982205-1-leitao@debian.org> MIME-Version: 1.0 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 agentk.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 (agentk.vger.email [0.0.0.0]); Thu, 19 Oct 2023 11:38:21 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1780210156215630878 X-GMAIL-MSGID: 1780210156215630878 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 | 16 +++++++++++----- arch/x86/kernel/cpu/bugs.c | 7 ++++--- 2 files changed, 15 insertions(+), 8 deletions(-) diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig index 7a283602b257..a5cada7443ea 100644 --- a/arch/x86/Kconfig +++ b/arch/x86/Kconfig @@ -2566,15 +2566,21 @@ 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. + 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[] = {