Received: by 2002:ab2:710b:0:b0:1ef:a325:1205 with SMTP id z11csp1842047lql; Wed, 13 Mar 2024 09:33:05 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCV/0mvnyrKzAfJbiDHaW6Qvdg3c0kLBjGGGCkpM8LFLYLNcslgf0hprI0pqUmXK7du6yXnsT3h0mW3iZ89F4A3VMtlkTaB4naB6FQnCWQ== X-Google-Smtp-Source: AGHT+IHOLv/hcpaxONBHiOA+MJ01adx5oKItsU9phQXlg5jvEeh+wABK8wynE+uY/0Y4CKF60cjv X-Received: by 2002:a17:907:c246:b0:a46:4ee3:1753 with SMTP id tj6-20020a170907c24600b00a464ee31753mr2559326ejc.1.1710347585074; Wed, 13 Mar 2024 09:33:05 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1710347585; cv=pass; d=google.com; s=arc-20160816; b=P1Tp+RWbTfebTd0t8Q8IWcghTEd584PgLTGG0sndFNV9lAhYIUvDlPqW+r9icc1S1y s2OTFC1NQj1OZzJyd21n1U7S5c4KoDOxdggY2LZL1xOf/PIIWRh2ME1pzaWmdtuvfNLO bGnnUYmu4DsIoO1xJ1KUK2HJmT3hN4kN0PhdAhMPaavmYE1wKcHtqR0TPoQc1OCFYT11 tBB/83bggoRE3vxAIyMx4t6MjebgfjCgsluPhYCiEgMcj9b+IiF8zY2JHp3UvrQPnLh+ ICnJFf/sJXxjHARQDMlvwflIXgKP5Zd2FrmIYUig7QeQxLH8pd1UPrYgdXrJCictkbEX FLTg== 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:dkim-signature; bh=DbFqodn34vJlsiSbnEe1XWjNIzFfTx+eHvSe2YLhB/o=; fh=n57q/1wYIzfY3Pv6PQYkmVYioDP3jD2Q5sJ+1AQwV4k=; b=Lc4PaxN8KwVn6p63l+XfDshGs2x7PH6oYApe0mL8Rfyh5NnlvQYuiuo2/yfHMUgvpi cO4NtAT00UmeFcwmhhVq8iDMVxHATVKYWTVjY+yEHtrSzFu7qjczeAtheJ+00TyOthXa s0g3kRPLg1dLeEKVsHyqA54zCdWDMbUjVqEDA0NpJ6ErwcOkqIBQPPX2qTIb0psyzGCW Otz6vPpVbey6pL34SaxnhuzON95KKczqOHolXJVcU0A33kdOpxDKfjmg50Bho7V0ZkF0 3RyF8pZw8U2RbKZNyok3l6k1ryBZLqRxvN6XfiJff6EsToRdAdHmf34DsGVVbmTl/mku nAJw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=L2WIDVKj; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-101740-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-101740-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id w15-20020a17090633cf00b00a4659bf5922si726050eja.208.2024.03.13.09.33.04 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 13 Mar 2024 09:33:05 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-101740-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=L2WIDVKj; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-101740-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-101740-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=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 am.mirrors.kernel.org (Postfix) with ESMTPS id C90201F2304F for ; Wed, 13 Mar 2024 16:33:04 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 951404D599; Wed, 13 Mar 2024 16:32:41 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="L2WIDVKj" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id BA1164CE18; Wed, 13 Mar 2024 16:32:40 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710347560; cv=none; b=hjCBtvWZ+fE/Dfwhoo9SX54Kr/eIcHe02s0bgi38Sgg2n/RVANxDu66DaiQFR63HVM3Y+S1BGk1kgKvY7r+MabtdWd2Ba+n8/LTxFlpxOxXTsy2nw91lkdbU6WhqywHDRwHEoFcbN9ZlHpqL/oZTFuinJ8KJXufVPQxwzadpWPk= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710347560; c=relaxed/simple; bh=Mr55yURH3JIMm+UgJzs7x2D2v6bMMaB6IeZnpVwY0zo=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=ocQOEBhICkEK0N+J+JWo7OOIXa9IqW89jVVy9aCxR38hfCQlK2JhaJUz+W290QJddKu/cUh5YQ9dm3SPLJwhiAirN0g3J3KNy3X3uyru820Nb7aTnustur0QrcrjloD5bZaHzBYgFRBVRPx46DU2iHgjoZaBTiMrBj0Fxt1m+D0= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=L2WIDVKj; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 9299DC433F1; Wed, 13 Mar 2024 16:32:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1710347560; bh=Mr55yURH3JIMm+UgJzs7x2D2v6bMMaB6IeZnpVwY0zo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=L2WIDVKjSpTlCLlbFl8yfq93yQI6TyYIbBG9oO+iECTEmHC19Cj1joTPKRhy6T7B7 DpBIsNSAtvGwRO5/tXWhVtGrnf72NdDlBpqg8hv+BO28Y5tG+MleT7Y9m3h1+RIacZ caYm1Qm9uV1qlhvrKugFlPlsmaAmOlQ2HVGX5jg+vxijBaU/RekuELZjgxhehmhogz jVstkoEtg6XdugVbPPU8O8bTsN7Bm8dRHarhaEV0JpT8ynpsN0SeZ/H2dkyDnaJ0Z6 ViHYvJH9+YcjtxFfnLsS7L17b0QlFhzq/2RxRxLuzqnNqMApYFo2kjj6Bj2fow2kNq /4FiLS6gamzIA== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Pawan Gupta , Dave Hansen , Greg Kroah-Hartman Subject: [PATCH 6.7 01/61] x86/mmio: Disable KVM mitigation when X86_FEATURE_CLEAR_CPU_BUF is set Date: Wed, 13 Mar 2024 12:31:36 -0400 Message-ID: <20240313163236.613880-2-sashal@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240313163236.613880-1-sashal@kernel.org> References: <20240313163236.613880-1-sashal@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-KernelTest-Patch: http://kernel.org/pub/linux/kernel/v6.x/stable-review/patch-6.7.10-rc1.gz X-KernelTest-Tree: git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.git X-KernelTest-Branch: linux-6.7.y X-KernelTest-Patches: git://git.kernel.org/pub/scm/linux/kernel/git/stable/stable-queue.git X-KernelTest-Version: 6.7.10-rc1 X-KernelTest-Deadline: 2024-03-15T16:32+00:00 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit From: Pawan Gupta commit e95df4ec0c0c9791941f112db699fae794b9862a upstream. Currently MMIO Stale Data mitigation for CPUs not affected by MDS/TAA is to only deploy VERW at VMentry by enabling mmio_stale_data_clear static branch. No mitigation is needed for kernel->user transitions. If such CPUs are also affected by RFDS, its mitigation may set X86_FEATURE_CLEAR_CPU_BUF to deploy VERW at kernel->user and VMentry. This could result in duplicate VERW at VMentry. Fix this by disabling mmio_stale_data_clear static branch when X86_FEATURE_CLEAR_CPU_BUF is enabled. Signed-off-by: Pawan Gupta Signed-off-by: Dave Hansen Reviewed-by: Dave Hansen Signed-off-by: Greg Kroah-Hartman --- arch/x86/kernel/cpu/bugs.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/arch/x86/kernel/cpu/bugs.c b/arch/x86/kernel/cpu/bugs.c index 48d049cd74e71..cd6ac89c1a0df 100644 --- a/arch/x86/kernel/cpu/bugs.c +++ b/arch/x86/kernel/cpu/bugs.c @@ -422,6 +422,13 @@ static void __init mmio_select_mitigation(void) if (boot_cpu_has_bug(X86_BUG_MDS) || (boot_cpu_has_bug(X86_BUG_TAA) && boot_cpu_has(X86_FEATURE_RTM))) setup_force_cpu_cap(X86_FEATURE_CLEAR_CPU_BUF); + + /* + * X86_FEATURE_CLEAR_CPU_BUF could be enabled by other VERW based + * mitigations, disable KVM-only mitigation in that case. + */ + if (boot_cpu_has(X86_FEATURE_CLEAR_CPU_BUF)) + static_branch_disable(&mmio_stale_data_clear); else static_branch_enable(&mmio_stale_data_clear); @@ -498,8 +505,11 @@ static void __init md_clear_update_mitigation(void) taa_mitigation = TAA_MITIGATION_VERW; taa_select_mitigation(); } - if (mmio_mitigation == MMIO_MITIGATION_OFF && - boot_cpu_has_bug(X86_BUG_MMIO_STALE_DATA)) { + /* + * MMIO_MITIGATION_OFF is not checked here so that mmio_stale_data_clear + * gets updated correctly as per X86_FEATURE_CLEAR_CPU_BUF state. + */ + if (boot_cpu_has_bug(X86_BUG_MMIO_STALE_DATA)) { mmio_mitigation = MMIO_MITIGATION_VERW; mmio_select_mitigation(); } -- 2.43.0