mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Shaohua Li <shaohua.li@intel.com>
To: kvm-devel <kvm-devel@lists.sourceforge.net>,
	lkml <linux-kernel@vger.kernel.org>
Cc: Avi Kivity <avi@qumranet.com>, Ingo Molnar <mingo@elte.hu>
Subject: [RFC 6/8]KVM: introduce kvm_mmu_zap_pagetbl
Date: Mon, 23 Jul 2007 14:51:43 +0800	[thread overview]
Message-ID: <1185173503.2645.70.camel@sli10-conroe.sh.intel.com> (raw)

add a routine to zap all shadow pgtble for a gfn. If kvm supports SMP,
the API should zap pgtble for all vcpus, but kvm shadow page table
really should be per-vm, instead of per-vcpu.

Signed-off-by: Shaohua Li <shaohua.li@intel.com>
---
 drivers/kvm/kvm.h |    1 +
 drivers/kvm/mmu.c |   28 ++++++++++++++++++++++++++++
 2 files changed, 29 insertions(+)

Index: linux/drivers/kvm/kvm.h
===================================================================
--- linux.orig/drivers/kvm/kvm.h	2007-07-20 14:19:15.000000000 +0800
+++ linux/drivers/kvm/kvm.h	2007-07-20 14:26:10.000000000 +0800
@@ -621,6 +621,7 @@ int kvm_mmu_unprotect_page_virt(struct k
 void kvm_mmu_free_some_pages(struct kvm_vcpu *vcpu);
 int kvm_mmu_load(struct kvm_vcpu *vcpu);
 void kvm_mmu_unload(struct kvm_vcpu *vcpu);
+void kvm_mmu_zap_pagetbl(struct kvm_vcpu *vcpu, u64 gfn);
 
 int kvm_hypercall(struct kvm_vcpu *vcpu, struct kvm_run *run);
 
Index: linux/drivers/kvm/mmu.c
===================================================================
--- linux.orig/drivers/kvm/mmu.c	2007-07-20 14:25:25.000000000 +0800
+++ linux/drivers/kvm/mmu.c	2007-07-20 14:26:10.000000000 +0800
@@ -1324,6 +1324,34 @@ void kvm_mmu_zap_all(struct kvm_vcpu *vc
 	init_kvm_mmu(vcpu);
 }
 
+/* FIXME: this should zap all vcpu's shadow pgtbl for gfn */
+void kvm_mmu_zap_pagetbl(struct kvm_vcpu *vcpu, u64 gfn)
+{
+	struct kvm *kvm = vcpu->kvm;
+	struct kvm_rmap_desc *desc;
+	struct page *page;
+	u64 *spte;
+
+	page = gfn_to_page(kvm, gfn);
+	BUG_ON(!page);
+
+	while (page_private(page)) {
+		if (!(page_private(page) & 1))
+			spte = (u64 *)page_private(page);
+		else {
+			desc = (struct kvm_rmap_desc *)(page_private(page) & ~1ul);
+			spte = desc->shadow_ptes[0];
+		}
+		BUG_ON(!spte);
+		BUG_ON((*spte & PT64_BASE_ADDR_MASK) >> PAGE_SHIFT
+			!= page_to_pfn(page));
+		BUG_ON(!(*spte & PT_PRESENT_MASK));
+		rmap_remove(vcpu, spte);
+		*spte = 0;
+	}
+	kvm_flush_remote_tlbs(vcpu->kvm);
+}
+
 void kvm_mmu_module_exit(void)
 {
 	if (pte_chain_cache)

             reply	other threads:[~2007-07-23  7:00 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-07-23  6:51 Shaohua Li [this message]
2007-07-23 11:16 ` Avi Kivity
2007-07-24  1:47   ` Shaohua Li

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=1185173503.2645.70.camel@sli10-conroe.sh.intel.com \
    --to=shaohua.li@intel.com \
    --cc=avi@qumranet.com \
    --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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®