From patchwork Sun Nov 30 18:19:26 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Auger X-Patchwork-Id: 416223 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 402C5140180 for ; Mon, 1 Dec 2014 05:21:11 +1100 (AEDT) Received: from localhost ([::1]:51214 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Xv97N-0005Wy-C3 for incoming@patchwork.ozlabs.org; Sun, 30 Nov 2014 13:21:09 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:54380) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Xv96Q-0004OR-7L for qemu-devel@nongnu.org; Sun, 30 Nov 2014 13:20:16 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Xv96H-0003vb-Na for qemu-devel@nongnu.org; Sun, 30 Nov 2014 13:20:10 -0500 Received: from mail-wi0-f182.google.com ([209.85.212.182]:56933) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Xv96H-0003uG-Fr for qemu-devel@nongnu.org; Sun, 30 Nov 2014 13:20:01 -0500 Received: by mail-wi0-f182.google.com with SMTP id h11so15236943wiw.3 for ; Sun, 30 Nov 2014 10:20:01 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=ITU2o018y30uyr853bQIef22QTTPgr7gbB0ZBC95ipQ=; b=IFwdB/q/hlL0EZJu8xs9KhxjN493reuSEn4Za7V7VyYv7CLcGbBRSRgW/6Upvd7fuT NTbKdlHQtKbvz2oYSblPi+g/ewJPcz3EuUc1WPunXKVgttPaIG4mJhOFvY3O46Gmx7yc 4sXPihjSAkMrgj9tZKh2XtMxcvRN9d16weHCTOhKugm9Pjlg7+pmTtTOqc/XzGhOWRCZ anICyNppaUpeAz5EmU38KrDoix9yDqP7k/mr96yJuccJ8EAjSi+/brYoMrBZsmr2gdyb EC9kPGo0XjcULzLMmX/5WzSSUKT1v0ev9bqovCqL/DSX8Nonv6SwnIKzVtwwQwrxJFW9 mVFg== X-Gm-Message-State: ALoCoQnrHVdgis+V/LiSbH3vlCrJMDkNN6tBoE9HPrDbqEL1GSj91FDe4B572X6nrkCwkb5lGmpd X-Received: by 10.194.62.163 with SMTP id z3mr87253407wjr.74.1417371601044; Sun, 30 Nov 2014 10:20:01 -0800 (PST) Received: from midway01-04-00.lavalab ([81.128.185.50]) by mx.google.com with ESMTPSA id ec2sm25092772wib.23.2014.11.30.10.20.00 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Sun, 30 Nov 2014 10:20:00 -0800 (PST) From: Eric Auger To: eric.auger@st.com, christoffer.dall@linaro.org, qemu-devel@nongnu.org, agraf@suse.de, pbonzini@redhat.com, kim.phillips@freescale.com, a.rigo@virtualopensystems.com, manish.jaggi@caviumnetworks.com, joel.schopp@amd.com, zhaoshenglong@huawei.com, ard.biesheuvel@linaro.org Date: Sun, 30 Nov 2014 18:19:26 +0000 Message-Id: <1417371570-11789-3-git-send-email-eric.auger@linaro.org> X-Mailer: git-send-email 1.8.3.2 In-Reply-To: <1417371570-11789-1-git-send-email-eric.auger@linaro.org> References: <1417371570-11789-1-git-send-email-eric.auger@linaro.org> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.85.212.182 Cc: peter.maydell@linaro.org, patches@linaro.org, eric.auger@linaro.org, will.deacon@arm.com, stuart.yoder@freescale.com, Bharat.Bhushan@freescale.com, alex.williamson@redhat.com, a.motakis@virtualopensystems.com, kvmarm@lists.cs.columbia.edu Subject: [Qemu-devel] [PATCH v5 2/6] hw/arm/boot: dtb start and limit moved in arm_boot_info X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Two fields are added in arm_boot_info (dtb_start and dtb_limit). The prototype of arm_load_kernel is changed to only use arm_boot_info. The rationale behind introducing that change is when dealing with dynamic sysbus devices, we need to upgrade the device tree with dynamic device nodes after the dtb is already loaded. Storing those parameters in arm_boot_info allows to avoid computing again dtb_start and dtb_load, as done in arm_load_kernel. Signed-off-by: Eric Auger --- hw/arm/boot.c | 38 +++++++++++++++++++++----------------- include/hw/arm/arm.h | 5 +++-- 2 files changed, 24 insertions(+), 19 deletions(-) diff --git a/hw/arm/boot.c b/hw/arm/boot.c index 9997bea..0398cd4 100644 --- a/hw/arm/boot.c +++ b/hw/arm/boot.c @@ -314,24 +314,21 @@ static void set_kernel_args_old(const struct arm_boot_info *info) /** * arm_load_dtb() - load a device tree binary image into memory - * @addr: the address to load the image at * @binfo: struct describing the boot environment - * @addr_limit: upper limit of the available memory area at @addr * * Load a device tree supplied by the machine or by the user with the - * '-dtb' command line option, and put it at offset @addr in target - * memory. + * '-dtb' command line option, and put it at offset binfo->dtb_start in + * target memory. * - * If @addr_limit contains a meaningful value (i.e., it is strictly greater - * than @addr), the device tree is only loaded if its size does not exceed - * the limit. + * If binfo->dtb_limit contains a meaningful value (i.e., it is strictly + * greater binfo->dtb_start, the device tree is only loaded if its size does + * not exceed this upper limit. * * Returns: the size of the device tree image on success, * 0 if the image size exceeds the limit, * -1 on errors. */ -int arm_load_dtb(hwaddr addr, const struct arm_boot_info *binfo, - hwaddr addr_limit) +int arm_load_dtb(const struct arm_boot_info *binfo) { void *fdt = NULL; int size, rc; @@ -360,7 +357,8 @@ int arm_load_dtb(hwaddr addr, const struct arm_boot_info *binfo, } } - if (addr_limit > addr && size > (addr_limit - addr)) { + if (binfo->dtb_limit > binfo->dtb_start && + size > (binfo->dtb_limit - binfo->dtb_start)) { /* Installing the device tree blob at addr would exceed addr_limit. * Whether this constitutes failure is up to the caller to decide, * so just return 0 as size, i.e., no error. @@ -427,7 +425,7 @@ int arm_load_dtb(hwaddr addr, const struct arm_boot_info *binfo, /* Put the DTB into the memory map as a ROM image: this will ensure * the DTB is copied again upon reset, even if addr points into RAM. */ - rom_add_blob_fixed("dtb", fdt, size, addr); + rom_add_blob_fixed("dtb", fdt, size, binfo->dtb_start); g_free(fdt); @@ -504,7 +502,10 @@ void arm_load_kernel(ARMCPU *cpu, struct arm_boot_info *info) /* If we have a device tree blob, but no kernel to supply it to, * copy it to the base of RAM for a bootloader to pick up. */ - if (arm_load_dtb(info->loader_start, info, 0) < 0) { + info->dtb_start = info->loader_start; + info->dtb_limit = 0; + + if (arm_load_dtb(info) < 0) { exit(1); } } @@ -572,7 +573,9 @@ void arm_load_kernel(ARMCPU *cpu, struct arm_boot_info *info) if (elf_low_addr < info->loader_start) { elf_low_addr = 0; } - if (arm_load_dtb(info->loader_start, info, elf_low_addr) < 0) { + info->dtb_start = info->loader_start; + info->dtb_limit = elf_low_addr; + if (arm_load_dtb(info) < 0) { exit(1); } } @@ -635,12 +638,13 @@ void arm_load_kernel(ARMCPU *cpu, struct arm_boot_info *info) * kernels will trash anything in the 4K page the initrd * ends in, so make sure the DTB isn't caught up in that. */ - hwaddr dtb_start = QEMU_ALIGN_UP(info->initrd_start + initrd_size, - 4096); - if (arm_load_dtb(dtb_start, info, 0) < 0) { + info->dtb_start = QEMU_ALIGN_UP(info->initrd_start + initrd_size, + 4096); + info->dtb_limit = 0; + if (arm_load_dtb(info) < 0) { exit(1); } - fixupcontext[FIXUP_ARGPTR] = dtb_start; + fixupcontext[FIXUP_ARGPTR] = info->dtb_start; } else { fixupcontext[FIXUP_ARGPTR] = info->loader_start + KERNEL_ARGS_ADDR; if (info->ram_size >= (1ULL << 32)) { diff --git a/include/hw/arm/arm.h b/include/hw/arm/arm.h index 5fdae7b..5f1ecb7 100644 --- a/include/hw/arm/arm.h +++ b/include/hw/arm/arm.h @@ -65,11 +65,12 @@ struct arm_boot_info { int is_linux; hwaddr initrd_start; hwaddr initrd_size; + hwaddr dtb_start; /* start address of the dtb */ + hwaddr dtb_limit; /* upper RAM limit the dtb cannot overshoot */ hwaddr entry; }; void arm_load_kernel(ARMCPU *cpu, struct arm_boot_info *info); -int arm_load_dtb(hwaddr addr, const struct arm_boot_info *binfo, - hwaddr addr_limit); +int arm_load_dtb(const struct arm_boot_info *binfo); /* Multiplication factor to convert from system clock ticks to qemu timer ticks. */