From: fuqiang wang <fuqiang.wng@gmail.com>
To: Marc Zyngier <maz@kernel.org>, Oliver Upton <oupton@kernel.org>,
Zenghui Yu <yuzenghui@huawei.com>,
linux-kernel@vger.kernel.org, kvmarm@lists.linux.dev
Cc: dongxu zhang <xu910121@sina.com>, wangfuqiang49 <wangfuqiang49@jd.com>
Subject: [PATCH v2 0/2] KVM: arm64: Fix MPIDR lookup for unreset vCPUs
Date: Thu, 11 Jun 2026 22:40:40 +0800 [thread overview]
Message-ID: <20260611144042.97981-1-fuqiang.wng@gmail.com> (raw)
From: wangfuqiang49 <wangfuqiang49@jd.com>
Hi,
This series fixes an MPIDR lookup issue when a VM is created with CPU
hotplug support.
kvm_init_mpidr_data() builds a compressed MPIDR-to-vCPU lookup table by
walking all possible vCPUs. However, vCPUs that have not been reset yet
still have a zero MPIDR_EL1 state, which aliases vCPU0. This can cause
cmpidr_to_idx[0] to be overwritten with the index of an unreset vCPU.
As a result, MPIDR 0 lookups can return the wrong vCPU, preventing
interrupts targeting vCPU0 from being delivered correctly and making
guest boot extremely slow in configurations using CPU hotplug.
Patch 1 adds named definitions for the MPIDR_EL1 RES1 bit used to detect
whether a vCPU's MPIDR_EL1 state has been reset.
Patch 2 skips unreset vCPUs when populating the compressed MPIDR lookup
table.
Thanks,
Fuqiang
SELF-TEST result:
1. use crash debug cmpidr_to_idx[]
(qemu args: -smp maxcpus=512,cpus=4,sockets=2,cores=128,threads=2)
crash> struct kvm_mpidr_data.mpidr_mask 0xffff2020acda15e0
mpidr_mask = 3,
crash> x/8xh 0xffff2020acda15e8
0xffff2020acda15e8: 0x0000 0x0001 0x0002 0x0003 0x642f 0x7665 0x6e2f 0x6d76
2. use link [1] to test IPI latency(Before the patch was merged, it often took
seconds for a kernel thread to be scheduled after being woken up.)
IPI Latency Matrix - avg (ns) [100000 samples]
CPU0 CPU1 CPU2 CPU3
CPU0 - 1355 2242 2238
CPU1 2730 - 2391 1852
CPU2 2149 3015 - 2033
CPU3 2005 1651 1801 -
Changes in v2:
- Fix macro naming/placement/type and pass vcpu instead of pre-masked
affinity to correctly check MPIDR_EL1 bit[31] (sashiko bot)
v1: https://lore.kernel.org/all/20260611090934.84469-1-fuqiang.wng@gmail.com/
[1]: https://github.com/cai-fuqiang/kernel_test/tree/master/ipi_latency
fuqiang wang (2):
arm64: Add MPIDR_EL1 RES1 definitions
KVM: arm64: Skip unreset vCPUs in MPIDR lookup table
arch/arm64/include/asm/cputype.h | 1 +
arch/arm64/include/asm/kvm_emulate.h | 9 +++++++++
arch/arm64/kvm/arm.c | 14 ++++++++++++--
3 files changed, 22 insertions(+), 2 deletions(-)
--
2.47.0
next reply other threads:[~2026-06-11 14:40 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-06-11 14:40 fuqiang wang [this message]
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
2026-06-15 10:08 ` Marc Zyngier
2026-06-18 11:38 ` fuqiang wang
2026-06-18 12:32 ` 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=20260611144042.97981-1-fuqiang.wng@gmail.com \
--to=fuqiang.wng@gmail.com \
--cc=kvmarm@lists.linux.dev \
--cc=linux-kernel@vger.kernel.org \
--cc=maz@kernel.org \
--cc=oupton@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
all inboxes | Powered by JetHome®