kvm tools: powerpc: Fix init order for xics
PATCH 1/1 kvm tools: powerpc: Fix init order for xics
xics_init() assumes kvm->nrcpus is already setup. kvm->nrcpus is setup in kvm_cpu_init()
Unfortunately xics_init() and kvm_cpu_init() both use base_init(). So depending on the order randomly determined by the compiler, xics_init() may initialised see kvm->nrcpus as 0 and not setup any of the icp VCPU pointers. This manifests itself later in boot when trying to raise an IRQ resulting in a null pointer deference/segv.
This moves xics_init() to use dev_base_init() to ensure it happens after kvm_cpu_init().
tools/kvm/powerpc/xics.c +1 -1
@@ -505,7 +505,7 @@ static int xics_init(struct kvm *kvm)return 0 ; } -base_init (xics_init); +dev_base_init (xics_init);void kvm__irq_line (struct kvm *kvm,int irq,int level)
Pekka Enberg
AppliedQuoted 9 lines · Michael Neuling
xics_init()assumeskvm->nrcpusis already setup.kvm->nrcpusis setup inkvm_cpu_init()Unfortunately
xics_init()andkvm_cpu_init()both usebase_init(). So depending on the order randomly determined by the compiler,xics_init()may initialised seekvm->nrcpusas 0 and not setup any of the icp VCPU pointers. This manifests itself later in boot when trying to raise an IRQ resulting in a null pointer deference/segv.
Quoted 4 lines
This moves
xics_init()to usedev_base_init()to ensure it happens afterkvm_cpu_init().Signed-off-by Michael Neuling <[email protected]>
Applied, thanks a lot!