Subject: [PATCH] ARM: KVM: iterate over all CPUs for CPU compatibility check

From: [email-masked] (Andre Przywara)
Date: Mon, 15 Apr 2013 15:13:55 +0200

On 04/15/2013 11:52 AM, Alexander Spyridakis wrote:
> On 15 April 2013 11:39, Andre Przywara <[email-masked]
> <mailto:[email-masked]>> wrote:
>
>      > [Q: does
>      >     all the hyp mode code have to also run on the A15s or
>      >     is it A7-safe?]
>
>     Good point. It seems like the code hangs in init_hyp_mode().
>     Will do more debugging in there now.
>
>
> I've run on this problem before, while trying to run KVM guests on A7 cores.
>
> For some reason the 3rd A7 hangs in arch/arm/kvm/init.S, on the
> instruction that updates HSCTLR between the two isbs on __do_hyp_init
> (mcr p15, 4, r0, c1, c0, 0). If you boot the system with maxcpus=4 then
> init_hyp_mode() will not hang on the A7 cluster. Other than that from my
> limited testing KVM on A7 works on a usual linux guest. I also tried to
> only boot the 3rd A7 core to rule out any racing issues, but still the
> same behaviour applies.

Could well be the same issue here. I chased it down till CPU 2 goes into 
HYP mode to do the initialization.
I am running with maxcpus=3 (this increases the likelyhood that 
kvm_target_cpu() runs on an A15), so CPU #2 is the only one A7.
As the HYP mode exception table is empty except for the HVC trap, it may 
be looping here. I am trying now to get the PC of the faulty instruction.

(on a TC2: 0-1: A15, 2-4: A7)
kvm_target_cpu() on CPU #1, part is c0f0
kvm [1]: entering init_hyp_mode on CPU 1
kvm [1]: kvm_mmu_init() returned 0 on CPU 1
kvm [1]: hyp_get_vectors() finished on CPU 1
kvm [1]: allocated stack for HV mode on 5 CPUs, now on CPU 1
kvm [0]: entering cpu_init_hyp_mode(8050fde0) on CPU 0
kvm [0]: c_i_h_m: set vectors finished
kvm [0]: c_i_h_m: initialization of local variables finished
kvm [0]: c_i_h_m: kvm_call_hyp() finished, returning...
kvm [1]: entering cpu_init_hyp_mode(8050fde0) on CPU 1
kvm [1]: c_i_h_m: set vectors finished
kvm [1]: c_i_h_m: initialization of local variables finished
kvm [1]: c_i_h_m: kvm_call_hyp() finished, returning...
kvm [0]: entering cpu_init_hyp_mode(8050fde0) on CPU 2
kvm [0]: c_i_h_m: set vectors finished
kvm [0]: c_i_h_m: initialization of local variables finished

Regards,
Andre.