[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CABgObfZMR5y7T_dv-V8ng0dv=L00XgUmaDm-V9Y1aVEuz=0anw@mail.gmail.com>
Date: Tue, 7 Jan 2025 15:02:28 +0100
From: Paolo Bonzini <pbonzini@...hat.com>
To: Yan Zhao <yan.y.zhao@...el.com>
Cc: seanjc@...gle.com, kvm@...r.kernel.org, dave.hansen@...ux.intel.com,
rick.p.edgecombe@...el.com, kai.huang@...el.com, adrian.hunter@...el.com,
reinette.chatre@...el.com, xiaoyao.li@...el.com, tony.lindgren@...el.com,
binbin.wu@...ux.intel.com, dmatlack@...gle.com, isaku.yamahata@...el.com,
isaku.yamahata@...il.com, nik.borisov@...e.com, linux-kernel@...r.kernel.org,
x86@...nel.org
Subject: Re: [PATCH v2 22/24] KVM: TDX: Finalize VM initialization
On Tue, Jan 7, 2025 at 8:45 AM Yan Zhao <yan.y.zhao@...el.com> wrote:
> > @@ -1715,8 +1715,8 @@ static int tdx_gmem_post_populate(struct kvm *kvm, gfn_t gfn, kvm_pfn_t pfn,
> > goto out;
> > }
> > - WARN_ON_ONCE(!atomic64_read(&kvm_tdx->nr_premapped));
> > - atomic64_dec(&kvm_tdx->nr_premapped);
> > + if (!WARN_ON_ONCE(!atomic64_read(&kvm_tdx->nr_premapped)))
> > + atomic64_dec(&kvm_tdx->nr_premapped);
> One concern here.
> If tdx_gmem_post_populate() is called when kvm_tdx->nr_premapped is 0, it will
> trigger the WARN_ON here, indicating that something has gone wrong.
> Should KVM refuse to start the TD in this case?
>
> If we don't decrease kvm_tdx->nr_premapped in that case, it will remain 0,
> allowing it to pass the check in tdx_td_finalize().
Let's make it a KVM_BUG_ON then.
Paolo
Powered by blists - more mailing lists