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 E40F13CFF51 for ; Mon, 16 Mar 2026 17:20:10 +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=1773681611; cv=none; b=d+kV5H+1sxTiuB8gfH/7FpkQhghVU4BdG/OJexz8ogWDt/pko0mMgZ2ndgCfNminmeZ4Pn6t36xEKptbFtn73Ar4KKYOatdnD+dMnTsLsG/hwE8PgioteticyvrIXUJkgPTICWTNw8QYiD0JH2aybHVEmOnVzmMvnTFAyseKwzs= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773681611; c=relaxed/simple; bh=hdVX+nRaGK9tzO/7tGq1HC/QPqPg3gJp7cInmTy2zGw=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=t7zTC3yzL6+x7XiMeEn4PIjc9kYeRo5KSYplYlmRGPEfjC0SbFnKUCNUibOgg+Ct49D/xosT7v1WZ3Hi2tdTDtTAnD6GOFaBlb1BEkv9H57D+fCeoWezBLfRGi0Q3rV72vSKs56huHxhR2Jggpy68dHedgnsN/fZUVDtRsc9bZg= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=lz8taum8; 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="lz8taum8" Received: by smtp.kernel.org (Postfix) with ESMTPSA id C8F91C2BC87; Mon, 16 Mar 2026 17:20:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1773681610; bh=hdVX+nRaGK9tzO/7tGq1HC/QPqPg3gJp7cInmTy2zGw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=lz8taum8JNgENwGgseWyjeJDBYFqmlLYtJdzD4I2zJFprq3zPdB39v//l6CWliCcg 2POdp3w8SvmmsSAxjxaJ9CTbbVFiM2sSnROWICIxKMNliQONffTXd8NVRS0bUifoAj dbY6O+F/NB4zTV5hhR82CgwOjOQnzKlDpafppFhwtYxRK1hKuOcVJo5fAumljJWZaQ cD55CPmLilQx93aTjedS4mGGTvMSLyObXmm9ZLdWrq40+LgoZb6+TPtTN1xp7kH0Cc 75Z75YY7Mdi5b9zoJ4YPxw/qF/lKfYh9ea82SPrae4/vzBfbjcmPjWxR8BJGgtx3Bv gKGizbPLPI/IQ== From: Sasha Levin To: stable@vger.kernel.org Cc: Chao Gao , Mathias Krause , John Allen , Rick Edgecombe , Binbin Wu , Sean Christopherson , Sasha Levin Subject: [PATCH 6.12.y 7/8] KVM: nVMX: Add consistency checks for CR0.WP and CR4.CET Date: Mon, 16 Mar 2026 13:20:02 -0400 Message-ID: <20260316172003.1024253-7-sashal@kernel.org> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20260316172003.1024253-1-sashal@kernel.org> References: <2026031659-scroll-setting-4687@gregkh> <20260316172003.1024253-1-sashal@kernel.org> Precedence: bulk X-Mailing-List: stable@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit From: Chao Gao [ Upstream commit 8060b2bd2dd05a19ad7ec248489d374f2bd2b057 ] Add consistency checks for CR4.CET and CR0.WP in guest-state or host-state area in the VMCS12. This ensures that configurations with CR4.CET set and CR0.WP not set result in VM-entry failure, aligning with architectural behavior. Tested-by: Mathias Krause Tested-by: John Allen Tested-by: Rick Edgecombe Signed-off-by: Chao Gao Reviewed-by: Binbin Wu Link: https://lore.kernel.org/r/20250919223258.1604852-33-seanjc@google.com Signed-off-by: Sean Christopherson Stable-dep-of: e2ffe85b6d2b ("KVM: x86: Introduce KVM_X86_QUIRK_VMCS12_ALLOW_FREEZE_IN_SMM") Signed-off-by: Sasha Levin --- arch/x86/kvm/vmx/nested.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/arch/x86/kvm/vmx/nested.c b/arch/x86/kvm/vmx/nested.c index 76f9624d49386..509f5c5e1f2b9 100644 --- a/arch/x86/kvm/vmx/nested.c +++ b/arch/x86/kvm/vmx/nested.c @@ -3022,6 +3022,9 @@ static int nested_vmx_check_host_state(struct kvm_vcpu *vcpu, CC(!kvm_vcpu_is_legal_cr3(vcpu, vmcs12->host_cr3))) return -EINVAL; + if (CC(vmcs12->host_cr4 & X86_CR4_CET && !(vmcs12->host_cr0 & X86_CR0_WP))) + return -EINVAL; + if (CC(is_noncanonical_msr_address(vmcs12->host_ia32_sysenter_esp, vcpu)) || CC(is_noncanonical_msr_address(vmcs12->host_ia32_sysenter_eip, vcpu))) return -EINVAL; @@ -3136,6 +3139,9 @@ static int nested_vmx_check_guest_state(struct kvm_vcpu *vcpu, CC(!nested_guest_cr4_valid(vcpu, vmcs12->guest_cr4))) return -EINVAL; + if (CC(vmcs12->guest_cr4 & X86_CR4_CET && !(vmcs12->guest_cr0 & X86_CR0_WP))) + return -EINVAL; + if ((vmcs12->vm_entry_controls & VM_ENTRY_LOAD_DEBUG_CONTROLS) && (CC(!kvm_dr7_valid(vmcs12->guest_dr7)) || CC(!vmx_is_valid_debugctl(vcpu, vmcs12->guest_ia32_debugctl, false)))) -- 2.51.0