Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

[PATCH] kvm tools: powerpc: Fix init order for xics

1 view
Skip to first unread message

Michael Neuling

unread,
Aug 19, 2013, 11:30:02 PM8/19/13
to
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().

Signed-off-by: Michael Neuling <mi...@neuling.org>

diff --git a/tools/kvm/powerpc/xics.c b/tools/kvm/powerpc/xics.c
index cf64a08..c1ef35b 100644
--- a/tools/kvm/powerpc/xics.c
+++ b/tools/kvm/powerpc/xics.c
@@ -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)
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majo...@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/

Pekka Enberg

unread,
Aug 27, 2013, 8:00:03 AM8/27/13
to
On Tue, Aug 20, 2013 at 6:28 AM, Michael Neuling <mi...@neuling.org> wrote:
> 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().
>
> Signed-off-by: Michael Neuling <mi...@neuling.org>

Applied, thanks a lot!
0 new messages