All of lore.kernel.org
 help / color / mirror / Atom feed
From: Peter Krempa <pkrempa@redhat.com>
To: qemu-devel@nongnu.org
Cc: Igor Mammedov <imammedo@redhat.com>, Peter Krempa <pkrempa@redhat.com>
Subject: [Qemu-devel] [PATCH 2/2] pc: memory: Validate alignment of maxram_size to page size
Date: Mon, 26 Jan 2015 16:31:32 +0100	[thread overview]
Message-ID: <51cf53611ea22a2c1ca0d55ad5e8ab13dcdea26f.1422285793.git.pkrempa@redhat.com> (raw)
In-Reply-To: <cover.1422285793.git.pkrempa@redhat.com>
In-Reply-To: <cover.1422285793.git.pkrempa@redhat.com>

If the maxram_size is not aligned and dimm devices were added on the
command line qemu would terminate with a rather unhelpful message:

ERROR:hw/mem/pc-dimm.c:150:pc_dimm_get_free_addr: assertion failed:
(QEMU_ALIGN_UP(address_space_size, align) == address_space_size)

In case no dimm device was originally added on the commandline qemu
exits on the assertion failure.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
---
 hw/i386/pc.c | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/hw/i386/pc.c b/hw/i386/pc.c
index e07f1fa..157eefe 100644
--- a/hw/i386/pc.c
+++ b/hw/i386/pc.c
@@ -1246,6 +1246,13 @@ FWCfgState *pc_memory_init(MachineState *machine,
             exit(EXIT_FAILURE);
         }

+        if (QEMU_ALIGN_UP(machine->maxram_size,
+                          TARGET_PAGE_SIZE) != machine->maxram_size) {
+            error_report("maximum memory size must by aligned to multiple of "
+                         "%d bytes", TARGET_PAGE_SIZE);
+            exit(EXIT_FAILURE);
+        }
+
         pcms->hotplug_memory_base =
             ROUND_UP(0x100000000ULL + above_4g_mem_size, 1ULL << 30);

-- 
2.2.1

  parent reply	other threads:[~2015-01-26 15:33 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-01-26 15:31 [Qemu-devel] [PATCH 0/2] pc: Fix startup with memory hotplug enabled Peter Krempa
2015-01-26 15:31 ` [Qemu-devel] [PATCH 1/2] vl.c: Fix error messages when parsing maxmem parameters Peter Krempa
2015-01-27 18:15   ` Eric Blake
2015-01-28  7:18     ` Peter Krempa
2015-01-26 15:31 ` Peter Krempa [this message]
2015-01-27 18:16   ` [Qemu-devel] [PATCH 2/2] pc: memory: Validate alignment of maxram_size to page size Eric Blake

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=51cf53611ea22a2c1ca0d55ad5e8ab13dcdea26f.1422285793.git.pkrempa@redhat.com \
    --to=pkrempa@redhat.com \
    --cc=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.