Port-xen archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: LOCKDEBUG kernel option crashes if vcpu > 1



On 12 November 2014 15:59, Emmanuel Dreyfus <manu%netbsd.org@localhost> wrote:
Hi

An i386 domU kernel will crash on startup of LOCKDEBUG kernel option is
enabled and vcpu is more than 1.

The backtrace is below. Finding the offending code is easy, and I
understand that LOCKDEBUG globals are not initialized at the time this
mutex is used. I am not sure of the proper fix, though.



Hi,

Does the following patch work for you ?

It's a bit tricky since we use uvm_km_alloc() at early bootup (even for ci, I think this should come from a static array or a poolcache) which is what triggers the pmap_growkernel() as you probably know.

The mutex needs to be init()ed as early as possible, which is my intention with this change.

--
~Cherry


diff -r bed6f574351e sys/arch/xen/x86/cpu.c                                                                                            
--- a/sys/arch/xen/x86/cpu.c    Sun Sep 07 00:15:54 2014 +0530                                                                         
+++ b/sys/arch/xen/x86/cpu.c    Tue Nov 18 10:09:02 2014 +0530                                                                         
@@ -397,6 +397,10 @@                                                                                                                   
        ci->ci_dev = self;                                                                                                             
        ci->ci_cpuid = cpunum;                                                                                                         
                                                                                                                                       
+#if defined(__x86_64__) || defined(PAE)                                                                                               
+       mutex_init(&ci->ci_kpm_mtx, MUTEX_DEFAULT, IPL_VM);                                                                            
+#endif                                                                                                                                
+                                                                                                                                      
        KASSERT(HYPERVISOR_shared_info != NULL);                                                                                       
        KASSERT(cpunum < XEN_LEGACY_MAX_VCPUS);                                                                                        
        ci->ci_vcpu = &HYPERVISOR_shared_info->vcpu_info[cpunum];                                                                      
@@ -547,10 +551,6 @@                                                                                                                   
        /* No user PGD mapped for this CPU yet */                                                                                      
        ci->ci_xen_current_user_pgd = 0;                                                                                               
 #endif                                                                                                                                
-#if defined(__x86_64__) || defined(PAE)                                                                                               
-       mutex_init(&ci->ci_kpm_mtx, MUTEX_DEFAULT, IPL_VM);                                                                            
-#endif                                                                                                                                
-                                                                                                                                      
        atomic_or_32(&ci->ci_flags, CPUF_RUNNING);                                                                                     
 }                                                                                                                                     






Home | Main Index | Thread Index | Old Index