Skip to contentSkip to conversation

Qemu & KVM bug

DISCUSSION Zdenek Kabelac 4 participants 5 messages Feb 13, 2008

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

Hi

I get this bug in my log whenever I start qemu-kvm - I do not use kqemu module - so it's with plain kernel modules.
If more details are needed - just ask.
(Cpu; C2D)

Bye

Zdenek

BUG: sleeping function called from invalid context at kernel/rwsem.c:48

in_atomic():1, irqs_disabled():0
INFO: lockdep is turned off.
Pid: 26600, comm: qemu-kvm Not tainted 2.6.25-rc1 #29

Call Trace:
 [<ffffffff81064873>] ? __debug_show_held_locks+0x23/0x30
 [<ffffffff81036765>] __might_sleep+0xe5/0x110
 [<ffffffff812f21b0>] down_write+0x20/0x70
 [<ffffffff88271a3c>] :kvm_intel:vmx_create_vcpu+0x48c/0x61c
 [<ffffffff810b5d92>] ? fd_install+0x52/0x60
 [<ffffffff8824edce>] :kvm:kvm_arch_vcpu_create+0xe/0x10
 [<ffffffff8824dca2>] :kvm:kvm_vm_ioctl+0x122/0x220
 [<ffffffff8824c770>] ? :kvm:kvm_dev_ioctl+0x80/0x1c0
 [<ffffffff810c67b1>] vfs_ioctl+0x31/0xa0
 [<ffffffff810c6aa3>] do_vfs_ioctl+0x283/0x2f0
 [<ffffffff810c6ba9>] sys_ioctl+0x99/0xa0
 [<ffffffff8100c8ae>] tracesys+0xdc/0xe1

SIPI to vcpu 1 vector 0x10
Ignoring de-assert INIT to vcpu 1
SIPI to vcpu 1 vector 0x06
SIPI to vcpu 1 vector 0x06
kvm: emulating exchange as write

#1 lore raw
Quoted 7 lines · Zdenek Kabelac

I get this bug in my log whenever I start qemu-kvm - I do not use kqemu module - so it's with plain kernel modules. If more details are needed - just ask. (Cpu; C2D)

BUG: sleeping function called from invalid context at kernel/rwsem.c:48

in_atomic():1, irqs_disabled():0
INFO: lockdep is turned off.
Pid: 26600, comm: qemu-kvm Not tainted 2.6.25-rc1 #29

This has been obviously caused by Marcelo's (added to CC) commit 10589a4699b, which added down_write(mmap_sem) to alloc_apic_access_page(), which is called with preempt disabled from vmx_create_vcpu().

Signature · 2 lines
Jiri Kosina
SUSE Labs
#2 lore raw
Quoted 10 lines · Jiri Kosina
Quoted 7 lines · Zdenek Kabelac

I get this bug in my log whenever I start qemu-kvm - I do not use kqemu module - so it's with plain kernel modules. If more details are needed - just ask. (Cpu; C2D)

BUG: sleeping function called from invalid context at kernel/rwsem.c:48

in_atomic():1, irqs_disabled():0
INFO: lockdep is turned off.
Pid: 26600, comm: qemu-kvm Not tainted 2.6.25-rc1 #29

Quoted 3 lines

This has been obviously caused by Marcelo's (added to CC) commit 10589a4699b, which added down_write(mmap_sem) to alloc_apic_access_page(), which is called with preempt disabled from vmx_create_vcpu().

alloc_apic_access_page() called mutex_lock, so the warning would trigger before that change.

I think it's fine to allocate the APIC page after put_cpu(), since no vcpu state is required.

Avi?

arch/x86/kvm/vmx.c +3 -3
@@ -1601,9 +1601,6 @@ static int vmx_vcpu_setup(struct vcpu_vm
 	vmcs_writel(CR0_GUEST_HOST_MASK, ~0UL);
 	vmcs_writel(CR4_GUEST_HOST_MASK, KVM_GUEST_CR4_MASK);
 
-	if (vm_need_virtualize_apic_accesses(vmx->vcpu.kvm))
-		if (alloc_apic_access_page(vmx->vcpu.kvm) != 0)
-			return -ENOMEM;
 
 	return 0;
 }
@@ -2533,6 +2530,9 @@ static struct kvm_vcpu *vmx_create_vcpu(
 	put_cpu();
 	if (err)
 		goto free_vmcs;
+	if (vm_need_virtualize_apic_accesses(kvm))
+		if (alloc_apic_access_page(kvm) != 0)
+			goto free_vmcs;
 
 	return &vmx->vcpu;
 
#3 lore raw

2008/2/13, Marcelo Tosatti <[email protected]>:

arch/x86/kvm/vmx.c static int vmx_vcpu_setup(struct vcpu_vm

Quoted 27 lines · Jiri Kosina
Quoted 10 lines · Zdenek Kabelac
Quoted 8 lines

I get this bug in my log whenever I start qemu-kvm - I do not use kqemu module - so it's with plain kernel modules. If more details are needed - just ask. (Cpu; C2D)

BUG: sleeping function called from invalid context at kernel/rwsem.c:48

in_atomic():1, irqs_disabled():0
INFO: lockdep is turned off.
Pid: 26600, comm: qemu-kvm Not tainted 2.6.25-rc1 #29

Quoted 3 lines

This has been obviously caused by Marcelo's (added to CC) commit 10589a4699b, which added down_write(mmap_sem) to alloc_apic_access_page(), which is called with preempt disabled from vmx_create_vcpu().

alloc_apic_access_page() called mutex_lock, so the warning would trigger before that change.

I think it's fine to allocate the APIC page after put_cpu(), since no vcpu state is required.

Avi?

arch/x86/kvm/vmx.c +0 -0
@@ -1601,9 +1601,6 @@ static int vmx_vcpu_setup(struct vcpu_vm

Hi

I've checked the patch myself - and looks like there is no BUG message now - nice
thanks.

Zdenek

#4 lore raw
In reply to Marcelo Tosatti
Quoted 11 lines · Marcelo Tosatti
Quoted 9 lines · Jiri Kosina
Quoted 6 lines · Zdenek Kabelac

I get this bug in my log whenever I start qemu-kvm - I do not use kqemu module - so it's with plain kernel modules. If more details are needed - just ask. (Cpu; C2D)

BUG: sleeping function called from invalid context at kernel/rwsem.c:48

in_atomic():1, irqs_disabled():0
INFO: lockdep is turned off.
Pid: 26600, comm: qemu-kvm Not tainted 2.6.25-rc1 #29

Quoted 9 lines
Quoted 2 lines

This has been obviously caused by Marcelo's (added to CC) commit 10589a4699b, which added down_write(mmap_sem) to alloc_apic_access_page(), which is called with preempt disabled from vmx_create_vcpu().

alloc_apic_access_page() called mutex_lock, so the warning would trigger before that change.

I think it's fine to allocate the APIC page after put_cpu(), since no vcpu state is required.

Looks right, but wants a changelog and signoff, of course.

Signature · 1 line
Any sufficiently difficult bug is indistinguishable from a feature.