From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from [140.186.70.92] (port=42757 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1OeQZg-0003JZ-K7 for qemu-devel@nongnu.org; Thu, 29 Jul 2010 06:43:09 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1OeQYf-0004kJ-IM for qemu-devel@nongnu.org; Thu, 29 Jul 2010 06:41:50 -0400 Received: from mx1.redhat.com ([209.132.183.28]:39265) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1OeQYf-0004k7-AX for qemu-devel@nongnu.org; Thu, 29 Jul 2010 06:41:49 -0400 Date: Thu, 29 Jul 2010 13:41:45 +0300 From: Gleb Natapov Message-ID: <20100729104145.GA24773@redhat.com> References: <1280330003-1467-1-git-send-email-gleb@redhat.com> <1280330003-1467-2-git-send-email-gleb@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1280330003-1467-2-git-send-email-gleb@redhat.com> Subject: [Qemu-devel] Re: [PATCH 1/2] Fix segfault in mmio subpage handling code. List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: kvm@vger.kernel.org Use this one instead. On Wed, Jul 28, 2010 at 06:13:22PM +0300, Gleb Natapov wrote: > 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 diff --git a/exec.c b/exec.c index 5e9a5b7..53483bc 100644 --- a/exec.c +++ b/exec.c @@ -3362,6 +3362,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; -- Gleb.