diff mbox

[RFC,v2,4/6] KVM: change mark_page_dirty() to handle endian issues explicitly

Message ID 20100420200043.956302db.yoshikawa.takuya@oss.ntt.co.jp (mailing list archive)
State New, archived
Headers show

Commit Message

Takuya Yoshikawa April 20, 2010, 11 a.m. UTC
None
diff mbox

Patch

diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c
index 6908304..66c4daf 100644
--- a/virt/kvm/kvm_main.c
+++ b/virt/kvm/kvm_main.c
@@ -1194,6 +1194,15 @@  int kvm_clear_guest(struct kvm *kvm, gpa_t gpa, unsigned long len)
 }
 EXPORT_SYMBOL_GPL(kvm_clear_guest);
 
+static int __mark_page_dirty(unsigned long nr,
+			     unsigned long *dirty_bitmap)
+{
+#ifdef __BIG_ENDIAN
+	nr = nr ^ BITOP_LE_SWIZZLE;
+#endif
+	__set_bit(nr, dirty_bitmap);
+}
+
 void mark_page_dirty(struct kvm *kvm, gfn_t gfn)
 {
 	struct kvm_memory_slot *memslot;
@@ -1203,11 +1212,8 @@  void mark_page_dirty(struct kvm *kvm, gfn_t gfn)
 	if (memslot && memslot->dirty_bitmap) {
 		unsigned long rel_gfn = gfn - memslot->base_gfn;
 
-		/* avoid RMW */
-		if (!generic_test_le_bit(rel_gfn, memslot->dirty_bitmap)) {
-			generic___set_le_bit(rel_gfn, memslot->dirty_bitmap);
-			memslot->is_dirty = true;
-		}
+		__mark_page_dirty(rel_gfn, memslot->dirty_bitmap);
+		memslot->is_dirty = true;
 	}
 }