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 6D7A93DE455; Mon, 4 May 2026 14:24:37 +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=1777904677; cv=none; b=Pqdpbosruy2T3OlotH0fGFR0++7rw/t5XgxIal4n+nqrNi04rvig7uHd6FDmft86KzBmwezOUuOaRJMaxSP2FXcjUz86RpwIv7fhQABOPd11gZuF1vvyeFwQKRjymjZzncnQelv5l+3YefCN6vtJhjlGoIA0XM4f+tTB7zD8PyQ= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777904677; c=relaxed/simple; bh=twb3E4WC7re5aZQDVZ6pO7TXlnTvBpVFTgKJe1kJTb8=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=ZgYG13Njg51yEQBLVu29fiEIY6ObtRDWUR6CmS1SOt81rsv9jzQYr9PkFUDNmoo/qyUWQHc64js1jEjR8UEu/6MFlqxi9udoUPjPvg7NRDXZ0UmlxuU3ajDypwCF2CWn43dtrvo22lCQhD5OTL20TD5iYtm3JQVPxR/1Mqlq0vg= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=N2NzW92r; 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="N2NzW92r" Received: by smtp.kernel.org (Postfix) with ESMTPSA id E3FEAC2BCB8; Mon, 4 May 2026 14:24:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1777904677; bh=twb3E4WC7re5aZQDVZ6pO7TXlnTvBpVFTgKJe1kJTb8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=N2NzW92rltqnb3OPfJ9MBEOmBL2iXT+PcvIlIk3MIWr96BMZYRaynrgO0Wwc04kcu pNo91cq1VgqUTqFFLCiWJ1iI9DeolSUsyEU//72+IgXC6k+Fg9R2dG91lb4n0YwaSi 58BmJV07iPs1752x+OW1AyZ0GTxseK4dETWcA+60= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Yosry Ahmed , Sean Christopherson Subject: [PATCH 6.12 130/215] KVM: nSVM: Add missing consistency check for EFER, CR0, CR4, and CS Date: Mon, 4 May 2026 15:52:29 +0200 Message-ID: <20260504135134.897150893@linuxfoundation.org> X-Mailer: git-send-email 2.54.0 In-Reply-To: <20260504135130.169210693@linuxfoundation.org> References: <20260504135130.169210693@linuxfoundation.org> User-Agent: quilt/0.69 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-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 6.12-stable review patch. If anyone has any objections, please let me know. ------------------ From: Yosry Ahmed commit 96bd3e76a171a8e21a6387e54e4c420a81968492 upstream. 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 Signed-off-by: Greg Kroah-Hartman --- arch/x86/kvm/svm/nested.c | 6 ++++++ arch/x86/kvm/svm/svm.h | 1 + 2 files changed, 7 insertions(+) --- a/arch/x86/kvm/svm/nested.c +++ b/arch/x86/kvm/svm/nested.c @@ -310,6 +310,10 @@ static bool __nested_vmcb_check_save(str 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. */ @@ -398,6 +402,8 @@ static void __nested_copy_vmcb_save_to_c * 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; --- a/arch/x86/kvm/svm/svm.h +++ b/arch/x86/kvm/svm/svm.h @@ -136,6 +136,7 @@ struct kvm_vmcb_info { }; struct vmcb_save_area_cached { + struct vmcb_seg cs; u64 efer; u64 cr4; u64 cr3;