Re: [PATCH v6 09/11] KVM: TDX: Get/put PAMT pages when (un)mapping private memory
From: Edgecombe, Rick P
Date: Mon Jul 06 2026 - 16:47:44 EST
On Fri, 2026-07-03 at 11:15 +0800, Binbin Wu wrote:
> > @@ -1669,16 +1683,29 @@ static struct page *tdx_spte_to_sept_pt(struct kvm
> > *kvm, gfn_t gfn,
> > static int tdx_sept_map_nonleaf_spte(struct kvm *kvm, gfn_t gfn,
> > enum pg_level level, u64 new_spte)
> > {
> > + struct kvm_vcpu *vcpu = kvm_get_running_vcpu();
> > + struct vcpu_tdx *tdx = to_tdx(vcpu);
>
> Nit:
> Is it better to move this after checking vcpu is not NULL?
> Although tdx is not dereferenced in between, if vcpu is NULL,
> it means container_of() does arithmetic to a NULL pointer.
Personally I'm on the fence. I'm going to leave it, because Sean did it that
way:
https://lore.kernel.org/kvm/20260129011517.3545883-23-seanjc@xxxxxxxxxx/