public inbox for kvm@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] KVM: Fix IOMMU memslot reference warning
@ 2010-07-01  7:00 Sheng Yang
  2010-07-01 15:58 ` Marcelo Tosatti
  2010-07-01 16:11 ` [PATCH v2] KVM: Fix IOMMU RCU related warning Sheng Yang
  0 siblings, 2 replies; 4+ messages in thread
From: Sheng Yang @ 2010-07-01  7:00 UTC (permalink / raw)
  To: Marcelo Tosatti; +Cc: Avi Kivity, kvm, Sheng Yang

This patch fixes the following warning.

===================================================
[ INFO: suspicious rcu_dereference_check() usage. ]
---------------------------------------------------
include/linux/kvm_host.h:259 invoked rcu_dereference_check() without
protection!

other info that might help us debug this:

rcu_scheduler_active = 1, debug_locks = 0
no locks held by qemu-system-x86/29679.

stack backtrace:
Pid: 29679, comm: qemu-system-x86 Not tainted 2.6.35-rc3+ #200
Call Trace:
 [<ffffffff810a224e>] lockdep_rcu_dereference+0xa8/0xb1
 [<ffffffffa018a06f>] kvm_iommu_unmap_memslots+0xc9/0xde [kvm]
 [<ffffffffa018a0c4>] kvm_iommu_unmap_guest+0x40/0x4e [kvm]
 [<ffffffffa018f772>] kvm_arch_destroy_vm+0x1a/0x186 [kvm]
 [<ffffffffa01800d0>] kvm_put_kvm+0x110/0x167 [kvm]
 [<ffffffffa0180ecc>] kvm_vcpu_release+0x18/0x1c [kvm]
 [<ffffffff81156f5d>] fput+0x22a/0x3a0
 [<ffffffff81152288>] filp_close+0xb4/0xcd
 [<ffffffff8106599f>] put_files_struct+0x1b7/0x36b
 [<ffffffff81065830>] ? put_files_struct+0x48/0x36b
 [<ffffffff8131ee59>] ? do_raw_spin_unlock+0x118/0x160
 [<ffffffff81065bc0>] exit_files+0x6d/0x75
 [<ffffffff81068348>] do_exit+0x47d/0xc60
 [<ffffffff8177e7b5>] ? _raw_spin_unlock_irq+0x30/0x36
 [<ffffffff81068bfa>] do_group_exit+0xcf/0x134
 [<ffffffff81080790>] get_signal_to_deliver+0x732/0x81d
 [<ffffffff81095996>] ? cpu_clock+0x4e/0x60
 [<ffffffff81002082>] do_notify_resume+0x117/0xc43
 [<ffffffff810a2fa3>] ? trace_hardirqs_on+0xd/0xf
 [<ffffffff81080d79>] ? sys_rt_sigtimedwait+0x2b5/0x3bf
 [<ffffffff8177d9f2>] ? trace_hardirqs_off_thunk+0x3a/0x3c
 [<ffffffff81003221>] ? sysret_signal+0x5/0x3d
 [<ffffffff8100343b>] int_signal+0x12/0x17

Signed-off-by: Sheng Yang <sheng@linux.intel.com>
---
 virt/kvm/iommu.c |    8 ++++++--
 1 files changed, 6 insertions(+), 2 deletions(-)

diff --git a/virt/kvm/iommu.c b/virt/kvm/iommu.c
index 673c88a..7795595 100644
--- a/virt/kvm/iommu.c
+++ b/virt/kvm/iommu.c
@@ -126,9 +126,10 @@ unmap_pages:
 
 static int kvm_iommu_map_memslots(struct kvm *kvm)
 {
-	int i, r = 0;
+	int i, idx, r = 0;
 	struct kvm_memslots *slots;
 
+	idx = srcu_read_lock(&kvm->srcu);
 	slots = kvm_memslots(kvm);
 
 	for (i = 0; i < slots->nmemslots; i++) {
@@ -136,6 +137,7 @@ static int kvm_iommu_map_memslots(struct kvm *kvm)
 		if (r)
 			break;
 	}
+	srcu_read_unlock(&kvm->srcu, idx);
 
 	return r;
 }
