aboutsummaryrefslogtreecommitdiff
path: root/exec.c
diff options
context:
space:
mode:
authorGleb Natapov <gleb@redhat.com>2010-07-29 10:41:45 +0300
committerBlue Swirl <blauwirbel@gmail.com>2010-08-28 08:47:23 +0000
commit95c318f5e1f88d7e5bcc6deac17330fd4806a2d3 (patch)
treedbfdcf03404842b798b7f30fe7198728aea985ad /exec.c
parent9e84a4708f820976afd825745d4110dbaf58f431 (diff)
Fix segfault in mmio subpage handling code.
It is possible that subpage mmio is registered over existing memory page. When this happens "memory" will have real memory address and not index into io_mem array so next access to the page will generate segfault. It is uncommon to have some part of a page to be accessed as memory and some as mmio, but qemu shouldn't crash even when guest does stupid things. So lets just pretend that the rest of the page is unassigned if guest configure part of the memory page as mmio. Signed-off-by: Gleb Natapov <gleb@redhat.com> Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
Diffstat (limited to 'exec.c')
-rw-r--r--exec.c2
1 files changed, 2 insertions, 0 deletions
diff --git a/exec.c b/exec.c
index 82bfffcb8b..380dab50be 100644
--- a/exec.c
+++ b/exec.c
@@ -3293,6 +3293,8 @@ static int subpage_register (subpage_t *mmio, uint32_t start, uint32_t end,
printf("%s: %p start %08x end %08x idx %08x eidx %08x mem %ld\n", __func__,
mmio, start, end, idx, eidx, memory);
#endif
+ if ((memory & ~TARGET_PAGE_MASK) == IO_MEM_RAM)
+ memory = IO_MEM_UNASSIGNED;
memory = (memory >> IO_MEM_SHIFT) & (IO_MEM_NB_ENTRIES - 1);
for (; idx <= eidx; idx++) {
mmio->sub_io_index[idx] = memory;