All of lore.kernel.org
 help / color / mirror / Atom feed
From: Avi Kivity <avi@qumranet.com>
To: kvm-devel@lists.sourceforge.net
Cc: linux-kernel@vger.kernel.org, akpm@osdl.org, mingo@elte.hu
Subject: [PATCH 1/13] KVM: mmu: add missing dirty page tracking cases
Date: Mon, 19 Feb 2007 10:21:51 -0000	[thread overview]
Message-ID: <20070219102151.9082E25016B@il.qumranet.com> (raw)
In-Reply-To: <45D979D3.2020907@qumranet.com>

We fail to mark a page dirty in three cases:

- setting the accessed bit in a pte
- setting the dirty bit in a pte
- emulating a write into a pagetable

This fix adds the missing cases.

Signed-off-by: Avi Kivity <avi@qumranet.com>

Index: linux-2.6/drivers/kvm/paging_tmpl.h
===================================================================
--- linux-2.6.orig/drivers/kvm/paging_tmpl.h
+++ linux-2.6/drivers/kvm/paging_tmpl.h
@@ -128,8 +128,10 @@ static int FNAME(walk_addr)(struct guest
 			goto access_error;
 #endif
 
-		if (!(*ptep & PT_ACCESSED_MASK))
-			*ptep |= PT_ACCESSED_MASK; 	/* avoid rmw */
+		if (!(*ptep & PT_ACCESSED_MASK)) {
+			mark_page_dirty(vcpu->kvm, table_gfn);
+			*ptep |= PT_ACCESSED_MASK;
+		}
 
 		if (walker->level == PT_PAGE_TABLE_LEVEL) {
 			walker->gfn = (*ptep & PT_BASE_ADDR_MASK)
@@ -185,6 +187,12 @@ static void FNAME(release_walker)(struct
 		kunmap_atomic(walker->table, KM_USER0);
 }
 
+static void FNAME(mark_pagetable_dirty)(struct kvm *kvm,
+					struct guest_walker *walker)
+{
+	mark_page_dirty(kvm, walker->table_gfn[walker->level - 1]);
+}
+
 static void FNAME(set_pte)(struct kvm_vcpu *vcpu, u64 guest_pte,
 			   u64 *shadow_pte, u64 access_bits, gfn_t gfn)
 {
@@ -348,12 +356,15 @@ static int FNAME(fix_write_pf)(struct kv
 	} else if (kvm_mmu_lookup_page(vcpu, gfn)) {
 		pgprintk("%s: found shadow page for %lx, marking ro\n",
 			 __FUNCTION__, gfn);
+		mark_page_dirty(vcpu->kvm, gfn);
+		FNAME(mark_pagetable_dirty)(vcpu->kvm, walker);
 		*guest_ent |= PT_DIRTY_MASK;
 		*write_pt = 1;
 		return 0;
 	}
 	mark_page_dirty(vcpu->kvm, gfn);
 	*shadow_ent |= PT_WRITABLE_MASK;
+	FNAME(mark_pagetable_dirty)(vcpu->kvm, walker);
 	*guest_ent |= PT_DIRTY_MASK;
 	rmap_add(vcpu, shadow_ent);
 

WARNING: multiple messages have this Message-ID (diff)
From: Avi Kivity <avi-atKUWr5tajBWk0Htik3J/w@public.gmane.org>
To: kvm-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org
Cc: akpm-3NddpPZAyC0@public.gmane.org,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
Subject: [PATCH 1/13] KVM: mmu: add missing dirty page tracking cases
Date: Mon, 19 Feb 2007 10:21:51 -0000	[thread overview]
Message-ID: <20070219102151.9082E25016B@il.qumranet.com> (raw)
In-Reply-To: <45D979D3.2020907-atKUWr5tajBWk0Htik3J/w@public.gmane.org>

We fail to mark a page dirty in three cases:

- setting the accessed bit in a pte
- setting the dirty bit in a pte
- emulating a write into a pagetable

This fix adds the missing cases.

Signed-off-by: Avi Kivity <avi-atKUWr5tajBWk0Htik3J/w@public.gmane.org>

Index: linux-2.6/drivers/kvm/paging_tmpl.h
===================================================================
--- linux-2.6.orig/drivers/kvm/paging_tmpl.h
+++ linux-2.6/drivers/kvm/paging_tmpl.h
@@ -128,8 +128,10 @@ static int FNAME(walk_addr)(struct guest
 			goto access_error;
 #endif
 
-		if (!(*ptep & PT_ACCESSED_MASK))
-			*ptep |= PT_ACCESSED_MASK; 	/* avoid rmw */
+		if (!(*ptep & PT_ACCESSED_MASK)) {
+			mark_page_dirty(vcpu->kvm, table_gfn);
+			*ptep |= PT_ACCESSED_MASK;
+		}
 
 		if (walker->level == PT_PAGE_TABLE_LEVEL) {
 			walker->gfn = (*ptep & PT_BASE_ADDR_MASK)
@@ -185,6 +187,12 @@ static void FNAME(release_walker)(struct
 		kunmap_atomic(walker->table, KM_USER0);
 }
 
+static void FNAME(mark_pagetable_dirty)(struct kvm *kvm,
+					struct guest_walker *walker)
+{
+	mark_page_dirty(kvm, walker->table_gfn[walker->level - 1]);
+}
+
 static void FNAME(set_pte)(struct kvm_vcpu *vcpu, u64 guest_pte,
 			   u64 *shadow_pte, u64 access_bits, gfn_t gfn)
 {
@@ -348,12 +356,15 @@ static int FNAME(fix_write_pf)(struct kv
 	} else if (kvm_mmu_lookup_page(vcpu, gfn)) {
 		pgprintk("%s: found shadow page for %lx, marking ro\n",
 			 __FUNCTION__, gfn);
+		mark_page_dirty(vcpu->kvm, gfn);
+		FNAME(mark_pagetable_dirty)(vcpu->kvm, walker);
 		*guest_ent |= PT_DIRTY_MASK;
 		*write_pt = 1;
 		return 0;
 	}
 	mark_page_dirty(vcpu->kvm, gfn);
 	*shadow_ent |= PT_WRITABLE_MASK;
+	FNAME(mark_pagetable_dirty)(vcpu->kvm, walker);
 	*guest_ent |= PT_DIRTY_MASK;
 	rmap_add(vcpu, shadow_ent);
 

-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys-and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV

  reply	other threads:[~2007-02-19 10:21 UTC|newest]

Thread overview: 67+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-02-19 10:20 [PATCH 0/13] kvm updates for 2.6.21 Avi Kivity
2007-02-19 10:20 ` Avi Kivity
2007-02-19 10:21 ` Avi Kivity [this message]
2007-02-19 10:21   ` [PATCH 1/13] KVM: mmu: add missing dirty page tracking cases Avi Kivity
2007-02-19 10:22 ` [PATCH 2/13] KVM: Move virtualization deactivation from CPU_DEAD state to CPU_DOWN_PREPARE Avi Kivity
2007-02-19 10:22   ` Avi Kivity
2007-02-19 10:23 ` [PATCH 3/13] KVM: Cosmetics Avi Kivity
2007-02-19 10:23   ` Avi Kivity
2007-02-19 10:24 ` [PATCH 4/13] KVM: vmx: hack set_cr0_no_modeswitch() to actually do modeswitch Avi Kivity
2007-02-19 10:24   ` Avi Kivity
2007-02-19 10:25 ` [PATCH 5/13] KVM: Use ARRAY_SIZE macro instead of manual calculation Avi Kivity
2007-02-19 10:25   ` Avi Kivity
2007-02-19 10:26 ` [PATCH 6/13] KVM: Use page_private()/set_page_private() apis Avi Kivity
2007-02-19 10:26   ` Avi Kivity
2007-02-19 10:27 ` [PATCH 7/13] KVM: add MSR based hypercall API Avi Kivity
2007-02-19 10:27   ` Avi Kivity
2007-02-19 10:28 ` [PATCH 8/13] KVM: Add host hypercall support for vmx Avi Kivity
2007-02-19 10:28   ` Avi Kivity
2007-02-19 10:29 ` [PATCH 9/13] KVM: Add hypercall host support for svm Avi Kivity
2007-02-19 10:29   ` Avi Kivity
2007-02-19 10:30 ` [PATCH 10/13] KVM: Wire up hypercall handlers to a central arch-independent location Avi Kivity
2007-02-19 10:30   ` Avi Kivity
2007-02-21 10:37   ` Pavel Machek
2007-02-21 10:37     ` Pavel Machek
2007-02-22 10:14     ` Avi Kivity
2007-02-22 10:14       ` Avi Kivity
2007-02-22 10:17       ` [kvm-devel] " Dor Laor
2007-02-22 10:17         ` Dor Laor
2007-02-22 10:22         ` [kvm-devel] " Joerg Roedel
2007-02-22 10:22           ` Joerg Roedel
2007-02-22 10:37           ` [kvm-devel] " Avi Kivity
2007-02-22 10:37             ` Avi Kivity
2007-02-22 10:34         ` [kvm-devel] " Arjan van de Ven
2007-02-22 10:34           ` Arjan van de Ven
2007-02-22 10:40           ` [kvm-devel] " Avi Kivity
2007-02-22 10:40             ` Avi Kivity
2007-02-22 11:01             ` [kvm-devel] " Arjan van de Ven
2007-02-22 11:01               ` Arjan van de Ven
2007-02-22 13:04               ` [kvm-devel] " Avi Kivity
2007-02-22 13:04                 ` Avi Kivity
2007-02-22 13:12                 ` [kvm-devel] " Arjan van de Ven
2007-02-22 13:29                   ` Avi Kivity
2007-02-22 13:29                     ` Avi Kivity
2007-02-22 14:09                     ` [kvm-devel] " Arjan van de Ven
2007-02-22 14:09                       ` Arjan van de Ven
2007-02-22 14:20                       ` [kvm-devel] " Avi Kivity
2007-02-22 14:20                         ` Avi Kivity
2007-02-23 14:55                         ` [kvm-devel] " Anthony Liguori
2007-02-23 14:55                           ` Anthony Liguori
2007-02-22 13:31                   ` [kvm-devel] [PATCH 10/13] KVM: Wire up hypercall handlers toa " Dor Laor
2007-02-22 13:31                     ` Dor Laor
     [not found]               ` <1172142081.3531.243.camel-NIQFrBLA1CpScpXdPBN83iCwEArCW2h5@public.gmane.org>
2007-02-23 21:14                 ` Booting from PV disk driver (Was: Re: [PATCH 10/13] KVM: Wire up hypercall handler ..) Anthony Liguori
     [not found]                   ` <45DF5943.3090304-rdkfGonbjUSkNkDKm+mE6A@public.gmane.org>
2007-02-23 22:33                     ` Arjan van de Ven
     [not found]                       ` <1172269981.3241.57.camel-NIQFrBLA1CpScpXdPBN83iCwEArCW2h5@public.gmane.org>
2007-02-24 22:35                         ` Booting from PV disk driver (Was: Re: [PATCH 10/13]KVM: " Dor Laor
     [not found]                           ` <64F9B87B6B770947A9F8391472E032160A91C385-yEcIvxbTEBqsx+V+t5oei8rau4O3wl8o3fe8/T/H7NteoWH0uzbU5w@public.gmane.org>
2007-02-25  5:20                             ` Avi Kivity
     [not found]                               ` <45E11C8A.9070006-atKUWr5tajBWk0Htik3J/w@public.gmane.org>
2007-02-25  5:48                                 ` Avi Kivity
2007-02-25  5:17                         ` Booting from PV disk driver (Was: Re: [PATCH 10/13] KVM: " Avi Kivity
     [not found]                           ` <45E11C00.2000602-atKUWr5tajBWk0Htik3J/w@public.gmane.org>
2007-02-25  6:31                             ` Arjan van de Ven
     [not found]                               ` <1172385067.3265.1.camel-NIQFrBLA1CpScpXdPBN83iCwEArCW2h5@public.gmane.org>
2007-02-25  6:34                                 ` Avi Kivity
     [not found]                                   ` <45E12E08.8040402-atKUWr5tajBWk0Htik3J/w@public.gmane.org>
2007-02-25  6:42                                     ` Arjan van de Ven
     [not found]                                       ` <1172385720.3265.12.camel-NIQFrBLA1CpScpXdPBN83iCwEArCW2h5@public.gmane.org>
2007-02-25  6:52                                         ` Avi Kivity
     [not found]                                           ` <45E13213.5070502-atKUWr5tajBWk0Htik3J/w@public.gmane.org>
2007-02-25  6:56                                             ` Arjan van de Ven
2007-02-19 10:31 ` [PATCH 11/13] KVM: svm: init cr0 with the wp bit set Avi Kivity
2007-02-19 10:31   ` Avi Kivity
2007-02-19 10:32 ` [PATCH 12/13] KVM: SVM: intercept SMI to handle it at host level Avi Kivity
2007-02-19 10:33 ` [PATCH 13/13] KVM: More 0 -> NULL conversions Avi Kivity
2007-02-19 10:33   ` Avi Kivity

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20070219102151.9082E25016B@il.qumranet.com \
    --to=avi@qumranet.com \
    --cc=akpm@osdl.org \
    --cc=kvm-devel@lists.sourceforge.net \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@elte.hu \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.