Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Merge tag 'for-linus' of git://git.kernel.org/pub/scm/virt/kvm/kvm

Pull kvm fix from Paolo Bonzini:
"Fix SRCU bug introduced in the merge window"

* tag 'for-linus' of git://git.kernel.org/pub/scm/virt/kvm/kvm:
KVM: x86/xen: Take srcu lock when accessing kvm_memslots()

+9 -11
+9 -11
arch/x86/kvm/x86.c
··· 4025 4025 { 4026 4026 struct kvm_host_map map; 4027 4027 struct kvm_steal_time *st; 4028 - int idx; 4029 4028 4030 4029 if (!(vcpu->arch.st.msr_val & KVM_MSR_ENABLED)) 4031 4030 return; ··· 4032 4033 if (vcpu->arch.st.preempted) 4033 4034 return; 4034 4035 4035 - /* 4036 - * Take the srcu lock as memslots will be accessed to check the gfn 4037 - * cache generation against the memslots generation. 4038 - */ 4039 - idx = srcu_read_lock(&vcpu->kvm->srcu); 4040 - 4041 4036 if (kvm_map_gfn(vcpu, vcpu->arch.st.msr_val >> PAGE_SHIFT, &map, 4042 4037 &vcpu->arch.st.cache, true)) 4043 - goto out; 4038 + return; 4044 4039 4045 4040 st = map.hva + 4046 4041 offset_in_page(vcpu->arch.st.msr_val & KVM_STEAL_VALID_BITS); ··· 4042 4049 st->preempted = vcpu->arch.st.preempted = KVM_VCPU_PREEMPTED; 4043 4050 4044 4051 kvm_unmap_gfn(vcpu, &map, &vcpu->arch.st.cache, true, true); 4045 - 4046 - out: 4047 - srcu_read_unlock(&vcpu->kvm->srcu, idx); 4048 4052 } 4049 4053 4050 4054 void kvm_arch_vcpu_put(struct kvm_vcpu *vcpu) 4051 4055 { 4056 + int idx; 4057 + 4052 4058 if (vcpu->preempted && !vcpu->arch.guest_state_protected) 4053 4059 vcpu->arch.preempted_in_kernel = !static_call(kvm_x86_get_cpl)(vcpu); 4054 4060 4061 + /* 4062 + * Take the srcu lock as memslots will be accessed to check the gfn 4063 + * cache generation against the memslots generation. 4064 + */ 4065 + idx = srcu_read_lock(&vcpu->kvm->srcu); 4055 4066 if (kvm_xen_msr_enabled(vcpu->kvm)) 4056 4067 kvm_xen_runstate_set_preempted(vcpu); 4057 4068 else 4058 4069 kvm_steal_time_set_preempted(vcpu); 4070 + srcu_read_unlock(&vcpu->kvm->srcu, idx); 4059 4071 4060 4072 static_call(kvm_x86_vcpu_put)(vcpu); 4061 4073 vcpu->arch.last_host_tsc = rdtsc();