=== snipet from commit c8240bd6f0b4b1b21ffd36dd44114d05c7afe0c0 ===
@@ -48,6 +48,7 @@
#include <asm/io.h>
#include <asm/uaccess.h>
#include <asm/pgtable.h>
+#include <asm-generic/bitops/le.h>
#ifdef KVM_COALESCED_MMIO_PAGE_OFFSET
#include "coalesced_mmio.h"
@@ -1665,8 +1666,8 @@ void mark_page_dirty(struct kvm *kvm, gfn_t gfn)
unsigned long rel_gfn = gfn - memslot->base_gfn;
/* avoid RMW */
- if (!test_bit(rel_gfn, memslot->dirty_bitmap))
- set_bit(rel_gfn, memslot->dirty_bitmap);
+ if (!generic_test_le_bit(rel_gfn, memslot->dirty_bitmap))
+ generic___set_le_bit(rel_gfn, memslot->dirty_bitmap);
}
}
===
=== not tested ===
[PATCH sample] KVM: avoid to include an asm-generic bitops header file directly
Including asm-generic bitops headers is kind of violation: there is no guarantee that
no one will change those functions we are using.
Signed-off-by: Takuya Yoshikawa <yoshikawatky@yshtky3.kern.oss.ntt.co.jp>
---
virt/kvm/kvm_main.c | 17 +++++++++++++----
1 files changed, 13 insertions(+), 4 deletions(-)
@@ -51,7 +51,6 @@
#include <asm/io.h>
#include <asm/uaccess.h>
#include <asm/pgtable.h>
-#include <asm-generic/bitops/le.h>
#include "coalesced_mmio.h"
@@ -1179,6 +1178,18 @@ int kvm_clear_guest(struct kvm *kvm, gpa_t gpa, unsigned long len)
}
EXPORT_SYMBOL_GPL(kvm_clear_guest);
+/*
+ * __set_le_bit is defined for ppc only.
+ */
+static void kvm___set_le_bit(unsigned long nr, unsigned long *addr)
+{
+#ifdef __set_le_bit
+ __set_le_bit(nr, addr);
+#else
+ __set_bit(nr, addr);
+#endif
+}
+
void mark_page_dirty(struct kvm *kvm, gfn_t gfn)
{
struct kvm_memory_slot *memslot;
@@ -1188,9 +1199,7 @@ 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);
+ kvm___set_le_bit(rel_gfn, memslot->dirty_bitmap);
}
}