Re: [PATCH 27/28] KVM: x86/mmu: Do remote TLB flush before dropping RCU in TDP MMU resched

From: Paolo Bonzini
Date: Tue Nov 30 2021 - 11:18:09 EST


On 11/30/21 16:45, Sean Christopherson wrote:
Couldn't this sleep in kvm_make_all_cpus_request, whilst in an RCU read-side
critical section?
No. And if kvm_make_all_cpus_request() can sleep, the TDP MMU is completely hosed
as tdp_mmu_zap_spte_atomic() and handle_removed_tdp_mmu_page() currently call
kvm_flush_remote_tlbs_with_range() while under RCU protection.

kvm_make_all_cpus_request_except() disables preemption via get_cpu(), and
smp_call_function() doubles down on disabling preemption as the inner helpers
require preemption to be disabled, so anything below them should complain if
there's a might_sleep(). hv_remote_flush_tlb_with_range() takes a spinlock, so
nothing in there should be sleeping either.

Yeah, of course you're right.

Paolo