From mboxrd@z Thu Jan 1 00:00:00 1970 From: Andrew Jones Subject: [PATCH kvm-unit-tests 03/15] arm/arm64: better document setup Date: Fri, 13 Jan 2017 19:15:21 +0100 Message-ID: <20170113181533.15145-4-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]:37488 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751105AbdAMSPp (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 AE2F848C for ; Fri, 13 Jan 2017 18:15:41 +0000 (UTC) In-Reply-To: <20170113181533.15145-1-drjones@redhat.com> Sender: kvm-owner@vger.kernel.org List-ID: To prepare for another region illustrate where we move the FDT. No functional change. Signed-off-by: Andrew Jones --- lib/arm/setup.c | 30 +++++++++++++++++++++++++----- 1 file changed, 25 insertions(+), 5 deletions(-) diff --git a/lib/arm/setup.c b/lib/arm/setup.c index dc94d312b262..dcf25c2f4365 100644 --- a/lib/arm/setup.c +++ b/lib/arm/setup.c @@ -112,31 +112,51 @@ static void mem_init(phys_addr_t freemem_start) void setup(const void *fdt) { + void *freemem = &stacktop; const char *bootargs; u32 fdt_size; int ret; /* - * Move the fdt to just above the stack. The free memory - * then starts just after the fdt. + * Before calling mem_init we need to move the fdt to a safe + * location. We move it above the stack to construct the memory + * map illustrated below: + * + * +----------------------+ <-- top of physical memory + * | | + * ~ ~ + * | | + * +----------------------+ <-- top of FDT + * | | + * +----------------------+ <-- top of cpu0's stack + * | | + * +----------------------+ <-- top of text/data/bss sections, + * | | see arm/flat.lds + * | | + * +----------------------+ <-- load address + * | | + * +----------------------+ */ fdt_size = fdt_totalsize(fdt); - ret = fdt_move(fdt, &stacktop, fdt_size); + ret = fdt_move(fdt, freemem, fdt_size); assert(ret == 0); - ret = dt_init(&stacktop); + ret = dt_init(freemem); assert(ret == 0); + freemem += fdt_size; + /* call init functions */ cpu_init(); /* cpu_init must be called before thread_info_init */ thread_info_init(current_thread_info(), 0); /* thread_info_init must be called before mem_init */ - mem_init(PAGE_ALIGN((unsigned long)&stacktop + fdt_size)); + mem_init(PAGE_ALIGN((unsigned long)freemem)); /* mem_init must be called before io_init */ io_init(); + /* finish setup */ ret = dt_get_bootargs(&bootargs); assert(ret == 0 || ret == -FDT_ERR_NOTFOUND); setup_args_progname(bootargs); -- 2.9.3