From: Oliver Upton <oupton@kernel.org>
To: Marc Zyngier <maz@kernel.org>
Cc: fuqiang wang <fuqiang.wng@gmail.com>,
Zenghui Yu <yuzenghui@huawei.com>,
linux-kernel@vger.kernel.org, kvmarm@lists.linux.dev,
dongxu zhang <xu910121@sina.com>,
wangfuqiang49 <wangfuqiang49@jd.com>
Subject: Re: [PATCH v2 2/2] KVM: arm64: Skip unreset vCPUs in MPIDR lookup table
Date: Sun, 14 Jun 2026 21:20:35 -0700 [thread overview]
Message-ID: <ai99kwiaJq-VIAUk@kernel.org> (raw)
In-Reply-To: <87o6hd8oc7.wl-maz@kernel.org>
On Sun, Jun 14, 2026 at 10:26:32AM +0100, Marc Zyngier wrote:
> > diff --git a/arch/arm64/kvm/arm.c b/arch/arm64/kvm/arm.c
> > index 3732ee9eb0d4..fccfa97370df 100644
> > --- a/arch/arm64/kvm/arm.c
> > +++ b/arch/arm64/kvm/arm.c
> > @@ -887,8 +887,18 @@ static void kvm_init_mpidr_data(struct kvm *kvm)
> > data->mpidr_mask = mask;
> >
> > kvm_for_each_vcpu(c, vcpu, kvm) {
> > - u64 aff = kvm_vcpu_get_mpidr_aff(vcpu);
> > - u16 index = kvm_mpidr_index(data, aff);
> > + u64 aff;
> > + u16 index;
> > +
> > + /*
> > + * Skip vCPUs that haven't been reset yet; their MPIDR_EL1 is
> > + * zero.
> > + */
> > + if (!kvm_vcpu_mpidr_is_reset(vcpu))
> > + continue;
>
> But what about the initial loop that computes the significant bits
> amongst the vcpus?
>
> > +
> > + aff = kvm_vcpu_get_mpidr_aff(vcpu);
> > + index = kvm_mpidr_index(data, aff);
>
> In all honesty, I think this is a userspace bug more than anything
> else, and checking for random bits in MPDR_EL1 to verify whether the
> value is plausible is gross.
+1. Checking the MPIDR value is also broken because userspace can write
whatever it wants to the register, which could even clear the RES1 bit
that's getting tested here.
> Yhis isn't different from setting MPIDR_EL1 to the same value on all
> vcpus, which we don't try to mitigate. Late setting of MPIDR_EL1 also
> defeats the whole point of having a cache for the affinity to index
> conversion, making SGIs pretty slow for late CPUs.
>
> I really think that by not finalising your vcpus and start running the
> guest, you have cornered yourself pretty badly, and we shouldn't try
> to paper over it.
I generally agree, although I wouldn't be against a change that nuked
any of the cached routings in case of userspace doing stupid things like
collisions and whatnot.
Thanks,
Oliver
next prev parent reply other threads:[~2026-06-15 4:20 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-06-11 14:40 [PATCH v2 0/2] KVM: arm64: Fix MPIDR lookup for unreset vCPUs fuqiang wang
2026-06-11 14:40 ` [PATCH v2 1/2] arm64: Add MPIDR_EL1 RES1 definitions fuqiang wang
2026-06-11 14:40 ` [PATCH v2 2/2] KVM: arm64: Skip unreset vCPUs in MPIDR lookup table fuqiang wang
2026-06-14 9:26 ` Marc Zyngier
2026-06-15 4:20 ` Oliver Upton [this message]
2026-06-15 10:08 ` Marc Zyngier
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=ai99kwiaJq-VIAUk@kernel.org \
--to=oupton@kernel.org \
--cc=fuqiang.wng@gmail.com \
--cc=kvmarm@lists.linux.dev \
--cc=linux-kernel@vger.kernel.org \
--cc=maz@kernel.org \
--cc=wangfuqiang49@jd.com \
--cc=xu910121@sina.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