summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRichard Lowe <richlowe@richlowe.net>2012-08-09 18:44:50 +0000
committerBryan Cantrill <bryan@joyent.com>2012-08-09 18:44:50 +0000
commitb0749fb0107ad74305cd1d91f54334888e070be4 (patch)
treecbeb6dd1c277f14be16b3c69ad575cc3642f3d2c
parentf42bb2093cad03110c3a6b625bffcd8921d89fc1 (diff)
downloadillumos-kvm-b0749fb0107ad74305cd1d91f54334888e070be4.tar.gz
HVM-742 off-by-one error in bitset manipulation20120823
-rw-r--r--kvm_mmu.c9
1 files changed, 5 insertions, 4 deletions
diff --git a/kvm_mmu.c b/kvm_mmu.c
index d2864c5..10e90ce 100644
--- a/kvm_mmu.c
+++ b/kvm_mmu.c
@@ -19,6 +19,7 @@
* Copyright 2011 various Linux Kernel contributors.
* Copyright 2011 Joyent, Inc. All Rights Reserved.
* Copyright 2011 Joshua M. Clulow <josh@sysmgr.org>
+ * Copyright 2011 Richard Lowe
*/
#include <sys/sysmacros.h>
@@ -948,9 +949,9 @@ typedef struct kvm_mmu_pages {
} kvm_mmu_pages_t;
#define for_each_unsync_children(bitmap, idx) \
- for (idx = bt_getlowbit(bitmap, 0, 512); \
- idx < 512; \
- idx = bt_getlowbit(bitmap, idx+1, 512))
+ for (idx = bt_getlowbit(bitmap, 0, 511); \
+ (idx != -1) && (idx < 512); \
+ idx = bt_getlowbit(bitmap, idx+1, 511))
static int
mmu_pages_add(struct kvm_mmu_pages *pvec, struct kvm_mmu_page *sp, int idx)
@@ -1004,7 +1005,7 @@ __mmu_unsync_walk(struct kvm_mmu_page *sp, struct kvm_mmu_pages *pvec,
}
}
- if (bt_getlowbit(sp->unsync_child_bitmap, 0, 512) == 512)
+ if (bt_getlowbit(sp->unsync_child_bitmap, 0, 511) == -1)
sp->unsync_children = 0;
return (nr_unsync_leaf);