From patchwork Thu Feb 8 17:45:53 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Breno Leitao X-Patchwork-Id: 198525 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:50ea:b0:106:860b:bbdd with SMTP id r10csp361419dyd; Thu, 8 Feb 2024 10:19:03 -0800 (PST) X-Google-Smtp-Source: AGHT+IHDr4DYa+unxOcb45ZU1/Y22/Ic/wh5Xm75Mvz8I1/QjGSn3A/4+sbl4iF0ROhxsQZHOzxv X-Received: by 2002:a05:6a21:1706:b0:19c:5523:eefe with SMTP id nv6-20020a056a21170600b0019c5523eefemr474634pzb.3.1707416342951; Thu, 08 Feb 2024 10:19:02 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707416342; cv=pass; d=google.com; s=arc-20160816; b=hewUN4FOzPvTlBUwOPiVfMBUGkJBz8bD8witEPXE2gA2gfs/uqoqSFRAU6uHCsQRq1 +Sfeyt6fCs1eNwVwPQXNl9WC0NCGPRAwm8YZgBoxmwndypJ8d/IBpmRNxC0y+9mTu1XR EE7UhbFDH4T0DVS2oX1EG/jpx9Wg8jG3CaLI5UYEqGEHA/FMq5Xw0TF9z6ed5+AHjHpu H6W4pCjd2WvljEZwzv2McotzPJ5cGjkV8JFJz527ovpJ2lW2/HpwZuvL8ruV0Mu/nM5i v9UY3jIxxeoeBPnVoUyixcqvarbhXTLTcGJfDbUVNfGROFSMR9x3cHOdIyMixPgjPuBq oQEw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from; bh=ih/jBTnio5/IZQFOp461sTdF+T+V2d6Zsp9b1u0NxxA=; fh=SvZYSqtNILO8zX5nFaT0u6U4C6m3t1pvqMzYMAymoGc=; b=s4kzqCShfNgc7MONfFXGTV/J+nY/iEMCi5ZZ0ih3mLGQ3b8vI0eZDp+9fPAgzOCu5J XlnUIWqqluPxFEKLbtV0fECFEaTTIUIvEJFToIV8Tr9HomxIiGL6NbtncVBh+gxM7LYg rSagGmOU6Tv+GCY0i4L9/VNeII2VKUxV3NZT1B4NO5ZxgAK0Kwv6EUDBiCy2iPpC1RtG 9+fFq8mvV1hiZ+S8g2JR63dqXYAXuMLUP0oiKNK/OuHkHkD5we3+sVgKJaRfZjpXQoXN wQDrDpc37uHgvlHYwOmT4kREWaBeeomg8QzRBvR13QIe9TEH7hW8QWchr+bj1g3WhQfK 9ZpQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1 spf=pass spfdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-58484-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-58484-ouuuleilei=gmail.com@vger.kernel.org" X-Forwarded-Encrypted: i=2; AJvYcCU2hz0Wgpe0Vv7X+YbVbHKr9NWd0EyjHWwPyX1fUSyfMQ7FsOPS3nFptqHE5uLST8Qm5uTbknJoet7xpDCzWWabIkPveQ== Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id v23-20020aa78517000000b006dbbae74070si43926pfn.184.2024.02.08.10.19.02 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 08 Feb 2024 10:19:02 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-58484-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) client-ip=2604:1380:40f1:3f00::1; Authentication-Results: mx.google.com; arc=pass (i=1 spf=pass spfdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-58484-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-58484-ouuuleilei=gmail.com@vger.kernel.org" Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id 2EE2FB2D646 for ; Thu, 8 Feb 2024 17:47:51 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 9FF9E1272C8; Thu, 8 Feb 2024 17:46:14 +0000 (UTC) Received: from mail-ej1-f48.google.com (mail-ej1-f48.google.com [209.85.218.48]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 4667782D61 for ; Thu, 8 Feb 2024 17:46:11 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.218.48 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707414373; cv=none; b=HZbZKj/FAK6mDSdgJxX0QcTKhb36bU+bbQivptypq4ttq2lY30whOfd20iRky65o00l/y5RN8PMNLmd+oLUziSAX4yvohphl0xHl9BgWyN3i2+JL9sAWGHgsngWzUaYu6fIBq9iZBy746YvdJK9OJ80QPjhiX+lO9onREvD4SZM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707414373; c=relaxed/simple; bh=q2dr7c/QVHh7zHm5CcoMvsNU3SwZfRo9G63HVxFAciY=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=pAZJQ5qLAvjsdT6bf8owT5jzUs+jIU7OCeGcefEdu3P0eZrapplldPtb2Rnotuk86j5tAzGD7CdV99dQVP2HpGJ8+95XmLcOa49NOU02+n6bH6jQETk/48V/TtDIhBMKoSseshXTc7eKPxNBw/sd6QH6OuKu53FuyHpHQJZBpHM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=debian.org; spf=pass smtp.mailfrom=gmail.com; arc=none smtp.client-ip=209.85.218.48 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=debian.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-ej1-f48.google.com with SMTP id a640c23a62f3a-a389a3b9601so6188866b.1 for ; Thu, 08 Feb 2024 09:46:11 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707414369; x=1708019169; 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=ih/jBTnio5/IZQFOp461sTdF+T+V2d6Zsp9b1u0NxxA=; b=aZ+bEJJ3nc1naSYGJcIRvxnny9pnYfPf1qUaZJzk3BHDr94lV4EsCSUPHr29XDZnEU XmxK6aqrfNZXg3E9J86310GpIhIjCf1fmytFvzw6/UoaZV24KtSJlVyNW/ky1ZWYc6q5 HcZXi7TOz9uGzbYm1a6C54hOoOUgCnN/FikebztQhYfITwvuv84q8mMuJuYTz1/Oujx/ L1r+MM6Wtbg1qYz/5haw7Mi3XSDs3obsNCefx3YUznsB1JMs8GS35Zg3bFvNO1DCdHtT OEXkADLdbeu4pMdNQLNCkn82sEaoO2+fzPzoIRyMewg0C2CrA1B0CHeA358GaDIngSWt O1Bg== X-Gm-Message-State: AOJu0YwNnOjlHnV9kmQTWIvQ/ll2pUEtOSl2FuvFr/p0PJRf6hwAsD3B D+Qxwin+NqOspzpXOgNboDtMwdfp8BMdhVax1tWkRrPgtlMAXdGw X-Received: by 2002:a17:906:80ca:b0:a36:fc15:c6b2 with SMTP id a10-20020a17090680ca00b00a36fc15c6b2mr32370ejx.35.1707414369418; Thu, 08 Feb 2024 09:46:09 -0800 (PST) X-Forwarded-Encrypted: i=1; AJvYcCWGQH8vx/d3kKVONIuJf8EGl3CmpVDMrfLZsOC9xxQc/X9ietRvOGVnfbaSwPLtfg2ltfyRqyZcBsYqZeRsQmQROgQZ07KNMI6lbs5z3QSQpeMhYfaSEiE2vqJFVTXM2e3CPPUyqqSZlGy2stdgrDkxYSjN4oVdKrX3YsAcI1r3tSfYUAEWimZyTaZ0QLE06sq+RlIwrBQWfV37sQjfj5UHgT4j+1YPW5phHG5uE9r5WRe+4BLyXeQ5tO5se7kn/iUpGMR14LegMhO2Z3t0HdRwPal02xQW0C8rOw== Received: from localhost (fwdproxy-lla-004.fbsv.net. [2a03:2880:30ff:4::face:b00c]) by smtp.gmail.com with ESMTPSA id en14-20020a056402528e00b0055fe55441cbsm1045813edb.40.2024.02.08.09.46.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 08 Feb 2024 09:46:08 -0800 (PST) From: Breno Leitao To: mingo@redhat.com, Thomas Gleixner , Borislav Petkov , Dave Hansen , x86@kernel.org, "H. Peter Anvin" , Peter Zijlstra , Josh Poimboeuf , Pawan Gupta Cc: linux-kernel@vger.kernel.org Subject: [PATCH v2 1/3] x86/bugs: Create a way to disable GDS mitigation Date: Thu, 8 Feb 2024 09:45:53 -0800 Message-Id: <20240208174555.44200-2-leitao@debian.org> X-Mailer: git-send-email 2.39.3 In-Reply-To: <20240208174555.44200-1-leitao@debian.org> References: <20240208174555.44200-1-leitao@debian.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1790355798846213028 X-GMAIL-MSGID: 1790355798846213028 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 Acked-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 0a9fea390ef3..d5e3f1a8cacd 100644 --- a/arch/x86/Kconfig +++ b/arch/x86/Kconfig @@ -2587,15 +2587,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[] = {