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 6E20A2E405; Mon, 8 Apr 2024 13:23:05 +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=1712582585; cv=none; b=fnJAhZtTBfibWj6046t1tcPPvf2HG8cka4Y6yBpyHKii5UeWPO71/sVsu6aLqiuZ0H/8A7HSHXThhhtTQa19Xdr+cHZXxjU6ltQtD0uPdGgF98OmhhwOc12uDL1Tnqz3dis4fzO2zirX+mbtjAtq8lLBgelSbh8IbHH8oSYAC9g= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712582585; c=relaxed/simple; bh=ghaWSDY3ROEoUpnvEguwo2Wo25L7V8NVTHHKMuzKMWM=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=m5M+m/KdamCtFGOHFk1NGzQGwfTEQle/KqEx0KrUnQXyGZ0E/ZtsuzZlGoIXkYwCxN32zT53SrFSucaqEL7r3Vb6yLhSE2wsIv/iUSmfA/Ab+otPV31uOIqi3dbtMyWQRT365Ril8azaPo18Gokg9ybw9clx11pgsQfT7E1pj+g= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=oShPykf+; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="oShPykf+" Received: by smtp.kernel.org (Postfix) with ESMTPSA id EAC93C433F1; Mon, 8 Apr 2024 13:23:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1712582585; bh=ghaWSDY3ROEoUpnvEguwo2Wo25L7V8NVTHHKMuzKMWM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=oShPykf+jgbe5+byheFSo6Cxg0EgmYiUQ7W6Fv/6RAsvhKCeXoWwms/qm8cBaItFl mnrJjAPEy+yJHMHKoOKIm5ns1UBBVvGAsgvs2pDOPQA9WUmRnr27AfHdxsPB/4WWiA TGKfD5jZ3XCVrCArZcBnPE8TcX5aB786wCEvld48= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Dave Hansen , Pawan Gupta Subject: [PATCH 5.15 157/690] x86/mmio: Disable KVM mitigation when X86_FEATURE_CLEAR_CPU_BUF is set Date: Mon, 8 Apr 2024 14:50:23 +0200 Message-ID: <20240408125405.216788425@linuxfoundation.org> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240408125359.506372836@linuxfoundation.org> References: <20240408125359.506372836@linuxfoundation.org> User-Agent: quilt/0.67 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: stable@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 5.15-stable review patch. If anyone has any objections, please let me know. ------------------ 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(-) --- a/arch/x86/kernel/cpu/bugs.c +++ b/arch/x86/kernel/cpu/bugs.c @@ -428,6 +428,13 @@ static void __init mmio_select_mitigatio 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); @@ -504,8 +511,11 @@ static void __init md_clear_update_mitig 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(); }