diff options
author | Takuya Yoshikawa <yoshikawa.takuya@oss.ntt.co.jp> | 2010-04-12 06:35:35 -0400 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@suse.de> | 2010-04-26 10:48:05 -0400 |
commit | ff5bfd4f4896c3f27dafcc4ae533b0d803968499 (patch) | |
tree | 06ff00917d803d3112ec379d3b75ad2e778a8afc /include/linux | |
parent | f1f52e1094fc4e39bfd3071e33803fbbf0543d49 (diff) |
KVM: fix the handling of dirty bitmaps to avoid overflows
(Cherry-picked from commit 87bf6e7de1134f48681fd2ce4b7c1ec45458cb6d)
Int is not long enough to store the size of a dirty bitmap.
This patch fixes this problem with the introduction of a wrapper
function to calculate the sizes of dirty bitmaps.
Note: in mark_page_dirty(), we have to consider the fact that
__set_bit() takes the offset as int, not long.
Signed-off-by: Takuya Yoshikawa <yoshikawa.takuya@oss.ntt.co.jp>
Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'include/linux')
-rw-r--r-- | include/linux/kvm_host.h | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/include/linux/kvm_host.h b/include/linux/kvm_host.h index bd5a616d9373..ddb7d5840de8 100644 --- a/include/linux/kvm_host.h +++ b/include/linux/kvm_host.h | |||
@@ -116,6 +116,11 @@ struct kvm_memory_slot { | |||
116 | int user_alloc; | 116 | int user_alloc; |
117 | }; | 117 | }; |
118 | 118 | ||
119 | static inline unsigned long kvm_dirty_bitmap_bytes(struct kvm_memory_slot *memslot) | ||
120 | { | ||
121 | return ALIGN(memslot->npages, BITS_PER_LONG) / 8; | ||
122 | } | ||
123 | |||
119 | struct kvm_kernel_irq_routing_entry { | 124 | struct kvm_kernel_irq_routing_entry { |
120 | u32 gsi; | 125 | u32 gsi; |
121 | u32 type; | 126 | u32 type; |