aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorXiao Guangrong <xiaoguangrong@cn.fujitsu.com>2010-06-07 22:15:51 -0400
committerAvi Kivity <avi@redhat.com>2010-08-01 03:46:23 -0400
commit4b9d3a04519fb508ad3b7ce8a7962929b2614185 (patch)
treeb906c2b106286c30e95becca0a5259383b7d32ff
parent1760dd4939a62591e492971858fac8cce1e4539e (diff)
KVM: VMX: fix rcu usage warning in init_rmode()
fix: [ INFO: suspicious rcu_dereference_check() usage. ] --------------------------------------------------- include/linux/kvm_host.h:258 invoked rcu_dereference_check() without protection! other info that might help us debug this: rcu_scheduler_active = 1, debug_locks = 1 1 lock held by qemu-system-x86/3796: #0: (&vcpu->mutex){+.+.+.}, at: [<ffffffffa0217fd8>] vcpu_load+0x1a/0x66 [kvm] stack backtrace: Pid: 3796, comm: qemu-system-x86 Not tainted 2.6.34 #25 Call Trace: [<ffffffff81070ed1>] lockdep_rcu_dereference+0x9d/0xa5 [<ffffffffa0214fdf>] gfn_to_memslot_unaliased+0x65/0xa0 [kvm] [<ffffffffa0216139>] gfn_to_hva+0x22/0x4c [kvm] [<ffffffffa0216217>] kvm_write_guest_page+0x2a/0x7f [kvm] [<ffffffffa0216286>] kvm_clear_guest_page+0x1a/0x1c [kvm] [<ffffffffa0278239>] init_rmode+0x3b/0x180 [kvm_intel] [<ffffffffa02786ce>] vmx_set_cr0+0x350/0x4d3 [kvm_intel] [<ffffffffa02274ff>] kvm_arch_vcpu_ioctl_set_sregs+0x122/0x31a [kvm] [<ffffffffa021859c>] kvm_vcpu_ioctl+0x578/0xa3d [kvm] [<ffffffff8106624c>] ? cpu_clock+0x2d/0x40 [<ffffffff810f7d86>] ? fget_light+0x244/0x28e [<ffffffff810709b9>] ? trace_hardirqs_off_caller+0x1f/0x10e [<ffffffff8110501b>] vfs_ioctl+0x32/0xa6 [<ffffffff81105597>] do_vfs_ioctl+0x47f/0x4b8 [<ffffffff813ae654>] ? sub_preempt_count+0xa3/0xb7 [<ffffffff810f7da8>] ? fget_light+0x266/0x28e [<ffffffff810f7c53>] ? fget_light+0x111/0x28e [<ffffffff81105617>] sys_ioctl+0x47/0x6a [<ffffffff81002c1b>] system_call_fastpath+0x16/0x1b Signed-off-by: Xiao Guangrong <xiaoguangrong@cn.fujitsu.com> Signed-off-by: Avi Kivity <avi@redhat.com>
-rw-r--r--arch/x86/kvm/vmx.c17
1 files changed, 11 insertions, 6 deletions
diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c
index 7d7361750bf2..01b054c98139 100644
--- a/arch/x86/kvm/vmx.c
+++ b/arch/x86/kvm/vmx.c
@@ -2659,21 +2659,27 @@ static int vmx_vcpu_setup(struct vcpu_vmx *vmx)
2659 2659
2660static int init_rmode(struct kvm *kvm) 2660static int init_rmode(struct kvm *kvm)
2661{ 2661{
2662 int idx, ret = 0;
2663
2664 idx = srcu_read_lock(&kvm->srcu);
2662 if (!init_rmode_tss(kvm)) 2665 if (!init_rmode_tss(kvm))
2663 return 0; 2666 goto exit;
2664 if (!init_rmode_identity_map(kvm)) 2667 if (!init_rmode_identity_map(kvm))
2665 return 0; 2668 goto exit;
2666 return 1; 2669
2670 ret = 1;
2671exit:
2672 srcu_read_unlock(&kvm->srcu, idx);
2673 return ret;
2667} 2674}
2668 2675
2669static int vmx_vcpu_reset(struct kvm_vcpu *vcpu) 2676static int vmx_vcpu_reset(struct kvm_vcpu *vcpu)
2670{ 2677{
2671 struct vcpu_vmx *vmx = to_vmx(vcpu); 2678 struct vcpu_vmx *vmx = to_vmx(vcpu);
2672 u64 msr; 2679 u64 msr;
2673 int ret, idx; 2680 int ret;
2674 2681
2675 vcpu->arch.regs_avail = ~((1 << VCPU_REGS_RIP) | (1 << VCPU_REGS_RSP)); 2682 vcpu->arch.regs_avail = ~((1 << VCPU_REGS_RIP) | (1 << VCPU_REGS_RSP));
2676 idx = srcu_read_lock(&vcpu->kvm->srcu);
2677 if (!init_rmode(vmx->vcpu.kvm)) { 2683 if (!init_rmode(vmx->vcpu.kvm)) {
2678 ret = -ENOMEM; 2684 ret = -ENOMEM;
2679 goto out; 2685 goto out;
@@ -2783,7 +2789,6 @@ static int vmx_vcpu_reset(struct kvm_vcpu *vcpu)
2783 vmx->emulation_required = 0; 2789 vmx->emulation_required = 0;
2784 2790
2785out: 2791out:
2786 srcu_read_unlock(&vcpu->kvm->srcu, idx);
2787 return ret; 2792 return ret;
2788} 2793}
2789 2794