diff mbox

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

Message ID 1342445056-9129-4-git-send-email-peter.maydell@linaro.org
State Accepted
Commit 3871481c0a3f64f25563a5a246c188acdc01ee49
Headers show

Commit Message

Peter Maydell July 16, 2012, 1:24 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 |    6 ++++++
 1 files changed, 6 insertions(+), 0 deletions(-)

Comments

Peter Crosthwaite July 18, 2012, 12:28 p.m. UTC | #1
On Mon, Jul 16, 2012 at 11:24 PM, 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>

Reviewed-by: Peter A. G. Crosthwaite <peter.crosthwaite@petalogix.com>

> ---
>  hw/arm_boot.c |    6 ++++++
>  1 files changed, 6 insertions(+), 0 deletions(-)
>
> diff --git a/hw/arm_boot.c b/hw/arm_boot.c
> index 29ae324..af71ed6 100644
> --- a/hw/arm_boot.c
> +++ b/hw/arm_boot.c
> @@ -399,6 +399,12 @@ 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 using ATAGS (try passing a device tree"
> +                        " using -dtb)\n");
> +                exit(1);
> +            }
>          }
>          bootloader[6] = entry;
>          for (n = 0; n < sizeof(bootloader) / 4; n++) {
> --
> 1.7.5.4
>
diff mbox

Patch

diff --git a/hw/arm_boot.c b/hw/arm_boot.c
index 29ae324..af71ed6 100644
--- a/hw/arm_boot.c
+++ b/hw/arm_boot.c
@@ -399,6 +399,12 @@  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 using ATAGS (try passing a device tree"
+                        " using -dtb)\n");
+                exit(1);
+            }
         }
         bootloader[6] = entry;
         for (n = 0; n < sizeof(bootloader) / 4; n++) {