All of lore.kernel.org
 help / color / mirror / Atom feed
From: Igor Mammedov <imammedo@redhat.com>
To: qemu-devel@nongnu.org
Subject: [PATCH v4 57/80] ppc/e500: drop RAM size fixup
Date: Fri, 31 Jan 2020 16:09:27 +0100	[thread overview]
Message-ID: <1580483390-131164-58-git-send-email-imammedo@redhat.com> (raw)
In-Reply-To: <1580483390-131164-1-git-send-email-imammedo@redhat.com>

If user provided non-sense RAM size, board will complain and
continue running with max RAM size supported.
Also RAM is going to be allocated by generic code, so it won't be
possible for board to fix things up for user.

Make it error message and exit to force user fix CLI,
instead of accepting non-sense CLI values.

While at it, replace usage of global ram_size with
machine->ram_size

Signed-off-by: Igor Mammedov <imammedo@redhat.com>
Acked-by: David Gibson <david@gibson.dropbear.id.au>
---
v2:
 * fix format string cousing build failure on 32-bit host
   (Philippe Mathieu-Daudé <philmd@redhat.com>)
---
 hw/ppc/e500.c | 16 +++++++++-------
 1 file changed, 9 insertions(+), 7 deletions(-)

diff --git a/hw/ppc/e500.c b/hw/ppc/e500.c
index 886442e..960024b 100644
--- a/hw/ppc/e500.c
+++ b/hw/ppc/e500.c
@@ -906,12 +906,14 @@ void ppce500_init(MachineState *machine)
 
     env = firstenv;
 
-    /* Fixup Memory size on a alignment boundary */
-    ram_size &= ~(RAM_SIZES_ALIGN - 1);
-    machine->ram_size = ram_size;
+    if (!QEMU_IS_ALIGNED(machine->ram_size, RAM_SIZES_ALIGN)) {
+        error_report("RAM size must be multiple of %" PRIu64, RAM_SIZES_ALIGN);
+        exit(EXIT_FAILURE);
+    }
 
     /* Register Memory */
-    memory_region_allocate_system_memory(ram, NULL, "mpc8544ds.ram", ram_size);
+    memory_region_allocate_system_memory(ram, NULL, "mpc8544ds.ram",
+                                         machine->ram_size);
     memory_region_add_subregion(address_space_mem, 0, ram);
 
     dev = qdev_create(NULL, "e500-ccsr");
