From: "Philippe Mathieu-Daudé" <f4bug@amsat.org>
To: Paolo Bonzini <pbonzini@redhat.com>,
Alexey Kardashevskiy <aik@ozlabs.ru>,
KONRAD Frederic <frederic.konrad@adacore.com>
Cc: "Philippe Mathieu-Daudé" <f4bug@amsat.org>, qemu-devel@nongnu.org
Subject: [Qemu-devel] [PATCH v2 1/4] memory: Avoid to create tiny RAM regions, handled as subpages
Date: Wed, 4 Apr 2018 22:22:38 -0300 [thread overview]
Message-ID: <20180405012241.25714-2-f4bug@amsat.org> (raw)
In-Reply-To: <20180405012241.25714-1-f4bug@amsat.org>
If an user creates a RAM region smaller than TARGET_PAGE_SIZE,
this region will be handled as a subpage.
While the subpage behavior can be noticed by an experienced QEMU
developper, it might takes hours to a novice to figure it out.
To save time to novices, do not allow subpage creation via the
memory_region_init_ram_*() functions.
Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
---
memory.c | 9 +++++++++
1 file changed, 9 insertions(+)
diff --git a/memory.c b/memory.c
index e70b64b8b9..51d27b7b26 100644
--- a/memory.c
+++ b/memory.c
@@ -1519,6 +1519,15 @@ void memory_region_init_ram_shared_nomigrate(MemoryRegion *mr,
bool share,
Error **errp)
{
+ if (size < TARGET_PAGE_SIZE) {
+ /* Region less than PAGE_SIZE are handled as subpages, which are
+ * surely not what the caller expects.
+ * Limit the minimum ram region size to avoid annoying debugging.
+ */
+ error_setg(errp, "Invalid RAM size: %ld (minimum required: %d)",
+ size, TARGET_PAGE_SIZE);
+ return;
+ }
memory_region_init(mr, owner, name, size);
mr->ram = true;
mr->terminates = true;
--
2.16.3
next prev parent reply other threads:[~2018-04-05 1:23 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-04-05 1:22 [Qemu-devel] [RFC PATCH v2 0/4] memory: fix access_with_adjusted_size() and misc Philippe Mathieu-Daudé
2018-04-05 1:22 ` Philippe Mathieu-Daudé [this message]
2018-04-05 9:27 ` [Qemu-devel] [PATCH v2 1/4] memory: Avoid to create tiny RAM regions, handled as subpages Peter Maydell
2018-04-05 12:53 ` Philippe Mathieu-Daudé
2018-04-05 13:20 ` Peter Maydell
2018-04-05 13:31 ` Philippe Mathieu-Daudé
2018-04-05 13:34 ` KONRAD Frederic
2018-04-05 13:42 ` Peter Maydell
2018-04-05 1:22 ` [Qemu-devel] [NOTFORMERGE PATCH v2 2/4] memory: Fix access_with_adjusted_size() when size < access_size_min Philippe Mathieu-Daudé
2018-04-08 19:21 ` Philippe Mathieu-Daudé
2018-04-05 1:22 ` [Qemu-devel] [PATCH v2 3/4] memory: Fix memory_region 'priority' property sign Philippe Mathieu-Daudé
2021-03-27 13:57 ` Philippe Mathieu-Daudé
2021-03-27 14:30 ` Philippe Mathieu-Daudé
2018-04-05 1:22 ` [Qemu-devel] [RFC PATCH v2 4/4] memory: Add memory_region_set_priority() Philippe Mathieu-Daudé
2018-04-05 3:25 ` Alexey Kardashevskiy
2018-04-05 8:44 ` KONRAD Frederic
2018-04-06 5:14 ` Alexey Kardashevskiy
2018-04-05 1:30 ` [Qemu-devel] [RFC PATCH v2 0/4] memory: fix access_with_adjusted_size() and misc no-reply
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=20180405012241.25714-2-f4bug@amsat.org \
--to=f4bug@amsat.org \
--cc=aik@ozlabs.ru \
--cc=frederic.konrad@adacore.com \
--cc=pbonzini@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).