@@ -285,15 +287,17 @@ static void kvm_iommu_put_pages(struct kvm *kvm,
 
 static int kvm_iommu_unmap_memslots(struct kvm *kvm)
 {
-	int i;
+	int i, idx;
 	struct kvm_memslots *slots;
 
+	idx = srcu_read_lock(&kvm->srcu);
 	slots = kvm_memslots(kvm);
 
 	for (i = 0; i < slots->nmemslots; i++) {
 		kvm_iommu_put_pages(kvm, slots->memslots[i].base_gfn,
 				    slots->memslots[i].npages);
 	}
+	srcu_read_unlock(&kvm->srcu, idx);
 
 	return 0;
 }
-- 
1.7.0.1


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] KVM: Fix IOMMU memslot reference warning
  2010-07-01  7:00 [PATCH] KVM: Fix IOMMU memslot reference warning Sheng Yang
@ 2010-07-01 15:58 ` Marcelo Tosatti
  2010-07-01 16:11 ` [PATCH v2] KVM: Fix IOMMU RCU related warning Sheng Yang
  1 sibling, 0 replies; 4+ messages in thread
From: Marcelo Tosatti @ 2010-07-01 15:58 UTC (permalink / raw)
  To: Sheng Yang; +Cc: Avi Kivity, kvm

On Thu, Jul 01, 2010 at 03:00:50PM +0800, Sheng Yang wrote:
> This patch fixes the following warning.
> 
> ===================================================
> [ INFO: suspicious rcu_dereference_check() usage. ]
> ---------------------------------------------------
> include/linux/kvm_host.h:259 invoked rcu_dereference_check() without
> protection!
> 
> other info that might help us debug this:
> 
> rcu_scheduler_active = 1, debug_locks = 0
> no locks held by qemu-system-x86/29679.
> 
> stack backtrace:
> Pid: 29679, comm: qemu-system-x86 Not tainted 2.6.35-rc3+ #200
> Call Trace:
>  [<ffffffff810a224e>] lockdep_rcu_dereference+0xa8/0xb1
>  [<ffffffffa018a06f>] kvm_iommu_unmap_memslots+0xc9/0xde [kvm]
>  [<ffffffffa018a0c4>] kvm_iommu_unmap_guest+0x40/0x4e [kvm]
>  [<ffffffffa018f772>] kvm_arch_destroy_vm+0x1a/0x186 [kvm]
>  [<ffffffffa01800d0>] kvm_put_kvm+0x110/0x167 [kvm]
>  [<ffffffffa0180ecc>] kvm_vcpu_release+0x18/0x1c [kvm]
>  [<ffffffff81156f5d>] fput+0x22a/0x3a0
>  [<ffffffff81152288>] filp_close+0xb4/0xcd
>  [<ffffffff8106599f>] put_files_struct+0x1b7/0x36b
>  [<ffffffff81065830>] ? put_files_struct+0x48/0x36b
>  [<ffffffff8131ee59>] ? do_raw_spin_unlock+0x118/0x160
>  [<ffffffff81065bc0>] exit_files+0x6d/0x75
>  [<ffffffff81068348>] do_exit+0x47d/0xc60
>  [<ffffffff8177e7b5>] ? _raw_spin_unlock_irq+0x30/0x36
>  [<ffffffff81068bfa>] do_group_exit+0xcf/0x134
>  [<ffffffff81080790>] get_signal_to_deliver+0x732/0x81d
>  [<ffffffff81095996>] ? cpu_clock+0x4e/0x60
>  [<ffffffff81002082>] do_notify_resume+0x117/0xc43
>  [<ffffffff810a2fa3>] ? trace_hardirqs_on+0xd/0xf
>  [<ffffffff81080d79>] ? sys_rt_sigtimedwait+0x2b5/0x3bf
>  [<ffffffff8177d9f2>] ? trace_hardirqs_off_thunk+0x3a/0x3c
>  [<ffffffff81003221>] ? sysret_signal+0x5/0x3d
>  [<ffffffff8100343b>] int_signal+0x12/0x17
> 
> Signed-off-by: Sheng Yang <sheng@linux.intel.com>
> ---
>  virt/kvm/iommu.c |    8 ++++++--
>  1 files changed, 6 insertions(+), 2 deletions(-)

Applied, thanks.


