Received: by 2002:ab2:710b:0:b0:1ef:a325:1205 with SMTP id z11csp1874774lql; Wed, 13 Mar 2024 10:26:24 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCVScfcoEY2viPZ0KEDXcqqUkrJ87CfDXGpk1sBONm80DEC8Ia5TnMp2AHTsxpVB4WJAb/E4mlTKNu1xp++wSR8Tm3iPkTwxWrdiRW9Uzg== X-Google-Smtp-Source: AGHT+IE4TR1Om1HXOJ1IZxs6k6AGnwZS23p78cLnXx0L5BMpsSRt16z6yzJB4EbVFWsnlEuV0Jf7 X-Received: by 2002:a17:906:f8d0:b0:a46:69ec:c674 with SMTP id lh16-20020a170906f8d000b00a4669ecc674mr345470ejb.35.1710350784264; Wed, 13 Mar 2024 10:26:24 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1710350784; cv=pass; d=google.com; s=arc-20160816; b=WnFUd8PSfvFzWgJraG+Rrj4HveVkZpW0lMCMXJSxmF6l17nDmd+5O+T+Si8c2wcAb1 CW+8MilPFrwFu/78m/cKJwiWOA0woYzmfJawDUTG24ytVgkRxhVEnInF2qShN3hCM6Ub TyHHmctYad8fy2hppnFwXK6AYyxbtFTJD33lf/2Vj+HiYvEl9pcAgHKvMrkesRk2Ao4K 4wWeg1Q9nMMY5lJiWWv3hODiSQRnbYYkCQgXzomRAPshcwafuvfLYj30+ClGn5qlLzrv r4wZroKD/aTUGp4205laWeMGnUY8k6wvelg6RxhJDOLha7bzg8IkNDs00SoXvWWbZnMi aGyA== 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=k8AeSC7w5CjrElm5Nw5SDUaX4G4HudwAqvgDGfW25h8=; fh=n57q/1wYIzfY3Pv6PQYkmVYioDP3jD2Q5sJ+1AQwV4k=; b=B3YpiTwXfQeMWcCYwR1rVJSax/wKBFi1bLKXnzMGvbE0mn/oAmVchASCTWDDOU1DSV pkbPW7czYn9MHsXD29MZmhghrmdgT6ikO7WY2ii29lEUeOYmVC+Ei5ZgXtlQcn52P9G5 svn2v+9NXZVGm1rYuXG7ErPXt1usz42mm78RgnyaL4jPNEjnWnszWjghxuzHer38IX8m wcX75Q6ABxZ5Z3o9BoH35rsyciJdX53NW70jILeLvNt01/5q2H54b60U/kzU5G67VACn YT+rJYwByTfSbJBkB+6ofkU6ouvdXrta5nzVEI2faEfaacCjzsSijeJTZLQHHYk9YWwj 8Ywg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=DVzy97oz; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-101911-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-101911-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 l9-20020a170906794900b00a43b6d6fd4asi4761256ejo.923.2024.03.13.10.26.24 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 13 Mar 2024 10:26:24 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-101911-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=DVzy97oz; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-101911-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-101911-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 6789B1F2FB92 for ; Wed, 13 Mar 2024 17:13:43 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 5969C84A2E; Wed, 13 Mar 2024 16:40:51 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="DVzy97oz" 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 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: 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.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