Skip to content
Commit be82abe6 authored by Anup Patel's avatar Anup Patel Committed by Anup Patel
Browse files

RISC-V: KVM: Fix SRCU deadlock caused by kvm_riscv_check_vcpu_requests()

The kvm_riscv_check_vcpu_requests() is called with SRCU read lock held
and for KVM_REQ_SLEEP request it will block the VCPU without releasing
SRCU read lock. This causes KVM ioctls (such as KVM_IOEVENTFD) from
other VCPUs of the same Guest/VM to hang/deadlock if there is any
synchronize_srcu() or synchronize_srcu_expedited() in the path.

To fix the above in kvm_riscv_check_vcpu_requests(), we should do SRCU
read unlock before blocking the VCPU and do SRCU read lock after VCPU
wakeup.

Fixes: cce69aff

 ("RISC-V: KVM: Implement VCPU interrupts and requests handling")
Reported-by: default avatarBin Meng <bmeng.cn@gmail.com>
Signed-off-by: default avatarAnup Patel <apatel@ventanamicro.com>
Reviewed-by: default avatarAtish Patra <atishp@rivosinc.com>
Tested-by: default avatarHeinrich Schuchardt <heinrich.schuchardt@canonical.com>
Tested-by: default avatarBin Meng <bmeng.cn@gmail.com>
Signed-off-by: default avatarAnup Patel <anup@brainfault.org>
parent 88573389
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment