aboutsummaryrefslogtreecommitdiff
path: root/xen-mapcache.c
diff options
context:
space:
mode:
authorAnthony PERARD <anthony.perard@citrix.com>2012-04-13 17:18:56 +0000
committerStefano Stabellini <stefano.stabellini@eu.citrix.com>2012-04-13 17:34:50 +0000
commit09ab48ee6c7ec082f56f85e234b066ed4fd874e2 (patch)
tree2dbfe17a2b736fde2696f1ab87bb14172ffe622f /xen-mapcache.c
parent77ba8fef8972854b7fad89d97a14f4f9c3eae7a8 (diff)
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 <anthony.perard@citrix.com> Signed-off-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
Diffstat (limited to 'xen-mapcache.c')
-rw-r--r--xen-mapcache.c12
1 files changed, 7 insertions, 5 deletions
diff --git a/xen-mapcache.c b/xen-mapcache.c
index a456479363..75ac313f28 100644
--- a/xen-mapcache.c
+++ b/xen-mapcache.c
@@ -216,12 +216,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];