From: Marc Zyngier <maz@kernel.org>
To: Zenghui Yu <yuzenghui@huawei.com>
Cc: <kvmarm@lists.linux.dev>, <linux-arm-kernel@lists.infradead.org>,
James Morse <james.morse@arm.com>,
Suzuki K Poulose <suzuki.poulose@arm.com>,
Oliver Upton <oliver.upton@linux.dev>,
Alexander Potapenko <glider@google.com>
Subject: Re: [PATCH] KVM: arm64: vgic: Hold config_lock while tearing down a CPU interface
Date: Mon, 19 Aug 2024 13:48:38 +0100 [thread overview]
Message-ID: <861q2kznix.wl-maz@kernel.org> (raw)
In-Reply-To: <40d0a14b-b501-aef6-a168-1c1acd5448e7@huawei.com>
On Mon, 19 Aug 2024 13:31:59 +0100,
Zenghui Yu <yuzenghui@huawei.com> wrote:
>
> On 2024/8/19 18:53, Marc Zyngier wrote:
> > On Mon, 19 Aug 2024 10:39:50 +0100,
> > Zenghui Yu <yuzenghui@huawei.com> wrote:
> > >
> > > Hi Marc,
> > >
> > > On 2024/8/8 17:15, Marc Zyngier wrote:
> > > > Tearing down a vcpu CPU interface involves freeing the private interrupt
> > > > array. If we don't hold the lock, we may race against another thread
> > > > trying to configure it. Yeah, fuzzers do wonderful things...
> > > >
> > > > Taking the lock early solves this particular problem.
> > > >
> > > > Fixes: 03b3d00a70b5 ("KVM: arm64: vgic: Allocate private interrupts on demand")
> > > > Reported-by: Alexander Potapenko <glider@google.com>
> > > > Tested-by: Alexander Potapenko <glider@google.com>
> > > > Signed-off-by: Marc Zyngier <maz@kernel.org>
> > > > ---
> > > > arch/arm64/kvm/vgic/vgic-init.c | 3 +--
> > > > 1 file changed, 1 insertion(+), 2 deletions(-)
> > > >
> > > > diff --git a/arch/arm64/kvm/vgic/vgic-init.c b/arch/arm64/kvm/vgic/vgic-init.c
> > > > index 7f68cf58b978..41feb858ff9a 100644
> > > > --- a/arch/arm64/kvm/vgic/vgic-init.c
> > > > +++ b/arch/arm64/kvm/vgic/vgic-init.c
> > > > @@ -438,14 +438,13 @@ void kvm_vgic_destroy(struct kvm *kvm)
> > > > unsigned long i;
> > > >
> > > > mutex_lock(&kvm->slots_lock);
> > > > + mutex_lock(&kvm->arch.config_lock);
> > > >
> > > > vgic_debug_destroy(kvm);
> > > >
> > > > kvm_for_each_vcpu(i, vcpu, kvm)
> > > > __kvm_vgic_vcpu_destroy(vcpu);
> > > >
> > > > - mutex_lock(&kvm->arch.config_lock);
> > > > -
> > > > kvm_vgic_dist_destroy(kvm);
> > > >
> > > > mutex_unlock(&kvm->arch.config_lock);
> > >
> > > The following splat was triggered when running the vgic_init selftest on
> > > a lockdep kernel (I use rc4, with defconfig + PROVE_LOCKING).
> > >
> > > I'm not entirely sure that the splat is related to this change. Just
> > > haven't got time to dig further so post it out early for record.
> >
> > Arghh. Thanks for reporting this. Can you try the following patch? It
> > does the trick for me, but I don't trust myself anymore...
>
> I tested it with defconfig+PROVE_LOCKING and my own config, both worked
> for me (the WARNING disappeared). I think the locking order should be
> correct now.
Awesome. Let me post a proper patch right away.
Thanks again,
M.
--
Without deviation from the norm, progress is not possible.
prev parent reply other threads:[~2024-08-19 12:49 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-08-08 9:15 [PATCH] KVM: arm64: vgic: Hold config_lock while tearing down a CPU interface Marc Zyngier
2024-08-08 17:07 ` Oliver Upton
2024-08-19 9:39 ` Zenghui Yu
2024-08-19 10:53 ` Marc Zyngier
2024-08-19 12:31 ` Zenghui Yu
2024-08-19 12:48 ` Marc Zyngier [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=861q2kznix.wl-maz@kernel.org \
--to=maz@kernel.org \
--cc=glider@google.com \
--cc=james.morse@arm.com \
--cc=kvmarm@lists.linux.dev \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=oliver.upton@linux.dev \
--cc=suzuki.poulose@arm.com \
--cc=yuzenghui@huawei.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).