Skip to contentSkip to conversation

KVM: arm64: vgic: Reset in_kernel on private IRQ allocation failure

PATCH Applied Fuad Tabba 3 participants 3 messages Aug 2 – Aug 13

Subsystems (3)
lore
Share & tools
lore

Fuad Tabba

author reviewer
#0 lore raw

PATCH 1/1 KVM: arm64: vgic: Reset in_kernel on private IRQ allocation failure

kvm_vgic_create() sets vgic.in_kernel before allocating the per-vCPU private IRQs, but the allocation-failure path resets only vgic_model and leaves in_kernel set. As irqchip_in_kernel() is !!in_kernel, the VM is left with an in-kernel irqchip but no model, and the -EEXIST guard at the top of kvm_vgic_create() rejects every retry, so userspace cannot recover from a transient -ENOMEM.

Reset in_kernel alongside vgic_model on the failure path.

Fixes 9435c1e1431003 ("KVM: arm64: gic: Set vgic_model before initing private IRQs")
---
 arch/arm64/kvm/vgic/vgic-init.c | 1 +
 1 file changed, 1 insertion(+)
arch/arm64/kvm/vgic/vgic-init.c +1 -0
index 907057881b26a..fdac6e24762da 100644
@@ -176,6 +176,7 @@ int kvm_vgic_create(struct kvm *kvm, u32 type)
 		}
 
 		kvm->arch.vgic.vgic_model = 0;
+		kvm->arch.vgic.in_kernel = false;
 		goto out_unlock;
 	}
 

base-commit: f5098b6bae761e346ebcd9da7f95622c04733cff

Signature · 1 line
2.39.5
maintainer Acked-by on v1 1/1
#1 lore raw
Quoted 23 lines · Fuad Tabba

kvm_vgic_create() sets vgic.in_kernel before allocating the per-vCPU private IRQs, but the allocation-failure path resets only vgic_model and leaves in_kernel set. As irqchip_in_kernel() is !!in_kernel, the VM is left with an in-kernel irqchip but no model, and the -EEXIST guard at the top of kvm_vgic_create() rejects every retry, so userspace cannot recover from a transient -ENOMEM.

Reset in_kernel alongside vgic_model on the failure path.

Fixes 9435c1e1431003 ("KVM: arm64: gic: Set vgic_model before initing private IRQs")
---
 arch/arm64/kvm/vgic/vgic-init.c | 1 +
 1 file changed, 1 insertion(+)
arch/arm64/kvm/vgic/vgic-init.c +0 -0
index 907057881b26a..fdac6e24762da 100644

arch/arm64/kvm/vgic/vgic-init.c int kvm_vgic_create(struct kvm *kvm, u32 type) · line 182

Quoted 7 lines
arch/arm64/kvm/vgic/vgic-init.c +1 -0
@@ -176,6 +176,7 @@ int kvm_vgic_create(struct kvm *kvm, u32 type)
 		}
 
 		kvm->arch.vgic.vgic_model = 0;
+		kvm->arch.vgic.in_kernel = false;
 		goto out_unlock;
 	}
 
	M.
Signature · 1 line
Jazz isn't dead. It just smells funny.
maintainer Applied
#2 lore raw
In reply to Fuad Tabba
Quoted 8 lines · Fuad Tabba

kvm_vgic_create() sets vgic.in_kernel before allocating the per-vCPU private IRQs, but the allocation-failure path resets only vgic_model and leaves in_kernel set. As irqchip_in_kernel() is !!in_kernel, the VM is left with an in-kernel irqchip but no model, and the -EEXIST guard at the top of kvm_vgic_create() rejects every retry, so userspace cannot recover from a transient -ENOMEM.

[...]

Applied to next, thanks!

[1/1] KVM: arm64: vgic: Reset in_kernel on private IRQ allocation failure

      https://git.kernel.org/kvmarm/kvmarm/c/43347154e7ab

--
Best,
Oliver