Skip to content

Commit 01ab08c

Browse files
Zenghui Yuoupton
authored andcommitted
KVM: arm64: vgic-debug: Exit the iterator properly w/o LPI
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 85d3ccc ("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: 85d3ccc ("KVM: arm64: vgic-debug: Use an xarray mark for debug iterator") Signed-off-by: Zenghui Yu <[email protected]> Acked-by: Marc Zyngier <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Oliver Upton <[email protected]>
1 parent 10f2ad0 commit 01ab08c

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

arch/arm64/kvm/vgic/vgic-debug.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,8 @@ static void iter_next(struct kvm *kvm, struct vgic_state_iter *iter)
4545
* Let the xarray drive the iterator after the last SPI, as the iterator
4646
* has exhausted the sequentially-allocated INTID space.
4747
*/
48-
if (iter->intid >= (iter->nr_spis + VGIC_NR_PRIVATE_IRQS - 1)) {
48+
if (iter->intid >= (iter->nr_spis + VGIC_NR_PRIVATE_IRQS - 1) &&
49+
iter->nr_lpis) {
4950
if (iter->lpi_idx < iter->nr_lpis)
5051
xa_find_after(&dist->lpi_xa, &iter->intid,
5152
VGIC_LPI_MAX_INTID,
@@ -112,7 +113,7 @@ static bool end_of_vgic(struct vgic_state_iter *iter)
112113
return iter->dist_id > 0 &&
113114
iter->vcpu_id == iter->nr_cpus &&
114115
iter->intid >= (iter->nr_spis + VGIC_NR_PRIVATE_IRQS) &&
115-
iter->lpi_idx > iter->nr_lpis;
116+
(!iter->nr_lpis || iter->lpi_idx > iter->nr_lpis);
116117
}
117118

118119
static void *vgic_debug_start(struct seq_file *s, loff_t *pos)

0 commit comments

Comments
 (0)