Skip to content

Commit 2d08935

Browse files
sean-jcbonzini
authored andcommitted
KVM: x86: Don't re-acquire SRCU lock in complete_emulated_io()
Don't re-acquire SRCU in complete_emulated_io() now that KVM acquires the lock in kvm_arch_vcpu_ioctl_run(). More importantly, don't overwrite vcpu->srcu_idx. If the index acquired by complete_emulated_io() differs from the one acquired by kvm_arch_vcpu_ioctl_run(), KVM will effectively leak a lock and hang if/when synchronize_srcu() is invoked for the relevant grace period. Fixes: 8d25b7b ("KVM: x86: pull kvm->srcu read-side to kvm_arch_vcpu_ioctl_run") Cc: stable@vger.kernel.org Signed-off-by: Sean Christopherson <seanjc@google.com> Reviewed-by: Maxim Levitsky <mlevitsk@redhat.com> Message-Id: <20220415004343.2203171-2-seanjc@google.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
1 parent 012c722 commit 2d08935

1 file changed

Lines changed: 1 addition & 6 deletions

File tree

arch/x86/kvm/x86.c

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10387,12 +10387,7 @@ static int vcpu_run(struct kvm_vcpu *vcpu)
1038710387

1038810388
static inline int complete_emulated_io(struct kvm_vcpu *vcpu)
1038910389
{
10390-
int r;
10391-
10392-
vcpu->srcu_idx = srcu_read_lock(&vcpu->kvm->srcu);
10393-
r = kvm_emulate_instruction(vcpu, EMULTYPE_NO_DECODE);
10394-
srcu_read_unlock(&vcpu->kvm->srcu, vcpu->srcu_idx);
10395-
return r;
10390+
return kvm_emulate_instruction(vcpu, EMULTYPE_NO_DECODE);
1039610391
}
1039710392

1039810393
static int complete_emulated_pio(struct kvm_vcpu *vcpu)

0 commit comments

Comments
 (0)