Re: [PATCH 1/7] KVM: TDX: Return -EBUSY when tdh_mem_page_add() encounters TDX_OPERAND_BUSY
From: Yan Zhao
Date: Wed Jan 15 2025 - 00:01:27 EST
On Wed, Jan 15, 2025 at 06:24:34AM +0800, Edgecombe, Rick P wrote:
> On Mon, 2025-01-13 at 10:10 +0800, Yan Zhao wrote:
> > diff --git a/arch/x86/kvm/vmx/tdx.c b/arch/x86/kvm/vmx/tdx.c
> > index d0dc3200fa37..1cf3ef0faff7 100644
> > --- a/arch/x86/kvm/vmx/tdx.c
> > +++ b/arch/x86/kvm/vmx/tdx.c
> > @@ -3024,13 +3024,11 @@ static int tdx_gmem_post_populate(struct kvm *kvm, gfn_t gfn, kvm_pfn_t pfn,
> > }
> >
> > ret = 0;
> > - do {
> > - err = tdh_mem_page_add(kvm_tdx->tdr_pa, gpa, pfn_to_hpa(pfn),
> > - pfn_to_hpa(page_to_pfn(page)),
> > - &entry, &level_state);
> > - } while (err == TDX_ERROR_SEPT_BUSY);
> > + err = tdh_mem_page_add(kvm_tdx->tdr_pa, gpa, pfn_to_hpa(pfn),
> > + pfn_to_hpa(page_to_pfn(page)),
> > + &entry, &level_state);
> > if (err) {
> > - ret = -EIO;
> > + ret = unlikely(err & TDX_OPERAND_BUSY) ? -EBUSY : -EIO;
> > goto out;
> > }
>
> Should we just squash this into "KVM: TDX: Add an ioctl to create initial guest
> memory"? I guess we get a little more specific log history on this corner as a
> separate patch, but seems strange to add and remove a loop before it even can
> get exercised.
No problem to me.