From mboxrd@z Thu Jan 1 00:00:00 1970 From: Gleb Natapov Subject: [PATCH 1/2] Fix segfault in mmio subpage handling code. Date: Wed, 28 Jul 2010 18:13:22 +0300 Message-ID: <1280330003-1467-2-git-send-email-gleb@redhat.com> References: <1280330003-1467-1-git-send-email-gleb@redhat.com> Cc: kvm@vger.kernel.org To: qemu-devel@nongnu.org Return-path: Received: from mx1.redhat.com ([209.132.183.28]:20082 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754598Ab0G1PNZ (ORCPT ); Wed, 28 Jul 2010 11:13:25 -0400 In-Reply-To: <1280330003-1467-1-git-send-email-gleb@redhat.com> Sender: kvm-owner@vger.kernel.org List-ID: 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 --- exec.c | 2 ++ 1 files changed, 2 insertions(+), 0 deletions(-) diff --git a/exec.c b/exec.c index 5e9a5b7..5945496 100644 --- a/exec.c +++ b/exec.c @@ -3363,6 +3363,8 @@ static int subpage_register (subpage_t *mmio, uint32_t start, uint32_t end, mmio, start, end, idx, eidx, memory); #endif memory = (memory >> IO_MEM_SHIFT) & (IO_MEM_NB_ENTRIES - 1); + if ((memory & ~TARGET_PAGE_MASK) == IO_MEM_RAM) + memory = IO_MEM_UNASSIGNED; for (; idx <= eidx; idx++) { mmio->sub_io_index[idx] = memory; mmio->region_offset[idx] = region_offset; -- 1.7.1