Re: [PATCH v3 05/19] KVM: arm64: vgic-debug: Use an xarray mark for debug iterator

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 2024/8/6 20:39, Zenghui Yu wrote:
On 2024/8/6 17:23, Zenghui Yu wrote:
> The following diff seems work for me.
>
> diff --git a/arch/arm64/kvm/vgic/vgic-debug.c > b/arch/arm64/kvm/vgic/vgic-debug.c
> index 6faa1d16c9ce..f56f74c8cf54 100644
> --- a/arch/arm64/kvm/vgic/vgic-debug.c
> +++ b/arch/arm64/kvm/vgic/vgic-debug.c
> @@ -41,11 +41,16 @@ static void iter_next(struct kvm *kvm, struct vgic_state_iter *iter)
>  		return;
>  	}
> > + iter->intid++;

[*]

> +	if (iter->intid == VGIC_NR_PRIVATE_IRQS &&
> +	    ++iter->vcpu_id < iter->nr_cpus)
> +		iter->intid = 0;
> +
>  	/*
>  	 * 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)) {
>  		if (iter->lpi_idx < iter->nr_lpis)
>  			xa_find_after(&dist->lpi_xa, &iter->intid,

Just noticed that it's wrong to increase intid before xa_find_after(),
which would break the LPI case. Let me have a think...

So searching the LPI xarray and populating lpi_idx when the guest
doesn't have LPI is pointless. We can fix the reported issue by dealing
with the 'nr_lpis == 0' case directly, which might be the easiest
approach. Let me know what do you think.

diff --git a/arch/arm64/kvm/vgic/vgic-debug.c b/arch/arm64/kvm/vgic/vgic-debug.c
index bcbc8c986b1d..8177e5972ea8 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->lpi_idx > iter->nr_lpis || !iter->nr_lpis);
 }

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

Thanks,
Zenghui




[Index of Archives]     [KVM ARM]     [KVM ia64]     [KVM ppc]     [Virtualization Tools]     [Spice Development]     [Libvirt]     [Libvirt Users]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite Questions]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux