WSL2-Linux-Kernel/arch/x86/kvm
Paolo Bonzini 8d25b7beca 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>
2022-03-02 10:55:58 -05:00
..
mmu KVM: x86/mmu: Passing up the error state of mmu_alloc_shadow_roots() 2022-03-02 10:55:58 -05:00
svm KVM: x86: nSVM: disallow userspace setting of MSR_AMD64_TSC_RATIO to non default value when tsc scaling disabled 2022-02-24 13:04:47 -05:00
vmx Revert "KVM: VMX: Save HOST_CR3 in vmx_prepare_switch_to_guest()" 2022-02-25 04:02:18 -05:00
Kconfig
Makefile
cpuid.c x86/kvm/fpu: Remove kvm_vcpu_arch.guest_supported_xcr0 2022-02-17 10:06:49 -05:00
cpuid.h
debugfs.c Merge branch 'kvm-pi-raw-spinlock' into HEAD 2022-01-19 12:14:02 -05:00
emulate.c
fpu.h
hyperv.c
hyperv.h
i8254.c
i8254.h
i8259.c
ioapic.c
ioapic.h
irq.c
irq.h
irq_comm.c
kvm_cache_regs.h
kvm_emulate.h
kvm_onhyperv.c
kvm_onhyperv.h
lapic.c KVM: x86: lapic: don't touch irr_pending in kvm_apic_update_apicv when inhibiting it 2022-02-08 13:30:49 -05:00
lapic.h
mmu.h
mtrr.c
pmu.c KVM: x86/pmu: Use AMD64_RAW_EVENT_MASK for PERF_TYPE_RAW 2022-02-14 07:44:51 -05:00
pmu.h
reverse_cpuid.h
trace.h
tss.h
x86.c KVM: x86: pull kvm->srcu read-side to kvm_arch_vcpu_ioctl_run 2022-03-02 10:55:58 -05:00
x86.h KVM/arm64 fixes for 5.17, take #2 2022-02-05 00:58:25 -05:00
xen.c KVM: x86/xen: Fix runstate updates to be atomic when preempting vCPU 2022-02-10 13:39:06 -05:00
xen.h