Skip to contentSkip to conversation

convert init_rmode_tss to slots_lock

PATCH Applied Marcelo Tosatti 3 participants 3 messages Mar 18, 2008 – Mar 19, 2008

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 convert init_rmode_tss to slots_lock

init_rmode_tss was forgotten during the conversion from mmap_sem to slots_lock.

There are several sites reading the slots data without taking slots_lock, including tdp_page_fault. I'll be sending a patch to move acquision to vcpu_run as suggested by Avi later today.

INFO: task qemu-system-x86:3748 blocked for more than 120 seconds.
Call Trace:
 [<ffffffff8053d100>] __down_read+0x86/0x9e
 [<ffffffff8053fb43>] do_page_fault+0x346/0x78e
 [<ffffffff8053d235>] trace_hardirqs_on_thunk+0x35/0x3a
 [<ffffffff8053dcad>] error_exit+0x0/0xa9
 [<ffffffff8035a7a7>] copy_user_generic_string+0x17/0x40
 [<ffffffff88099a8a>] :kvm:kvm_write_guest_page+0x3e/0x5f
 [<ffffffff880b661a>] :kvm_intel:init_rmode_tss+0xa7/0xf9
 [<ffffffff880b7d7e>] :kvm_intel:vmx_vcpu_reset+0x10/0x38a
 [<ffffffff8809b9a5>] :kvm:kvm_arch_vcpu_setup+0x20/0x53
 [<ffffffff8809a1e4>] :kvm:kvm_vm_ioctl+0xad/0x1cf
 [<ffffffff80249dea>] __lock_acquire+0x4f7/0xc28
 [<ffffffff8028fad9>] vfs_ioctl+0x21/0x6b
 [<ffffffff8028fd75>] do_vfs_ioctl+0x252/0x26b
 [<ffffffff8028fdca>] sys_ioctl+0x3c/0x5e
 [<ffffffff8020b01b>] system_call_after_swapgs+0x7b/0x80
arch/x86/kvm/vmx.c +2 -2
Index: kvm/arch/x86/kvm/vmx.c
===================================================================
@@ -1480,7 +1480,7 @@ static int init_rmode_tss(struct kvm *kv
 	int ret = 0;
 	int r;
 
-	down_read(&current->mm->mmap_sem);
+	down_read(&kvm->slots_lock);
 	r = kvm_clear_guest_page(kvm, fn, 0, PAGE_SIZE);
 	if (r < 0)
 		goto out;
@@ -1503,7 +1503,7 @@ static int init_rmode_tss(struct kvm *kv
 
 	ret = 1;
 out:
-	up_read(&current->mm->mmap_sem);
+	up_read(&kvm->slots_lock);
 	return ret;
 }
 

-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/

#1 lore raw
Quoted 3 lines · Marcelo Tosatti

init_rmode_tss was forgotten during the conversion from mmap_sem to slots_lock.

yup, good catch.

Quoted 40 lines

There are several sites reading the slots data without taking slots_lock, including tdp_page_fault. I'll be sending a patch to move acquision to vcpu_run as suggested by Avi later today.

INFO: task qemu-system-x86:3748 blocked for more than 120 seconds.
Call Trace:
 [<ffffffff8053d100>] __down_read+0x86/0x9e
 [<ffffffff8053fb43>] do_page_fault+0x346/0x78e
 [<ffffffff8053d235>] trace_hardirqs_on_thunk+0x35/0x3a
 [<ffffffff8053dcad>] error_exit+0x0/0xa9
 [<ffffffff8035a7a7>] copy_user_generic_string+0x17/0x40
 [<ffffffff88099a8a>] :kvm:kvm_write_guest_page+0x3e/0x5f
 [<ffffffff880b661a>] :kvm_intel:init_rmode_tss+0xa7/0xf9
 [<ffffffff880b7d7e>] :kvm_intel:vmx_vcpu_reset+0x10/0x38a
 [<ffffffff8809b9a5>] :kvm:kvm_arch_vcpu_setup+0x20/0x53
 [<ffffffff8809a1e4>] :kvm:kvm_vm_ioctl+0xad/0x1cf
 [<ffffffff80249dea>] __lock_acquire+0x4f7/0xc28
 [<ffffffff8028fad9>] vfs_ioctl+0x21/0x6b
 [<ffffffff8028fd75>] do_vfs_ioctl+0x252/0x26b
 [<ffffffff8028fdca>] sys_ioctl+0x3c/0x5e
 [<ffffffff8020b01b>] system_call_after_swapgs+0x7b/0x80

Index: kvm/arch/x86/kvm/vmx.c
===================================================================

arch/x86/kvm/vmx.c +1 -1
@@ -1480,7 +1480,7 @@ static int init_rmode_tss(struct kvm *kv
 	int ret = 0;
 	int r;
 
-	down_read(&current->mm->mmap_sem);
+	down_read(&kvm->slots_lock);
 	r = kvm_clear_guest_page(kvm, fn, 0, PAGE_SIZE);
 	if (r < 0)
 		goto out;

arch/x86/kvm/vmx.c static int init_rmode_tss(struct kvm *kv · line 1509

Quoted 8 lines
arch/x86/kvm/vmx.c +1 -1
@@ -1503,7 +1503,7 @@ static int init_rmode_tss(struct kvm *kv
 
 	ret = 1;
 out:
-	up_read(&current->mm->mmap_sem);
+	up_read(&kvm->slots_lock);
 	return ret;
 }
 

-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/

Applied
#2 lore raw
In reply to Marcelo Tosatti
Quoted 4 lines · Marcelo Tosatti

init_rmode_tss was forgotten during the conversion from mmap_sem to slots_lock.

Applied, thanks.

Quoted 4 lines

There are several sites reading the slots data without taking slots_lock, including tdp_page_fault. I'll be sending a patch to move acquision to vcpu_run as suggested by Avi later today.

You'll need to acquire it for KVM_SET_MSRS (since that can trigger a write, if writing to the clock base).

Signature · 7 lines
error compiling committee.c: too many arguments to function


-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/