Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 197744
b: refs/heads/master
c: 660c22c
h: refs/heads/master
v: v3
  • Loading branch information
Takuya Yoshikawa authored and Avi Kivity committed May 17, 2010
1 parent f3c8022 commit aa6f9fe
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 6 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 020df0794f5764e742feaa718be88b8f1b4ce04f
refs/heads/master: 660c22c425cbe14badfb3b0a0206862577701ab7
6 changes: 6 additions & 0 deletions trunk/include/linux/kvm_host.h
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,12 @@ struct kvm_vcpu {
struct kvm_vcpu_arch arch;
};

/*
* Some of the bitops functions do not support too long bitmaps.
* This number must be determined not to exceed such limits.
*/
#define KVM_MEM_MAX_NR_PAGES ((1UL << 31) - 1)

struct kvm_memory_slot {
gfn_t base_gfn;
unsigned long npages;
Expand Down
11 changes: 6 additions & 5 deletions trunk/virt/kvm/kvm_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -557,6 +557,10 @@ int __kvm_set_memory_region(struct kvm *kvm,
base_gfn = mem->guest_phys_addr >> PAGE_SHIFT;
npages = mem->memory_size >> PAGE_SHIFT;

r = -EINVAL;
if (npages > KVM_MEM_MAX_NR_PAGES)
goto out;

if (!npages)
mem->flags &= ~KVM_MEM_LOG_DIRTY_PAGES;

Expand Down Expand Up @@ -1187,13 +1191,10 @@ void mark_page_dirty(struct kvm *kvm, gfn_t gfn)
memslot = gfn_to_memslot_unaliased(kvm, gfn);
if (memslot && memslot->dirty_bitmap) {
unsigned long rel_gfn = gfn - memslot->base_gfn;
unsigned long *p = memslot->dirty_bitmap +
rel_gfn / BITS_PER_LONG;
int offset = rel_gfn % BITS_PER_LONG;

/* avoid RMW */
if (!generic_test_le_bit(offset, p))
generic___set_le_bit(offset, p);
if (!generic_test_le_bit(rel_gfn, memslot->dirty_bitmap))
generic___set_le_bit(rel_gfn, memslot->dirty_bitmap);
}
}

Expand Down

0 comments on commit aa6f9fe

Please sign in to comment.