From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:50061) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1X9VVH-0006aX-5v for qemu-devel@nongnu.org; Tue, 22 Jul 2014 04:33:02 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1X9VVA-0001D0-SE for qemu-devel@nongnu.org; Tue, 22 Jul 2014 04:32:55 -0400 Received: from mx1.redhat.com ([209.132.183.28]:44704) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1X9VVA-0001Cn-Jm for qemu-devel@nongnu.org; Tue, 22 Jul 2014 04:32:48 -0400 Message-ID: <1406017961.27264.9.camel@nilsson.home.kraxel.org> From: Gerd Hoffmann Date: Tue, 22 Jul 2014 10:32:41 +0200 In-Reply-To: <1405955204-10438-1-git-send-email-pbonzini@redhat.com> References: <1405955204-10438-1-git-send-email-pbonzini@redhat.com> Content-Type: text/plain; charset="UTF-8" Mime-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH for-2.1] exec: fix migration with devices that use address_space_rw List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Paolo Bonzini Cc: peter.maydell@linaro.org, mst@redhat.com, qemu-devel@nongnu.org, dgilbert@redhat.com, quintela@redhat.com On Mo, 2014-07-21 at 17:06 +0200, Paolo Bonzini wrote: > Devices that use address_space_rw to write large areas to memory > (as opposed to address_space_map/unmap) were broken with respect > to migration since fe680d0 (exec: Limit translation limiting in > address_space_translate to xen, 2014-05-07). Such devices include > IDE CD-ROMs. > > The reason is that invalidate_and_set_dirty (called by address_space_rw > but not address_space_map/unmap) was only setting the dirty bit for > the first page in the translation. > > To fix this, introduce cpu_physical_memory_set_dirty_range_nocode that > is the same as cpu_physical_memory_set_dirty_range except it does not > muck with the DIRTY_MEMORY_CODE bitmap. This function can be used if > the caller invalidates translations with tb_invalidate_phys_page_range. > > There is another difference between cpu_physical_memory_set_dirty_range > and cpu_physical_memory_set_dirty_flag; the former includes a call > to xen_modified_memory. This is handled separately in > invalidate_and_set_dirty, and is not needed in other callers of > cpu_physical_memory_set_dirty_range_nocode, so leave it alone. > > Just one nit: now that invalidate_and_set_dirty takes care of handling > multiple pages, there is no need for address_space_unmap to wrap it > in a loop. In fact that loop would now be O(n^2). > > Reported-by: Dave Gilbert > Signed-off-by: Paolo Bonzini Tested-by: Gerd Hoffmann