The following warning was triggered by missing srcu locks around
the storage key handling functions.
=============================
WARNING: suspicious RCU usage
4.12.0+ #56 Not tainted
-----------------------------
./include/linux/kvm_host.h:572 suspicious rcu_dereference_check() usage!
rcu_scheduler_active = 2, debug_locks = 1
1 lock held by live_migration/4936:
#0: (&mm->mmap_sem){++++++}, at: [<
0000000000141be0>]
kvm_arch_vm_ioctl+0x6b8/0x22d0
CPU: 8 PID: 4936 Comm: live_migration Not tainted 4.12.0+ #56
Hardware name: IBM 2964 NC9 704 (LPAR)
Call Trace:
([<
000000000011378a>] show_stack+0xea/0xf0)
[<
000000000055cc4c>] dump_stack+0x94/0xd8
[<
000000000012ee70>] gfn_to_memslot+0x1a0/0x1b8
[<
0000000000130b76>] gfn_to_hva+0x2e/0x48
[<
0000000000141c3c>] kvm_arch_vm_ioctl+0x714/0x22d0
[<
000000000013306c>] kvm_vm_ioctl+0x11c/0x7b8
[<
000000000037e2c0>] do_vfs_ioctl+0xa8/0x6c8
[<
000000000037e984>] SyS_ioctl+0xa4/0xb8
[<
00000000008b20a4>] system_call+0xc4/0x27c
1 lock held by live_migration/4936:
#0: (&mm->mmap_sem){++++++}, at: [<
0000000000141be0>]
kvm_arch_vm_ioctl+0x6b8/0x22d0
Signed-off-by: Christian Borntraeger <borntraeger@de.ibm.com>
Reviewed-by: Pierre Morel<pmorel@linux.vnet.ibm.com>
{
uint8_t *keys;
uint64_t hva;
- int i, r = 0;
+ int srcu_idx, i, r = 0;
if (args->flags != 0)
return -EINVAL;
return -ENOMEM;
down_read(¤t->mm->mmap_sem);
+ srcu_idx = srcu_read_lock(&kvm->srcu);
for (i = 0; i < args->count; i++) {
hva = gfn_to_hva(kvm, args->start_gfn + i);
if (kvm_is_error_hva(hva)) {
if (r)
break;
}
+ srcu_read_unlock(&kvm->srcu, srcu_idx);
up_read(¤t->mm->mmap_sem);
if (!r) {
{
uint8_t *keys;
uint64_t hva;
- int i, r = 0;
+ int srcu_idx, i, r = 0;
if (args->flags != 0)
return -EINVAL;
goto out;
down_read(¤t->mm->mmap_sem);
+ srcu_idx = srcu_read_lock(&kvm->srcu);
for (i = 0; i < args->count; i++) {
hva = gfn_to_hva(kvm, args->start_gfn + i);
if (kvm_is_error_hva(hva)) {
if (r)
break;
}
+ srcu_read_unlock(&kvm->srcu, srcu_idx);
up_read(¤t->mm->mmap_sem);
out:
kvfree(keys);