From: Alexander Graf <agraf@suse.de>
To: qemu-devel@nongnu.org
Subject: [Qemu-devel] [PATCH] s390x: initialize virtio dev region
Date: Thu, 10 Nov 2011 02:19:41 +0100 [thread overview]
Message-ID: <1320887981-2099-1-git-send-email-agraf@suse.de> (raw)
When running the s390x virtio machine we can potentially use uninitialized
memory for the virtio device backing ram. That can lead to weird breakge.
So let's better initialize it to 0 properly.
Reported-by: Andreas Färber <afaerber@suse.de>
Signed-off-by: Alexander Graf <agraf@suse.de>
---
hw/s390-virtio.c | 9 +++++++++
1 files changed, 9 insertions(+), 0 deletions(-)
diff --git a/hw/s390-virtio.c b/hw/s390-virtio.c
index 37945d5..d936809 100644
--- a/hw/s390-virtio.c
+++ b/hw/s390-virtio.c
@@ -165,6 +165,8 @@ static void s390_init(ram_addr_t my_ram_size,
ram_addr_t initrd_size = 0;
int shift = 0;
uint8_t *storage_keys;
+ void *virtio_region;
+ target_phys_addr_t virtio_region_len;
int i;
/* s390x ram size detection needs a 16bit multiplier + an increment. So
@@ -184,6 +186,13 @@ static void s390_init(ram_addr_t my_ram_size,
memory_region_init_ram(ram, NULL, "s390.ram", my_ram_size);
memory_region_add_subregion(sysmem, 0, ram);
+ /* clear virtio region */
+ virtio_region_len = my_ram_size - ram_size;
+ virtio_region = cpu_physical_memory_map(ram_size, &virtio_region_len, true);
+ memset(virtio_region, 0, virtio_region_len);
+ cpu_physical_memory_unmap(virtio_region, virtio_region_len, 1,
+ virtio_region_len);
+
/* allocate storage keys */
storage_keys = g_malloc0(my_ram_size / TARGET_PAGE_SIZE);
--
1.6.0.2
next reply other threads:[~2011-11-10 1:07 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-11-10 1:19 Alexander Graf [this message]
2011-11-10 1:36 ` [Qemu-devel] [PATCH] s390x: initialize virtio dev region Peter Maydell
2011-11-10 1:45 ` Alexander Graf
2011-11-10 2:19 ` Peter Maydell
2011-11-11 15:59 ` Alexander Graf
2011-11-11 16:11 ` Peter Maydell
2011-11-11 16:24 ` Alexander Graf
2011-11-11 16:44 ` Peter Maydell
2011-11-11 16:46 ` Alexander Graf
2011-11-11 17:38 ` Alexander Graf
2011-11-11 17:40 ` Alexander Graf
2011-11-11 18:01 ` Peter Maydell
2011-11-11 22:43 ` Andreas Färber
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=1320887981-2099-1-git-send-email-agraf@suse.de \
--to=agraf@suse.de \
--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).