linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] KVM: arm64: vgic-debug: Don't put unmarked LPIs
@ 2024-08-17 10:15 Zenghui Yu
  2024-08-17 10:25 ` Marc Zyngier
  2024-08-19 17:25 ` Oliver Upton
  0 siblings, 2 replies; 5+ messages in thread
From: Zenghui Yu @ 2024-08-17 10:15 UTC (permalink / raw)
  To: kvmarm, linux-arm-kernel, linux-kernel
  Cc: maz, oliver.upton, james.morse, suzuki.poulose, wanghaibin.wang,
	Zenghui Yu

If there were LPIs being mapped behind our back (i.e., between .start() and
.stop()), we would put them at iter_unmark_lpis() without checking if they
were actually *marked*, which is obviously not good.

Switch to use the xa_for_each_marked() iterator to fix it.

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 | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/arm64/kvm/vgic/vgic-debug.c b/arch/arm64/kvm/vgic/vgic-debug.c
index bc74d06398ef..e1397ab2072a 100644
--- a/arch/arm64/kvm/vgic/vgic-debug.c
+++ b/arch/arm64/kvm/vgic/vgic-debug.c
@@ -85,7 +85,7 @@ static void iter_unmark_lpis(struct kvm *kvm)
 	struct vgic_irq *irq;
 	unsigned long intid;
 
-	xa_for_each(&dist->lpi_xa, intid, irq) {
+	xa_for_each_marked(&dist->lpi_xa, intid, irq, LPI_XA_MARK_DEBUG_ITER) {
 		xa_clear_mark(&dist->lpi_xa, intid, LPI_XA_MARK_DEBUG_ITER);
 		vgic_put_irq(kvm, irq);
 	}
-- 
2.33.0



^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH] KVM: arm64: vgic-debug: Don't put unmarked LPIs
  2024-08-17 10:15 [PATCH] KVM: arm64: vgic-debug: Don't put unmarked LPIs Zenghui Yu
@ 2024-08-17 10:25 ` Marc Zyngier
  2024-08-17 10:31   ` Zenghui Yu
  2024-08-19 17:25 ` Oliver Upton
  1 sibling, 1 reply; 5+ messages in thread
From: Marc Zyngier @ 2024-08-17 10:25 UTC (permalink / raw)
  To: Zenghui Yu
  Cc: kvmarm, linux-arm-kernel, linux-kernel, oliver.upton, james.morse,
	suzuki.poulose, wanghaibin.wang

On Sat, 17 Aug 2024 11:15:41 +0100,
Zenghui Yu <yuzenghui@huawei.com> wrote:
> 
> If there were LPIs being mapped behind our back (i.e., between .start() and
> .stop()), we would put them at iter_unmark_lpis() without checking if they
> were actually *marked*, which is obviously not good.
> 
> Switch to use the xa_for_each_marked() iterator to fix it.
> 
> 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 | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/arch/arm64/kvm/vgic/vgic-debug.c b/arch/arm64/kvm/vgic/vgic-debug.c
> index bc74d06398ef..e1397ab2072a 100644
> --- a/arch/arm64/kvm/vgic/vgic-debug.c
> +++ b/arch/arm64/kvm/vgic/vgic-debug.c
> @@ -85,7 +85,7 @@ static void iter_unmark_lpis(struct kvm *kvm)
>  	struct vgic_irq *irq;
>  	unsigned long intid;
>  
> -	xa_for_each(&dist->lpi_xa, intid, irq) {
> +	xa_for_each_marked(&dist->lpi_xa, intid, irq, LPI_XA_MARK_DEBUG_ITER) {
>  		xa_clear_mark(&dist->lpi_xa, intid, LPI_XA_MARK_DEBUG_ITER);
>  		vgic_put_irq(kvm, irq);
>  	}

Ouch. Nicely caught. I think this deserves a

Cc: stable@vger.kernel.org # v6.10

With that,

Reviewed-by: Marc Zyngier <maz@kernel.org>

Thanks,

	M.

-- 
Without deviation from the norm, progress is not possible.


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] KVM: arm64: vgic-debug: Don't put unmarked LPIs
  2024-08-17 10:25 ` Marc Zyngier
@ 2024-08-17 10:31   ` Zenghui Yu
  2024-08-19 16:26     ` Oliver Upton
  0 siblings, 1 reply; 5+ messages in thread
From: Zenghui Yu @ 2024-08-17 10:31 UTC (permalink / raw)
  To: Marc Zyngier
  Cc: kvmarm, linux-arm-kernel, linux-kernel, oliver.upton, james.morse,
	suzuki.poulose, wanghaibin.wang

On 2024/8/17 18:25, Marc Zyngier wrote:
> On Sat, 17 Aug 2024 11:15:41 +0100,
> Zenghui Yu <yuzenghui@huawei.com> wrote:
> >
> > If there were LPIs being mapped behind our back (i.e., between .start() and
> > .stop()), we would put them at iter_unmark_lpis() without checking if they
> > were actually *marked*, which is obviously not good.
> >
> > Switch to use the xa_for_each_marked() iterator to fix it.
> >
> > 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 | 2 +-
> >  1 file changed, 1 insertion(+), 1 deletion(-)
> >
> > diff --git a/arch/arm64/kvm/vgic/vgic-debug.c b/arch/arm64/kvm/vgic/vgic-debug.c
> > index bc74d06398ef..e1397ab2072a 100644
> > --- a/arch/arm64/kvm/vgic/vgic-debug.c
> > +++ b/arch/arm64/kvm/vgic/vgic-debug.c
> > @@ -85,7 +85,7 @@ static void iter_unmark_lpis(struct kvm *kvm)
> >  	struct vgic_irq *irq;
> >  	unsigned long intid;
> >  
> > -	xa_for_each(&dist->lpi_xa, intid, irq) {
> > +	xa_for_each_marked(&dist->lpi_xa, intid, irq, LPI_XA_MARK_DEBUG_ITER) {
> >  		xa_clear_mark(&dist->lpi_xa, intid, LPI_XA_MARK_DEBUG_ITER);
> >  		vgic_put_irq(kvm, irq);
> >  	}
> 
> Ouch. Nicely caught. I think this deserves a
> 
> Cc: stable@vger.kernel.org # v6.10

Yup. I guess Oliver will help to add it when applying ;-)

> 
> With that,
> 
> Reviewed-by: Marc Zyngier <maz@kernel.org>

Thanks!

Zenghui


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] KVM: arm64: vgic-debug: Don't put unmarked LPIs
  2024-08-17 10:31   ` Zenghui Yu
@ 2024-08-19 16:26     ` Oliver Upton
  0 siblings, 0 replies; 5+ messages in thread
From: Oliver Upton @ 2024-08-19 16:26 UTC (permalink / raw)
  To: Zenghui Yu
  Cc: Marc Zyngier, kvmarm, linux-arm-kernel, linux-kernel, james.morse,
	suzuki.poulose, wanghaibin.wang

On Sat, Aug 17, 2024 at 06:31:45PM +0800, Zenghui Yu wrote:
> On 2024/8/17 18:25, Marc Zyngier wrote:
> > On Sat, 17 Aug 2024 11:15:41 +0100,
> > Zenghui Yu <yuzenghui@huawei.com> wrote:
> > >
> > > If there were LPIs being mapped behind our back (i.e., between .start() and
> > > .stop()), we would put them at iter_unmark_lpis() without checking if they
> > > were actually *marked*, which is obviously not good.
> > >
> > > Switch to use the xa_for_each_marked() iterator to fix it.

Urgh, that's what I'd meant to do. Thanks for catching this Zenghui.

> > > 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 | 2 +-
> > >  1 file changed, 1 insertion(+), 1 deletion(-)
> > >
> > > diff --git a/arch/arm64/kvm/vgic/vgic-debug.c b/arch/arm64/kvm/vgic/vgic-debug.c
> > > index bc74d06398ef..e1397ab2072a 100644
> > > --- a/arch/arm64/kvm/vgic/vgic-debug.c
> > > +++ b/arch/arm64/kvm/vgic/vgic-debug.c
> > > @@ -85,7 +85,7 @@ static void iter_unmark_lpis(struct kvm *kvm)
> > >  	struct vgic_irq *irq;
> > >  	unsigned long intid;
> > >  
> > > -	xa_for_each(&dist->lpi_xa, intid, irq) {
> > > +	xa_for_each_marked(&dist->lpi_xa, intid, irq, LPI_XA_MARK_DEBUG_ITER) {
> > >  		xa_clear_mark(&dist->lpi_xa, intid, LPI_XA_MARK_DEBUG_ITER);
> > >  		vgic_put_irq(kvm, irq);
> > >  	}
> > 
> > Ouch. Nicely caught. I think this deserves a
> > 
> > Cc: stable@vger.kernel.org # v6.10
> 
> Yup. I guess Oliver will help to add it when applying ;-)

Indeed, I'll grab it here in a moment.

> > 
> > With that,
> > 
> > Reviewed-by: Marc Zyngier <maz@kernel.org>
> 

Thanks both!

-- 
Best,
Oliver


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] KVM: arm64: vgic-debug: Don't put unmarked LPIs
  2024-08-17 10:15 [PATCH] KVM: arm64: vgic-debug: Don't put unmarked LPIs Zenghui Yu
  2024-08-17 10:25 ` Marc Zyngier
@ 2024-08-19 17:25 ` Oliver Upton
  1 sibling, 0 replies; 5+ messages in thread
From: Oliver Upton @ 2024-08-19 17:25 UTC (permalink / raw)
  To: linux-kernel, kvmarm, linux-arm-kernel, Zenghui Yu
  Cc: Oliver Upton, james.morse, suzuki.poulose, wanghaibin.wang, maz

On Sat, 17 Aug 2024 18:15:41 +0800, Zenghui Yu wrote:
> If there were LPIs being mapped behind our back (i.e., between .start() and
> .stop()), we would put them at iter_unmark_lpis() without checking if they
> were actually *marked*, which is obviously not good.
> 
> Switch to use the xa_for_each_marked() iterator to fix it.
> 
> 
> [...]

Applied to kvmarm/fixes, thanks!

[1/1] KVM: arm64: vgic-debug: Don't put unmarked LPIs
      https://git.kernel.org/kvmarm/kvmarm/c/2240a50e6294

--
Best,
Oliver


^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2024-08-19 17:45 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-08-17 10:15 [PATCH] KVM: arm64: vgic-debug: Don't put unmarked LPIs Zenghui Yu
2024-08-17 10:25 ` Marc Zyngier
2024-08-17 10:31   ` Zenghui Yu
2024-08-19 16:26     ` Oliver Upton
2024-08-19 17:25 ` 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).