diff options
author | Rusty Russell <rusty@rustcorp.com.au> | 2007-07-31 06:41:14 -0400 |
---|---|---|
committer | Avi Kivity <avi@qumranet.com> | 2007-10-13 04:18:22 -0400 |
commit | 7e9d619d2aa28b71d547edfa15c66d6ab9a3a39c (patch) | |
tree | 6500d9365b0d9db2988fd7d33cacb1e2cf1d0337 /drivers/kvm | |
parent | fb764416492a1204c20fdf4507019012d27bd1a2 (diff) |
KVM: Cleanup mark_page_dirty
For some reason, mark_page_dirty open-codes __gfn_to_memslot().
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Signed-off-by: Avi Kivity <avi@qumranet.com>
Diffstat (limited to 'drivers/kvm')
-rw-r--r-- | drivers/kvm/kvm_main.c | 24 |
1 files changed, 7 insertions, 17 deletions
diff --git a/drivers/kvm/kvm_main.c b/drivers/kvm/kvm_main.c index 5dc601702782..55639aceca63 100644 --- a/drivers/kvm/kvm_main.c +++ b/drivers/kvm/kvm_main.c | |||
@@ -916,28 +916,18 @@ struct page *gfn_to_page(struct kvm *kvm, gfn_t gfn) | |||
916 | } | 916 | } |
917 | EXPORT_SYMBOL_GPL(gfn_to_page); | 917 | EXPORT_SYMBOL_GPL(gfn_to_page); |
918 | 918 | ||
919 | /* WARNING: Does not work on aliased pages. */ | ||
919 | void mark_page_dirty(struct kvm *kvm, gfn_t gfn) | 920 | void mark_page_dirty(struct kvm *kvm, gfn_t gfn) |
920 | { | 921 | { |
921 | int i; | ||
922 | struct kvm_memory_slot *memslot; | 922 | struct kvm_memory_slot *memslot; |
923 | unsigned long rel_gfn; | ||
924 | 923 | ||
925 | for (i = 0; i < kvm->nmemslots; ++i) { | 924 | memslot = __gfn_to_memslot(kvm, gfn); |
926 | memslot = &kvm->memslots[i]; | 925 | if (memslot && memslot->dirty_bitmap) { |
926 | unsigned long rel_gfn = gfn - memslot->base_gfn; | ||
927 | 927 | ||
928 | if (gfn >= memslot->base_gfn | 928 | /* avoid RMW */ |
929 | && gfn < memslot->base_gfn + memslot->npages) { | 929 | if (!test_bit(rel_gfn, memslot->dirty_bitmap)) |
930 | 930 | set_bit(rel_gfn, memslot->dirty_bitmap); | |
931 | if (!memslot->dirty_bitmap) | ||
932 | return; | ||
933 | |||
934 | rel_gfn = gfn - memslot->base_gfn; | ||
935 | |||
936 | /* avoid RMW */ | ||
937 | if (!test_bit(rel_gfn, memslot->dirty_bitmap)) | ||
938 | set_bit(rel_gfn, memslot->dirty_bitmap); | ||
939 | return; | ||
940 | } | ||
941 | } | 931 | } |
942 | } | 932 | } |
943 | 933 | ||