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 9C42626CE11 for ; Sun, 3 May 2026 12:18:55 +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=1777810735; cv=none; b=mBlVXpTtSqnfXHcx2OVe6NTMhNK30aMY01aE5EVU4jcJsn61k2LAdtgI0bPuyC4jA8tI3yqxis9B3nnagbQOSavkgixoSQLzwSriGNf60wzy8WDls3JP+GUOH/mxiAgJsaisuV4RUlGWEmipqNSTaap8BTemI8w9W2qf92cV+Pk= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777810735; c=relaxed/simple; bh=qeE5+kd+UEatjYuSHBvk/Rm8YfuMyAD5PeftIuaq0N0=; h=Subject:To:Cc:From:Date:Message-ID:MIME-Version:Content-Type; b=XsLrVGi28E+btCEdhH08lRYBhrSgvEvVjhdT3kIAQOfJgcINb3jMwWwsGkma+CHC72gAv9RmZ+ofZ2UL1QS0XzvA571s1UWjkQSES58gSOfHtWYxl5QiLJPOzVnLBjFL3kH23410cW5ZRmZLhFkpQkeeXHIm6SJg2u7KJp5bJfs= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=N2B1iBHY; 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="N2B1iBHY" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 07AF7C2BCB4; Sun, 3 May 2026 12:18:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1777810735; bh=qeE5+kd+UEatjYuSHBvk/Rm8YfuMyAD5PeftIuaq0N0=; h=Subject:To:Cc:From:Date:From; b=N2B1iBHYkQOlkWXqR/gsEfl4iEkb7WxZOwUR4gCqybPrLCgPkR8ezTqpi7D1wBfcT R9hQnQFRxkkQWIEDPrTWexPV8GBslWfPHfWTXey7/0qhepBMla3tSVvzAQE4B6hLLu +5CXm7uve86F/GmmGgzIa3KVz0J3edF8pcyJE6Pc= Subject: FAILED: patch "[PATCH] KVM: nSVM: Add missing consistency check for EFER, CR0, CR4," failed to apply to 5.10-stable tree To: yosry@kernel.org,seanjc@google.com Cc: From: Date: Sun, 03 May 2026 14:18:44 +0200 Message-ID: <2026050344-throwback-dilation-fc45@gregkh> Precedence: bulk X-Mailing-List: stable@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The patch below does not apply to the 5.10-stable tree. If someone wants it applied there, or to any other stable or longterm tree, then please email the backport, including the original git commit id to . To reproduce the conflict and resubmit, you may use the following commands: git fetch https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/ linux-5.10.y git checkout FETCH_HEAD git cherry-pick -x 96bd3e76a171a8e21a6387e54e4c420a81968492 # git commit -s git send-email --to '' --in-reply-to '2026050344-throwback-dilation-fc45@gregkh' --subject-prefix 'PATCH 5.10.y' HEAD^.. Possible dependencies: thanks, greg k-h ------------------ original commit in Linus's tree ------------------ >From 96bd3e76a171a8e21a6387e54e4c420a81968492 Mon Sep 17 00:00:00 2001 From: Yosry Ahmed Date: Tue, 3 Mar 2026 00:34:10 +0000 Subject: [PATCH] KVM: nSVM: Add missing consistency check for EFER, CR0, CR4, and CS MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit According to the APM Volume #2, 15.5, Canonicalization and Consistency Checks (24593—Rev. 3.42—March 2024), the following condition (among others) results in a #VMEXIT with VMEXIT_INVALID (aka SVM_EXIT_ERR): EFER.LME, CR0.PG, CR4.PAE, CS.L, and CS.D are all non-zero. In the list of consistency checks done when EFER.LME and CR0.PG are set, add a check that CS.L and CS.D are not both set, after the existing check that CR4.PAE is set. This is functionally a nop because the nested VMRUN results in SVM_EXIT_ERR in HW, which is forwarded to L1, but KVM makes all consistency checks before a VMRUN is actually attempted. Fixes: 3d6368ef580a ("KVM: SVM: Add VMRUN handler") Cc: stable@vger.kernel.org Signed-off-by: Yosry Ahmed Link: https://patch.msgid.link/20260303003421.2185681-17-yosry@kernel.org Signed-off-by: Sean Christopherson diff --git a/arch/x86/kvm/svm/nested.c b/arch/x86/kvm/svm/nested.c index a59b976c16db..50180565bcfc 100644 --- a/arch/x86/kvm/svm/nested.c +++ b/arch/x86/kvm/svm/nested.c @@ -391,6 +391,10 @@ static bool nested_vmcb_check_save(struct kvm_vcpu *vcpu, CC(!(save->cr0 & X86_CR0_PE)) || CC(!kvm_vcpu_is_legal_cr3(vcpu, save->cr3))) return false; + + if (CC((save->cs.attrib & SVM_SELECTOR_L_MASK) && + (save->cs.attrib & SVM_SELECTOR_DB_MASK))) + return false; } /* Note, SVM doesn't have any additional restrictions on CR4. */ @@ -486,6 +490,8 @@ static void __nested_copy_vmcb_save_to_cache(struct vmcb_save_area_cached *to, * Copy only fields that are validated, as we need them * to avoid TOC/TOU races. */ + to->cs = from->cs; + to->efer = from->efer; to->cr0 = from->cr0; to->cr3 = from->cr3; diff --git a/arch/x86/kvm/svm/svm.h b/arch/x86/kvm/svm/svm.h index 7629cb37c930..0a5d5a4453b7 100644 --- a/arch/x86/kvm/svm/svm.h +++ b/arch/x86/kvm/svm/svm.h @@ -140,6 +140,7 @@ struct kvm_vmcb_info { }; struct vmcb_save_area_cached { + struct vmcb_seg cs; u64 efer; u64 cr4; u64 cr3;