diff options
author | Alexander Graf <agraf@suse.de> | 2011-11-10 01:59:23 +0100 |
---|---|---|
committer | Alexander Graf <agraf@suse.de> | 2011-11-14 17:47:27 +0100 |
commit | 326384d5b6dcea69ca44695ee807f8b50234ab71 (patch) | |
tree | dcdf2048fed4b16a031fe23b1cdbc24b1c235d18 /hw/s390-virtio.c | |
parent | 2a534aff30b29f7e504451c6ed04658e850144ba (diff) |
s390x: initialize virtio dev region
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>
---
v1 -> v2:
- use target_phys_addr_t
Diffstat (limited to 'hw/s390-virtio.c')
-rw-r--r-- | hw/s390-virtio.c | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/hw/s390-virtio.c b/hw/s390-virtio.c index 37945d5d83..61b67e8c3a 100644 --- a/hw/s390-virtio.c +++ b/hw/s390-virtio.c @@ -165,6 +165,9 @@ 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; + target_phys_addr_t virtio_region_start; int i; /* s390x ram size detection needs a 16bit multiplier + an increment. So @@ -184,6 +187,15 @@ 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_start = ram_size; + virtio_region = cpu_physical_memory_map(virtio_region_start, + &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); |