Patch "KVM: x86: disable preemption around the call to kvm_arch_vcpu_{un|}blocking" 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

    KVM: x86: disable preemption around the call to kvm_arch_vcpu_{un|}blocking

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:
     kvm-x86-disable-preemption-around-the-call-to-kvm_ar.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 51da2a430f49e1115c2e805118fe91667ced63cf
Author: Maxim Levitsky <mlevitsk@xxxxxxxxxx>
Date:   Mon Jun 6 21:08:28 2022 +0300

    KVM: x86: disable preemption around the call to kvm_arch_vcpu_{un|}blocking
    
    [ Upstream commit 18869f26df1a11ed11031dfb7392bc7d774062e8 ]
    
    On SVM, if preemption happens right after the call to finish_rcuwait
    but before call to kvm_arch_vcpu_unblocking on SVM/AVIC, it itself
    will re-enable AVIC, and then we will try to re-enable it again
    in kvm_arch_vcpu_unblocking which will lead to a warning
    in __avic_vcpu_load.
    
    The same problem can happen if the vCPU is preempted right after the call
    to kvm_arch_vcpu_blocking but before the call to prepare_to_rcuwait
    and in this case, we will end up with AVIC enabled during sleep -
    Ooops.
    
    Signed-off-by: Maxim Levitsky <mlevitsk@xxxxxxxxxx>
    Message-Id: <20220606180829.102503-7-mlevitsk@xxxxxxxxxx>
    Signed-off-by: Paolo Bonzini <pbonzini@xxxxxxxxxx>
    Signed-off-by: Sasha Levin <sashal@xxxxxxxxxx>

diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c
index 24cb37d19c63..7f1d19689701 100644
--- a/virt/kvm/kvm_main.c
+++ b/virt/kvm/kvm_main.c
@@ -3327,9 +3327,11 @@ bool kvm_vcpu_block(struct kvm_vcpu *vcpu)
 
 	vcpu->stat.generic.blocking = 1;
 
+	preempt_disable();
 	kvm_arch_vcpu_blocking(vcpu);
-
 	prepare_to_rcuwait(wait);
+	preempt_enable();
+
 	for (;;) {
 		set_current_state(TASK_INTERRUPTIBLE);
 
@@ -3339,9 +3341,11 @@ bool kvm_vcpu_block(struct kvm_vcpu *vcpu)
 		waited = true;
 		schedule();
 	}
-	finish_rcuwait(wait);
 
+	preempt_disable();
+	finish_rcuwait(wait);
 	kvm_arch_vcpu_unblocking(vcpu);
+	preempt_enable();
 
 	vcpu->stat.generic.blocking = 0;
 



[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