From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pl1-f202.google.com (mail-pl1-f202.google.com [209.85.214.202]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 07AD935F190 for ; Tue, 3 Mar 2026 16:56:18 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.202 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1772556980; cv=none; b=LnnRtdjZVtPZqXYV4jsSkhPDx9nya/YORvAEiSvtEOYJMm3j95lSr3qJro4NFPDW9MT6OzJex1ht9jgAQzWHtncqSKaqyBx0MdbXOC6azYCIeX7wyappITPkvdw4voc0y8/YA8ogx6NNoRm3sFCA3VXQBcetOz51Vhc9GACkRuo= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1772556980; c=relaxed/simple; bh=eWysGtIDtMY7WDGsLwuZ7l3aSoC9YDb5TvHL34ug0ic=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=ul5pmLWmTdnBgV1sI827O9Fb5AWIZKcYaEJN4+5rMwyER0d1BNVUSOtRtoEq5JNZHm4QkKsOOHMoWjj8J3NbOr3fVPFMV/uXJgEbqii0qX3eHA0xXpbBOUxmBoAqzk7eA9HPqfcBfcOc2vWGUxh7jclLPrQ0f+bAJG37hglC6SU= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--seanjc.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=c8YvlDnQ; arc=none smtp.client-ip=209.85.214.202 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--seanjc.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="c8YvlDnQ" Received: by mail-pl1-f202.google.com with SMTP id d9443c01a7336-2a90510a6d1so41133115ad.0 for ; Tue, 03 Mar 2026 08:56:18 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1772556978; x=1773161778; darn=vger.kernel.org; h=content-transfer-encoding:cc:to:from:subject:message-id:references :mime-version:in-reply-to:date:from:to:cc:subject:date:message-id :reply-to; bh=eEsXhRGfZVnXfS8LLMQGFDrO1HKI5tLULsw5o2HLG48=; b=c8YvlDnQtAni58rJFLcmjT8FZMpwFZCyY+lKHOuNoeLV21Ms4jddjfIPJtVRXeEtTH 3FdrTrn1j1cL63Hypa1Opzizcm1y9XZiSF6qORwZh07tKST4XozT1Mmxf3ua470qzzSc 4/i7fs9YtRCk5T05HQeKTrnkwPgwLnnE0V4nKkVW81XSP9DXgXiMve9ODE33q3zokHrC CnKbCQG8HCOoqyVy/x8UxOvSioW8TRvjd7OYX3D+542SeVju7hoF01DjZ68DcsIVJKcV WEs70t/zSGY+qto9xa5s7aCLnuuarZwiRweXhlvFWAHdYG5Jb+TH2uSDqxQrE0siyZSs o2Eg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1772556978; x=1773161778; h=content-transfer-encoding:cc:to:from:subject:message-id:references :mime-version:in-reply-to:date:x-gm-message-state:from:to:cc:subject :date:message-id:reply-to; bh=eEsXhRGfZVnXfS8LLMQGFDrO1HKI5tLULsw5o2HLG48=; b=UauD/JDZ0O28TV2nEsl5dx3RuUf9B3L2RvKawqkrGUM+ZGbt5JjZY6z3WSXPHX3LMr Lvc6Q7DkXvkvMBiDySyX0Yjf4lR5qO0yO5PC8SDqklWEAR1g/sUyE0dmd5l2BJN33zmx Y9OB+s++VJ0tT13UQ5kdA0RHS6OGHjk8DSrKnVbiRhieH5yhfOa6CzcgKdBjXICWdqk4 K3fSr/vRwf2lohwkYf+vkUTh6EvdFO6HMdsHhqHq4rEEXQNDfltjmlQpPj2JtFccJjws RDY4PbwgCvWGr+0S3cpU39Jgi8QkbVH7y+wqQ9wSJ1aB1s/dlRFef9bBR41xLrz6+snQ J34w== X-Forwarded-Encrypted: i=1; AJvYcCXMkmpgRD5nD5vUDeLkfL1cRpIzt/1UiWaJCnfrOY/KIfJfkQjz9wRJkldiKgxNPsA0r/1zBiFRGzRMy7s=@vger.kernel.org X-Gm-Message-State: AOJu0YwbwSqeLd+BsmoB4mqyKQZzXXg5Ij+ugfLXAlmU2Sh2Afh+o6Ra TFg5FG8X0cnv1YFHIFzVCB4sWReCEP7o9OdXkPSb4l18Nph89kEDBV49oMN0z3Kx42ditWnq80A i7AEXXA== X-Received: from plsl16.prod.google.com ([2002:a17:903:2450:b0:2ae:4482:4ee0]) (user=seanjc job=prod-delivery.src-stubby-dispatcher) by 2002:a17:903:2446:b0:2a7:5f26:aaf9 with SMTP id d9443c01a7336-2ae60d54212mr25676705ad.14.1772556977076; Tue, 03 Mar 2026 08:56:17 -0800 (PST) Date: Tue, 3 Mar 2026 08:56:15 -0800 In-Reply-To: <20260303003421.2185681-16-yosry@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20260303003421.2185681-1-yosry@kernel.org> <20260303003421.2185681-16-yosry@kernel.org> Message-ID: Subject: Re: [PATCH v7 15/26] KVM: nSVM: Add missing consistency check for nCR3 validity From: Sean Christopherson To: Yosry Ahmed Cc: Paolo Bonzini , kvm@vger.kernel.org, linux-kernel@vger.kernel.org, stable@vger.kernel.org Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable On Tue, Mar 03, 2026, Yosry Ahmed wrote: > >From the APM Volume #2, 15.25.4 (24593=E2=80=94Rev. 3.42=E2=80=94March 2= 024): >=20 > 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. >=20 > Add the consistency check for nCR3 being a legal GPA with no MBZ bits > set. The G_PAT.PA check was proposed separately [*]. >=20 > [*]https://lore.kernel.org/kvm/20260205214326.1029278-3-jmattson@google.c= om/ >=20 > Fixes: 4b16184c1cca ("KVM: SVM: Initialize Nested Nested MMU context on V= MRUN") > Cc: stable@vger.kernel.org > Signed-off-by: Yosry Ahmed > --- > arch/x86/kvm/svm/nested.c | 5 +++++ > 1 file changed, 5 insertions(+) >=20 > 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_vc= pu *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; Put the full if-statement in CC(), that way the tracepoint will capture the= entire clause, i.e. will help the reader understand than nested_cr3 was checked specifically because NPT was enabled. if (CC((control->nested_ctl & SVM_NESTED_CTL_NP_ENABLE) && !kvm_vcpu_is_legal_gpa(vcpu, control->nested_cr3))) return false;