Use Little Endian for Dirty Bitmap
PATCH 1/1 Use Little Endian for Dirty Bitmap
We currently use host endian long types to store information in the dirty bitmap.
This works reasonably well on Little Endian targets, because the u32 after the first contains the next 32 bits. On Big Endian this breaks completely though, forcing us to be inventive here.
So Ben suggested to always use Little Endian, which looks reasonable.
We only have dirty bitmap implemented in Little Endian targets so far and since PowerPC would be the first Big Endian platform, we can just as well switch to Little Endian always with little effort without breaking existing targets.
--- virt/kvm/kvm_main.c | 5 +++-- 1 files changed, 3 insertions(+), 2 deletions(-)
virt/kvm/kvm_main.c +3 -2
@@ -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"
@@ -1656,8 +1657,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); } }
Signature · 6 lines
1.6.0.2 -- To unsubscribe from this list: send the line "unsubscribe kvm-ppc" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
A message that is not in the archive (sent off-list or not yet received): 1248691134-54120-1-git-send-email-agraf-l3A5Bk7waGM@public.gmane.org
bump
Quoted 49 lines · Alexander Graf
We currently use host endian long types to store information in the dirty bitmap.
This works reasonably well on Little Endian targets, because the u32 after the first contains the next 32 bits. On Big Endian this breaks completely though, forcing us to be inventive here.
So Ben suggested to always use Little Endian, which looks reasonable.
We only have dirty bitmap implemented in Little Endian targets so far and since PowerPC would be the first Big Endian platform, we can just as well switch to Little Endian always with little effort without breaking existing targets.
Signed-off-by Alexander Graf <[email protected]>---
virt/kvm/kvm_main.c| 5 +++--1 files changed, 3 insertions(+), 2 deletions(-)virt/kvm/kvm_main.c +3
-2@@ -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" @@ -1656,8 +1657,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); } }Signature · 6 lines
1.6.0.2 -- To unsubscribe from this list: send the line "unsubscribe kvm" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
--
To unsubscribe from this list: send the line "unsubscribe kvm-ppc" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
Quoted 32 lines · Alexander Graf
We currently use host endian long types to store information in the dirty bitmap.
This works reasonably well on Little Endian targets, because the u32 after the first contains the next 32 bits. On Big Endian this breaks completely though, forcing us to be inventive here.
So Ben suggested to always use Little Endian, which looks reasonable.
We only have dirty bitmap implemented in Little Endian targets so far and since PowerPC would be the first Big Endian platform, we can just as well switch to Little Endian always with little effort without breaking existing targets.
Signed-off-by Alexander Graf <[email protected]>--- virt/kvm/kvm_main.c | 5 +++-- 1 files changed, 3 insertions(+), 2 deletions(-)virt/kvm/kvm_main.c +1
-0@@ -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"
virt/kvm/kvm_main.c void mark_page_dirty(struct kvm *kvm, gfn_t gfn) · line 1663
Quoted 9 lines
virt/kvm/kvm_main.c +2
-2@@ -1656,8 +1657,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); } }
I don't think I've ever exercised the dirty bitmap code, and I don't really have an opinion. Avi?
Signature · 2 lines
Hollis Blanchard IBM Linux Technology Center
A message that is not in the archive (sent off-list or not yet received): 1254182880.15622.157.camel-yDUrRDS8jBVhsM67afOH+sxtgHpCUUYS@public.gmane.org
Quoted 36 lines · Hollis Blanchard
Quoted 35 lines · Alexander Graf
We currently use host endian long types to store information in the dirty bitmap.
This works reasonably well on Little Endian targets, because the u32 after the first contains the next 32 bits. On Big Endian this breaks completely though, forcing us to be inventive here.
So Ben suggested to always use Little Endian, which looks reasonable.
We only have dirty bitmap implemented in Little Endian targets so far and since PowerPC would be the first Big Endian platform, we can just as well switch to Little Endian always with little effort without breaking existing targets.
Signed-off-by Alexander Graf <[email protected]>---
virt/kvm/kvm_main.c| 5 +++--1 files changed, 3 insertions(+), 2 deletions(-)virt/kvm/kvm_main.c +1
-0@@ -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" @@ -1656,8 +1657,8 @@ void mark_page_dirty(struct kvm *kvm, gfn_t gfn)unsigned long rel_gfn = gfn - memslot->base_gfn;
Quoted 10 lines
virt/kvm/kvm_main.c void mark_page_dirty(struct kvm *kvm, gfn_t gfn) · line 1663
Quoted 7 lines
virt/kvm/kvm_main.c +2
-2/* 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); } }I don't think I've ever exercised the dirty bitmap code, and I don't really have an opinion. Avi?
No big endian kvm target currently implements dirty bitmaps. In fact, IIRC only x86 does atm. So by pinning it to LE now, we save ourselves from much trouble for any later user.
Alex
--
To unsubscribe from this list: send the line "unsubscribe kvm-ppc" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html