From nobody Sat Feb 7 18:15:43 2026 Received: from out-179.mta0.migadu.com (out-179.mta0.migadu.com [91.218.175.179]) (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 D94E742EEA3 for ; Fri, 6 Feb 2026 19:09:40 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=91.218.175.179 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1770404981; cv=none; b=g7lb5QljP8jQYR/dq+60eZbmmJdzh4iS6aPBC06pp+2KQBRkOylNCwBjgU1UBf3bgE97Vq+3Wb0M0A5AxN2ptmJgVcIMtw5hX8HnNwuzSvZgn5LowJvvSLLqQ65az3t6Sexf6PKGqXXkcG96nOcv/HmyLpBUM08nMiK30mwNqls= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1770404981; c=relaxed/simple; bh=Vtfsd92Nedk+qa5QTjaWDaB64PIzJ/VkPPqgqlm5874=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=cPmBRcCfbKukvljE/7BYTVUpfDxScehSyEwSlOrC7BjWXoDDiFVQEJIQGWg3SPdtWfwy5yn2xe2lkvNexYkC4rnsv2rcOZ8vhc3s2pD9+vs++wC9zr3dBXKhODRjELWkujqkBsqCr3UIuB92uqldx4cSkLlp8Av/qtHWNHUFQR4= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev; spf=pass smtp.mailfrom=linux.dev; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b=HR0CrVbk; arc=none smtp.client-ip=91.218.175.179 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.dev Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b="HR0CrVbk" X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1770404979; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=oBlYJPqz9gw2yBOyADq3T7jaA/xUIHeZ1woVZ8G8pf8=; b=HR0CrVbkX/z+cZlMDMrIH5jObvqLSGsXyvMVFBp5eMEqUSwiBu/RnxWRz+WnW8/495Xyx+ 951x2KsV+ZWh/F5xQ+YI/rP5GwD8sh33BhuQy80KvgLTjhtLWA27TOxHLwkRh7ckHIFhJD pKHggN2riJKQti0ktUIC4Bt5OlWne5o= 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 v5 18/26] KVM: nSVM: Add missing consistency check for hCR0.PG and NP_ENABLE Date: Fri, 6 Feb 2026 19:08:43 +0000 Message-ID: <20260206190851.860662-19-yosry.ahmed@linux.dev> In-Reply-To: <20260206190851.860662-1-yosry.ahmed@linux.dev> References: <20260206190851.860662-1-yosry.ahmed@linux.dev> 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 X-Migadu-Flow: FLOW_OUT From the APM Volume #2, 15.25.3 (24593=E2=80=94Rev. 3.42=E2=80=94March 2024= ): If VMRUN is executed with hCR0.PG cleared to zero and NP_ENABLE set to 1 , VMRUN terminates with #VMEXIT(VMEXIT_INVALID). Add the consistency check by plumbing L1's CR0 to nested_vmcb_check_controls(). 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 | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/arch/x86/kvm/svm/nested.c b/arch/x86/kvm/svm/nested.c index a5a5ce060f47..ca2d1b1b8be6 100644 --- a/arch/x86/kvm/svm/nested.c +++ b/arch/x86/kvm/svm/nested.c @@ -342,7 +342,8 @@ static bool nested_svm_check_bitmap_pa(struct kvm_vcpu = *vcpu, u64 pa, u32 size) } =20 static bool nested_vmcb_check_controls(struct kvm_vcpu *vcpu, - struct vmcb_ctrl_area_cached *control) + struct vmcb_ctrl_area_cached *control, + unsigned long l1_cr0) { if (CC(!vmcb12_is_intercept(control, INTERCEPT_VMRUN))) return false; @@ -353,6 +354,8 @@ static bool nested_vmcb_check_controls(struct kvm_vcpu = *vcpu, if (control->nested_ctl & SVM_NESTED_CTL_NP_ENABLE) { if (CC(!kvm_vcpu_is_legal_gpa(vcpu, control->nested_cr3))) return false; + if (CC(!(l1_cr0 & X86_CR0_PG))) + return false; } =20 if (CC(!nested_svm_check_bitmap_pa(vcpu, control->msrpm_base_pa, @@ -947,7 +950,8 @@ int enter_svm_guest_mode(struct kvm_vcpu *vcpu, u64 vmc= b12_gpa, enter_guest_mode(vcpu); =20 if (!nested_vmcb_check_save(vcpu, &svm->nested.save) || - !nested_vmcb_check_controls(vcpu, &svm->nested.ctl)) + !nested_vmcb_check_controls(vcpu, &svm->nested.ctl, + svm->vmcb01.ptr->save.cr0)) return -EINVAL; =20 if (nested_npt_enabled(svm)) @@ -1879,7 +1883,8 @@ static int svm_set_nested_state(struct kvm_vcpu *vcpu, =20 ret =3D -EINVAL; __nested_copy_vmcb_control_to_cache(vcpu, &ctl_cached, ctl); - if (!nested_vmcb_check_controls(vcpu, &ctl_cached)) + /* 'save' contains L1 state saved from before VMRUN */ + if (!nested_vmcb_check_controls(vcpu, &ctl_cached, save->cr0)) goto out_free; =20 /* --=20 2.53.0.rc2.204.g2597b5adb4-goog