Patch "RISC-V: KVM: Fix SRCU deadlock caused by kvm_riscv_check_vcpu_requests()" has been added to the 5.18-stable tree

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This is a note to let you know that I've just added the patch titled

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

to the 5.18-stable tree which can be found at:
    http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary

The filename of the patch is:
     risc-v-kvm-fix-srcu-deadlock-caused-by-kvm_riscv_che.patch
and it can be found in the queue-5.18 subdirectory.

If you, or anyone else, feels it should not be added to the stable tree,
please let <stable@xxxxxxxxxxxxxxx> know about it.



commit 79ed92567dfe00c3d8e228968dc43656176c5131
Author: Anup Patel <apatel@xxxxxxxxxxxxxxxx>
Date:   Mon Jul 11 09:36:32 2022 +0530

    RISC-V: KVM: Fix SRCU deadlock caused by kvm_riscv_check_vcpu_requests()
    
    [ Upstream commit be82abe6a76ba8e76f25312566182b0f13c4fbf9 ]
    
    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: cce69aff689e ("RISC-V: KVM: Implement VCPU interrupts and requests handling")
    Reported-by: Bin Meng <bmeng.cn@xxxxxxxxx>
    Signed-off-by: Anup Patel <apatel@xxxxxxxxxxxxxxxx>
    Reviewed-by: Atish Patra <atishp@xxxxxxxxxxxx>
    Tested-by: Heinrich Schuchardt <heinrich.schuchardt@xxxxxxxxxxxxx>
    Tested-by: Bin Meng <bmeng.cn@xxxxxxxxx>
    Signed-off-by: Anup Patel <anup@xxxxxxxxxxxxxx>
    Signed-off-by: Sasha Levin <sashal@xxxxxxxxxx>

diff --git a/arch/riscv/kvm/vcpu.c b/arch/riscv/kvm/vcpu.c
index 7461f964d20a..3894777bfa87 100644
--- a/arch/riscv/kvm/vcpu.c
+++ b/arch/riscv/kvm/vcpu.c
@@ -673,9 +673,11 @@ static void kvm_riscv_check_vcpu_requests(struct kvm_vcpu *vcpu)
 
 	if (kvm_request_pending(vcpu)) {
 		if (kvm_check_request(KVM_REQ_SLEEP, vcpu)) {
+			kvm_vcpu_srcu_read_unlock(vcpu);
 			rcuwait_wait_event(wait,
 				(!vcpu->arch.power_off) && (!vcpu->arch.pause),
 				TASK_INTERRUPTIBLE);
+			kvm_vcpu_srcu_read_lock(vcpu);
 
 			if (vcpu->arch.power_off || vcpu->arch.pause) {
 				/*



[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux