From mboxrd@z Thu Jan 1 00:00:00 1970 From: Andrew Jones Subject: [PATCH kvm-unit-tests 06/15] powerpc: import initrd Date: Fri, 13 Jan 2017 19:15:24 +0100 Message-ID: <20170113181533.15145-7-drjones@redhat.com> References: <20170113181533.15145-1-drjones@redhat.com> Cc: rkrcmar@redhat.com, pbonzini@redhat.com, lvivier@redhat.com, thuth@redhat.com To: kvm@vger.kernel.org Return-path: Received: from mx1.redhat.com ([209.132.183.28]:58218 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751104AbdAMSPp (ORCPT ); Fri, 13 Jan 2017 13:15:45 -0500 Received: from int-mx14.intmail.prod.int.phx2.redhat.com (int-mx14.intmail.prod.int.phx2.redhat.com [10.5.11.27]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 8C8C861BAE for ; Fri, 13 Jan 2017 18:15:46 +0000 (UTC) In-Reply-To: <20170113181533.15145-1-drjones@redhat.com> Sender: kvm-owner@vger.kernel.org List-ID: If an initrd is provided on the qemu command line, then "import" it by copying it to a safe location during setup. Signed-off-by: Andrew Jones --- lib/powerpc/setup.c | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/lib/powerpc/setup.c b/lib/powerpc/setup.c index f55b23fb5080..f2dc10e01352 100644 --- a/lib/powerpc/setup.c +++ b/lib/powerpc/setup.c @@ -22,6 +22,9 @@ extern unsigned long stacktop; extern void io_init(void); extern void setup_args_progname(const char *args); +char *initrd; +u32 initrd_size; + u32 cpus[NR_CPUS] = { [0 ... NR_CPUS-1] = (~0U) }; int nr_cpus; uint64_t tb_hz; @@ -154,19 +157,21 @@ static void mem_init(phys_addr_t freemem_start) void setup(const void *fdt) { void *freemem = &stacktop; - const char *bootargs; + const char *bootargs, *tmp; u32 fdt_size; int ret; /* - * Before calling mem_init we need to move the fdt to a safe - * location. We move it above the stack to construct the memory + * Before calling mem_init we need to move the fdt and initrd + * to safe locations. We move them to construct the memory * map illustrated below: * * +----------------------+ <-- top of physical memory * | | * ~ ~ * | | + * +----------------------+ <-- top of initrd + * | | * +----------------------+ <-- top of FDT * | | * +----------------------+ <-- top of cpu0's stack @@ -185,6 +190,14 @@ void setup(const void *fdt) assert(ret == 0); freemem += fdt_size; + ret = dt_get_initrd(&tmp, &initrd_size); + assert(ret == 0 || ret == -FDT_ERR_NOTFOUND); + if (ret == 0) { + initrd = freemem; + memmove(initrd, tmp, initrd_size); + freemem += initrd_size; + } + /* call init functions */ cpu_init(); -- 2.9.3