public inbox for kvm@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] KVM: arm64: gic: Check for vGICv3 when clearing TWI
@ 2026-01-06 16:52 Sascha Bischoff
  2026-01-06 18:13 ` Marc Zyngier
  2026-01-10 10:22 ` Oliver Upton
  0 siblings, 2 replies; 3+ messages in thread
From: Sascha Bischoff @ 2026-01-06 16:52 UTC (permalink / raw)
  To: linux-arm-kernel@lists.infradead.org, kvmarm@lists.linux.dev,
	kvm@vger.kernel.org
  Cc: nd, maz@kernel.org, oliver.upton@linux.dev, Joey Gouly,
	Suzuki Poulose, yuzenghui@huawei.com

Explicitly check for the vgic being v3 when disabling TWI. Failure to
check this can result in using the wrong view of the vgic CPU IF union
causing undesirable/unexpected behaviour.

Signed-off-by: Sascha Bischoff <sascha.bischoff@arm.com>
---
 arch/arm64/kvm/arm.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/arch/arm64/kvm/arm.c b/arch/arm64/kvm/arm.c
index 4f80da0c0d1de..620a465248d1b 100644
--- a/arch/arm64/kvm/arm.c
+++ b/arch/arm64/kvm/arm.c
@@ -569,6 +569,7 @@ static bool kvm_vcpu_should_clear_twi(struct kvm_vcpu *vcpu)
 		return kvm_wfi_trap_policy == KVM_WFX_NOTRAP;
 
 	return single_task_running() &&
+	       vcpu->kvm->arch.vgic.vgic_model == KVM_DEV_TYPE_ARM_VGIC_V3 &&
 	       (atomic_read(&vcpu->arch.vgic_cpu.vgic_v3.its_vpe.vlpi_count) ||
 		vcpu->kvm->arch.vgic.nassgireq);
 }
-- 
2.34.1

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

* Re: [PATCH] KVM: arm64: gic: Check for vGICv3 when clearing TWI
  2026-01-06 16:52 [PATCH] KVM: arm64: gic: Check for vGICv3 when clearing TWI Sascha Bischoff
@ 2026-01-06 18:13 ` Marc Zyngier
  2026-01-10 10:22 ` Oliver Upton
  1 sibling, 0 replies; 3+ messages in thread
From: Marc Zyngier @ 2026-01-06 18:13 UTC (permalink / raw)
  To: Sascha Bischoff
  Cc: linux-arm-kernel@lists.infradead.org, kvmarm@lists.linux.dev,
	kvm@vger.kernel.org, nd, oliver.upton@linux.dev, Joey Gouly,
	Suzuki Poulose, yuzenghui@huawei.com

On Tue, 06 Jan 2026 16:52:10 +0000,
Sascha Bischoff <Sascha.Bischoff@arm.com> wrote:
> 
> Explicitly check for the vgic being v3 when disabling TWI. Failure to
> check this can result in using the wrong view of the vgic CPU IF union
> causing undesirable/unexpected behaviour.
> 
> Signed-off-by: Sascha Bischoff <sascha.bischoff@arm.com>
> ---
>  arch/arm64/kvm/arm.c | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/arch/arm64/kvm/arm.c b/arch/arm64/kvm/arm.c
> index 4f80da0c0d1de..620a465248d1b 100644
> --- a/arch/arm64/kvm/arm.c
> +++ b/arch/arm64/kvm/arm.c
> @@ -569,6 +569,7 @@ static bool kvm_vcpu_should_clear_twi(struct kvm_vcpu *vcpu)
>  		return kvm_wfi_trap_policy == KVM_WFX_NOTRAP;
>  
>  	return single_task_running() &&
> +	       vcpu->kvm->arch.vgic.vgic_model == KVM_DEV_TYPE_ARM_VGIC_V3 &&
>  	       (atomic_read(&vcpu->arch.vgic_cpu.vgic_v3.its_vpe.vlpi_count) ||
>  		vcpu->kvm->arch.vgic.nassgireq);
>  }

Nice one. Wonder how many other similar cases we have... :-/

Reviewed-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: gic: Check for vGICv3 when clearing TWI
  2026-01-06 16:52 [PATCH] KVM: arm64: gic: Check for vGICv3 when clearing TWI Sascha Bischoff
  2026-01-06 18:13 ` Marc Zyngier
@ 2026-01-10 10:22 ` Oliver Upton
  1 sibling, 0 replies; 3+ messages in thread
From: Oliver Upton @ 2026-01-10 10:22 UTC (permalink / raw)
  To: linux-arm-kernel, kvmarm, kvm, Sascha Bischoff
  Cc: Oliver Upton, nd, maz, Joey Gouly, Suzuki Poulose, yuzenghui

On Tue, 06 Jan 2026 16:52:10 +0000, Sascha Bischoff wrote:
> Explicitly check for the vgic being v3 when disabling TWI. Failure to
> check this can result in using the wrong view of the vgic CPU IF union
> causing undesirable/unexpected behaviour.
> 
> 

Applied to fixes, thanks!

[1/1] KVM: arm64: gic: Check for vGICv3 when clearing TWI
      https://git.kernel.org/kvmarm/kvmarm/c/5e8b511c39f3

--
Best,
Oliver

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

end of thread, other threads:[~2026-01-10 10:23 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-01-06 16:52 [PATCH] KVM: arm64: gic: Check for vGICv3 when clearing TWI Sascha Bischoff
2026-01-06 18:13 ` Marc Zyngier
2026-01-10 10:22 ` Oliver Upton

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox