From patchwork Tue Apr 20 11:00:43 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Takuya Yoshikawa X-Patchwork-Id: 93651 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter.kernel.org (8.14.3/8.14.3) with ESMTP id o3KAv87o008005 for ; Tue, 20 Apr 2010 10:57:08 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754492Ab0DTK5F (ORCPT ); Tue, 20 Apr 2010 06:57:05 -0400 Received: from serv2.oss.ntt.co.jp ([222.151.198.100]:46899 "EHLO serv2.oss.ntt.co.jp" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753944Ab0DTK5E (ORCPT ); Tue, 20 Apr 2010 06:57:04 -0400 Received: from serv2.oss.ntt.co.jp (localhost [127.0.0.1]) by serv2.oss.ntt.co.jp (Postfix) with ESMTP id C024524820B; Tue, 20 Apr 2010 19:57:01 +0900 (JST) Received: from serv1.oss.ntt.co.jp (serv1.oss.ntt.co.jp [172.19.0.2]) by serv2.oss.ntt.co.jp (Postfix) with ESMTP id AE10E2481F9; Tue, 20 Apr 2010 19:57:01 +0900 (JST) Received: from yshtky3.kern.oss.ntt.co.jp (unknown [172.17.1.144]) by serv1.oss.ntt.co.jp (Postfix) with SMTP id 2EA3D11C11E; Tue, 20 Apr 2010 19:57:01 +0900 (JST) Date: Tue, 20 Apr 2010 20:00:43 +0900 From: Takuya Yoshikawa To: avi@redhat.com, mtosatti@redhat.com Cc: kvm@vger.kernel.org, kvm-ia64@vger.kernel.org, kvm-ppc@vger.kernel.org, fernando@oss.ntt.co.jp Subject: [PATCH RFC v2 4/6] KVM: change mark_page_dirty() to handle endian issues explicitly Message-Id: <20100420200043.956302db.yoshikawa.takuya@oss.ntt.co.jp> In-Reply-To: <20100420195349.dab60b1d.yoshikawa.takuya@oss.ntt.co.jp> References: <20100420195349.dab60b1d.yoshikawa.takuya@oss.ntt.co.jp> X-Mailer: Sylpheed 2.6.0 (GTK+ 2.16.1; i486-pc-linux-gnu) Mime-Version: 1.0 Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.3 (demeter.kernel.org [140.211.167.41]); Tue, 20 Apr 2010 10:57:08 +0000 (UTC) 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; } }