From nobody Thu Apr 2 06:27:04 2026 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 E71AA35F171; Tue, 3 Mar 2026 00:34: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=1772498078; cv=none; b=X7zKLQayGq1txiz/VTIlrEddvMB8Pkp5TyE/rhAA1/23p4jAwcCuaRAIOqSG8kvz8NoYoeu04o57JWlkc1TxvT/tzELQZSGRhHC1duZQ8in00wHNEAW7ORzK/Z2Q0tgB+x0uwuUaflFkWcM8dGyDatdGme6lpOKhGmd/4A+rr2g= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1772498078; c=relaxed/simple; bh=4yF4ObMkUIsa5S10Tx/7NPubGq6kLDk80Z+SpNKvNkI=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=IwxH/xw3vYKDSDTty77LKaTMRlqVc6MJHfKkKmoppYn9g1rCLYG/0rQTDI4V/4qyGl+y0RK97oxLCjv5Vh3K0t6f/M6mkejawHOX2GQvlAm6a3JWOZEgUCkY0yZQXSf0RqNm1V81mbkKo7VuAZg0vvt8asSLZ/DJwIaW2hAgMuo= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=X5Qmc9Ii; 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="X5Qmc9Ii" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 75490C2BCB0; Tue, 3 Mar 2026 00:34:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1772498077; bh=4yF4ObMkUIsa5S10Tx/7NPubGq6kLDk80Z+SpNKvNkI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=X5Qmc9Ii20cmtZR0kZRHCf2J3nrhhIeANVXWoTmRV+A0ujH3++pnqOFIXuzsB3uYp SI+3VQGG2xcZYI2TFJIo2p/tpF4TKzJldOjnD8y3VGkQLvlZc5Cyiuwk+hz/1TXK3B 7U44VvMKClHwhNN8sOgQ1iyAjQ3+4yCXCz6sHt8B9+R+2XK/GU4jBtKEU0sFVRJOo/ kQFIzlhk3bwtpX2j4WXTbve5axtL9P0NC1Pi1s1EPzXAS19fgs1E+gBzq8osoLhPto Wl/EXifzy4Gmf6VQbPaS6DM78dKBiJZ5bmhYTKbJQWXIJthYSdZn8DBAZ0OkN2GSXN V8opTrbYOx50g== From: Yosry Ahmed To: Sean Christopherson Cc: Paolo Bonzini , kvm@vger.kernel.org, linux-kernel@vger.kernel.org, Yosry Ahmed , stable@vger.kernel.org Subject: [PATCH v7 15/26] KVM: nSVM: Add missing consistency check for nCR3 validity Date: Tue, 3 Mar 2026 00:34:09 +0000 Message-ID: <20260303003421.2185681-16-yosry@kernel.org> X-Mailer: git-send-email 2.53.0.473.g4a7958ca14-goog In-Reply-To: <20260303003421.2185681-1-yosry@kernel.org> References: <20260303003421.2185681-1-yosry@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable From the APM Volume #2, 15.25.4 (24593=E2=80=94Rev. 3.42=E2=80=94March 2024= ): When VMRUN is executed with nested paging enabled (NP_ENABLE =3D 1), the following conditions are considered illegal state combinations, in addition to those mentioned in =E2=80=9CCanonicalization and Consistency Checks=E2=80=9D: =E2=80=A2 Any MBZ bit of nCR3 is set. =E2=80=A2 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. The G_PAT.PA check was proposed separately [*]. [*]https://lore.kernel.org/kvm/20260205214326.1029278-3-jmattson@google.com/ Fixes: 4b16184c1cca ("KVM: SVM: Initialize Nested Nested MMU context on VMR= UN") Cc: stable@vger.kernel.org Signed-off-by: Yosry Ahmed --- arch/x86/kvm/svm/nested.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/arch/x86/kvm/svm/nested.c b/arch/x86/kvm/svm/nested.c index 613d5e2e7c3d1..3aaa4f0bb31ab 100644 --- a/arch/x86/kvm/svm/nested.c +++ b/arch/x86/kvm/svm/nested.c @@ -348,6 +348,11 @@ static bool nested_vmcb_check_controls(struct kvm_vcpu= *vcpu, if (CC(control->asid =3D=3D 0)) return false; =20 + if (control->nested_ctl & SVM_NESTED_CTL_NP_ENABLE) { + if (CC(!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; --=20 2.53.0.473.g4a7958ca14-goog