From: "Alex Bennée" <alex.bennee@linaro.org>
To: qemu-devel@nongnu.org
Cc: qemu-arm@nongnu.org, Mark Rutland <mark.rutland@arm.com>,
Richard Henderson <richard.henderson@linaro.org>
Subject: Re: [Qemu-devel] [PATCH v2 1/4] hw/arm/boot: Don't assume RAM starts at address zero
Date: Thu, 13 Jun 2019 13:44:21 +0100 [thread overview]
Message-ID: <87k1dpejtm.fsf@zen.linaroharston> (raw)
In-Reply-To: <20190516144733.32399-2-peter.maydell@linaro.org>
Peter Maydell <peter.maydell@linaro.org> writes:
> In the Arm kernel/initrd loading code, in some places we make the
> incorrect assumption that info->ram_size can be treated as the
> address of the end of RAM, as for instance when we calculate the
> available space for the initrd using "info->ram_size - info->initrd_start".
> This is wrong, because many Arm boards (including "virt") specify
> a non-zero info->loader_start to indicate that their RAM area
> starts at a non-zero physical address.
>
> Correct the places which make this incorrect assumption.
>
> Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
> ---
> hw/arm/boot.c | 9 ++++-----
> 1 file changed, 4 insertions(+), 5 deletions(-)
>
> diff --git a/hw/arm/boot.c b/hw/arm/boot.c
> index a830655e1af..0bb9a7d5b5c 100644
> --- a/hw/arm/boot.c
> +++ b/hw/arm/boot.c
> @@ -976,6 +976,7 @@ static void arm_setup_direct_kernel_boot(ARMCPU *cpu,
> int elf_machine;
> hwaddr entry;
> static const ARMInsnFixup *primary_loader;
> + uint64_t ram_end = info->loader_start + info->ram_size;
>
> if (arm_feature(&cpu->env, ARM_FEATURE_AARCH64)) {
> primary_loader = bootloader_aarch64;
> @@ -1047,8 +1048,7 @@ static void arm_setup_direct_kernel_boot(ARMCPU *cpu,
> /* 32-bit ARM */
> entry = info->loader_start + KERNEL_LOAD_ADDR;
> kernel_size = load_image_targphys_as(info->kernel_filename, entry,
> - info->ram_size - KERNEL_LOAD_ADDR,
> - as);
> + ram_end - KERNEL_LOAD_ADDR, as);
> is_linux = 1;
> }
> if (kernel_size < 0) {
> @@ -1062,12 +1062,11 @@ static void arm_setup_direct_kernel_boot(ARMCPU *cpu,
> if (info->initrd_filename) {
> initrd_size = load_ramdisk_as(info->initrd_filename,
> info->initrd_start,
> - info->ram_size - info->initrd_start,
> - as);
> + ram_end - info->initrd_start, as);
> if (initrd_size < 0) {
> initrd_size = load_image_targphys_as(info->initrd_filename,
> info->initrd_start,
> - info->ram_size -
> + ram_end -
> info->initrd_start,
> as);
> }
--
Alex Bennée
WARNING: multiple messages have this Message-ID (diff)
From: "Alex Bennée" <alex.bennee@linaro.org>
To: qemu-devel@nongnu.org
Cc: Mark Rutland <mark.rutland@arm.com>,
qemu-arm@nongnu.org,
Richard Henderson <richard.henderson@linaro.org>
Subject: Re: [Qemu-devel] [PATCH v2 1/4] hw/arm/boot: Don't assume RAM starts at address zero
Date: Thu, 13 Jun 2019 13:44:21 +0100 [thread overview]
Message-ID: <87k1dpejtm.fsf@zen.linaroharston> (raw)
In-Reply-To: <20190516144733.32399-2-peter.maydell@linaro.org>
Peter Maydell <peter.maydell@linaro.org> writes:
> In the Arm kernel/initrd loading code, in some places we make the
> incorrect assumption that info->ram_size can be treated as the
> address of the end of RAM, as for instance when we calculate the
> available space for the initrd using "info->ram_size - info->initrd_start".
> This is wrong, because many Arm boards (including "virt") specify
> a non-zero info->loader_start to indicate that their RAM area
> starts at a non-zero physical address.
>
> Correct the places which make this incorrect assumption.
>
> Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
> ---
> hw/arm/boot.c | 9 ++++-----
> 1 file changed, 4 insertions(+), 5 deletions(-)
>
> diff --git a/hw/arm/boot.c b/hw/arm/boot.c
> index a830655e1af..0bb9a7d5b5c 100644
> --- a/hw/arm/boot.c
> +++ b/hw/arm/boot.c
> @@ -976,6 +976,7 @@ static void arm_setup_direct_kernel_boot(ARMCPU *cpu,
> int elf_machine;
> hwaddr entry;
> static const ARMInsnFixup *primary_loader;
> + uint64_t ram_end = info->loader_start + info->ram_size;
>
> if (arm_feature(&cpu->env, ARM_FEATURE_AARCH64)) {
> primary_loader = bootloader_aarch64;
> @@ -1047,8 +1048,7 @@ static void arm_setup_direct_kernel_boot(ARMCPU *cpu,
> /* 32-bit ARM */
> entry = info->loader_start + KERNEL_LOAD_ADDR;
> kernel_size = load_image_targphys_as(info->kernel_filename, entry,
> - info->ram_size - KERNEL_LOAD_ADDR,
> - as);
> + ram_end - KERNEL_LOAD_ADDR, as);
> is_linux = 1;
> }
> if (kernel_size < 0) {
> @@ -1062,12 +1062,11 @@ static void arm_setup_direct_kernel_boot(ARMCPU *cpu,
> if (info->initrd_filename) {
> initrd_size = load_ramdisk_as(info->initrd_filename,
> info->initrd_start,
> - info->ram_size - info->initrd_start,
> - as);
> + ram_end - info->initrd_start, as);
> if (initrd_size < 0) {
> initrd_size = load_image_targphys_as(info->initrd_filename,
> info->initrd_start,
> - info->ram_size -
> + ram_end -
> info->initrd_start,
> as);
> }
--
Alex Bennée
next prev parent reply other threads:[~2019-06-13 12:44 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-05-16 14:47 [Qemu-arm] [PATCH v2 0/4] hw/arm/boot: handle large Images more gracefully Peter Maydell
2019-05-16 14:47 ` [Qemu-devel] " Peter Maydell
2019-05-16 14:47 ` [Qemu-devel] [PATCH v2 1/4] hw/arm/boot: Don't assume RAM starts at address zero Peter Maydell
2019-06-13 12:44 ` Alex Bennée [this message]
2019-06-13 12:44 ` Alex Bennée
2019-05-16 14:47 ` [Qemu-devel] [PATCH v2 2/4] hw/arm/boot: Diagnose layouts that put initrd or DTB off the end of RAM Peter Maydell
2019-06-13 12:47 ` Alex Bennée
2019-06-13 12:47 ` Alex Bennée
2019-05-16 14:47 ` [Qemu-arm] [PATCH v2 3/4] hw/arm/boot: Avoid placing the initrd on top of the kernel Peter Maydell
2019-05-16 14:47 ` [Qemu-devel] " Peter Maydell
2019-06-13 12:53 ` [Qemu-arm] " Alex Bennée
2019-06-13 12:53 ` [Qemu-devel] " Alex Bennée
2019-07-19 16:47 ` Mark Rutland
2019-07-19 16:47 ` [Qemu-devel] " Mark Rutland
2019-07-22 11:59 ` [Qemu-arm] " Peter Maydell
2019-07-22 11:59 ` [Qemu-devel] " Peter Maydell
2019-07-22 12:56 ` [Qemu-arm] " Mark Rutland
2019-07-22 12:56 ` [Qemu-devel] " Mark Rutland
2019-05-16 14:47 ` [Qemu-devel] [PATCH v2 4/4] hw/arm/boot: Honour image size field in AArch64 Image format kernels Peter Maydell
2019-06-13 12:55 ` Alex Bennée
2019-06-13 12:55 ` Alex Bennée
2019-06-07 13:07 ` [Qemu-devel] [PATCH v2 0/4] hw/arm/boot: handle large Images more gracefully Peter Maydell
2019-06-07 14:12 ` [Qemu-arm] " Philippe Mathieu-Daudé
2019-06-07 14:12 ` Philippe Mathieu-Daudé
2019-06-07 14:07 ` Mark Rutland
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=87k1dpejtm.fsf@zen.linaroharston \
--to=alex.bennee@linaro.org \
--cc=mark.rutland@arm.com \
--cc=qemu-arm@nongnu.org \
--cc=qemu-devel@nongnu.org \
--cc=richard.henderson@linaro.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.