From mboxrd@z Thu Jan 1 00:00:00 1970 From: Stefano Stabellini Subject: [PATCH] Linux-HVM, qemu, and xen-balloon.ko Date: Mon, 15 Dec 2008 11:51:01 +0000 Message-ID: <494644A5.3020305@eu.citrix.com> References: Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xensource.com Errors-To: xen-devel-bounces@lists.xensource.com To: George Dunlap Cc: "xen-devel@lists.xensource.com" List-Id: xen-devel@lists.xenproject.org George Dunlap wrote: > There seems to be some sort of a bug when qemu interacts with the > balloon driver. Stefano is trying to repro it, but I thought I'd > share it for people to look at. There is a bug in qemu_map_cache: if address_index == last_address_index we don't check that there is a valid_mapping for address_offset in the bucket. The following patch fixes it. Signed-off-by: Stefano Stabellini --- diff -r 0ea6bd53cfb6 hw/xen_machine_fv.c --- a/hw/xen_machine_fv.c Thu Oct 23 10:26:02 2008 +0100 +++ b/hw/xen_machine_fv.c Mon Dec 15 11:43:52 2008 +0000 @@ -135,10 +135,11 @@ unsigned long address_index = phys_addr >> MCACHE_BUCKET_SHIFT; unsigned long address_offset = phys_addr & (MCACHE_BUCKET_SIZE-1); - if (address_index == last_address_index) + entry = &mapcache_entry[address_index % nr_buckets]; + + if (address_index == last_address_index && + test_bit(address_offset>>XC_PAGE_SHIFT, entry->valid_mapping)) return last_address_vaddr + address_offset; - - entry = &mapcache_entry[address_index % nr_buckets]; if (entry->vaddr_base == NULL || entry->paddr_index != address_index || !test_bit(address_offset>>XC_PAGE_SHIFT, entry->valid_mapping))