From: Ian Jackson Subject: Re: [PATCH] xen: xen_sync_dirty_bitmap: attempt to fix SEGV [and 1 more messages] Date: Wed, 6 Mar 2013 17:12:12 +0000 Message-ID: <20791.30956.857713.216230@mariner.uk.xensource.com> References: <1362581885-13221-1-git-send-email-alex@alex.org.uk> <89D1720972979969F5F2FA5A@Ximines.local> <1362579002-7981-1-git-send-email-alex@alex.org.uk> <20791.20406.657234.174164@mariner.uk.xensource.com> <6AEE06E4395BA377613977FB@nimrod.local> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: <6AEE06E4395BA377613977FB@nimrod.local>, <1362581885-13221-1-git-send-email-alex@alex.org.uk> List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org To: Alex Bligh Cc: Stefano Stabellini , Ian Campbell , xen-devel List-Id: xen-devel@lists.xenproject.org Alex Bligh writes ("Re: [PATCH] xen: xen_sync_dirty_bitmap: attempt to fix SEGV"): > If the former, then I think the problem is that the address that > cpu_physical_memory_set_dirty (and xen_modified_memory) takes needs > to be passed through get_physmapping()->phys_offset before use, > like the second case already does. In this case the patch I've > just sent should (hopefully) work. Indeed. Your patch fixes the problem. I discussed this with Stefano before he went away and he said I should push a fix to qemu-xen-upstream-4.2-testing.git staging, so I have done that. I edited the commit message slightly. Thanks for your help! Regards, Ian. commit 351f94ff4bf3a7795ca5b282305aa610e598eec0 Author: Alex Bligh Date: Wed Mar 6 14:59:27 2013 +0000 xen: xen_sync_dirty_bitmap: attempt to fix SEGV When xc_hvm_track_dirty_vram fails, iterate through pages based on vram_offset and npages, rather than start_addr and size. DPRINTF before the loop too. [ Fixes a regression introduced by eccc68722696864fc4823f048c7be58d11281b97 - iwj ] Signed-off-by: Alex Bligh Tested-by: Ian Jackson diff --git a/xen-all.c b/xen-all.c index dbd759c..96a34a9 100644 --- a/xen-all.c +++ b/xen-all.c @@ -472,18 +472,17 @@ static int xen_sync_dirty_bitmap(XenIOState *state, bitmap); if (rc < 0) { if (rc != -ENODATA) { - ram_addr_t addr, end; - - xen_modified_memory(start_addr, size); - - end = TARGET_PAGE_ALIGN(start_addr + size); - for (addr = start_addr & TARGET_PAGE_MASK; addr < end; addr += TARGET_PAGE_SIZE) { - cpu_physical_memory_set_dirty(addr); - } + target_phys_addr_t todirty; DPRINTF("xen: track_dirty_vram failed (0x" TARGET_FMT_plx ", 0x" TARGET_FMT_plx "): %s\n", start_addr, start_addr + size, strerror(-rc)); + + xen_modified_memory(vram_offset, npages * TARGET_PAGE_SIZE); + + for (todirty = vram_offset, i=0; i < npages; todirty += TARGET_PAGE_SIZE, i++) { + cpu_physical_memory_set_dirty(todirty); + } } return rc; }