public inbox for kvm@vger.kernel.org
 help / color / mirror / Atom feed
From: Michael Ellerman <michael@ellerman.id.au>
To: <penberg@kernel.org>
Cc: <kvm@vger.kernel.org>, levinsasha928@gmail.com, <matt@ozlabs.org>,
	<kvm-ppc@vger.kernel.org>
Subject: [PATCH 3/3] kvm tools: Do setup_fdt() later, get powerpc to boot again
Date: Fri,  5 Oct 2012 11:15:19 +1000	[thread overview]
Message-ID: <1349399719-9317-3-git-send-email-michael@ellerman.id.au> (raw)
In-Reply-To: <1349399719-9317-1-git-send-email-michael@ellerman.id.au>

In commit e3d3ced "kernel load/firmware cleanup", the call to
kvm__arch_setup_firmware() was moved. Previously more or less at the end
of the init sequence, but that commit moved it into kvm__init() which
is a core_init() call and so runs quite early.

This broke booting powerpc guests, as setup_fdt() needs to be called
later in the setup sequence. In particular it looks at kvm->nrcpus,
which is uninitialised at that point.

In general setup_fdt() needs to run late in the sequence, as it encodes
the setup of the machine into the device tree.

So move setup_fdt() out of kvm__arch_setup_firmware() and make it a
firmware_init() call of its own.

With this patch I am able to boot guests again on HV KVM.

Signed-off-by: Michael Ellerman <michael@ellerman.id.au>
---
 tools/kvm/powerpc/kvm.c |    8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/tools/kvm/powerpc/kvm.c b/tools/kvm/powerpc/kvm.c
index e4f5315..d675265 100644
--- a/tools/kvm/powerpc/kvm.c
+++ b/tools/kvm/powerpc/kvm.c
@@ -286,7 +286,7 @@ static void generate_segment_page_sizes(struct kvm_ppc_smmu_info *info, struct f
  * and whilst most PPC targets will require CPU/memory nodes, others like RTAS
  * should eventually be added separately.
  */
-static void setup_fdt(struct kvm *kvm)
+static int setup_fdt(struct kvm *kvm)
 {
 	uint64_t 	mem_reg_property[] = { 0, cpu_to_be64(kvm->ram_size) };
 	int 		smp_cpus = kvm->nrcpus;
@@ -488,7 +488,10 @@ static void setup_fdt(struct kvm *kvm)
 	_FDT(fdt_pack(fdt_dest));
 
 	free(segment_page_sizes.value);
+
+	return 0;
 }
+firmware_init(setup_fdt);
 
 /**
  * kvm__arch_setup_firmware
@@ -517,9 +520,6 @@ int kvm__arch_setup_firmware(struct kvm *kvm)
 
 	/* Load SLOF */
 
-	/* Init FDT */
-	setup_fdt(kvm);
-
 	return 0;
 }
 
-- 
1.7.9.5


  parent reply	other threads:[~2012-10-05  1:15 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-10-05  1:15 [PATCH 1/3] kvm tools: Fix powerpc build errors caused by recent changes Michael Ellerman
2012-10-05  1:15 ` [PATCH 2/3] kvm tools: Fix segfault on powerpc in xics_register() Michael Ellerman
2012-10-05  1:15 ` Michael Ellerman [this message]
2012-10-05  6:30 ` [PATCH 1/3] kvm tools: Fix powerpc build errors caused by recent changes Pekka Enberg
2012-10-05  6:33   ` Michael Ellerman

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1349399719-9317-3-git-send-email-michael@ellerman.id.au \
    --to=michael@ellerman.id.au \
    --cc=kvm-ppc@vger.kernel.org \
    --cc=kvm@vger.kernel.org \
    --cc=levinsasha928@gmail.com \
    --cc=matt@ozlabs.org \
    --cc=penberg@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox