* [PATCH] KVM: arm64: vgic-debug: Exit the iterator properly w/o LPI
@ 2024-08-07 5:20 Zenghui Yu
2024-08-07 10:01 ` Marc Zyngier
2024-08-08 17:07 ` Oliver Upton
0 siblings, 2 replies; 3+ messages in thread
From: Zenghui Yu @ 2024-08-07 5:20 UTC (permalink / raw)
To: kvmarm, linux-arm-kernel, linux-kernel
Cc: maz, oliver.upton, james.morse, suzuki.poulose, wanghaibin.wang,
Zenghui Yu
In case the guest doesn't have any LPI, we previously relied on the
iterator setting
'intid = nr_spis + VGIC_NR_PRIVATE_IRQS' && 'lpi_idx = 1'
to exit the iterator. But it was broken with commit 85d3ccc8b75b ("KVM:
arm64: vgic-debug: Use an xarray mark for debug iterator") -- the intid
remains at 'nr_spis + VGIC_NR_PRIVATE_IRQS - 1', and we end up endlessly
printing the last SPI's state.
Consider that it's meaningless to search the LPI xarray and populate
lpi_idx when there is no LPI, let's just skip the process for that case.
The result is that
* If there's no LPI, we focus on the intid and exit the iterator when it
runs out of the valid SPI range.
* Otherwise we keep the current logic and let the xarray drive the
iterator.
Fixes: 85d3ccc8b75b ("KVM: arm64: vgic-debug: Use an xarray mark for debug iterator")
Signed-off-by: Zenghui Yu <yuzenghui@huawei.com>
---
arch/arm64/kvm/vgic/vgic-debug.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/arch/arm64/kvm/vgic/vgic-debug.c b/arch/arm64/kvm/vgic/vgic-debug.c
index bcbc8c986b1d..bc74d06398ef 100644
--- a/arch/arm64/kvm/vgic/vgic-debug.c
+++ b/arch/arm64/kvm/vgic/vgic-debug.c
@@ -45,7 +45,8 @@ static void iter_next(struct kvm *kvm, struct vgic_state_iter *iter)
* Let the xarray drive the iterator after the last SPI, as the iterator
* has exhausted the sequentially-allocated INTID space.
*/
- if (iter->intid >= (iter->nr_spis + VGIC_NR_PRIVATE_IRQS - 1)) {
+ if (iter->intid >= (iter->nr_spis + VGIC_NR_PRIVATE_IRQS - 1) &&
+ iter->nr_lpis) {
if (iter->lpi_idx < iter->nr_lpis)
xa_find_after(&dist->lpi_xa, &iter->intid,
VGIC_LPI_MAX_INTID,
@@ -112,7 +113,7 @@ static bool end_of_vgic(struct vgic_state_iter *iter)
return iter->dist_id > 0 &&
iter->vcpu_id == iter->nr_cpus &&
iter->intid >= (iter->nr_spis + VGIC_NR_PRIVATE_IRQS) &&
- iter->lpi_idx > iter->nr_lpis;
+ (!iter->nr_lpis || iter->lpi_idx > iter->nr_lpis);
}
static void *vgic_debug_start(struct seq_file *s, loff_t *pos)
--
2.33.0
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] KVM: arm64: vgic-debug: Exit the iterator properly w/o LPI
2024-08-07 5:20 [PATCH] KVM: arm64: vgic-debug: Exit the iterator properly w/o LPI Zenghui Yu
@ 2024-08-07 10:01 ` Marc Zyngier
2024-08-08 17:07 ` Oliver Upton
1 sibling, 0 replies; 3+ messages in thread
From: Marc Zyngier @ 2024-08-07 10:01 UTC (permalink / raw)
To: Zenghui Yu
Cc: kvmarm, linux-arm-kernel, linux-kernel, oliver.upton, james.morse,
suzuki.poulose, wanghaibin.wang
On Wed, 07 Aug 2024 06:20:24 +0100,
Zenghui Yu <yuzenghui@huawei.com> wrote:
>
> In case the guest doesn't have any LPI, we previously relied on the
> iterator setting
>
> 'intid = nr_spis + VGIC_NR_PRIVATE_IRQS' && 'lpi_idx = 1'
>
> to exit the iterator. But it was broken with commit 85d3ccc8b75b ("KVM:
> arm64: vgic-debug: Use an xarray mark for debug iterator") -- the intid
> remains at 'nr_spis + VGIC_NR_PRIVATE_IRQS - 1', and we end up endlessly
> printing the last SPI's state.
>
> Consider that it's meaningless to search the LPI xarray and populate
> lpi_idx when there is no LPI, let's just skip the process for that case.
>
> The result is that
>
> * If there's no LPI, we focus on the intid and exit the iterator when it
> runs out of the valid SPI range.
> * Otherwise we keep the current logic and let the xarray drive the
> iterator.
>
> Fixes: 85d3ccc8b75b ("KVM: arm64: vgic-debug: Use an xarray mark for debug iterator")
> Signed-off-by: Zenghui Yu <yuzenghui@huawei.com>
Acked-by: Marc Zyngier <maz@kernel.org>
M.
--
Without deviation from the norm, progress is not possible.
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] KVM: arm64: vgic-debug: Exit the iterator properly w/o LPI
2024-08-07 5:20 [PATCH] KVM: arm64: vgic-debug: Exit the iterator properly w/o LPI Zenghui Yu
2024-08-07 10:01 ` Marc Zyngier
@ 2024-08-08 17:07 ` Oliver Upton
1 sibling, 0 replies; 3+ messages in thread
From: Oliver Upton @ 2024-08-08 17:07 UTC (permalink / raw)
To: kvmarm, Zenghui Yu, linux-arm-kernel, linux-kernel
Cc: Oliver Upton, wanghaibin.wang, maz, james.morse, suzuki.poulose
On Wed, 7 Aug 2024 13:20:24 +0800, Zenghui Yu wrote:
> In case the guest doesn't have any LPI, we previously relied on the
> iterator setting
>
> 'intid = nr_spis + VGIC_NR_PRIVATE_IRQS' && 'lpi_idx = 1'
>
> to exit the iterator. But it was broken with commit 85d3ccc8b75b ("KVM:
> arm64: vgic-debug: Use an xarray mark for debug iterator") -- the intid
> remains at 'nr_spis + VGIC_NR_PRIVATE_IRQS - 1', and we end up endlessly
> printing the last SPI's state.
>
> [...]
Applied to kvmarm/fixes, thanks!
[1/1] KVM: arm64: vgic-debug: Exit the iterator properly w/o LPI
https://git.kernel.org/kvmarm/kvmarm/c/01ab08cafece
--
Best,
Oliver
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2024-08-08 17:10 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-08-07 5:20 [PATCH] KVM: arm64: vgic-debug: Exit the iterator properly w/o LPI Zenghui Yu
2024-08-07 10:01 ` Marc Zyngier
2024-08-08 17:07 ` Oliver Upton
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).