From: Naveen N Rao <naveen@kernel.org>
To: Sean Christopherson <seanjc@google.com>
Cc: Paolo Bonzini <pbonzini@redhat.com>,
kvm@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH 2/2] KVM: SVM: Drop unnecessary avic_vm_destroy() call on init failure
Date: Fri, 3 Jul 2026 21:51:59 +0530 [thread overview]
Message-ID: <akffsFoCvlyz5y9S@blrnaveerao1> (raw)
In-Reply-To: <akMLDayXmzhmvJBG@google.com>
On Mon, Jun 29, 2026 at 05:17:17PM -0700, Sean Christopherson wrote:
> On Mon, Jun 29, 2026, Naveen N Rao wrote:
> > On Thu, Jun 25, 2026 at 03:09:33PM -0700, Sean Christopherson wrote:
> > > Don't bother calling avic_vm_destroy() when allocating the logical ID table
> > > fails, as there is nothing to clean up now that the physical ID table is
> > > allocated later, on-demand at first vCPU creation.
> > >
> > > For all intents and purposes, no functional change intended, as calling
> > > avic_vm_destroy() is a big nop in this case.
> > >
> > > Fixes: 54ffe74cc4ab ("KVM: SVM: Move AVIC Physical ID table allocation to vcpu_precreate()")
> > > Cc: Naveen N Rao (AMD) <naveen@kernel.org>
> > > Signed-off-by: Sean Christopherson <seanjc@google.com>
> > > ---
> > > arch/x86/kvm/svm/avic.c | 7 +------
> > > 1 file changed, 1 insertion(+), 6 deletions(-)
> >
> > This LGTM, though I'm not sure this deserves a fixes tag.
>
> Yeah, it's borderline. Because KVM (x86) doesn't do AUTOSEL, i.e. requires an
> explicit "Cc: stable@vger.kernel.org" for the vast majority of cases, we can be
> very liberal with Fixes. And so I like to use Fixes to create a paper trail for
> anything where a commit did something that would have necessitate a new version
> of the patch, had it been caught in code review.
Ah, that's the reason for preferring Fixes: tag over Cc: stable, got it.
>
> > FWIW, I have had a patch (part of a larger series I am going to post
> > soon) to move the logical_id_table allocation alongside the physical ID
> > table allocation. I'm fine if you want to queue your patch first, but
> > this is what I have locally:
>
> Ah shoot, I should have read this mail earlier. While floundering around, trying
> to figure out how to deal with kvm_arch_pre_destroy_vm() not being called when
> VM creation fails after kvm_arch_init_vm(), I ended up with the same idea, though
> I moved *all* of avic_vm_init() to the vCPU-precreate phase. Because what I
> needed was to defer adding the VM to the GA Log list until the VM is fully
> created.
>
> > @@ -303,10 +303,16 @@ int avic_alloc_physical_id_table(struct kvm *kvm)
> > if (kvm_svm->avic_physical_id_table)
> > return 0;
> >
> > + kvm_svm->avic_logical_id_table = (void *)get_zeroed_page(GFP_KERNEL_ACCOUNT);
> > + if (!kvm_svm->avic_logical_id_table)
> > + return -ENOMEM;
> > +
> > kvm_svm->avic_physical_id_table = (void *)__get_free_pages(GFP_KERNEL_ACCOUNT | __GFP_ZERO,
> > avic_get_physical_id_table_order(kvm));
> > - if (!kvm_svm->avic_physical_id_table)
> > + if (!kvm_svm->avic_physical_id_table) {
> > + free_page((unsigned long)kvm_svm->avic_logical_id_table);
>
> Freeing the page on failure is "wrong". To keep vCPU creation idempotent from
> userspace's perspective (well, not truly idempotent, but close-ish), KVM
> deliberately doesn't unwind if .vcpu_precreate() fails. E.g. so that if
> allocating the tables succeeds, but a later stage of vCPU creation fails,
> subsequent calls to create vCPUs won't fail at the earlier stage.
>
> The nice thing is that since the VM has already been created, there's no need to
> every unwind on failure, because it's no different than if KVM had successfully
> allocate the assets during VM creation.
Understood - I see there is a comment about this in
kvm_arch_vcpu_precreate() which I missed. Thanks for the details!
- Naveen
prev parent reply other threads:[~2026-07-03 16:27 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-06-25 22:09 [PATCH 0/2] KVM: SVM: Fix a (very) unlikely UAF for GA Log IRQs Sean Christopherson
2026-06-25 22:09 ` [PATCH 1/2] KVM: SVM: Remove VM from the GA Log notifier list before VM destruction Sean Christopherson
2026-06-25 22:26 ` sashiko-bot
2026-06-28 18:30 ` XIAO WU
2026-06-25 22:09 ` [PATCH 2/2] KVM: SVM: Drop unnecessary avic_vm_destroy() call on init failure Sean Christopherson
2026-06-25 22:25 ` sashiko-bot
2026-06-29 13:27 ` Naveen N Rao
2026-06-30 0:17 ` Sean Christopherson
2026-07-03 16:21 ` Naveen N Rao [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=akffsFoCvlyz5y9S@blrnaveerao1 \
--to=naveen@kernel.org \
--cc=kvm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=pbonzini@redhat.com \
--cc=seanjc@google.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.