From: "Alex Bennée" <alex.bennee@linaro.org>
To: qemu-arm@nongnu.org
Cc: qemu-devel@nongnu.org, Mark Rutland <mark.rutland@arm.com>,
Richard Henderson <richard.henderson@linaro.org>
Subject: Re: [Qemu-arm] [PATCH v2 3/4] hw/arm/boot: Avoid placing the initrd on top of the kernel
Date: Thu, 13 Jun 2019 13:53:36 +0100 [thread overview]
Message-ID: <87h88teje7.fsf@zen.linaroharston> (raw)
In-Reply-To: <20190516144733.32399-4-peter.maydell@linaro.org>
Peter Maydell <peter.maydell@linaro.org> writes:
> We currently put the initrd at the smaller of:
> * 128MB into RAM
> * halfway into the RAM
> (with the dtb following it).
>
> However for large kernels this might mean that the kernel
> overlaps the initrd. For some kinds of kernel (self-decompressing
> 32-bit kernels, and ELF images with a BSS section at the end)
> we don't know the exact size, but even there we have a
> minimum size. Put the initrd at least further into RAM than
> that. For image formats that can give us an exact kernel size, this
> will mean that we definitely avoid overlaying kernel and initrd.
>
> Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
> ---
> hw/arm/boot.c | 34 ++++++++++++++++++++--------------
> 1 file changed, 20 insertions(+), 14 deletions(-)
>
> diff --git a/hw/arm/boot.c b/hw/arm/boot.c
> index 935be3b92a5..e441393fdf5 100644
> --- a/hw/arm/boot.c
> +++ b/hw/arm/boot.c
> @@ -999,20 +999,6 @@ static void arm_setup_direct_kernel_boot(ARMCPU *cpu,
> if (info->nb_cpus == 0)
> info->nb_cpus = 1;
>
> - /*
> - * We want to put the initrd far enough into RAM that when the
> - * kernel is uncompressed it will not clobber the initrd. However
> - * on boards without much RAM we must ensure that we still leave
> - * enough room for a decent sized initrd, and on boards with large
> - * amounts of RAM we must avoid the initrd being so far up in RAM
> - * that it is outside lowmem and inaccessible to the kernel.
> - * So for boards with less than 256MB of RAM we put the initrd
> - * halfway into RAM, and for boards with 256MB of RAM or more we put
> - * the initrd at 128MB.
> - */
> - info->initrd_start = info->loader_start +
> - MIN(info->ram_size / 2, 128 * 1024 * 1024);
> -
> /* Assume that raw images are linux kernels, and ELF images are not. */
> kernel_size = arm_load_elf(info, &elf_entry, &elf_low_addr,
> &elf_high_addr, elf_machine, as);
> @@ -1064,6 +1050,26 @@ static void arm_setup_direct_kernel_boot(ARMCPU *cpu,
> }
>
> info->entry = entry;
> +
> + /*
> + * We want to put the initrd far enough into RAM that when the
> + * kernel is uncompressed it will not clobber the initrd. However
> + * on boards without much RAM we must ensure that we still leave
> + * enough room for a decent sized initrd, and on boards with large
> + * amounts of RAM we must avoid the initrd being so far up in RAM
> + * that it is outside lowmem and inaccessible to the kernel.
> + * So for boards with less than 256MB of RAM we put the initrd
> + * halfway into RAM, and for boards with 256MB of RAM or more we put
> + * the initrd at 128MB.
> + * We also refuse to put the initrd somewhere that will definitely
> + * overlay the kernel we just loaded, though for kernel formats which
> + * don't tell us their exact size (eg self-decompressing 32-bit kernels)
> + * we might still make a bad choice here.
> + */
> + info->initrd_start = info->loader_start +
> + MAX(MIN(info->ram_size / 2, 128 * 1024 * 1024), kernel_size);
> + info->initrd_start = TARGET_PAGE_ALIGN(info->initrd_start);
> +
> if (is_linux) {
> uint32_t fixupcontext[FIXUP_MAX];
--
Alex Bennée
WARNING: multiple messages have this Message-ID (diff)
From: "Alex Bennée" <alex.bennee@linaro.org>
To: qemu-arm@nongnu.org
Cc: Mark Rutland <mark.rutland@arm.com>,
Richard Henderson <richard.henderson@linaro.org>,
qemu-devel@nongnu.org
Subject: Re: [Qemu-devel] [Qemu-arm] [PATCH v2 3/4] hw/arm/boot: Avoid placing the initrd on top of the kernel
Date: Thu, 13 Jun 2019 13:53:36 +0100 [thread overview]
Message-ID: <87h88teje7.fsf@zen.linaroharston> (raw)
In-Reply-To: <20190516144733.32399-4-peter.maydell@linaro.org>
Peter Maydell <peter.maydell@linaro.org> writes:
> We currently put the initrd at the smaller of:
> * 128MB into RAM
> * halfway into the RAM
> (with the dtb following it).
>
> However for large kernels this might mean that the kernel
> overlaps the initrd. For some kinds of kernel (self-decompressing
> 32-bit kernels, and ELF images with a BSS section at the end)
> we don't know the exact size, but even there we have a
> minimum size. Put the initrd at least further into RAM than
> that. For image formats that can give us an exact kernel size, this
> will mean that we definitely avoid overlaying kernel and initrd.
>
> Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
> ---
> hw/arm/boot.c | 34 ++++++++++++++++++++--------------
> 1 file changed, 20 insertions(+), 14 deletions(-)
>
> diff --git a/hw/arm/boot.c b/hw/arm/boot.c
> index 935be3b92a5..e441393fdf5 100644
> --- a/hw/arm/boot.c
> +++ b/hw/arm/boot.c
> @@ -999,20 +999,6 @@ static void arm_setup_direct_kernel_boot(ARMCPU *cpu,
> if (info->nb_cpus == 0)
> info->nb_cpus = 1;
>
> - /*
> - * We want to put the initrd far enough into RAM that when the
> - * kernel is uncompressed it will not clobber the initrd. However
> - * on boards without much RAM we must ensure that we still leave
> - * enough room for a decent sized initrd, and on boards with large
> - * amounts of RAM we must avoid the initrd being so far up in RAM
> - * that it is outside lowmem and inaccessible to the kernel.
> - * So for boards with less than 256MB of RAM we put the initrd
> - * halfway into RAM, and for boards with 256MB of RAM or more we put
> - * the initrd at 128MB.
> - */
> - info->initrd_start = info->loader_start +
> - MIN(info->ram_size / 2, 128 * 1024 * 1024);
> -
> /* Assume that raw images are linux kernels, and ELF images are not. */
> kernel_size = arm_load_elf(info, &elf_entry, &elf_low_addr,
> &elf_high_addr, elf_machine, as);
> @@ -1064,6 +1050,26 @@ static void arm_setup_direct_kernel_boot(ARMCPU *cpu,
> }
>
> info->entry = entry;
> +
> + /*
> + * We want to put the initrd far enough into RAM that when the
> + * kernel is uncompressed it will not clobber the initrd. However
> + * on boards without much RAM we must ensure that we still leave
> + * enough room for a decent sized initrd, and on boards with large
> + * amounts of RAM we must avoid the initrd being so far up in RAM
> + * that it is outside lowmem and inaccessible to the kernel.
> + * So for boards with less than 256MB of RAM we put the initrd
> + * halfway into RAM, and for boards with 256MB of RAM or more we put
> + * the initrd at 128MB.
> + * We also refuse to put the initrd somewhere that will definitely
> + * overlay the kernel we just loaded, though for kernel formats which
> + * don't tell us their exact size (eg self-decompressing 32-bit kernels)
> + * we might still make a bad choice here.
> + */
> + info->initrd_start = info->loader_start +
> + MAX(MIN(info->ram_size / 2, 128 * 1024 * 1024), kernel_size);
> + info->initrd_start = TARGET_PAGE_ALIGN(info->initrd_start);
> +
> if (is_linux) {
> uint32_t fixupcontext[FIXUP_MAX];
--
Alex Bennée
next prev parent reply other threads:[~2019-06-13 12:53 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
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 ` Alex Bennée [this message]
2019-06-13 12:53 ` [Qemu-devel] [Qemu-arm] " 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=87h88teje7.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.