From mboxrd@z Thu Jan 1 00:00:00 1970 From: Yaniv Kamay Subject: Re: [PATCH] fix bad physical address in kvm_update_dirty_pages_log() Date: Tue, 24 Mar 2009 23:27:10 +0200 Message-ID: <49C9502E.7070907@redhat.com> References: <49C94A2F.9070706@redhat.com> <5d6222a80903241413n6f1a472fp4a546b1cac6fadd4@mail.gmail.com> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Cc: kvm@vger.kernel.org To: Glauber Costa Return-path: Received: from mx2.redhat.com ([66.187.237.31]:44212 "EHLO mx2.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751405AbZCXV1S (ORCPT ); Tue, 24 Mar 2009 17:27:18 -0400 In-Reply-To: <5d6222a80903241413n6f1a472fp4a546b1cac6fadd4@mail.gmail.com> Sender: kvm-owner@vger.kernel.org List-ID: Glauber Costa wrote: > @@ -1223,12 +1244,44 @@ static int kvm_get_dirty_bitmap_cb(unsigned > long start, unsigned long len, > int kvm_update_dirty_pages_log(void) > { > int r = 0; > + ram_addr_t now = 0; > + ram_addr_t end = phys_ram_size; > + ram_addr_t offset; > + target_phys_addr_t area_start; > + ram_addr_t area_size; > + unsigned char *dirty_bitmap = kvm_dirty_bitmap; > + > + if (!dirty_bitmap) { > + printf("%s: no dirty bitmap\n", __FUNCTION__); > + return -1; > + } > nitpick: you probably want fprintf(stderr...). > > > + while (now < end && !find_phys_area(now, &offset, &area_start, > &area_size)) { > + if ((offset & ~TARGET_PAGE_MASK) || (area_start & > ~TARGET_PAGE_MASK) || > + (area_size & > ~TARGET_PAGE_MASK)) { > + printf("%s: invalid mem area\n", __FUNCTION__); > same here. > > > > + if ((now += offset) >= end) { > + break; > + } > + > + if (area_size > end - now) { > + return -1; > + } > any reason why you're handling those two differently? > The first is orderly end of mappings and the later is error. > -- > Glauber Costa. > "Free as in Freedom" > http://glommer.net > > "The less confident you are, the more serious you have to act." >