From patchwork Tue Aug 20 03:28:34 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Neuling X-Patchwork-Id: 268354 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 038272C0124 for ; Tue, 20 Aug 2013 13:29:08 +1000 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751925Ab3HTD2g (ORCPT ); Mon, 19 Aug 2013 23:28:36 -0400 Received: from ozlabs.org ([203.10.76.45]:42825 "EHLO ozlabs.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751757Ab3HTD2f (ORCPT ); Mon, 19 Aug 2013 23:28:35 -0400 Received: from localhost.localdomain (localhost [127.0.0.1]) by ozlabs.org (Postfix) with ESMTP id 8B8FC2C010A; Tue, 20 Aug 2013 13:28:34 +1000 (EST) Received: by localhost.localdomain (Postfix, from userid 1000) id 5B244D43B8D; Tue, 20 Aug 2013 13:28:34 +1000 (EST) Received: from ale.ozlabs.ibm.com (localhost [127.0.0.1]) by localhost.localdomain (Postfix) with ESMTP id 586E7D42D77; Tue, 20 Aug 2013 13:28:34 +1000 (EST) From: Michael Neuling To: penberg@kernel.org cc: kvm@vger.kernel.org, kvm-ppc@vger.kernel.org, linux-kernel@vger.kernel.org, michael@ellerman.id.au, Ian Munsie X-GPG-Fingerprint: 9B25 DC2A C58D 2C8D 47C2 457E 0887 E86F 32E6 BE16 X-GPG-Fingerprint: 9365 87D7 A7EF 4721 420B 91D9 CD5B 874B EAC1 B3F5 MIME-Version: 1.0 Subject: [PATCH] kvm tools: powerpc: Fix init order for xics X-Mailer: MH-E 8.2; nmh 1.5; GNU Emacs 23.4.1 Date: Tue, 20 Aug 2013 13:28:34 +1000 Message-ID: <32637.1376969314@ale.ozlabs.ibm.com> Sender: kvm-ppc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm-ppc@vger.kernel.org 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 --- To unsubscribe from this list: send the line "unsubscribe kvm-ppc" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html 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)