@@ -1083,7 +1085,7 @@ void ppce500_init(MachineState *machine)
         kernel_base = cur_base;
         kernel_size = load_image_targphys(machine->kernel_filename,
                                           cur_base,
-                                          ram_size - cur_base);
+                                          machine->ram_size - cur_base);
         if (kernel_size < 0) {
             error_report("could not load kernel '%s'",
                          machine->kernel_filename);
@@ -1097,7 +1099,7 @@ void ppce500_init(MachineState *machine)
     if (machine->initrd_filename) {
         initrd_base = (cur_base + INITRD_LOAD_PAD) & ~INITRD_PAD_MASK;
         initrd_size = load_image_targphys(machine->initrd_filename, initrd_base,
-                                          ram_size - initrd_base);
+                                          machine->ram_size - initrd_base);
 
         if (initrd_size < 0) {
             error_report("could not load initial ram disk '%s'",
@@ -1115,7 +1117,7 @@ void ppce500_init(MachineState *machine)
      * ensures enough space between kernel and initrd.
      */
     dt_base = (loadaddr + payload_size + DTC_LOAD_PAD) & ~DTC_PAD_MASK;
-    if (dt_base + DTB_MAX_SIZE > ram_size) {
+    if (dt_base + DTB_MAX_SIZE > machine->ram_size) {
             error_report("not enough memory for device tree");
             exit(1);
     }
-- 
2.7.4



  parent reply	other threads:[~2020-01-31 16:05 UTC|newest]

Thread overview: 102+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-01-31 15:08 [PATCH v4 00/80] refactor main RAM allocation to use hostmem backend Igor Mammedov
2020-01-31 15:08 ` [PATCH v4 01/80] numa: remove deprecated -mem-path fallback to anonymous RAM Igor Mammedov
2020-01-31 15:08 ` [PATCH v4 02/80] machine: introduce memory-backend property Igor Mammedov
2020-01-31 15:08 ` [PATCH v4 03/80] machine: alias -mem-path and -mem-prealloc into memory-foo backend Igor Mammedov
2020-02-03  9:04   ` Michael S. Tsirkin
2020-02-03  9:27     ` Igor Mammedov
2020-02-03  9:42       ` Michael S. Tsirkin
2020-02-03 10:40         ` Igor Mammedov
2020-01-31 15:08 ` [PATCH v4 04/80] machine: introduce convenience MachineState::ram Igor Mammedov
2020-01-31 15:08 ` [PATCH v4 05/80] initialize MachineState::ram in NUMA case Igor Mammedov
2020-01-31 15:08 ` [PATCH v4 06/80] vl.c: move -m parsing after memory backends has been processed Igor Mammedov
2020-01-31 15:08 ` [PATCH v4 07/80] vl.c: ensure that ram_size matches size of machine.memory-backend Igor Mammedov
2020-01-31 15:08 ` [PATCH v4 08/80] alpha/dp264: use memdev for RAM Igor Mammedov
2020-01-31 15:08 ` [PATCH v4 09/80] arm/aspeed: actually check RAM size Igor Mammedov
2020-01-31 15:08 ` [PATCH v4 10/80] arm/aspeed: use memdev for RAM Igor Mammedov
2020-01-31 15:08 ` [PATCH v4 11/80] arm/collie: " Igor Mammedov
2020-01-31 15:08 ` [PATCH v4 12/80] arm/cubieboard: " Igor Mammedov
2020-01-31 15:08 ` [PATCH v4 13/80] arm/digic_boards: " Igor Mammedov
2020-01-31 15:08 ` [PATCH v4 14/80] arm/highbank: " Igor Mammedov
2020-01-31 15:08 ` [PATCH v4 15/80] arm/imx25_pdk: drop RAM size fixup Igor Mammedov
2020-01-31 15:08 ` [PATCH v4 16/80] arm/imx25_pdk: use memdev for RAM Igor Mammedov
2020-01-31 15:08 ` [PATCH v4 17/80] arm/integratorcp: " Igor Mammedov
2020-01-31 15:08 ` [PATCH v4 18/80] arm/kzm: drop RAM size fixup Igor Mammedov
2020-01-31 15:08 ` [PATCH v4 19/80] arm/kzm: use memdev for RAM Igor Mammedov
2020-01-31 15:08 ` [PATCH v4 20/80] arm/mcimx6ul-evk: " Igor Mammedov
2020-01-31 15:08 ` [PATCH v4 21/80] arm/mcimx7d-sabre: " Igor Mammedov
2020-01-31 15:08 ` [PATCH v4 22/80] arm/mps2-tz: " Igor Mammedov
2020-01-31 15:08 ` [PATCH v4 23/80] arm/mps2: " Igor Mammedov
2020-01-31 15:08 ` [PATCH v4 24/80] arm/musicpal: " Igor Mammedov
2020-01-31 15:08 ` [PATCH v4 25/80] arm/nseries: " Igor Mammedov
2020-01-31 15:08 ` [PATCH v4 26/80] arm/omap_sx1: " Igor Mammedov
2020-01-31 15:08 ` [PATCH v4 27/80] arm/palm: " Igor Mammedov
2020-01-31 15:08 ` [PATCH v4 28/80] arm/raspi: " Igor Mammedov
2020-01-31 15:08 ` [PATCH v4 29/80] arm/sabrelite: " Igor Mammedov
2020-01-31 15:09 ` [PATCH v4 30/80] arm/sbsa-ref: " Igor Mammedov
2020-01-31 15:09 ` [PATCH v4 31/80] arm/versatilepb: " Igor Mammedov
2020-01-31 15:09 ` [PATCH v4 32/80] arm/vexpress: " Igor Mammedov
2020-01-31 15:09 ` [PATCH v4 33/80] arm/virt: " Igor Mammedov
2020-01-31 15:09 ` [PATCH v4 34/80] arm/xilinx_zynq: drop RAM size fixup Igor Mammedov
2020-01-31 15:09 ` [PATCH v4 35/80] arm/xilinx_zynq: use memdev for RAM Igor Mammedov
2020-01-31 15:09 ` [PATCH v4 36/80] arm/xlnx-versal-virt: " Igor Mammedov
2020-01-31 15:09 ` [PATCH v4 37/80] arm/xlnx-zcu102: " Igor Mammedov
2020-01-31 15:09 ` [PATCH v4 38/80] s390x/s390-virtio-ccw: " Igor Mammedov
2020-02-05 20:11   ` Halil Pasic
2020-02-06 13:15     ` Igor Mammedov
2020-02-10 19:33       ` Halil Pasic
2020-01-31 15:09 ` [PATCH v4 39/80] null-machine: " Igor Mammedov
2020-01-31 15:09 ` [PATCH v4 40/80] cris/axis_dev88: " Igor Mammedov
2020-01-31 15:09 ` [PATCH v4 41/80] hppa: " Igor Mammedov
2020-01-31 15:09 ` [PATCH v4 42/80] x86/microvm: " Igor Mammedov
2020-02-03  8:58   ` Michael S. Tsirkin
2020-01-31 15:09 ` [PATCH v4 43/80] x86/pc: " Igor Mammedov
2020-02-03  9:07   ` Michael S. Tsirkin
2020-02-03  9:45     ` Igor Mammedov
2020-01-31 15:09 ` [PATCH v4 44/80] lm32/lm32_boards: " Igor Mammedov
2020-01-31 15:09 ` [PATCH v4 45/80] lm32/milkymist: " Igor Mammedov
2020-01-31 15:09 ` [PATCH v4 46/80] m68k/an5206: " Igor Mammedov
2020-01-31 15:09 ` [PATCH v4 47/80] m68k/q800: " Igor Mammedov
2020-01-31 15:09 ` [PATCH v4 48/80] m68k/mcf5208: " Igor Mammedov
2020-01-31 15:09 ` [PATCH v4 49/80] m68k/next-cube: " Igor Mammedov
2020-01-31 15:09 ` [PATCH v4 50/80] mips/boston: " Igor Mammedov
2020-01-31 15:09 ` [PATCH v4 51/80] mips/mips_fulong2e: drop RAM size fixup Igor Mammedov
2020-01-31 15:09 ` [PATCH v4 52/80] mips/mips_fulong2e: use memdev for RAM Igor Mammedov
2020-01-31 15:09 ` [PATCH v4 53/80] mips/mips_jazz: " Igor Mammedov
2020-02-09 16:41   ` Philippe Mathieu-Daudé
2020-02-10 15:06     ` [PATCH v5 81/80] mips/mips_jazz: add max ram size check Igor Mammedov
2020-02-10 17:04       ` Philippe Mathieu-Daudé
2020-01-31 15:09 ` [PATCH v4 54/80] mips/mips_malta: use memdev for RAM Igor Mammedov
2020-01-31 15:09 ` [PATCH v4 55/80] mips/mips_mipssim: " Igor Mammedov
2020-01-31 15:09 ` [PATCH v4 56/80] mips/mips_r4k: " Igor Mammedov
2020-01-31 15:09 ` Igor Mammedov [this message]
2020-01-31 15:09 ` [PATCH v4 58/80] ppc/e500: " Igor Mammedov
2020-01-31 15:09 ` [PATCH v4 59/80] ppc/mac_newworld: " Igor Mammedov
2020-01-31 15:09 ` [PATCH v4 60/80] ppc/mac_oldworld: " Igor Mammedov
2020-01-31 15:09 ` [PATCH v4 61/80] ppc/pnv: " Igor Mammedov
2020-01-31 15:09 ` [PATCH v4 62/80] ppc/ppc405_boards: add RAM size checks Igor Mammedov
2020-01-31 15:09 ` [PATCH v4 63/80] ppc/ppc405_boards: use memdev for RAM Igor Mammedov
2020-01-31 15:09 ` [PATCH v4 64/80] ppc/{ppc440_bamboo, sam460ex}: drop RAM size fixup Igor Mammedov
2020-01-31 15:09 ` [PATCH v4 65/80] ppc/{ppc440_bamboo, sam460ex}: use memdev for RAM Igor Mammedov
2020-01-31 15:09 ` [PATCH v4 66/80] ppc/prep: " Igor Mammedov
2020-01-31 15:09 ` [PATCH v4 67/80] ppc/spapr: " Igor Mammedov
2020-01-31 15:09 ` [PATCH v4 68/80] ppc/virtex_ml507: remove unused arguments Igor Mammedov
2020-01-31 15:09 ` [PATCH v4 69/80] ppc/virtex_ml507: use memdev for RAM Igor Mammedov
2020-01-31 15:09 ` [PATCH v4 70/80] sparc/leon3: " Igor Mammedov
2020-01-31 15:09 ` [PATCH v4 71/80] sparc/sun4m: " Igor Mammedov
2020-01-31 15:09 ` [PATCH v4 72/80] sparc/niagara: " Igor Mammedov
2020-01-31 15:09 ` [PATCH v4 73/80] remove no longer used memory_region_allocate_system_memory() Igor Mammedov
2020-01-31 15:09 ` [PATCH v4 74/80] exec: cleanup qemu_minrampagesize()/qemu_maxrampagesize() Igor Mammedov
2020-01-31 15:09 ` [PATCH v4 75/80] exec: drop bogus mem_path from qemu_ram_alloc_from_fd() Igor Mammedov
2020-02-07 14:42   ` Marc-André Lureau
2020-01-31 15:09 ` [PATCH v4 76/80] make mem_path local variable Igor Mammedov
2020-01-31 15:09 ` [PATCH v4 77/80] hostmem: introduce "prealloc-threads" property Igor Mammedov
2020-01-31 15:09 ` [PATCH v4 78/80] hostmem: fix strict bind policy Igor Mammedov
2020-01-31 15:09 ` [PATCH v4 79/80] tests/numa-test: make top level args dynamic and g_autofree(cli) cleanups Igor Mammedov
2020-01-31 15:09 ` [PATCH v4 80/80] tests:numa-test: use explicit memdev to specify node RAM Igor Mammedov
2020-01-31 16:16 ` [PATCH v4 00/80] refactor main RAM allocation to use hostmem backend no-reply
2020-01-31 16:28 ` no-reply
2020-02-03  9:49   ` Igor Mammedov
2020-02-04 15:08 ` Igor Mammedov
2020-02-04 15:39   ` Igor Mammedov
2020-02-04 22:05     ` Paolo Bonzini
2020-02-05 13:20       ` Philippe Mathieu-Daudé

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=1580483390-131164-58-git-send-email-imammedo@redhat.com \
    --to=imammedo@redhat.com \
    --cc=qemu-devel@nongnu.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.