Commit 8d25b7b
committed
KVM: x86: pull kvm->srcu read-side to kvm_arch_vcpu_ioctl_run
kvm_arch_vcpu_ioctl_run is already doing srcu_read_lock/unlock in two
places, namely vcpu_run and post_kvm_run_save, and a third is actually
needed around the call to vcpu->arch.complete_userspace_io to avoid
the following splat:
WARNING: suspicious RCU usage
arch/x86/kvm/pmu.c:190 suspicious rcu_dereference_check() usage!
other info that might help us debug this:
rcu_scheduler_active = 2, debug_locks = 1
1 lock held by CPU 28/KVM/370841:
#0: ff11004089f280b8 (&vcpu->mutex){+.+.}-{3:3}, at: kvm_vcpu_ioctl+0x87/0x730 [kvm]
Call Trace:
<TASK>
dump_stack_lvl+0x59/0x73
reprogram_fixed_counter+0x15d/0x1a0 [kvm]
kvm_pmu_trigger_event+0x1a3/0x260 [kvm]
? free_moved_vector+0x1b4/0x1e0
complete_fast_pio_in+0x8a/0xd0 [kvm]
This splat is not at all unexpected, since complete_userspace_io callbacks
can execute similar code to vmexits. For example, SVM with nrips=false
will call into the emulator from svm_skip_emulated_instruction().
While it's tempting to never acquire kvm->srcu for an uninitialized vCPU,
practically speaking there's no penalty to acquiring kvm->srcu "early"
as the KVM_MP_STATE_UNINITIALIZED path is a one-time thing per vCPU. On
the other hand, seemingly innocuous helpers like kvm_apic_accept_events()
and sync_regs() can theoretically reach code that might access
SRCU-protected data structures, e.g. sync_regs() can trigger forced
existing of nested mode via kvm_vcpu_ioctl_x86_set_vcpu_events().
Reported-by: Like Xu <likexu@tencent.com>
Co-developed-by: Sean Christopherson <seanjc@google.com>
Signed-off-by: Sean Christopherson <seanjc@google.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>1 parent c6c937d commit 8d25b7b
1 file changed
Lines changed: 13 additions & 12 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
9180 | 9180 | | |
9181 | 9181 | | |
9182 | 9182 | | |
| 9183 | + | |
9183 | 9184 | | |
9184 | 9185 | | |
9185 | 9186 | | |
| |||
9188 | 9189 | | |
9189 | 9190 | | |
9190 | 9191 | | |
9191 | | - | |
9192 | | - | |
9193 | | - | |
9194 | | - | |
9195 | | - | |
9196 | | - | |
9197 | 9192 | | |
9198 | 9193 | | |
9199 | 9194 | | |
9200 | | - | |
9201 | 9195 | | |
9202 | 9196 | | |
9203 | 9197 | | |
| |||
9815 | 9809 | | |
9816 | 9810 | | |
9817 | 9811 | | |
| 9812 | + | |
9818 | 9813 | | |
9819 | 9814 | | |
9820 | 9815 | | |
| |||
10193 | 10188 | | |
10194 | 10189 | | |
10195 | 10190 | | |
| 10191 | + | |
10196 | 10192 | | |
10197 | 10193 | | |
10198 | 10194 | | |
| |||
10252 | 10248 | | |
10253 | 10249 | | |
10254 | 10250 | | |
| 10251 | + | |
10255 | 10252 | | |
10256 | 10253 | | |
10257 | 10254 | | |
10258 | 10255 | | |
10259 | 10256 | | |
10260 | | - | |
10261 | 10257 | | |
10262 | 10258 | | |
10263 | 10259 | | |
| |||
10285 | 10281 | | |
10286 | 10282 | | |
10287 | 10283 | | |
| 10284 | + | |
10288 | 10285 | | |
10289 | 10286 | | |
10290 | | - | |
10291 | 10287 | | |
10292 | 10288 | | |
10293 | 10289 | | |
10294 | | - | |
10295 | | - | |
10296 | 10290 | | |
10297 | 10291 | | |
10298 | 10292 | | |
| |||
10398 | 10392 | | |
10399 | 10393 | | |
10400 | 10394 | | |
| 10395 | + | |
10401 | 10396 | | |
10402 | 10397 | | |
10403 | 10398 | | |
10404 | 10399 | | |
10405 | 10400 | | |
10406 | 10401 | | |
10407 | 10402 | | |
| 10403 | + | |
10408 | 10404 | | |
10409 | 10405 | | |
10410 | 10406 | | |
| |||
10415 | 10411 | | |
10416 | 10412 | | |
10417 | 10413 | | |
| 10414 | + | |
| 10415 | + | |
10418 | 10416 | | |
| 10417 | + | |
| 10418 | + | |
10419 | 10419 | | |
10420 | 10420 | | |
10421 | 10421 | | |
| |||
10475 | 10475 | | |
10476 | 10476 | | |
10477 | 10477 | | |
10478 | | - | |
| 10478 | + | |
10479 | 10479 | | |
| 10480 | + | |
10480 | 10481 | | |
10481 | 10482 | | |
10482 | 10483 | | |
| |||
0 commit comments