^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH v2] KVM: Fix IOMMU RCU related warning
  2010-07-01  7:00 [PATCH] KVM: Fix IOMMU memslot reference warning Sheng Yang
  2010-07-01 15:58 ` Marcelo Tosatti
@ 2010-07-01 16:11 ` Sheng Yang
  2010-07-01 16:16   ` Marcelo Tosatti
  1 sibling, 1 reply; 4+ messages in thread
From: Sheng Yang @ 2010-07-01 16:11 UTC (permalink / raw)
  To: Marcelo Tosatti; +Cc: Avi Kivity, kvm, Sheng Yang

This patch fixes the following warning.

===================================================
[ INFO: suspicious rcu_dereference_check() usage. ]
---------------------------------------------------
include/linux/kvm_host.h:259 invoked rcu_dereference_check() without
protection!

other info that might help us debug this:

rcu_scheduler_active = 1, debug_locks = 0
no locks held by qemu-system-x86/29679.

stack backtrace:
Pid: 29679, comm: qemu-system-x86 Not tainted 2.6.35-rc3+ #200
Call Trace:
 [<ffffffff810a224e>] lockdep_rcu_dereference+0xa8/0xb1
 [<ffffffffa018a06f>] kvm_iommu_unmap_memslots+0xc9/0xde [kvm]
 [<ffffffffa018a0c4>] kvm_iommu_unmap_guest+0x40/0x4e [kvm]
 [<ffffffffa018f772>] kvm_arch_destroy_vm+0x1a/0x186 [kvm]
 [<ffffffffa01800d0>] kvm_put_kvm+0x110/0x167 [kvm]
 [<ffffffffa0180ecc>] kvm_vcpu_release+0x18/0x1c [kvm]
 [<ffffffff81156f5d>] fput+0x22a/0x3a0
 [<ffffffff81152288>] filp_close+0xb4/0xcd
 [<ffffffff8106599f>] put_files_struct+0x1b7/0x36b
 [<ffffffff81065830>] ? put_files_struct+0x48/0x36b
 [<ffffffff8131ee59>] ? do_raw_spin_unlock+0x118/0x160
 [<ffffffff81065bc0>] exit_files+0x6d/0x75
 [<ffffffff81068348>] do_exit+0x47d/0xc60
 [<ffffffff8177e7b5>] ? _raw_spin_unlock_irq+0x30/0x36
 [<ffffffff81068bfa>] do_group_exit+0xcf/0x134
 [<ffffffff81080790>] get_signal_to_deliver+0x732/0x81d
 [<ffffffff81095996>] ? cpu_clock+0x4e/0x60
 [<ffffffff81002082>] do_notify_resume+0x117/0xc43
 [<ffffffff810a2fa3>] ? trace_hardirqs_on+0xd/0xf
 [<ffffffff81080d79>] ? sys_rt_sigtimedwait+0x2b5/0x3bf
 [<ffffffff8177d9f2>] ? trace_hardirqs_off_thunk+0x3a/0x3c
 [<ffffffff81003221>] ? sysret_signal+0x5/0x3d
 [<ffffffff8100343b>] int_signal+0x12/0x17

Signed-off-by: Sheng Yang <sheng@linux.intel.com>
---
I just realized the first version of patch unnecessarily covered
kvm_iommu_map_memslots(), because that part had already been
covered by kvm_vm_ioctl_assign_device() definitely(though unpaired
callings seems a little strange...).

 virt/kvm/iommu.c |    4 +++-
 1 files changed, 3 insertions(+), 1 deletions(-)

diff --git a/virt/kvm/iommu.c b/virt/kvm/iommu.c
index 673c88a..c050f32 100644
--- a/virt/kvm/iommu.c
+++ b/virt/kvm/iommu.c
@@ -285,15 +285,17 @@ static void kvm_iommu_put_pages(struct kvm *kvm,
 
 static int kvm_iommu_unmap_memslots(struct kvm *kvm)
 {
-	int i;
+	int i, idx;
 	struct kvm_memslots *slots;
 
+	idx = srcu_read_lock(&kvm->srcu);
 	slots = kvm_memslots(kvm);
 
 	for (i = 0; i < slots->nmemslots; i++) {
 		kvm_iommu_put_pages(kvm, slots->memslots[i].base_gfn,
 				    slots->memslots[i].npages);
 	}
+	srcu_read_unlock(&kvm->srcu, idx);
 
 	return 0;
 }
-- 
1.7.0.1


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH v2] KVM: Fix IOMMU RCU related warning
  2010-07-01 16:11 ` [PATCH v2] KVM: Fix IOMMU RCU related warning Sheng Yang
