From: Anthony PERARD Date: Fri, 13 Apr 2012 17:18:56 +0000 (+0000) Subject: Xen, mapcache: Fix the compute of the size of bucket. X-Git-Tag: qemu-xen-4.2.0~25 X-Git-Url: http://xenbits.xensource.com/gitweb?a=commitdiff_plain;h=0ec445db3137e501e758a50d64e9c2b39d23a6b6;p=qemu-upstream-4.2-testing.git Xen, mapcache: Fix the compute of the size of bucket. Because the size of a mapping is wrong when there is an offset and a size >= bucket_size. Signed-off-by: Anthony PERARD Signed-off-by: Stefano Stabellini --- diff --git a/xen-mapcache.c b/xen-mapcache.c index d5f52b2cb..eade81632 100644 --- a/xen-mapcache.c +++ b/xen-mapcache.c @@ -214,12 +214,14 @@ tryagain: } /* size is always a multiple of MCACHE_BUCKET_SIZE */ - if ((address_offset + (__size % MCACHE_BUCKET_SIZE)) > MCACHE_BUCKET_SIZE) - __size += MCACHE_BUCKET_SIZE; - if (__size % MCACHE_BUCKET_SIZE) - __size += MCACHE_BUCKET_SIZE - (__size % MCACHE_BUCKET_SIZE); - if (!__size) + if (size) { + __size = size + address_offset; + if (__size % MCACHE_BUCKET_SIZE) { + __size += MCACHE_BUCKET_SIZE - (__size % MCACHE_BUCKET_SIZE); + } + } else { __size = MCACHE_BUCKET_SIZE; + } entry = &mapcache->entry[address_index % mapcache->nr_buckets];