From patchwork Fri Oct 31 13:53:28 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Auger Eric X-Patchwork-Id: 39895 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-la0-f72.google.com (mail-la0-f72.google.com [209.85.215.72]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 8EDD3202FE for ; Fri, 31 Oct 2014 13:53:50 +0000 (UTC) Received: by mail-la0-f72.google.com with SMTP id mc6sf4150351lab.7 for ; Fri, 31 Oct 2014 06:53:49 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:delivered-to:from:to:cc:subject :date:message-id:in-reply-to:references:x-original-sender :x-original-authentication-results:precedence:mailing-list:list-id :list-post:list-help:list-archive:list-unsubscribe; bh=tGKuVq7ZFvu9uSyR73PCl5cGwrpOMwZLObsBRUL51KA=; b=VX2vZwCln12x8PhgPSOpbBfDWchd94C/FjZPlMxWyveoJKfDLcULPYPJXqT8KOl7hC F+Kc/8sM1HdP8A41GpMD6fvzO63nHjivSvo3T3qRJADQxf7paqdauYv/4VoC1B/qViZh H5Lrm3Kp5BgvQDPXPpMUxo+SnhZGCBKGICpAK1rMQNEXrHXe3NXSwQEGmCvtZM6nHEIS bdx870AYqg5KQ/53ZgmbjOi0VaWd7UD+p9eoZA5t2+gxedW1gLzIIqSeZ2H4AV1AKY6P LvQZ+aEi76suwSJ6cWW1mhLiIyTZEREOkof1KeDshJGhB/oelhravKzACjEhHF/5kc+k 7UDQ== X-Gm-Message-State: ALoCoQm0jH3DcEdV+jYa/a4tnX1+ZDpy6EuUUGIbUq2w6tihgZr20jAwPzF4K0gYuzlHcnOeRfbb X-Received: by 10.180.105.74 with SMTP id gk10mr698098wib.0.1414763629086; Fri, 31 Oct 2014 06:53:49 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.37.103 with SMTP id x7ls421890laj.37.gmail; Fri, 31 Oct 2014 06:53:48 -0700 (PDT) X-Received: by 10.112.42.198 with SMTP id q6mr26315137lbl.69.1414763628933; Fri, 31 Oct 2014 06:53:48 -0700 (PDT) Received: from mail-lb0-f171.google.com (mail-lb0-f171.google.com. [209.85.217.171]) by mx.google.com with ESMTPS id pg10si16736609lbb.127.2014.10.31.06.53.48 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 31 Oct 2014 06:53:48 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.171 as permitted sender) client-ip=209.85.217.171; Received: by mail-lb0-f171.google.com with SMTP id u10so4224436lbd.30 for ; Fri, 31 Oct 2014 06:53:48 -0700 (PDT) X-Received: by 10.152.5.38 with SMTP id p6mr26199234lap.44.1414763628844; Fri, 31 Oct 2014 06:53:48 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patches@linaro.org Received: by 10.112.84.229 with SMTP id c5csp205528lbz; Fri, 31 Oct 2014 06:53:48 -0700 (PDT) X-Received: by 10.180.90.230 with SMTP id bz6mr4047061wib.67.1414763628106; Fri, 31 Oct 2014 06:53:48 -0700 (PDT) Received: from mail-wg0-f52.google.com (mail-wg0-f52.google.com. [74.125.82.52]) by mx.google.com with ESMTPS id j1si14750856wiv.6.2014.10.31.06.53.47 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 31 Oct 2014 06:53:48 -0700 (PDT) Received-SPF: pass (google.com: domain of eric.auger@linaro.org designates 74.125.82.52 as permitted sender) client-ip=74.125.82.52; Received: by mail-wg0-f52.google.com with SMTP id b13so5982517wgh.11 for ; Fri, 31 Oct 2014 06:53:47 -0700 (PDT) X-Received: by 10.194.76.202 with SMTP id m10mr5483667wjw.42.1414763627890; Fri, 31 Oct 2014 06:53:47 -0700 (PDT) Received: from midway01-04-00.lavalab ([88.98.47.97]) by mx.google.com with ESMTPSA id w13sm12167570wjq.29.2014.10.31.06.53.46 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 31 Oct 2014 06:53:47 -0700 (PDT) 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 Cc: eric.auger@linaro.org, kvmarm@lists.cs.columbia.edu, patches@linaro.org, alex.williamson@redhat.com, peter.maydell@linaro.org, will.deacon@arm.com, Bharat.Bhushan@freescale.com, stuart.yoder@freescale.com, a.motakis@virtualopensystems.com Subject: [PATCH v4 2/6] hw/arm/boot: dtb start and limit moved in arm_boot_info Date: Fri, 31 Oct 2014 13:53:28 +0000 Message-Id: <1414763612-4939-3-git-send-email-eric.auger@linaro.org> X-Mailer: git-send-email 1.8.3.2 In-Reply-To: <1414763612-4939-1-git-send-email-eric.auger@linaro.org> References: <1414763612-4939-1-git-send-email-eric.auger@linaro.org> X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: eric.auger@linaro.org X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.171 as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Precedence: list Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org List-ID: X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , 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 f5714ea..9f0662e 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. */