@ 2010-07-01 16:16   ` Marcelo Tosatti
  0 siblings, 0 replies; 4+ messages in thread
From: Marcelo Tosatti @ 2010-07-01 16:16 UTC (permalink / raw)
  To: Sheng Yang; +Cc: Avi Kivity, kvm

On Fri, Jul 02, 2010 at 12:11:53AM +0800, Sheng Yang wrote:
> This patch fixes the following warning.
> 
> ===================================================
> [ INFO: suspicious rcu_dereference_check() usage. ]
> ---------------------------------------------------
> include/linux/kvm_host.h:259 invoked rcu_dereference_check() without
> protection!
> 
> other info that might help us debug this:
> 
> rcu_scheduler_active = 1, debug_locks = 0
> no locks held by qemu-system-x86/29679.
> 
> stack backtrace:
> Pid: 29679, comm: qemu-system-x86 Not tainted 2.6.35-rc3+ #200
> Call Trace:
>  [<ffffffff810a224e>] lockdep_rcu_dereference+0xa8/0xb1
>  [<ffffffffa018a06f>] kvm_iommu_unmap_memslots+0xc9/0xde [kvm]
>  [<ffffffffa018a0c4>] kvm_iommu_unmap_guest+0x40/0x4e [kvm]
>  [<ffffffffa018f772>] kvm_arch_destroy_vm+0x1a/0x186 [kvm]
>  [<ffffffffa01800d0>] kvm_put_kvm+0x110/0x167 [kvm]
>  [<ffffffffa0180ecc>] kvm_vcpu_release+0x18/0x1c [kvm]
>  [<ffffffff81156f5d>] fput+0x22a/0x3a0
>  [<ffffffff81152288>] filp_close+0xb4/0xcd
>  [<ffffffff8106599f>] put_files_struct+0x1b7/0x36b
>  [<ffffffff81065830>] ? put_files_struct+0x48/0x36b
>  [<ffffffff8131ee59>] ? do_raw_spin_unlock+0x118/0x160
>  [<ffffffff81065bc0>] exit_files+0x6d/0x75
>  [<ffffffff81068348>] do_exit+0x47d/0xc60
>  [<ffffffff8177e7b5>] ? _raw_spin_unlock_irq+0x30/0x36
>  [<ffffffff81068bfa>] do_group_exit+0xcf/0x134
>  [<ffffffff81080790>] get_signal_to_deliver+0x732/0x81d
>  [<ffffffff81095996>] ? cpu_clock+0x4e/0x60
>  [<ffffffff81002082>] do_notify_resume+0x117/0xc43
>  [<ffffffff810a2fa3>] ? trace_hardirqs_on+0xd/0xf
>  [<ffffffff81080d79>] ? sys_rt_sigtimedwait+0x2b5/0x3bf
>  [<ffffffff8177d9f2>] ? trace_hardirqs_off_thunk+0x3a/0x3c
>  [<ffffffff81003221>] ? sysret_signal+0x5/0x3d
>  [<ffffffff8100343b>] int_signal+0x12/0x17
> 
> Signed-off-by: Sheng Yang <sheng@linux.intel.com>
> ---
> I just realized the first version of patch unnecessarily covered
> kvm_iommu_map_memslots(), because that part had already been
> covered by kvm_vm_ioctl_assign_device() definitely(though unpaired
> callings seems a little strange...).

Since nesting srcu_read_lock is OK, its fine to have it in
kvm_iommu_map_memslots, even if unnecessary.


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2010-07-01 16:17 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-07-01  7:00 [PATCH] KVM: Fix IOMMU memslot reference warning Sheng Yang
2010-07-01 15:58 ` Marcelo Tosatti
2010-07-01 16:11 ` [PATCH v2] KVM: Fix IOMMU RCU related warning Sheng Yang
2010-07-01 16:16   ` Marcelo Tosatti

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox