diff options
author | Xiao Guangrong <xiaoguangrong@cn.fujitsu.com> | 2011-01-12 02:39:18 -0500 |
---|---|---|
committer | Marcelo Tosatti <mtosatti@redhat.com> | 2011-03-17 12:08:26 -0400 |
commit | 63f42e023ea270fde65fa27f0ca766e13faa5608 (patch) | |
tree | 8cad1e7f55d9c8b6db2c7dc83153b90a79b4927f | |
parent | 40712faeb84dacfcb3925a88231daa08b3624d34 (diff) |
KVM: fix rcu usage warning in kvm_arch_vcpu_ioctl_set_sregs()
Fix:
[ 1001.499596] ===================================================
[ 1001.499599] [ INFO: suspicious rcu_dereference_check() usage. ]
[ 1001.499601] ---------------------------------------------------
[ 1001.499604] include/linux/kvm_host.h:301 invoked rcu_dereference_check() without protection!
......
[ 1001.499636] Pid: 6035, comm: qemu-system-x86 Not tainted 2.6.37-rc6+ #62
[ 1001.499638] Call Trace:
[ 1001.499644] [] lockdep_rcu_dereference+0x9d/0xa5
[ 1001.499653] [] gfn_to_memslot+0x8d/0xc8 [kvm]
[ 1001.499661] [] gfn_to_hva+0x16/0x3f [kvm]
[ 1001.499669] [] kvm_read_guest_page+0x1e/0x5e [kvm]
[ 1001.499681] [] kvm_read_guest_page_mmu+0x53/0x5e [kvm]
[ 1001.499699] [] load_pdptrs+0x3f/0x9c [kvm]
[ 1001.499705] [] ? vmx_set_cr0+0x507/0x517 [kvm_intel]
[ 1001.499717] [] kvm_arch_vcpu_ioctl_set_sregs+0x1f3/0x3c0 [kvm]
[ 1001.499727] [] kvm_vcpu_ioctl+0x6a5/0xbc5 [kvm]
Signed-off-by: Xiao Guangrong <xiaoguangrong@cn.fujitsu.com>
Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
-rw-r--r-- | arch/x86/kvm/x86.c | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c index bcc0efce85b..4be89e1c014 100644 --- a/arch/x86/kvm/x86.c +++ b/arch/x86/kvm/x86.c | |||
@@ -5574,7 +5574,7 @@ int kvm_arch_vcpu_ioctl_set_sregs(struct kvm_vcpu *vcpu, | |||
5574 | struct kvm_sregs *sregs) | 5574 | struct kvm_sregs *sregs) |
5575 | { | 5575 | { |
5576 | int mmu_reset_needed = 0; | 5576 | int mmu_reset_needed = 0; |
5577 | int pending_vec, max_bits; | 5577 | int pending_vec, max_bits, idx; |
5578 | struct desc_ptr dt; | 5578 | struct desc_ptr dt; |
5579 | 5579 | ||
5580 | dt.size = sregs->idt.limit; | 5580 | dt.size = sregs->idt.limit; |
@@ -5603,10 +5603,13 @@ int kvm_arch_vcpu_ioctl_set_sregs(struct kvm_vcpu *vcpu, | |||
5603 | kvm_x86_ops->set_cr4(vcpu, sregs->cr4); | 5603 | kvm_x86_ops->set_cr4(vcpu, sregs->cr4); |
5604 | if (sregs->cr4 & X86_CR4_OSXSAVE) | 5604 | if (sregs->cr4 & X86_CR4_OSXSAVE) |
5605 | update_cpuid(vcpu); | 5605 | update_cpuid(vcpu); |
5606 | |||
5607 | idx = srcu_read_lock(&vcpu->kvm->srcu); | ||
5606 | if (!is_long_mode(vcpu) && is_pae(vcpu)) { | 5608 | if (!is_long_mode(vcpu) && is_pae(vcpu)) { |
5607 | load_pdptrs(vcpu, vcpu->arch.walk_mmu, kvm_read_cr3(vcpu)); | 5609 | load_pdptrs(vcpu, vcpu->arch.walk_mmu, kvm_read_cr3(vcpu)); |
5608 | mmu_reset_needed = 1; | 5610 | mmu_reset_needed = 1; |
5609 | } | 5611 | } |
5612 | srcu_read_unlock(&vcpu->kvm->srcu, idx); | ||
5610 | 5613 | ||
5611 | if (mmu_reset_needed) | 5614 | if (mmu_reset_needed) |
5612 | kvm_mmu_reset_context(vcpu); | 5615 | kvm_mmu_reset_context(vcpu); |