diff mbox

[3/6] hw/arm_boot.c: Check for RAM sizes exceeding ATAGS capacity

Message ID 1341507652-22155-4-git-send-email-peter.maydell@linaro.org
State New
Headers show

Commit Message

Peter Maydell July 5, 2012, 5 p.m. UTC
The legacy ATAGS format for passing information to the kernel only
allows RAM sizes which fit in 32 bits; enforce this restriction
rather than silently doing something weird.

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
---
 hw/arm_boot.c |    5 +++++
 1 files changed, 5 insertions(+), 0 deletions(-)

Comments

Peter A. G. Crosthwaite July 6, 2012, 2:05 a.m. UTC | #1
On Fri, Jul 6, 2012 at 3:00 AM, Peter Maydell <peter.maydell@linaro.org> wrote:
> The legacy ATAGS format for passing information to the kernel only
> allows RAM sizes which fit in 32 bits; enforce this restriction
> rather than silently doing something weird.
>
> Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
> ---
>  hw/arm_boot.c |    5 +++++
>  1 files changed, 5 insertions(+), 0 deletions(-)
>
> diff --git a/hw/arm_boot.c b/hw/arm_boot.c
> index 29ae324..7366427 100644
> --- a/hw/arm_boot.c
> +++ b/hw/arm_boot.c
> @@ -399,6 +399,11 @@ void arm_load_kernel(ARMCPU *cpu, struct arm_boot_info *info)
>              bootloader[5] = dtb_start;
>          } else {
>              bootloader[5] = info->loader_start + KERNEL_ARGS_ADDR;
> +            if (info->ram_size >= (1ULL << 32)) {
> +                fprintf(stderr, "qemu: RAM size must be less than 4GB to boot"
> +                        " Linux kernel without device tree\n");

Error message is a bit weird. Shouldnt it be "RAM size must be less
than 4GB to boot Linux kernel with ATAG command line". DTB shouldnt be
the only way to boot with >4GB.

Regards,
Peter

> +                exit(1);
> +            }
>          }
>          bootloader[6] = entry;
>          for (n = 0; n < sizeof(bootloader) / 4; n++) {
> --
> 1.7.1
>
Peter Maydell July 6, 2012, 7:25 a.m. UTC | #2
On 6 July 2012 03:05, Peter Crosthwaite <peter.crosthwaite@petalogix.com> wrote:
> On Fri, Jul 6, 2012 at 3:00 AM, Peter Maydell <peter.maydell@linaro.org> wrote:
>> +            if (info->ram_size >= (1ULL << 32)) {
>> +                fprintf(stderr, "qemu: RAM size must be less than 4GB to boot"
>> +                        " Linux kernel without device tree\n");
>
> Error message is a bit weird. Shouldnt it be "RAM size must be less
> than 4GB to boot Linux kernel with ATAG command line". DTB shouldnt be
> the only way to boot with >4GB.

I'm trying to steer the user toward the way to solve their problem,
which is to use a device tree. I expect less than 1 QEMU user in 100
has any idea what ATAGS are.

> DTB shouldnt be the only way to boot with >4GB.

I'm not sure what you mean here -- we have two boot methods and
only DTB handles large RAM sizes. Or do you mean machines with eg
flash where you could boot by putting a bootloader in flash?

-- PMM
diff mbox

Patch

diff --git a/hw/arm_boot.c b/hw/arm_boot.c
index 29ae324..7366427 100644
--- a/hw/arm_boot.c
+++ b/hw/arm_boot.c
@@ -399,6 +399,11 @@  void arm_load_kernel(ARMCPU *cpu, struct arm_boot_info *info)
             bootloader[5] = dtb_start;
         } else {
             bootloader[5] = info->loader_start + KERNEL_ARGS_ADDR;
+            if (info->ram_size >= (1ULL << 32)) {
+                fprintf(stderr, "qemu: RAM size must be less than 4GB to boot"
+                        " Linux kernel without device tree\n");
+                exit(1);
+            }
         }
         bootloader[6] = entry;
         for (n = 0; n < sizeof(bootloader) / 4; n++) {