From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (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 E0577346E55; Sat, 30 May 2026 17:49:32 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780163373; cv=none; b=qfInH16Pj9sytSbz2+/feitiYk1H5qkvbNI6fXuHiUXa4x3krtccThWsi5PK33kj0b22emcI538JgezygWwDfZ4Ur7pj/k/SuwR/rdQFC+xI0lnIRU6iFepcF/gNpTVTfCb5AbMQ9bewuOh04+19MTbBkfIZxkrbwOEadN0nviw= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780163373; c=relaxed/simple; bh=v9C+CnXuon2zysMfIWvlX1q/1uDzMcI4p48B8IT8pcM=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=tkEZIJ35rGuRDXIiQDUCGt6aULckyNawi5bRycstat6NN1hD8buhICshgrws20/5gLuYw6Q7Ydn7awreVzsyPNYK8hCEDwHFLKSJQmfjvU9lDAr2sugboys/iV2Oh5ghsRojooJduWcH3S/mDG043FUbp8cXbWujCYfM3DuMS9o= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=k0zOEoc5; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="k0zOEoc5" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 30B071F00893; Sat, 30 May 2026 17:49:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1780163372; bh=vdNbfytVZmzbAJWNxkONcqjyRIOFxV79QOFEGDBJK9E=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=k0zOEoc50ucaz57LOY8RrTJGgvpZ+J7FEI2dPafrFFpNjhnMjssrWhee/IBvpkdtD 1WHJMaUPYoz0ZyeprYrgPeTYlbtRqjag/Y/eCmigBKbPM5/J4aQP36uePveNaiI498 ev8rHIMQ8IVe5zz8TiYn9SpkYVaEU5tqULVzLYv8= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Yosry Ahmed , Sean Christopherson Subject: [PATCH 5.15 239/776] KVM: nSVM: Add missing consistency check for nCR3 validity Date: Sat, 30 May 2026 17:59:13 +0200 Message-ID: <20260530160246.708192373@linuxfoundation.org> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260530160240.228940103@linuxfoundation.org> References: <20260530160240.228940103@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: patches@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 5.15-stable review patch. If anyone has any objections, please let me know. ------------------ From: Yosry Ahmed commit b71138fcc362c67ebe66747bb22cb4e6b4d6a651 upstream. >>From the APM Volume #2, 15.25.4 (24593—Rev. 3.42—March 2024): When VMRUN is executed with nested paging enabled (NP_ENABLE = 1), the following conditions are considered illegal state combinations, in addition to those mentioned in “Canonicalization and Consistency Checks”: • Any MBZ bit of nCR3 is set. • Any G_PAT.PA field has an unsupported type encoding or any reserved field in G_PAT has a nonzero value. Add the consistency check for nCR3 being a legal GPA with no MBZ bits set. Note, the G_PAT.PA check is being handled separately[*]. Link: https://lore.kernel.org/kvm/20260205214326.1029278-3-jmattson@google.com [*] Fixes: 4b16184c1cca ("KVM: SVM: Initialize Nested Nested MMU context on VMRUN") Cc: stable@vger.kernel.org Signed-off-by: Yosry Ahmed Link: https://patch.msgid.link/20260303003421.2185681-16-yosry@kernel.org [sean: capture everything in CC(), massage changelog formatting] Signed-off-by: Sean Christopherson Signed-off-by: Greg Kroah-Hartman --- arch/x86/kvm/svm/nested.c | 4 ++++ 1 file changed, 4 insertions(+) --- a/arch/x86/kvm/svm/nested.c +++ b/arch/x86/kvm/svm/nested.c @@ -256,6 +256,10 @@ static bool nested_vmcb_check_controls(s if (CC((control->nested_ctl & SVM_NESTED_CTL_NP_ENABLE) && !npt_enabled)) return false; + if (CC((control->nested_ctl & SVM_NESTED_CTL_NP_ENABLE) && + !kvm_vcpu_is_legal_gpa(vcpu, control->nested_cr3))) + return false; + if (CC(!nested_svm_check_bitmap_pa(vcpu, control->msrpm_base_pa, MSRPM_SIZE))) return false;