Skip to content

Commit d26b9cb

Browse files
Marc Zyngieroupton
authored andcommitted
KVM: arm64: vgic: Add a non-locking primitive for kvm_vgic_vcpu_destroy()
As we are going to need to call into kvm_vgic_vcpu_destroy() without prior holding of the slots_lock, introduce __kvm_vgic_vcpu_destroy() as a non-locking primitive of kvm_vgic_vcpu_destroy(). Cc: [email protected] Signed-off-by: Marc Zyngier <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Oliver Upton <[email protected]>
1 parent 01ad29d commit d26b9cb

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

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

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -368,7 +368,7 @@ static void kvm_vgic_dist_destroy(struct kvm *kvm)
368368
vgic_v4_teardown(kvm);
369369
}
370370

371-
void kvm_vgic_vcpu_destroy(struct kvm_vcpu *vcpu)
371+
static void __kvm_vgic_vcpu_destroy(struct kvm_vcpu *vcpu)
372372
{
373373
struct vgic_cpu *vgic_cpu = &vcpu->arch.vgic_cpu;
374374

@@ -382,6 +382,15 @@ void kvm_vgic_vcpu_destroy(struct kvm_vcpu *vcpu)
382382
vgic_cpu->rd_iodev.base_addr = VGIC_ADDR_UNDEF;
383383
}
384384

385+
void kvm_vgic_vcpu_destroy(struct kvm_vcpu *vcpu)
386+
{
387+
struct kvm *kvm = vcpu->kvm;
388+
389+
mutex_lock(&kvm->slots_lock);
390+
__kvm_vgic_vcpu_destroy(vcpu);
391+
mutex_unlock(&kvm->slots_lock);
392+
}
393+
385394
void kvm_vgic_destroy(struct kvm *kvm)
386395
{
387396
struct kvm_vcpu *vcpu;
@@ -392,7 +401,7 @@ void kvm_vgic_destroy(struct kvm *kvm)
392401
vgic_debug_destroy(kvm);
393402

394403
kvm_for_each_vcpu(i, vcpu, kvm)
395-
kvm_vgic_vcpu_destroy(vcpu);
404+
__kvm_vgic_vcpu_destroy(vcpu);
396405

397406
mutex_lock(&kvm->arch.config_lock);
398407

0 commit comments

Comments
 (0)