lkml.org 
[lkml]   [2008]   [Feb]   [13]   [last100]   RSS-feed
Views: [more markup]  [less markup]  [headers]  [forward] 
 
Messages in this thread
Complete thread (EXPERIMENTAL)
Patch in this message
/
DateWed, 13 Feb 2008 14:09:05 -0200
FromMarcelo Tosatti <>
SubjectRe: Qemu & KVM bug
Digg This
On Wed, Feb 13, 2008 at 04:24:53PM +0100, Jiri Kosina wrote:
On Wed, 13 Feb 2008, Zdenek Kabelac wrote:

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().

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?



[view this diff only]
--- linux-2.6.orig/arch/x86/kvm/vmx.c
+++ linux-2.6/arch/x86/kvm/vmx.c
@@ -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;
 


\
ISP Services
Valid XHTML 1.0!\ /
Valid CSS! Last update: 2008-02-13 17:09    [W:0.185 / U:0.550 seconds]
©2003-2005 Jasper Spaans