From mboxrd@z Thu Jan 1 00:00:00 1970 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 5B34683CDD; Wed, 13 Mar 2024 16:40:50 +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=1710348050; cv=none; b=KBhSfQoaAHT0a+lBAGAnozhAM74d6faxKiC4HyyHQtfDpuedqxELUuWoa1NnQb0+Ej8tNQlpj0CUC2rZTUI/9dLGMTcKoXYa1zNDGtJEecYzBbpqZ/v+AdTDsTSvhLyxHykvQm1NpZ6UVMXeE7B4LsXejiMpkpCLHlF4g/J8tAM= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710348050; c=relaxed/simple; bh=gojXZ1PnmUJ7mDvNYX1vmpfxgI7l8CTlrUz+jldhxsA=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=mbk+NkOPTdIDd2XcNI8ZxtBJU+5erma0bC4DxFZ8evPWOp0z9hLaniylKRka0CL3Ebuc34/FGY39B4DJbDC0wqQfK/tNeI2WNsyZPSHCC5jVaV0UTGFuzwVrU5074bFbDkLiR0UDQXZR2gblEMwEPb7zX5IgEf0qUEMosP1FwwU= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=DVzy97oz; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="DVzy97oz" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 8BD71C433F1; Wed, 13 Mar 2024 16:40:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1710348050; bh=gojXZ1PnmUJ7mDvNYX1vmpfxgI7l8CTlrUz+jldhxsA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=DVzy97ozxj73qbWeZOrlIwZ5QHl173EcmffQuW1PoJtfChvRsRjahmdPh4joh+M9W DGJktAA39+b3GC1Z278qk9Y6y/mCZ4t0ScFVp5E3SyKUtYBCWUDaLH5p3tilDWOWeU iAJqtQZWe0gVr51wlj1ZD3BMIpLR4bUlHgMJ/DcObE9cKLI4u+EXxFxuu3WeIKzI/Y pRZ0cX9z+ibagRvQlCN+jmW/IQyiAZsh7vbSQvkoIaBvuw32yUi1m34ctOhAWVtgTA eVendoP3fmMvi3diXjYt67rTnXR+0UG0ErY+1Ss1p07EqtuXVN2589aPbcz8WC1c81 a7NdESLuiymVA== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Pawan Gupta , Dave Hansen , Greg Kroah-Hartman Subject: [PATCH 6.1 43/71] x86/mmio: Disable KVM mitigation when X86_FEATURE_CLEAR_CPU_BUF is set Date: Wed, 13 Mar 2024 12:39:29 -0400 Message-ID: <20240313163957.615276-44-sashal@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240313163957.615276-1-sashal@kernel.org> References: <20240313163957.615276-1-sashal@kernel.org> Precedence: bulk X-Mailing-List: stable@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.1.82-rc1.gz X-KernelTest-Tree: git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.git X-KernelTest-Branch: linux-6.1.y X-KernelTest-Patches: git://git.kernel.org/pub/scm/linux/kernel/git/stable/stable-queue.git X-KernelTest-Version: 6.1.82-rc1 X-KernelTest-Deadline: 2024-03-15T16:39+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 d1895930e6eb8..c66f6eb40afb1 100644 --- a/arch/x86/kernel/cpu/bugs.c +++ b/arch/x86/kernel/cpu/bugs.c @@ -421,6 +421,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); @@ -497,8 +504,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